aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-08-07 02:11:08 -0400
committerDavid S. Miller <davem@davemloft.net>2008-08-07 02:11:08 -0400
commitea771bd51c3b9b9683860515d93e6155a345fa2f (patch)
tree6b77d738be0e9080b4a43a78948b5b2dfdf097a9 /arch/sparc64
parentf8d91faff3bb82c7026d6a2a5c97ee7d88bc0229 (diff)
sparc64: Use kernel/uid16.c helpers instead of own copy.
Noticed by Adrian Bunk. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64')
-rw-r--r--arch/sparc64/kernel/sys_sparc32.c176
-rw-r--r--arch/sparc64/kernel/systbls.S20
2 files changed, 10 insertions, 186 deletions
diff --git a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c
index 97b77fb5c50e..3d118531baff 100644
--- a/arch/sparc64/kernel/sys_sparc32.c
+++ b/arch/sparc64/kernel/sys_sparc32.c
@@ -58,182 +58,6 @@
58#include <asm/mmu_context.h> 58#include <asm/mmu_context.h>
59#include <asm/compat_signal.h> 59#include <asm/compat_signal.h>
60 60
61asmlinkage long sys32_chown16(const char __user * filename, u16 user, u16 group)
62{
63 return sys_chown(filename, low2highuid(user), low2highgid(group));
64}
65
66asmlinkage long sys32_lchown16(const char __user * filename, u16 user, u16 group)
67{
68 return sys_lchown(filename, low2highuid(user), low2highgid(group));
69}
70
71asmlinkage long sys32_fchown16(unsigned int fd, u16 user, u16 group)
72{
73 return sys_fchown(fd, low2highuid(user), low2highgid(group));
74}
75
76asmlinkage long sys32_setregid16(u16 rgid, u16 egid)
77{
78 return sys_setregid(low2highgid(rgid), low2highgid(egid));
79}
80
81asmlinkage long sys32_setgid16(u16 gid)
82{
83 return sys_setgid((gid_t)gid);
84}
85
86asmlinkage long sys32_setreuid16(u16 ruid, u16 euid)
87{
88 return sys_setreuid(low2highuid(ruid), low2highuid(euid));
89}
90
91asmlinkage long sys32_setuid16(u16 uid)
92{
93 return sys_setuid((uid_t)uid);
94}
95
96asmlinkage long sys32_setresuid16(u16 ruid, u16 euid, u16 suid)
97{
98 return sys_setresuid(low2highuid(ruid), low2highuid(euid),
99 low2highuid(suid));
100}
101
102asmlinkage long sys32_getresuid16(u16 __user *ruid, u16 __user *euid, u16 __user *suid)
103{
104 int retval;
105
106 if (!(retval = put_user(high2lowuid(current->uid), ruid)) &&
107 !(retval = put_user(high2lowuid(current->euid), euid)))
108 retval = put_user(high2lowuid(current->suid), suid);
109
110 return retval;
111}
112
113asmlinkage long sys32_setresgid16(u16 rgid, u16 egid, u16 sgid)
114{
115 return sys_setresgid(low2highgid(rgid), low2highgid(egid),
116 low2highgid(sgid));
117}
118
119asmlinkage long sys32_getresgid16(u16 __user *rgid, u16 __user *egid, u16 __user *sgid)
120{
121 int retval;
122
123 if (!(retval = put_user(high2lowgid(current->gid), rgid)) &&
124 !(retval = put_user(high2lowgid(current->egid), egid)))
125 retval = put_user(high2lowgid(current->sgid), sgid);
126
127 return retval;
128}
129
130asmlinkage long sys32_setfsuid16(u16 uid)
131{
132 return sys_setfsuid((uid_t)uid);
133}
134
135asmlinkage long sys32_setfsgid16(u16 gid)
136{
137 return sys_setfsgid((gid_t)gid);
138}
139
140static int groups16_to_user(u16 __user *grouplist, struct group_info *group_info)
141{
142 int i;
143 u16 group;
144
145 for (i = 0; i < group_info->ngroups; i++) {
146 group = (u16)GROUP_AT(group_info, i);
147 if (put_user(group, grouplist+i))
148 return -EFAULT;
149 }
150
151 return 0;
152}
153
154static int groups16_from_user(struct group_info *group_info, u16 __user *grouplist)
155{
156 int i;
157 u16 group;
158
159 for (i = 0; i < group_info->ngroups; i++) {
160 if (get_user(group, grouplist+i))
161 return -EFAULT;
162 GROUP_AT(group_info, i) = (gid_t)group;
163 }
164
165 return 0;
166}
167
168asmlinkage long sys32_getgroups16(int gidsetsize, u16 __user *grouplist)
169{
170 int i;
171
172 if (gidsetsize < 0)
173 return -EINVAL;
174
175 get_group_info(current->group_info);
176 i = current->group_info->ngroups;
177 if (gidsetsize) {
178 if (i > gidsetsize) {
179 i = -EINVAL;
180 goto out;
181 }
182 if (groups16_to_user(grouplist, current->group_info)) {
183 i = -EFAULT;
184 goto out;
185 }
186 }
187out:
188 put_group_info(current->group_info);
189 return i;
190}
191
192asmlinkage long sys32_setgroups16(int gidsetsize, u16 __user *grouplist)
193{
194 struct group_info *group_info;
195 int retval;
196
197 if (!capable(CAP_SETGID))
198 return -EPERM;
199 if ((unsigned)gidsetsize > NGROUPS_MAX)
200 return -EINVAL;
201
202 group_info = groups_alloc(gidsetsize);
203 if (!group_info)
204 return -ENOMEM;
205 retval = groups16_from_user(group_info, grouplist);
206 if (retval) {
207 put_group_info(group_info);
208 return retval;
209 }
210
211 retval = set_current_groups(group_info);
212 put_group_info(group_info);
213
214 return retval;
215}
216
217asmlinkage long sys32_getuid16(void)
218{
219 return high2lowuid(current->uid);
220}
221
222asmlinkage long sys32_geteuid16(void)
223{
224 return high2lowuid(current->euid);
225}
226
227asmlinkage long sys32_getgid16(void)
228{
229 return high2lowgid(current->gid);
230}
231
232asmlinkage long sys32_getegid16(void)
233{
234 return high2lowgid(current->egid);
235}
236
237/* 32-bit timeval and related flotsam. */ 61/* 32-bit timeval and related flotsam. */
238 62
239static inline long put_tv32(struct compat_timeval __user *o, struct timeval *i) 63static inline long put_tv32(struct compat_timeval __user *o, struct timeval *i)
diff --git a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
index 1095bf4c5100..0fdbf3ba956e 100644
--- a/arch/sparc64/kernel/systbls.S
+++ b/arch/sparc64/kernel/systbls.S
@@ -20,21 +20,21 @@
20sys_call_table32: 20sys_call_table32:
21/*0*/ .word sys_restart_syscall, sys32_exit, sys_fork, sys_read, sys_write 21/*0*/ .word sys_restart_syscall, sys32_exit, sys_fork, sys_read, sys_write
22/*5*/ .word sys32_open, sys_close, sys32_wait4, sys32_creat, sys_link 22/*5*/ .word sys32_open, sys_close, sys32_wait4, sys32_creat, sys_link
23/*10*/ .word sys_unlink, sunos_execv, sys_chdir, sys32_chown16, sys32_mknod 23/*10*/ .word sys_unlink, sunos_execv, sys_chdir, sys_chown16, sys32_mknod
24/*15*/ .word sys_chmod, sys32_lchown16, sparc_brk, sys32_perfctr, sys32_lseek 24/*15*/ .word sys_chmod, sys_lchown16, sparc_brk, sys32_perfctr, sys32_lseek
25/*20*/ .word sys_getpid, sys_capget, sys_capset, sys32_setuid16, sys32_getuid16 25/*20*/ .word sys_getpid, sys_capget, sys_capset, sys_setuid16, sys_getuid16
26/*25*/ .word sys32_vmsplice, compat_sys_ptrace, sys_alarm, sys32_sigaltstack, sys32_pause 26/*25*/ .word sys32_vmsplice, compat_sys_ptrace, sys_alarm, sys32_sigaltstack, sys32_pause
27/*30*/ .word compat_sys_utime, sys_lchown, sys_fchown, sys32_access, sys32_nice 27/*30*/ .word compat_sys_utime, sys_lchown, sys_fchown, sys32_access, sys32_nice
28 .word sys_chown, sys_sync, sys32_kill, compat_sys_newstat, sys32_sendfile 28 .word sys_chown, sys_sync, sys32_kill, compat_sys_newstat, sys32_sendfile
29/*40*/ .word compat_sys_newlstat, sys_dup, sys_pipe, compat_sys_times, sys_getuid 29/*40*/ .word compat_sys_newlstat, sys_dup, sys_pipe, compat_sys_times, sys_getuid
30 .word sys32_umount, sys32_setgid16, sys32_getgid16, sys32_signal, sys32_geteuid16 30 .word sys32_umount, sys_setgid16, sys_getgid16, sys32_signal, sys_geteuid16
31/*50*/ .word sys32_getegid16, sys_acct, sys_nis_syscall, sys_getgid, compat_sys_ioctl 31/*50*/ .word sys_getegid16, sys_acct, sys_nis_syscall, sys_getgid, compat_sys_ioctl
32 .word sys32_reboot, sys32_mmap2, sys_symlink, sys32_readlink, sys32_execve 32 .word sys32_reboot, sys32_mmap2, sys_symlink, sys32_readlink, sys32_execve
33/*60*/ .word sys32_umask, sys_chroot, compat_sys_newfstat, compat_sys_fstat64, sys_getpagesize 33/*60*/ .word sys32_umask, sys_chroot, compat_sys_newfstat, compat_sys_fstat64, sys_getpagesize
34 .word sys32_msync, sys_vfork, sys32_pread64, sys32_pwrite64, sys_geteuid 34 .word sys32_msync, sys_vfork, sys32_pread64, sys32_pwrite64, sys_geteuid
35/*70*/ .word sys_getegid, sys_mmap, sys_setreuid, sys_munmap, sys_mprotect 35/*70*/ .word sys_getegid, sys_mmap, sys_setreuid, sys_munmap, sys_mprotect
36 .word sys_madvise, sys_vhangup, sys32_truncate64, sys_mincore, sys32_getgroups16 36 .word sys_madvise, sys_vhangup, sys32_truncate64, sys_mincore, sys_getgroups16
37/*80*/ .word sys32_setgroups16, sys_getpgrp, sys32_setgroups, sys32_setitimer, sys32_ftruncate64 37/*80*/ .word sys_setgroups16, sys_getpgrp, sys32_setgroups, sys32_setitimer, sys32_ftruncate64
38 .word sys32_swapon, sys32_getitimer, sys_setuid, sys32_sethostname, sys_setgid 38 .word sys32_swapon, sys32_getitimer, sys_setuid, sys32_sethostname, sys_setgid
39/*90*/ .word sys_dup2, sys_setfsuid, compat_sys_fcntl, sys32_select, sys_setfsgid 39/*90*/ .word sys_dup2, sys_setfsuid, compat_sys_fcntl, sys32_select, sys_setfsgid
40 .word sys_fsync, sys32_setpriority, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall 40 .word sys_fsync, sys32_setpriority, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
@@ -42,8 +42,8 @@ sys_call_table32:
42 .word compat_sys_rt_sigtimedwait, sys32_rt_sigqueueinfo, compat_sys_rt_sigsuspend, sys_setresuid, sys_getresuid 42 .word compat_sys_rt_sigtimedwait, sys32_rt_sigqueueinfo, compat_sys_rt_sigsuspend, sys_setresuid, sys_getresuid
43/*110*/ .word sys_setresgid, sys_getresgid, sys_setregid, sys_nis_syscall, sys_nis_syscall 43/*110*/ .word sys_setresgid, sys_getresgid, sys_setregid, sys_nis_syscall, sys_nis_syscall
44 .word sys32_getgroups, sys32_gettimeofday, sys32_getrusage, sys_nis_syscall, sys_getcwd 44 .word sys32_getgroups, sys32_gettimeofday, sys32_getrusage, sys_nis_syscall, sys_getcwd
45/*120*/ .word compat_sys_readv, compat_sys_writev, sys32_settimeofday, sys32_fchown16, sys_fchmod 45/*120*/ .word compat_sys_readv, compat_sys_writev, sys32_settimeofday, sys_fchown16, sys_fchmod
46 .word sys_nis_syscall, sys32_setreuid16, sys32_setregid16, sys_rename, sys_truncate 46 .word sys_nis_syscall, sys_setreuid16, sys_setregid16, sys_rename, sys_truncate
47/*130*/ .word sys_ftruncate, sys_flock, compat_sys_lstat64, sys_nis_syscall, sys_nis_syscall 47/*130*/ .word sys_ftruncate, sys_flock, compat_sys_lstat64, sys_nis_syscall, sys_nis_syscall
48 .word sys_nis_syscall, sys32_mkdir, sys_rmdir, compat_sys_utimes, compat_sys_stat64 48 .word sys_nis_syscall, sys32_mkdir, sys_rmdir, compat_sys_utimes, compat_sys_stat64
49/*140*/ .word sys32_sendfile64, sys_nis_syscall, sys32_futex, sys_gettid, compat_sys_getrlimit 49/*140*/ .word sys32_sendfile64, sys_nis_syscall, sys32_futex, sys_gettid, compat_sys_getrlimit
@@ -63,7 +63,7 @@ sys_call_table32:
63/*210*/ .word sys32_fadvise64_64, sys32_tgkill, sys32_waitpid, sys_swapoff, compat_sys_sysinfo 63/*210*/ .word sys32_fadvise64_64, sys32_tgkill, sys32_waitpid, sys_swapoff, compat_sys_sysinfo
64 .word compat_sys_ipc, sys32_sigreturn, sys_clone, sys32_ioprio_get, compat_sys_adjtimex 64 .word compat_sys_ipc, sys32_sigreturn, sys_clone, sys32_ioprio_get, compat_sys_adjtimex
65/*220*/ .word sys32_sigprocmask, sys_ni_syscall, sys32_delete_module, sys_ni_syscall, sys32_getpgid 65/*220*/ .word sys32_sigprocmask, sys_ni_syscall, sys32_delete_module, sys_ni_syscall, sys32_getpgid
66 .word sys32_bdflush, sys32_sysfs, sys_nis_syscall, sys32_setfsuid16, sys32_setfsgid16 66 .word sys32_bdflush, sys32_sysfs, sys_nis_syscall, sys_setfsuid16, sys_setfsgid16
67/*230*/ .word sys32_select, compat_sys_time, sys32_splice, compat_sys_stime, compat_sys_statfs64 67/*230*/ .word sys32_select, compat_sys_time, sys32_splice, compat_sys_stime, compat_sys_statfs64
68 .word compat_sys_fstatfs64, sys_llseek, sys_mlock, sys_munlock, sys32_mlockall 68 .word compat_sys_fstatfs64, sys_llseek, sys_mlock, sys_munlock, sys32_mlockall
69/*240*/ .word sys_munlockall, sys32_sched_setparam, sys32_sched_getparam, sys32_sched_setscheduler, sys32_sched_getscheduler 69/*240*/ .word sys_munlockall, sys32_sched_setparam, sys32_sched_getparam, sys32_sched_setscheduler, sys32_sched_getscheduler