mirror of
https://github.com/lkl/linux.git
synced 2025-12-19 16:13:19 +09:00
lsm,fs: fix vfs_getxattr_alloc() return type and caller error paths
The vfs_getxattr_alloc() function currently returns a ssize_t value despite the fact that it only uses int values internally for return values. Fix this by converting vfs_getxattr_alloc() to return an int type and adjust the callers as necessary. As part of these caller modifications, some of the callers are fixed to properly free the xattr value buffer on both success and failure to ensure that memory is not leaked in the failure case. Reviewed-by: Serge Hallyn <serge@hallyn.com> Reviewed-by: Mimi Zohar <zohar@linux.ibm.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:
@@ -519,14 +519,17 @@ static int evm_xattr_change(struct user_namespace *mnt_userns,
|
||||
|
||||
rc = vfs_getxattr_alloc(&init_user_ns, dentry, xattr_name, &xattr_data,
|
||||
0, GFP_NOFS);
|
||||
if (rc < 0)
|
||||
return 1;
|
||||
if (rc < 0) {
|
||||
rc = 1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (rc == xattr_value_len)
|
||||
rc = !!memcmp(xattr_value, xattr_data, rc);
|
||||
else
|
||||
rc = 1;
|
||||
|
||||
out:
|
||||
kfree(xattr_data);
|
||||
return rc;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user