Skip to content

Commit 81407c8

Browse files
committed
audit: allow unsetting the loginuid (with priv)
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 <eparis@redhat.com> Signed-off-by: Richard Guy Briggs <rgb@redhat.com> Signed-off-by: Eric Paris <eparis@redhat.com>
1 parent 83fa6bb commit 81407c8

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎fs/proc/base.c‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,10 +1151,16 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
11511151
goto out_free_page;
11521152

11531153
}
1154-
kloginuid = make_kuid(file->f_cred->user_ns, loginuid);
1155-
if (!uid_valid(kloginuid)) {
1156-
length = -EINVAL;
1157-
goto out_free_page;
1154+
1155+
/* is userspace tring to explicitly UNSET the loginuid? */
1156+
if (loginuid == AUDIT_UID_UNSET) {
1157+
kloginuid = INVALID_UID;
1158+
} else {
1159+
kloginuid = make_kuid(file->f_cred->user_ns, loginuid);
1160+
if (!uid_valid(kloginuid)) {
1161+
length = -EINVAL;
1162+
goto out_free_page;
1163+
}
11581164
}
11591165

11601166
length = audit_set_loginuid(kloginuid);

‎kernel/auditsc.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,9 @@ int audit_set_loginuid(kuid_t loginuid)
20192019
if (rc)
20202020
goto out;
20212021

2022-
sessionid = atomic_inc_return(&session_id);
2022+
/* are we setting or clearing? */
2023+
if (uid_valid(loginuid))
2024+
sessionid = atomic_inc_return(&session_id);
20232025

20242026
task->sessionid = sessionid;
20252027
task->loginuid = loginuid;

0 commit comments

Comments
 (0)