Skip to content

Commit e7eda15

Browse files
WOnder93brauner
authored andcommitted
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. Fixes: 38f3865 ("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]> Reviewed-by: Christian Brauner (Microsoft) <[email protected]> Reviewed-by: Paul Moore <[email protected]> Signed-off-by: Christian Brauner (Microsoft) <[email protected]>
1 parent f0c4d9f commit e7eda15

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/xattr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ static int xattr_list_one(char **buffer, ssize_t *remaining_size,
11401140
ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs,
11411141
char *buffer, size_t size)
11421142
{
1143-
bool trusted = capable(CAP_SYS_ADMIN);
1143+
bool trusted = ns_capable_noaudit(&init_user_ns, CAP_SYS_ADMIN);
11441144
struct simple_xattr *xattr;
11451145
ssize_t remaining_size = size;
11461146
int err = 0;

0 commit comments

Comments
 (0)