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>
16 #include <asm/uaccess.h>
18 extern asmlinkage
long sys_chown(const char *, uid_t
,gid_t
);
19 extern asmlinkage
long sys_lchown(const char *, uid_t
,gid_t
);
20 extern asmlinkage
long sys_fchown(unsigned int, uid_t
,gid_t
);
21 extern asmlinkage
long sys_setregid(gid_t
, gid_t
);
22 extern asmlinkage
long sys_setgid(gid_t
);
23 extern asmlinkage
long sys_setreuid(uid_t
, uid_t
);
24 extern asmlinkage
long sys_setuid(uid_t
);
25 extern asmlinkage
long sys_setresuid(uid_t
, uid_t
, uid_t
);
26 extern asmlinkage
long sys_setresgid(gid_t
, gid_t
, gid_t
);
27 extern asmlinkage
long sys_setfsuid(uid_t
);
28 extern asmlinkage
long sys_setfsgid(gid_t
);
30 asmlinkage
long sys_chown16(const char * filename
, old_uid_t user
, old_gid_t group
)
32 return sys_chown(filename
, low2highuid(user
), low2highgid(group
));
35 asmlinkage
long sys_lchown16(const char * filename
, old_uid_t user
, old_gid_t group
)
37 return sys_lchown(filename
, low2highuid(user
), low2highgid(group
));
40 asmlinkage
long sys_fchown16(unsigned int fd
, old_uid_t user
, old_gid_t group
)
42 return sys_fchown(fd
, low2highuid(user
), low2highgid(group
));
45 asmlinkage
long sys_setregid16(old_gid_t rgid
, old_gid_t egid
)
47 return sys_setregid(low2highgid(rgid
), low2highgid(egid
));
50 asmlinkage
long sys_setgid16(old_gid_t gid
)
52 return sys_setgid((gid_t
)gid
);
55 asmlinkage
long sys_setreuid16(old_uid_t ruid
, old_uid_t euid
)
57 return sys_setreuid(low2highuid(ruid
), low2highuid(euid
));
60 asmlinkage
long sys_setuid16(old_uid_t uid
)
62 return sys_setuid((uid_t
)uid
);
65 asmlinkage
long sys_setresuid16(old_uid_t ruid
, old_uid_t euid
, old_uid_t suid
)
67 return sys_setresuid(low2highuid(ruid
), low2highuid(euid
),
71 asmlinkage
long sys_getresuid16(old_uid_t
*ruid
, old_uid_t
*euid
, old_uid_t
*suid
)
75 if (!(retval
= put_user(high2lowuid(current
->uid
), ruid
)) &&
76 !(retval
= put_user(high2lowuid(current
->euid
), euid
)))
77 retval
= put_user(high2lowuid(current
->suid
), suid
);
82 asmlinkage
long sys_setresgid16(old_gid_t rgid
, old_gid_t egid
, old_gid_t sgid
)
84 return sys_setresgid(low2highgid(rgid
), low2highgid(egid
),
88 asmlinkage
long sys_getresgid16(old_gid_t
*rgid
, old_gid_t
*egid
, old_gid_t
*sgid
)
92 if (!(retval
= put_user(high2lowgid(current
->gid
), rgid
)) &&
93 !(retval
= put_user(high2lowgid(current
->egid
), egid
)))
94 retval
= put_user(high2lowgid(current
->sgid
), sgid
);
99 asmlinkage
long sys_setfsuid16(old_uid_t uid
)
101 return sys_setfsuid((uid_t
)uid
);
104 asmlinkage
long sys_setfsgid16(old_gid_t gid
)
106 return sys_setfsgid((gid_t
)gid
);
109 asmlinkage
long sys_getgroups16(int gidsetsize
, old_gid_t
*grouplist
)
111 old_gid_t groups
[NGROUPS
];
116 i
= current
->ngroups
;
121 groups
[j
] = current
->groups
[j
];
122 if (copy_to_user(grouplist
, groups
, sizeof(old_gid_t
)*i
))
128 asmlinkage
long sys_setgroups16(int gidsetsize
, old_gid_t
*grouplist
)
130 old_gid_t groups
[NGROUPS
];
133 if (!capable(CAP_SETGID
))
135 if ((unsigned) gidsetsize
> NGROUPS
)
137 if (copy_from_user(groups
, grouplist
, gidsetsize
* sizeof(old_gid_t
)))
139 for (i
= 0 ; i
< gidsetsize
; i
++)
140 current
->groups
[i
] = (gid_t
)groups
[i
];
141 current
->ngroups
= gidsetsize
;
145 asmlinkage
long sys_getuid16(void)
147 return high2lowuid(current
->uid
);
150 asmlinkage
long sys_geteuid16(void)
152 return high2lowuid(current
->euid
);
155 asmlinkage
long sys_getgid16(void)
157 return high2lowgid(current
->gid
);
160 asmlinkage
long sys_getegid16(void)
162 return high2lowgid(current
->egid
);