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 return sys_chown(filename
, low2highuid(user
), low2highgid(group
));
26 asmlinkage
long sys_lchown16(const char __user
* filename
, old_uid_t user
, old_gid_t group
)
28 return sys_lchown(filename
, low2highuid(user
), low2highgid(group
));
31 asmlinkage
long sys_fchown16(unsigned int fd
, old_uid_t user
, old_gid_t group
)
33 return sys_fchown(fd
, low2highuid(user
), low2highgid(group
));
36 asmlinkage
long sys_setregid16(old_gid_t rgid
, old_gid_t egid
)
38 return sys_setregid(low2highgid(rgid
), low2highgid(egid
));
41 asmlinkage
long sys_setgid16(old_gid_t gid
)
43 return sys_setgid(low2highgid(gid
));
46 asmlinkage
long sys_setreuid16(old_uid_t ruid
, old_uid_t euid
)
48 return sys_setreuid(low2highuid(ruid
), low2highuid(euid
));
51 asmlinkage
long sys_setuid16(old_uid_t uid
)
53 return sys_setuid(low2highuid(uid
));
56 asmlinkage
long sys_setresuid16(old_uid_t ruid
, old_uid_t euid
, old_uid_t suid
)
58 return sys_setresuid(low2highuid(ruid
), low2highuid(euid
),
62 asmlinkage
long sys_getresuid16(old_uid_t __user
*ruid
, old_uid_t __user
*euid
, old_uid_t __user
*suid
)
66 if (!(retval
= put_user(high2lowuid(current
->uid
), ruid
)) &&
67 !(retval
= put_user(high2lowuid(current
->euid
), euid
)))
68 retval
= put_user(high2lowuid(current
->suid
), suid
);
73 asmlinkage
long sys_setresgid16(old_gid_t rgid
, old_gid_t egid
, old_gid_t sgid
)
75 return sys_setresgid(low2highgid(rgid
), low2highgid(egid
),
79 asmlinkage
long sys_getresgid16(old_gid_t __user
*rgid
, old_gid_t __user
*egid
, old_gid_t __user
*sgid
)
83 if (!(retval
= put_user(high2lowgid(current
->gid
), rgid
)) &&
84 !(retval
= put_user(high2lowgid(current
->egid
), egid
)))
85 retval
= put_user(high2lowgid(current
->sgid
), sgid
);
90 asmlinkage
long sys_setfsuid16(old_uid_t uid
)
92 return sys_setfsuid(low2highuid(uid
));
95 asmlinkage
long sys_setfsgid16(old_gid_t gid
)
97 return sys_setfsgid(low2highgid(gid
));
100 static int groups16_to_user(old_gid_t __user
*grouplist
,
101 struct group_info
*group_info
)
106 for (i
= 0; i
< group_info
->ngroups
; i
++) {
107 group
= high2lowgid(GROUP_AT(group_info
, i
));
108 if (put_user(group
, grouplist
+i
))
115 static int groups16_from_user(struct group_info
*group_info
,
116 old_gid_t __user
*grouplist
)
121 for (i
= 0; i
< group_info
->ngroups
; i
++) {
122 if (get_user(group
, grouplist
+i
))
124 GROUP_AT(group_info
, i
) = low2highgid(group
);
130 asmlinkage
long sys_getgroups16(int gidsetsize
, old_gid_t __user
*grouplist
)
137 get_group_info(current
->group_info
);
138 i
= current
->group_info
->ngroups
;
140 if (i
> gidsetsize
) {
144 if (groups16_to_user(grouplist
, current
->group_info
)) {
150 put_group_info(current
->group_info
);
154 asmlinkage
long sys_setgroups16(int gidsetsize
, old_gid_t __user
*grouplist
)
156 struct group_info
*group_info
;
159 if (!capable(CAP_SETGID
))
161 if ((unsigned)gidsetsize
> NGROUPS_MAX
)
164 group_info
= groups_alloc(gidsetsize
);
167 retval
= groups16_from_user(group_info
, grouplist
);
169 put_group_info(group_info
);
173 retval
= set_current_groups(group_info
);
174 put_group_info(group_info
);
179 asmlinkage
long sys_getuid16(void)
181 return high2lowuid(current
->uid
);
184 asmlinkage
long sys_geteuid16(void)
186 return high2lowuid(current
->euid
);
189 asmlinkage
long sys_getgid16(void)
191 return high2lowgid(current
->gid
);
194 asmlinkage
long sys_getegid16(void)
196 return high2lowgid(current
->egid
);