selinux,smack: remove the capability checks in the removexattr hooks
Subsystems (3)
Paul Moore
maintainerPATCH 1/1 selinux,smack: remove the capability checks in the removexattr hooks
Commit 61df7b828204 ("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.
--- security/selinux/hooks.c | 10 ++-------- security/smack/smack_lsm.c | 3 +-- 2 files changed, 3 insertions(+), 10 deletions(-)
security/selinux/hooks.c +2 -8
@@ -3356,15 +3356,9 @@ static int selinux_inode_listxattr(struct dentry *dentry)static int selinux_inode_removexattr (struct mnt_idmap *idmap,struct dentry *dentry,const char *name) { -if (strcmp (name,XATTR_NAME_SELINUX )) { -int rc =cap_inode_removexattr (idmap, dentry, name); -if (rc) -return rc; - -/* Not an attribute we recognize, so just check the -ordinary setattr permission. */ +/* if not a selinux xattr, only check the ordinary setattr perm */ +if (strcmp (name,XATTR_NAME_SELINUX ))return dentry_has_perm (current_cred (), dentry,FILE__SETATTR ); - }if (!selinux_initialized ())return 0 ;
security/smack/smack_lsm.c +1 -2
@@ -1461,8 +1461,7 @@ static int smack_inode_removexattr(struct mnt_idmap *idmap, strcmp(name, XATTR_NAME_SMACKMMAP) == 0) {if (!smack_privileged (CAP_MAC_ADMIN )) rc = -EPERM ; - } else - rc =cap_inode_removexattr (idmap, dentry, name); + }if (rc !=0 )return rc;
Signature · 1 line
2.45.2
Paul Moore
maintainerQuoted 10 lines · Paul Moore
Commit
61df7b828204("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.
Quoted 8 lines
This patch removes the duplicated code from SELinux and Smack.
Fixes 61df7b828204 ("lsm: fixup the inode xattr capability handling")Signed-off-by Paul Moore <[email protected]>--- security/selinux/hooks.c | 10 ++-------- security/smack/smack_lsm.c | 3 +-- 2 files changed, 3 insertions(+), 10 deletions(-)
FYI, this is still untested as my test kernel is compiling now, but I wanted to get this out onto the list before the holiday in the US for folks (/me looks at Casey for the Smack bits) to look at and potentially review.
Signature · 1 line
paul-moore.com
Casey Schaufler
maintainerQuoted 18 lines · Paul Moore
Quoted 9 lines · Paul Moore
Commit
61df7b828204("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.Quoted 8 lines
This patch removes the duplicated code from SELinux and Smack.
Fixes 61df7b828204 ("lsm: fixup the inode xattr capability handling")Signed-off-by Paul Moore <[email protected]>--- security/selinux/hooks.c | 10 ++-------- security/smack/smack_lsm.c | 3 +-- 2 files changed, 3 insertions(+), 10 deletions(-)
Quoted 3 lines
FYI, this is still untested as my test kernel is compiling now, but I wanted to get this out onto the list before the holiday in the US for folks (/me looks at Casey for the Smack bits)
Let me know how your test goes, and then I'll have a closer look.
Quoted 3 lines
to look at and
potentially review.
Paul Moore
maintainerQuoted 19 lines · Casey Schaufler
Quoted 18 lines · Paul Moore
Quoted 17 lines · Paul Moore
Commit
61df7b828204("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 61df7b828204 ("lsm: fixup the inode xattr capability handling")Signed-off-by Paul Moore <[email protected]>--- security/selinux/hooks.c | 10 ++-------- security/smack/smack_lsm.c | 3 +-- 2 files changed, 3 insertions(+), 10 deletions(-)
Quoted 5 lines
Quoted 3 lines
FYI, this is still untested as my test kernel is compiling now, but I wanted to get this out onto the list before the holiday in the US for folks (/me looks at Casey for the Smack bits)
Let me know how your test goes, and then I'll have a closer look.
It looks good - my SELinux test system booted up, appears to be running normally, and all of the selinux-testsuite tests pass.
Signature · 1 line
paul-moore.com
Quoted 9 lines · Paul Moore
Commit
61df7b828204("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.
Quoted 4 lines
This patch removes the duplicated code from SELinux and Smack.
Fixes 61df7b828204 ("lsm: fixup the inode xattr capability handling")Signed-off-by Paul Moore <[email protected]>
Quoted 41 lines
--- security/selinux/hooks.c | 10 ++-------- security/smack/smack_lsm.c | 3 +-- 2 files changed, 3 insertions(+), 10 deletions(-)security/selinux/hooks.c +2
-8@@ -3356,15 +3356,9 @@ static int selinux_inode_listxattr(struct dentry *dentry)static int selinux_inode_removexattr (struct mnt_idmap *idmap,struct dentry *dentry,const char *name) { -if (strcmp (name,XATTR_NAME_SELINUX )) { -int rc =cap_inode_removexattr (idmap, dentry, name); -if (rc) -return rc; - -/* Not an attribute we recognize, so just check the -ordinary setattr permission. */ +/* if not a selinux xattr, only check the ordinary setattr perm */ +if (strcmp (name,XATTR_NAME_SELINUX ))return dentry_has_perm (current_cred (), dentry,FILE__SETATTR ); - }if (!selinux_initialized ())return 0 ;security/smack/smack_lsm.c +1
-2@@ -1461,8 +1461,7 @@ static int smack_inode_removexattr(struct mnt_idmap *idmap, strcmp(name, XATTR_NAME_SMACKMMAP) == 0) {if (!smack_privileged (CAP_MAC_ADMIN )) rc = -EPERM ; - } else - rc =cap_inode_removexattr (idmap, dentry, name); + }if (rc !=0 )return rc;
Paul Moore
maintainerQuoted 10 lines · Casey Schaufler
Quoted 9 lines · Paul Moore
Commit
61df7b828204("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.
Quoted 6 lines
Quoted 4 lines
This patch removes the duplicated code from SELinux and Smack.
Fixes 61df7b828204 ("lsm: fixup the inode xattr capability handling")Signed-off-by Paul Moore <[email protected]>Acked-by Casey Schaufler <[email protected]>
Thanks Casey. As this is a pretty minor fix, I'm going to go ahead and merge it into lsm/dev so it will go up to Linus during the next merge window; if anyone has any objections to that please let me know soon.
Signature · 1 line
paul-moore.com