mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
userns: Convert the audit loginuid to be a kuid
Always store audit loginuids in type kuid_t. Print loginuids by converting them into uids in the appropriate user namespace, and then printing the resulting uid. Modify audit_get_loginuid to return a kuid_t. Modify audit_set_loginuid to take a kuid_t. Modify /proc/<pid>/loginuid on read to convert the loginuid into the user namespace of the opener of the file. Modify /proc/<pid>/loginud on write to convert the loginuid rom the user namespace of the opener of the file. Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Eric Paris <eparis@redhat.com> Cc: Paul Moore <paul@paul-moore.com> ? Cc: David Miller <davem@davemloft.net> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
This commit is contained in:
parent
ca57ec0f00
commit
e1760bd5ff
18 changed files with 80 additions and 66 deletions
|
@ -1089,7 +1089,8 @@ static ssize_t proc_loginuid_read(struct file * file, char __user * buf,
|
|||
if (!task)
|
||||
return -ESRCH;
|
||||
length = scnprintf(tmpbuf, TMPBUFLEN, "%u",
|
||||
audit_get_loginuid(task));
|
||||
from_kuid(file->f_cred->user_ns,
|
||||
audit_get_loginuid(task)));
|
||||
put_task_struct(task);
|
||||
return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
|
||||
}
|
||||
|
@ -1101,6 +1102,7 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
|
|||
char *page, *tmp;
|
||||
ssize_t length;
|
||||
uid_t loginuid;
|
||||
kuid_t kloginuid;
|
||||
|
||||
rcu_read_lock();
|
||||
if (current != pid_task(proc_pid(inode), PIDTYPE_PID)) {
|
||||
|
@ -1130,7 +1132,13 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
|
|||
goto out_free_page;
|
||||
|
||||
}
|
||||
length = audit_set_loginuid(loginuid);
|
||||
kloginuid = make_kuid(file->f_cred->user_ns, loginuid);
|
||||
if (!uid_valid(kloginuid)) {
|
||||
length = -EINVAL;
|
||||
goto out_free_page;
|
||||
}
|
||||
|
||||
length = audit_set_loginuid(kloginuid);
|
||||
if (likely(length == 0))
|
||||
length = count;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue