diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-02-07 21:51:01 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-05-03 06:28:41 -0400 |
commit | a29c33f4e506e1dae7e0985b6328046535becbf8 (patch) | |
tree | 529720b8aefaf115b4be197e5d7628657cf5b4bc /kernel/uid16.c | |
parent | 18815a18085364d8514c0d0c4c986776cb74272c (diff) |
userns: Convert setting and getting uid and gid system calls to use kuid and kgid
Convert setregid, setgid, setreuid, setuid,
setresuid, getresuid, setresgid, getresgid, setfsuid, setfsgid,
getuid, geteuid, getgid, getegid,
waitpid, waitid, wait4.
Convert userspace uids and gids into kuids and kgids before
being placed on struct cred. Convert struct cred kuids and
kgids into userspace uids and gids when returning them.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'kernel/uid16.c')
-rw-r--r-- | kernel/uid16.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/kernel/uid16.c b/kernel/uid16.c index e530bc34c4cf..d7948eb10225 100644 --- a/kernel/uid16.c +++ b/kernel/uid16.c | |||
@@ -81,14 +81,19 @@ SYSCALL_DEFINE3(setresuid16, old_uid_t, ruid, old_uid_t, euid, old_uid_t, suid) | |||
81 | return ret; | 81 | return ret; |
82 | } | 82 | } |
83 | 83 | ||
84 | SYSCALL_DEFINE3(getresuid16, old_uid_t __user *, ruid, old_uid_t __user *, euid, old_uid_t __user *, suid) | 84 | SYSCALL_DEFINE3(getresuid16, old_uid_t __user *, ruidp, old_uid_t __user *, euidp, old_uid_t __user *, suidp) |
85 | { | 85 | { |
86 | const struct cred *cred = current_cred(); | 86 | const struct cred *cred = current_cred(); |
87 | int retval; | 87 | int retval; |
88 | old_uid_t ruid, euid, suid; | ||
88 | 89 | ||
89 | if (!(retval = put_user(high2lowuid(cred->uid), ruid)) && | 90 | ruid = high2lowuid(from_kuid_munged(cred->user_ns, cred->uid)); |
90 | !(retval = put_user(high2lowuid(cred->euid), euid))) | 91 | euid = high2lowuid(from_kuid_munged(cred->user_ns, cred->euid)); |
91 | retval = put_user(high2lowuid(cred->suid), suid); | 92 | suid = high2lowuid(from_kuid_munged(cred->user_ns, cred->suid)); |
93 | |||
94 | if (!(retval = put_user(ruid, ruidp)) && | ||
95 | !(retval = put_user(euid, euidp))) | ||
96 | retval = put_user(suid, suidp); | ||
92 | 97 | ||
93 | return retval; | 98 | return retval; |
94 | } | 99 | } |
@@ -103,14 +108,19 @@ SYSCALL_DEFINE3(setresgid16, old_gid_t, rgid, old_gid_t, egid, old_gid_t, sgid) | |||
103 | } | 108 | } |
104 | 109 | ||
105 | 110 | ||
106 | SYSCALL_DEFINE3(getresgid16, old_gid_t __user *, rgid, old_gid_t __user *, egid, old_gid_t __user *, sgid) | 111 | SYSCALL_DEFINE3(getresgid16, old_gid_t __user *, rgidp, old_gid_t __user *, egidp, old_gid_t __user *, sgidp) |
107 | { | 112 | { |
108 | const struct cred *cred = current_cred(); | 113 | const struct cred *cred = current_cred(); |
109 | int retval; | 114 | int retval; |
115 | old_gid_t rgid, egid, sgid; | ||
116 | |||
117 | rgid = high2lowgid(from_kgid_munged(cred->user_ns, cred->gid)); | ||
118 | egid = high2lowgid(from_kgid_munged(cred->user_ns, cred->egid)); | ||
119 | sgid = high2lowgid(from_kgid_munged(cred->user_ns, cred->sgid)); | ||
110 | 120 | ||
111 | if (!(retval = put_user(high2lowgid(cred->gid), rgid)) && | 121 | if (!(retval = put_user(rgid, rgidp)) && |
112 | !(retval = put_user(high2lowgid(cred->egid), egid))) | 122 | !(retval = put_user(egid, egidp))) |
113 | retval = put_user(high2lowgid(cred->sgid), sgid); | 123 | retval = put_user(sgid, sgidp); |
114 | 124 | ||
115 | return retval; | 125 | return retval; |
116 | } | 126 | } |
@@ -221,20 +231,20 @@ SYSCALL_DEFINE2(setgroups16, int, gidsetsize, old_gid_t __user *, grouplist) | |||
221 | 231 | ||
222 | SYSCALL_DEFINE0(getuid16) | 232 | SYSCALL_DEFINE0(getuid16) |
223 | { | 233 | { |
224 | return high2lowuid(current_uid()); | 234 | return high2lowuid(from_kuid_munged(current_user_ns(), current_uid())); |
225 | } | 235 | } |
226 | 236 | ||
227 | SYSCALL_DEFINE0(geteuid16) | 237 | SYSCALL_DEFINE0(geteuid16) |
228 | { | 238 | { |
229 | return high2lowuid(current_euid()); | 239 | return high2lowuid(from_kuid_munged(current_user_ns(), current_euid())); |
230 | } | 240 | } |
231 | 241 | ||
232 | SYSCALL_DEFINE0(getgid16) | 242 | SYSCALL_DEFINE0(getgid16) |
233 | { | 243 | { |
234 | return high2lowgid(current_gid()); | 244 | return high2lowgid(from_kgid_munged(current_user_ns(), current_gid())); |
235 | } | 245 | } |
236 | 246 | ||
237 | SYSCALL_DEFINE0(getegid16) | 247 | SYSCALL_DEFINE0(getegid16) |
238 | { | 248 | { |
239 | return high2lowgid(current_egid()); | 249 | return high2lowgid(from_kgid_munged(current_user_ns(), current_egid())); |
240 | } | 250 | } |