summaryrefslogtreecommitdiff
path: root/security/security.c
diff options
context:
space:
mode:
authorXu Kuohai <xukuohai@huawei.com>2024-07-24 10:06:59 +0800
committerPaul Moore <paul@paul-moore.com>2024-07-31 14:47:09 -0400
commit924e19c39e8f0bbd581ab8a049f95a0ed02235b1 (patch)
tree19035cdf88e11452b06828295b4cd4b372d46fd6 /security/security.c
parentbe72a57527fde6c80061c5f9d0e28762eb817b03 (diff)
downloadlwn-924e19c39e8f0bbd581ab8a049f95a0ed02235b1.tar.gz
lwn-924e19c39e8f0bbd581ab8a049f95a0ed02235b1.zip
lsm: Refactor return value of LSM hook inode_copy_up_xattr
To be consistent with most LSM hooks, convert the return value of hook inode_copy_up_xattr to 0 or a negative error code. Before: - Hook inode_copy_up_xattr returns 0 when accepting xattr, 1 when discarding xattr, -EOPNOTSUPP if it does not know xattr, or any other negative error code otherwise. After: - Hook inode_copy_up_xattr returns 0 when accepting xattr, *-ECANCELED* when discarding xattr, -EOPNOTSUPP if it does not know xattr, or any other negative error code otherwise. Signed-off-by: Xu Kuohai <xukuohai@huawei.com> Reviewed-by: Casey Schaufler <casey@schaufler-ca.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security/security.c')
-rw-r--r--security/security.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/security/security.c b/security/security.c
index b2f0e9a57864..338e0d243a3c 100644
--- a/security/security.c
+++ b/security/security.c
@@ -2674,19 +2674,14 @@ EXPORT_SYMBOL(security_inode_copy_up);
* lower layer to the union/overlay layer. The caller is responsible for
* reading and writing the xattrs, this hook is merely a filter.
*
- * Return: Returns 0 to accept the xattr, 1 to discard the xattr, -EOPNOTSUPP
- * if the security module does not know about attribute, or a negative
- * error code to abort the copy up.
+ * Return: Returns 0 to accept the xattr, -ECANCELED to discard the xattr,
+ * -EOPNOTSUPP if the security module does not know about attribute,
+ * or a negative error code to abort the copy up.
*/
int security_inode_copy_up_xattr(struct dentry *src, const char *name)
{
int rc;
- /*
- * The implementation can return 0 (accept the xattr), 1 (discard the
- * xattr), -EOPNOTSUPP if it does not know anything about the xattr or
- * any other error code in case of an error.
- */
rc = call_int_hook(inode_copy_up_xattr, src, name);
if (rc != LSM_RET_DEFAULT(inode_copy_up_xattr))
return rc;