mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
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>
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user