Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit dd44477

Browse files
committed
selinux,smack: remove the capability checks in the removexattr hooks
Commit 61df7b8 ("lsm: fixup the inode xattr capability handling") moved the responsibility of doing the inode xattr capability checking out of the individual LSMs and into the LSM framework itself. Unfortunately, while the original commit added the capability checks to both the setxattr and removexattr code in the LSM framework, it only removed the setxattr capability checks from the individual LSMs, leaving duplicated removexattr capability checks in both the SELinux and Smack code. This patch removes the duplicated code from SELinux and Smack. Fixes: 61df7b8 ("lsm: fixup the inode xattr capability handling") Acked-by: Casey Schaufler <casey@schaufler-ca.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 61df7b8 commit dd44477

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

security/selinux/hooks.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3356,15 +3356,9 @@ static int selinux_inode_listxattr(struct dentry *dentry)
33563356
static int selinux_inode_removexattr(struct mnt_idmap *idmap,
33573357
struct dentry *dentry, const char *name)
33583358
{
3359-
if (strcmp(name, XATTR_NAME_SELINUX)) {
3360-
int rc = cap_inode_removexattr(idmap, dentry, name);
3361-
if (rc)
3362-
return rc;
3363-
3364-
/* Not an attribute we recognize, so just check the
3365-
ordinary setattr permission. */
3359+
/* if not a selinux xattr, only check the ordinary setattr perm */
3360+
if (strcmp(name, XATTR_NAME_SELINUX))
33663361
return dentry_has_perm(current_cred(), dentry, FILE__SETATTR);
3367-
}
33683362

33693363
if (!selinux_initialized())
33703364
return 0;

security/smack/smack_lsm.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,8 +1461,7 @@ static int smack_inode_removexattr(struct mnt_idmap *idmap,
14611461
strcmp(name, XATTR_NAME_SMACKMMAP) == 0) {
14621462
if (!smack_privileged(CAP_MAC_ADMIN))
14631463
rc = -EPERM;
1464-
} else
1465-
rc = cap_inode_removexattr(idmap, dentry, name);
1464+
}
14661465

14671466
if (rc != 0)
14681467
return rc;

0 commit comments

Comments
 (0)