LSM: Signal to SafeSetID when setting group IDs
authorThomas Cedeno <thomascedeno@google.com>
Thu, 16 Jul 2020 19:13:57 +0000 (19:13 +0000)
committerMicah Morton <mortonm@chromium.org>
Tue, 13 Oct 2020 16:17:34 +0000 (09:17 -0700)
commit111767c1d86bd9661f8b72ace50cbcb13507a1bf
treeeb61e1cd69c7b43ce363d8cde1c67ae0751eeb37
parentbbf5c979011a099af5dc76498918ed7df445635b
LSM: Signal to SafeSetID when setting group IDs

For SafeSetID to properly gate set*gid() calls, it needs to know whether
ns_capable() is being called from within a sys_set*gid() function or is
being called from elsewhere in the kernel. This allows SafeSetID to deny
CAP_SETGID to restricted groups when they are attempting to use the
capability for code paths other than updating GIDs (e.g. setting up
userns GID mappings). This is the identical approach to what is
currently done for CAP_SETUID.

NOTE: We also add signaling to SafeSetID from the setgroups() syscall,
as we have future plans to restrict a process' ability to set
supplementary groups in addition to what is added in this series for
restricting setting of the primary group.

Signed-off-by: Thomas Cedeno <thomascedeno@google.com>
Signed-off-by: Micah Morton <mortonm@chromium.org>
kernel/capability.c
kernel/groups.c
kernel/sys.c