]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ucount: check for CAP_SYS_RESOURCE using ns_capable_noaudit()
authorOndrej Mosnacek <omosnace@redhat.com>
Thu, 22 Jan 2026 14:07:45 +0000 (15:07 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 1 Feb 2026 00:16:08 +0000 (16:16 -0800)
commit0895a000e4fff9e950a7894210db45973e485c35
tree4f19ff7b509912c65cb89cf65b2878640b35fe6e
parent8924336531e21b187d724b5fdf5277269c9ec22c
ucount: check for CAP_SYS_RESOURCE using ns_capable_noaudit()

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: dbec28460a89 ("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>
kernel/ucount.c