Skip to content

Commit

Permalink
audit: allow unsetting the loginuid (with priv)
Browse files Browse the repository at this point in the history
If a task has CAP_AUDIT_CONTROL allow that task to unset their loginuid.
This would allow a child of that task to set their loginuid without
CAP_AUDIT_CONTROL.  Thus when launching a new login daemon, a
priviledged helper would be able to unset the loginuid and then the
daemon, which may be malicious user facing, do not need priv to function
correctly.

Signed-off-by: Eric Paris <[email protected]>
Signed-off-by: Richard Guy Briggs <[email protected]>
Signed-off-by: Eric Paris <[email protected]>
  • Loading branch information
eparis committed Nov 5, 2013
1 parent 83fa6bb commit 81407c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 10 additions & 4 deletions fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -1151,10 +1151,16 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
goto out_free_page;

}
kloginuid = make_kuid(file->f_cred->user_ns, loginuid);
if (!uid_valid(kloginuid)) {
length = -EINVAL;
goto out_free_page;

/* is userspace tring to explicitly UNSET the loginuid? */
if (loginuid == AUDIT_UID_UNSET) {
kloginuid = INVALID_UID;
} else {
kloginuid = make_kuid(file->f_cred->user_ns, loginuid);
if (!uid_valid(kloginuid)) {
length = -EINVAL;
goto out_free_page;
}
}

length = audit_set_loginuid(kloginuid);
Expand Down
4 changes: 3 additions & 1 deletion kernel/auditsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2019,7 +2019,9 @@ int audit_set_loginuid(kuid_t loginuid)
if (rc)
goto out;

sessionid = atomic_inc_return(&session_id);
/* are we setting or clearing? */
if (uid_valid(loginuid))
sessionid = atomic_inc_return(&session_id);

task->sessionid = sessionid;
task->loginuid = loginuid;
Expand Down

0 comments on commit 81407c8

Please sign in to comment.