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/init.h>
14 #include <linux/highuid.h>
15 #include <linux/security.h>
16 #include <linux/syscalls.h>
18 #include <asm/uaccess.h>
20 asmlinkage long sys_chown16(const char __user * filename, old_uid_t user, old_gid_t group)
22 return sys_chown(filename, low2highuid(user), low2highgid(group));
25 asmlinkage long sys_lchown16(const char __user * filename, old_uid_t user, old_gid_t group)
27 return sys_lchown(filename, low2highuid(user), low2highgid(group));
30 asmlinkage long sys_fchown16(unsigned int fd, old_uid_t user, old_gid_t group)
32 return sys_fchown(fd, low2highuid(user), low2highgid(group));
35 asmlinkage long sys_setregid16(old_gid_t rgid, old_gid_t egid)
37 return sys_setregid(low2highgid(rgid), low2highgid(egid));
40 asmlinkage long sys_setgid16(old_gid_t gid)
42 return sys_setgid(low2highgid(gid));
45 asmlinkage long sys_setreuid16(old_uid_t ruid, old_uid_t euid)
47 return sys_setreuid(low2highuid(ruid), low2highuid(euid));
50 asmlinkage long sys_setuid16(old_uid_t uid)
52 return sys_setuid(low2highuid(uid));
55 asmlinkage long sys_setresuid16(old_uid_t ruid, old_uid_t euid, old_uid_t suid)
57 return sys_setresuid(low2highuid(ruid), low2highuid(euid),
61 asmlinkage long sys_getresuid16(old_uid_t __user *ruid, old_uid_t __user *euid, old_uid_t __user *suid)
65 if (!(retval = put_user(high2lowuid(current->uid), ruid)) &&
66 !(retval = put_user(high2lowuid(current->euid), euid)))
67 retval = put_user(high2lowuid(current->suid), suid);
72 asmlinkage long sys_setresgid16(old_gid_t rgid, old_gid_t egid, old_gid_t sgid)
74 return sys_setresgid(low2highgid(rgid), low2highgid(egid),
78 asmlinkage long sys_getresgid16(old_gid_t __user *rgid, old_gid_t __user *egid, old_gid_t __user *sgid)
82 if (!(retval = put_user(high2lowgid(current->gid), rgid)) &&
83 !(retval = put_user(high2lowgid(current->egid), egid)))
84 retval = put_user(high2lowgid(current->sgid), sgid);
89 asmlinkage long sys_setfsuid16(old_uid_t uid)
91 return sys_setfsuid(low2highuid(uid));
94 asmlinkage long sys_setfsgid16(old_gid_t gid)
96 return sys_setfsgid(low2highgid(gid));
99 static int groups16_to_user(old_gid_t __user *grouplist,
100 struct group_info *group_info)
105 for (i = 0; i < group_info->ngroups; i++) {
106 group = high2lowgid(GROUP_AT(group_info, i));
107 if (put_user(group, grouplist+i))
114 static int groups16_from_user(struct group_info *group_info,
115 old_gid_t __user *grouplist)
120 for (i = 0; i < group_info->ngroups; i++) {
121 if (get_user(group, grouplist+i))
123 GROUP_AT(group_info, i) = low2highgid(group);
129 asmlinkage long sys_getgroups16(int gidsetsize, old_gid_t __user *grouplist)
136 get_group_info(current->group_info);
137 i = current->group_info->ngroups;
139 if (i > gidsetsize) {
143 if (groups16_to_user(grouplist, current->group_info)) {
149 put_group_info(current->group_info);
153 asmlinkage long sys_setgroups16(int gidsetsize, old_gid_t __user *grouplist)
155 struct group_info *group_info;
158 if (!capable(CAP_SETGID))
160 if ((unsigned)gidsetsize > NGROUPS_MAX)
163 group_info = groups_alloc(gidsetsize);
166 retval = groups16_from_user(group_info, grouplist);
168 put_group_info(group_info);
172 retval = set_current_groups(group_info);
173 put_group_info(group_info);
178 asmlinkage long sys_getuid16(void)
180 return high2lowuid(current->uid);
183 asmlinkage long sys_geteuid16(void)
185 return high2lowuid(current->euid);
188 asmlinkage long sys_getgid16(void)
190 return high2lowgid(current->gid);
193 asmlinkage long sys_getegid16(void)
195 return high2lowgid(current->egid);