summaryrefslogtreecommitdiffstats
path: root/kernel/groups.c
diff options
context:
space:
mode:
authorMicah Morton <mortonm@chromium.org>2022-06-08 20:57:11 +0000
committerMicah Morton <mortonm@chromium.org>2022-07-15 18:21:49 +0000
commitfcfe0ac2fcfae7d5fcad3d0375cb8ff38caf8aba (patch)
tree5cb709520c62f77b5a276d77d069a0238b2443ae /kernel/groups.c
parenta1732d6898ced0523cb4073c7f02d236edf312b1 (diff)
downloadlinux-fcfe0ac2fcfae7d5fcad3d0375cb8ff38caf8aba.tar.gz
linux-fcfe0ac2fcfae7d5fcad3d0375cb8ff38caf8aba.tar.bz2
linux-fcfe0ac2fcfae7d5fcad3d0375cb8ff38caf8aba.zip
security: Add LSM hook to setgroups() syscall
Give the LSM framework the ability to filter setgroups() syscalls. There are already analagous hooks for the set*uid() and set*gid() syscalls. The SafeSetID LSM will use this new hook to ensure setgroups() calls are allowed by the installed security policy. Tested by putting print statement in security_task_fix_setgroups() hook and confirming that it gets hit when userspace does a setgroups() syscall. Acked-by: Casey Schaufler <casey@schaufler-ca.com> Reviewed-by: Serge Hallyn <serge@hallyn.com> Signed-off-by: Micah Morton <mortonm@chromium.org>
Diffstat (limited to 'kernel/groups.c')
-rw-r--r--kernel/groups.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/kernel/groups.c b/kernel/groups.c
index 787b381c7c00..9aaed2a31073 100644
--- a/kernel/groups.c
+++ b/kernel/groups.c
@@ -134,13 +134,26 @@ EXPORT_SYMBOL(set_groups);
int set_current_groups(struct group_info *group_info)
{
struct cred *new;
+ const struct cred *old;
+ int retval;
new = prepare_creds();
if (!new)
return -ENOMEM;
+ old = current_cred();
+
set_groups(new, group_info);
+
+ retval = security_task_fix_setgroups(new, old);
+ if (retval < 0)
+ goto error;
+
return commit_creds(new);
+
+error:
+ abort_creds(new);
+ return retval;
}
EXPORT_SYMBOL(set_current_groups);