Skip to content
/ linux Public

Commit 530d1ec

Browse files
WOnder93Sasha Levin
authored andcommitted
ucount: check for CAP_SYS_RESOURCE using ns_capable_noaudit()
[ Upstream commit 0895a00 ] The user.* sysctls implement the ctl_table_root::permissions hook and they override the file access mode based on the CAP_SYS_RESOURCE capability (at most rwx if capable, at most r-- if not). The capability is being checked unconditionally, so if an LSM denies the capability, an audit record may be logged even when access is in fact granted. Given the logic in the set_permissions() function in kernel/ucount.c and the unfortunate way the permission checking is implemented, it doesn't seem viable to avoid false positive denials by deferring the capability check. Thus, do the same as in net_ctl_permissions() (net/sysctl_net.c) - switch from ns_capable() to ns_capable_noaudit(), so that the check never logs an audit record. Link: https://lkml.kernel.org/r/20260122140745.239428-1-omosnace@redhat.com Fixes: dbec284 ("userns: Add per user namespace sysctls.") Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> Reviewed-by: Paul Moore <paul@paul-moore.com> Acked-by: Serge Hallyn <serge@hallyn.com> Cc: Eric Biederman <ebiederm@xmission.com> Cc: Alexey Gladkov <legion@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent d075cf1 commit 530d1ec

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/ucount.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static int set_permissions(struct ctl_table_header *head,
4545
int mode;
4646

4747
/* Allow users with CAP_SYS_RESOURCE unrestrained access */
48-
if (ns_capable(user_ns, CAP_SYS_RESOURCE))
48+
if (ns_capable_noaudit(user_ns, CAP_SYS_RESOURCE))
4949
mode = (table->mode & S_IRWXU) >> 6;
5050
else
5151
/* Allow all others at most read-only access */

0 commit comments

Comments
 (0)