2 * Wrapper functions for 16bit uid back compatibility. All nicely tied
3 * together in the faint hope we can take the out in five years time.
7 #include <linux/utsname.h>
8 #include <linux/mman.h>
9 #include <linux/smp_lock.h>
10 #include <linux/notifier.h>
11 #include <linux/reboot.h>
12 #include <linux/prctl.h>
13 #include <linux/capability.h>
14 #include <linux/init.h>
15 #include <linux/highuid.h>
16 #include <linux/security.h>
17 #include <linux/syscalls.h>
19 #include <asm/uaccess.h>
21 asmlinkage long sys_chown16(const char __user * filename, old_uid_t user, old_gid_t group)
23 long ret = sys_chown(filename, low2highuid(user), low2highgid(group));
24 /* avoid REGPARM breakage on x86: */
25 prevent_tail_call(ret);
29 asmlinkage long sys_lchown16(const char __user * filename, old_uid_t user, old_gid_t group)
31 long ret = sys_lchown(filename, low2highuid(user), low2highgid(group));
32 /* avoid REGPARM breakage on x86: */
33 prevent_tail_call(ret);
37 asmlinkage long sys_fchown16(unsigned int fd, old_uid_t user, old_gid_t group)
39 long ret = sys_fchown(fd, low2highuid(user), low2highgid(group));
40 /* avoid REGPARM breakage on x86: */
41 prevent_tail_call(ret);
45 asmlinkage long sys_setregid16(old_gid_t rgid, old_gid_t egid)
47 long ret = sys_setregid(low2highgid(rgid), low2highgid(egid));
48 /* avoid REGPARM breakage on x86: */
49 prevent_tail_call(ret);
53 asmlinkage long sys_setgid16(old_gid_t gid)
55 long ret = sys_setgid(low2highgid(gid));
56 /* avoid REGPARM breakage on x86: */
57 prevent_tail_call(ret);
61 asmlinkage long sys_setreuid16(old_uid_t ruid, old_uid_t euid)
63 long ret = sys_setreuid(low2highuid(ruid), low2highuid(euid));
64 /* avoid REGPARM breakage on x86: */
65 prevent_tail_call(ret);
69 asmlinkage long sys_setuid16(old_uid_t uid)
71 long ret = sys_setuid(low2highuid(uid));
72 /* avoid REGPARM breakage on x86: */
73 prevent_tail_call(ret);
77 asmlinkage long sys_setresuid16(old_uid_t ruid, old_uid_t euid, old_uid_t suid)
79 long ret = sys_setresuid(low2highuid(ruid), low2highuid(euid),
81 /* avoid REGPARM breakage on x86: */
82 prevent_tail_call(ret);
86 asmlinkage long sys_getresuid16(old_uid_t __user *ruid, old_uid_t __user *euid, old_uid_t __user *suid)
90 if (!(retval = put_user(high2lowuid(current->uid), ruid)) &&
91 !(retval = put_user(high2lowuid(current->euid), euid)))
92 retval = put_user(high2lowuid(current->suid), suid);
97 asmlinkage long sys_setresgid16(old_gid_t rgid, old_gid_t egid, old_gid_t sgid)
99 long ret = sys_setresgid(low2highgid(rgid), low2highgid(egid),
101 /* avoid REGPARM breakage on x86: */
102 prevent_tail_call(ret);
106 asmlinkage long sys_getresgid16(old_gid_t __user *rgid, old_gid_t __user *egid, old_gid_t __user *sgid)
110 if (!(retval = put_user(high2lowgid(current->gid), rgid)) &&
111 !(retval = put_user(high2lowgid(current->egid), egid)))
112 retval = put_user(high2lowgid(current->sgid), sgid);
117 asmlinkage long sys_setfsuid16(old_uid_t uid)
119 long ret = sys_setfsuid(low2highuid(uid));
120 /* avoid REGPARM breakage on x86: */
121 prevent_tail_call(ret);
125 asmlinkage long sys_setfsgid16(old_gid_t gid)
127 long ret = sys_setfsgid(low2highgid(gid));
128 /* avoid REGPARM breakage on x86: */
129 prevent_tail_call(ret);
133 static int groups16_to_user(old_gid_t __user *grouplist,
134 struct group_info *group_info)
139 for (i = 0; i < group_info->ngroups; i++) {
140 group = high2lowgid(GROUP_AT(group_info, i));
141 if (put_user(group, grouplist+i))
148 static int groups16_from_user(struct group_info *group_info,
149 old_gid_t __user *grouplist)
154 for (i = 0; i < group_info->ngroups; i++) {
155 if (get_user(group, grouplist+i))
157 GROUP_AT(group_info, i) = low2highgid(group);
163 asmlinkage long sys_getgroups16(int gidsetsize, old_gid_t __user *grouplist)
170 get_group_info(current->group_info);
171 i = current->group_info->ngroups;
173 if (i > gidsetsize) {
177 if (groups16_to_user(grouplist, current->group_info)) {
183 put_group_info(current->group_info);
187 asmlinkage long sys_setgroups16(int gidsetsize, old_gid_t __user *grouplist)
189 struct group_info *group_info;
192 if (!capable(CAP_SETGID))
194 if ((unsigned)gidsetsize > NGROUPS_MAX)
197 group_info = groups_alloc(gidsetsize);
200 retval = groups16_from_user(group_info, grouplist);
202 put_group_info(group_info);
206 retval = set_current_groups(group_info);
207 put_group_info(group_info);
212 asmlinkage long sys_getuid16(void)
214 return high2lowuid(current->uid);
217 asmlinkage long sys_geteuid16(void)
219 return high2lowuid(current->euid);
222 asmlinkage long sys_getgid16(void)
224 return high2lowgid(current->gid);
227 asmlinkage long sys_getegid16(void)
229 return high2lowgid(current->egid);