mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 04:33:26 +02:00
security: Add LSM hooks to set*gid syscalls
The SafeSetID LSM uses the security_task_fix_setuid hook to filter set*uid() syscalls according to its configured security policy. In preparation for adding analagous support in the LSM for set*gid() syscalls, we add the requisite hook here. Tested by putting print statements in the security_task_fix_setgid hook and seeing them get hit during kernel boot. Signed-off-by: Thomas Cedeno <thomascedeno@google.com> Signed-off-by: Micah Morton <mortonm@chromium.org>
This commit is contained in:
committed by
Micah Morton
parent
3d77e6a880
commit
39030e1351
15
kernel/sys.c
15
kernel/sys.c
@@ -393,6 +393,10 @@ long __sys_setregid(gid_t rgid, gid_t egid)
|
||||
new->sgid = new->egid;
|
||||
new->fsgid = new->egid;
|
||||
|
||||
retval = security_task_fix_setgid(new, old, LSM_SETID_RE);
|
||||
if (retval < 0)
|
||||
goto error;
|
||||
|
||||
return commit_creds(new);
|
||||
|
||||
error:
|
||||
@@ -435,6 +439,10 @@ long __sys_setgid(gid_t gid)
|
||||
else
|
||||
goto error;
|
||||
|
||||
retval = security_task_fix_setgid(new, old, LSM_SETID_ID);
|
||||
if (retval < 0)
|
||||
goto error;
|
||||
|
||||
return commit_creds(new);
|
||||
|
||||
error:
|
||||
@@ -756,6 +764,10 @@ long __sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid)
|
||||
new->sgid = ksgid;
|
||||
new->fsgid = new->egid;
|
||||
|
||||
retval = security_task_fix_setgid(new, old, LSM_SETID_RES);
|
||||
if (retval < 0)
|
||||
goto error;
|
||||
|
||||
return commit_creds(new);
|
||||
|
||||
error:
|
||||
@@ -862,7 +874,8 @@ long __sys_setfsgid(gid_t gid)
|
||||
ns_capable(old->user_ns, CAP_SETGID)) {
|
||||
if (!gid_eq(kgid, old->fsgid)) {
|
||||
new->fsgid = kgid;
|
||||
goto change_okay;
|
||||
if (security_task_fix_setgid(new,old,LSM_SETID_FS) == 0)
|
||||
goto change_okay;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user