fs: don't audit the capability check in simple_xattr_list()
Subsystems (3)
PATCH v2 1/1 fs: don't audit the capability check in simple_xattr_list()
The check being unconditional may lead to unwanted denials reported by LSMs when a process has the capability granted by DAC, but denied by an LSM. In the case of SELinux such denials are a problem, since they can't be effectively filtered out via the policy and when not silenced, they produce noise that may hide a true problem or an attack.
Checking for the capability only if any trusted xattr is actually present wouldn't really address the issue, since calling listxattr(2) on such node on its own doesn't indicate an explicit attempt to see the trusted xattrs. Additionally, it could potentially leak the presence of trusted xattrs to an unprivileged user if they can check for the denials (e.g. through dmesg).
Therefore, it's best (and simplest) to keep the check unconditional and instead use ns_capable_noaudit() that will silence any associated LSM denials.
---
v1 -> v2: switch to simpler and better solution as suggested by Christian
fs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xattr.c +1 -1
@@ -1140,7 +1140,7 @@ static int xattr_list_one(char **buffer, ssize_t *remaining_size,ssize_t simple_xattr_list (struct inode *inode,struct simple_xattrs *xattrs,char *buffer,size_t size) { -bool trusted =capable (CAP_SYS_ADMIN ); +bool trusted =ns_capable_noaudit (&init_user_ns,CAP_SYS_ADMIN );struct simple_xattr *xattr;ssize_t remaining_size = size;int err =0 ;
Signature · 1 line
2.38.1
Quoted 17 lines · Ondrej Mosnacek
The check being unconditional may lead to unwanted denials reported by LSMs when a process has the capability granted by DAC, but denied by an LSM. In the case of SELinux such denials are a problem, since they can't be effectively filtered out via the policy and when not silenced, they produce noise that may hide a true problem or an attack.
Checking for the capability only if any trusted xattr is actually present wouldn't really address the issue, since calling listxattr(2) on such node on its own doesn't indicate an explicit attempt to see the trusted xattrs. Additionally, it could potentially leak the presence of trusted xattrs to an unprivileged user if they can check for the denials (e.g. through dmesg).
Therefore, it's best (and simplest) to keep the check unconditional and instead use
ns_capable_noaudit()that will silence any associated LSM denials.
Quoted 5 lines
Fixes 38f38657444d ("xattr: extract simple_xattr code from tmpfs")Reported-by Martin Pitt <[email protected]>Suggested-by Christian Brauner (Microsoft) <[email protected]>Signed-off-by Ondrej Mosnacek <[email protected]>---
Looks good,
Quoted 22 lines · Ondrej Mosnacek
The check being unconditional may lead to unwanted denials reported by LSMs when a process has the capability granted by DAC, but denied by an LSM. In the case of SELinux such denials are a problem, since they can't be effectively filtered out via the policy and when not silenced, they produce noise that may hide a true problem or an attack.
Checking for the capability only if any trusted xattr is actually present wouldn't really address the issue, since calling listxattr(2) on such node on its own doesn't indicate an explicit attempt to see the trusted xattrs. Additionally, it could potentially leak the presence of trusted xattrs to an unprivileged user if they can check for the denials (e.g. through dmesg).
Therefore, it's best (and simplest) to keep the check unconditional and instead use
ns_capable_noaudit()that will silence any associated LSM denials.Fixes 38f38657444d ("xattr: extract simple_xattr code from tmpfs")Reported-by Martin Pitt <[email protected]>Suggested-by Christian Brauner (Microsoft) <[email protected]>Signed-off-by Ondrej Mosnacek <[email protected]>
Quoted 8 lines
---
v1 -> v2: switch to simpler and better solution as suggested by Christian
fs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
VFS folks, this should really go through a vfs tree, but if nobody wants to pick it up *and* there are no objections to the change, I can take this via the LSM tree.
Signature · 1 line
paul-moore.com
Christian Brauner
maintainerQuoted 27 lines · Paul Moore
Quoted 26 lines · Ondrej Mosnacek
The check being unconditional may lead to unwanted denials reported by LSMs when a process has the capability granted by DAC, but denied by an LSM. In the case of SELinux such denials are a problem, since they can't be effectively filtered out via the policy and when not silenced, they produce noise that may hide a true problem or an attack.
Checking for the capability only if any trusted xattr is actually present wouldn't really address the issue, since calling listxattr(2) on such node on its own doesn't indicate an explicit attempt to see the trusted xattrs. Additionally, it could potentially leak the presence of trusted xattrs to an unprivileged user if they can check for the denials (e.g. through dmesg).
Therefore, it's best (and simplest) to keep the check unconditional and instead use
ns_capable_noaudit()that will silence any associated LSM denials.Fixes 38f38657444d ("xattr: extract simple_xattr code from tmpfs")Reported-by Martin Pitt <[email protected]>Suggested-by Christian Brauner (Microsoft) <[email protected]>Signed-off-by Ondrej Mosnacek <[email protected]>---
v1 -> v2: switch to simpler and better solution as suggested by Christian
Quoted 8 lines
Quoted 4 lines
fs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)VFS folks, this should really go through a vfs tree, but if nobody wants to pick it up *and* there are no objections to the change, I can take this via the LSM tree.
I can pick this up as I'm currently massaging the simple xattr infrastructure. I think the fix is pretty straightforward otherwise.
Christian
Paul Moore
maintainerQuoted 34 lines · Christian Brauner
Quoted 32 lines · Paul Moore
Quoted 30 lines · Ondrej Mosnacek
The check being unconditional may lead to unwanted denials reported by LSMs when a process has the capability granted by DAC, but denied by an LSM. In the case of SELinux such denials are a problem, since they can't be effectively filtered out via the policy and when not silenced, they produce noise that may hide a true problem or an attack.
Checking for the capability only if any trusted xattr is actually present wouldn't really address the issue, since calling listxattr(2) on such node on its own doesn't indicate an explicit attempt to see the trusted xattrs. Additionally, it could potentially leak the presence of trusted xattrs to an unprivileged user if they can check for the denials (e.g. through dmesg).
Therefore, it's best (and simplest) to keep the check unconditional and instead use
ns_capable_noaudit()that will silence any associated LSM denials.Fixes 38f38657444d ("xattr: extract simple_xattr code from tmpfs")Reported-by Martin Pitt <[email protected]>Suggested-by Christian Brauner (Microsoft) <[email protected]>Signed-off-by Ondrej Mosnacek <[email protected]>---
v1 -> v2: switch to simpler and better solution as suggested by Christian
fs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 6 lines
Quoted 3 lines
VFS folks, this should really go through a vfs tree, but if nobody wants to pick it up *and* there are no objections to the change, I can take this via the LSM tree.
I can pick this up as I'm currently massaging the simple xattr infrastructure.
Thanks Christian.
Quoted 1 line
I think the fix is pretty straightforward otherwise.
Agreed.
Signature · 1 line
paul-moore.com