tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
compat linux/linux32 uid16 functions cleanup/fixes
Hi,
While performing some regressions tests under compat linux/linux32, i
noticed that some uid16 functions were failing ... I started fixing
them; and while here, made some other cleanups :
- Add linux_sys_getres{uid,gid}16 to fix an overflow with incorrect
sizes given to copyout.
- Move all uid16 functions to a new linux_uid16.c file, only included
by needed archs (currently arm, i386 and m68k).
- Add some macros to handle conversions between linux_uid_t and uid_t
(likewise for gid).
- Use linux_uid_t/linux_gid_t for syscalls arguments types where
appropriate (instead of int, uid_t/gid_t, ...).
- Update arm syscall table to use more uid16 functions where
applicable.
Comments ?
--
Nicolas Joly
Biological Software and Databanks.
Institut Pasteur, Paris.
Index: sys/compat/linux/arch/arm/linux_commons.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/arch/arm/linux_commons.c,v
retrieving revision 1.5
diff -u -p -r1.5 linux_commons.c
--- sys/compat/linux/arch/arm/linux_commons.c 15 Aug 2007 12:07:29 -0000
1.5
+++ sys/compat/linux/arch/arm/linux_commons.c 4 Jan 2008 13:06:00 -0000
@@ -39,3 +39,4 @@ __KERNEL_RCSID(1, "$NetBSD: linux_common
#include "../../common/linux_oldselect.c"
#include "../../common/linux_olduname.c"
#include "../../common/linux_oldolduname.c"
+#include "../../common/linux_uid16.c"
Index: sys/compat/linux/arch/arm/syscalls.master
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/arch/arm/syscalls.master,v
retrieving revision 1.32
diff -u -p -r1.32 syscalls.master
--- sys/compat/linux/arch/arm/syscalls.master 24 Dec 2007 14:17:17 -0000
1.32
+++ sys/compat/linux/arch/arm/syscalls.master 4 Jan 2008 13:06:01 -0000
@@ -75,8 +75,8 @@
14 STD { int linux_sys_mknod(const char *path, int mode, \
int dev); }
15 NOARGS { int sys_chmod(const char *path, int mode); }
-16 STD { int linux_sys_lchown16(const char *path, int uid, \
- int gid); }
+16 STD { int linux_sys_lchown16(const char *path, \
+ linux_uid_t uid, linux_gid_t gid); }
17 OBSOL break
18 OBSOL ostat
19 NOARGS { long compat_43_sys_lseek(int fd, long offset, \
@@ -139,8 +139,10 @@
struct linux_old_sigaction *osa); }
68 STD { int linux_sys_siggetmask(void); }
69 STD { int linux_sys_sigsetmask(linux_old_sigset_t mask); }
-70 NOARGS { int sys_setreuid(uid_t ruid, uid_t euid); }
-71 NOARGS { int sys_setregid(gid_t rgid, gid_t egid); }
+70 STD { int linux_sys_setreuid16(linux_uid_t ruid, \
+ linux_uid_t euid); }
+71 STD { int linux_sys_setregid16(linux_gid_t rgid, \
+ linux_gid_t egid); }
72 STD { int linux_sys_sigsuspend(void *restart, \
int oldmask, int mask); }
73 STD { int linux_sys_sigpending(linux_old_sigset_t *set); }
@@ -155,8 +157,10 @@
struct timezone *tzp); }
79 STD { int linux_sys_settimeofday(struct timeval *tp, \
struct timezone *tzp); }
-80 NOARGS { int sys_getgroups(u_int gidsetsize, gid_t *gidset); }
-81 NOARGS { int sys_setgroups(u_int gidsetsize, gid_t *gidset); }
+80 STD { int linux_sys_getgroups16(int gidsetsize, \
+ linux_gid_t *gidset); }
+81 STD { int linux_sys_setgroups16(int gidsetsize, \
+ linux_gid_t *gidset); }
82 STD { int linux_sys_oldselect(struct linux_oldselect *lsp);
}
83 NOARGS { int sys_symlink(const char *path, const char *to); }
84 NOARGS { int compat_43_sys_lstat(const char *path, \
@@ -179,7 +183,8 @@
long length); }
93 NOARGS { int compat_43_sys_ftruncate(int fd, long length); }
94 NOARGS { int sys_fchmod(int fd, int mode); }
-95 STD { int linux_sys_fchown16(int fd, int uid, int gid); }
+95 STD { int linux_sys_fchown16(int fd, linux_uid_t uid, \
+ linux_gid_t gid); }
96 STD { int linux_sys_getpriority(int which, int who); }
97 NOARGS { int sys_setpriority(int which, int who, int prio); }
98 NOARGS { int sys_profil(void *samples, u_int size, \
@@ -272,19 +277,19 @@
struct timespec *rmtp); }
163 STD { void *linux_sys_mremap(void *old_address, \
size_t old_size, size_t new_size, u_long flags); }
-164 STD { int linux_sys_setresuid(uid_t ruid, uid_t euid, \
- uid_t suid); }
-165 STD { int linux_sys_getresuid(uid_t *ruid, uid_t *euid, \
- uid_t *suid); }
+164 STD { int linux_sys_setresuid16(linux_uid_t ruid, \
+ linux_uid_t euid, linux_uid_t suid); }
+165 STD { int linux_sys_getresuid16( linux_uid_t *ruid, \
+ linux_uid_t *euid, linux_uid_t *suid); }
166 UNIMPL
167 UNIMPL query_module
168 NOARGS { int sys_poll(struct pollfd *fds, u_int nfds, \
int timeout); }
169 UNIMPL nfsservctl
-170 STD { int linux_sys_setresgid(gid_t rgid, gid_t egid, \
- gid_t sgid); }
-171 STD { int linux_sys_getresgid(gid_t *rgid, gid_t *egid, \
- gid_t *sgid); }
+170 STD { int linux_sys_setresgid16(linux_gid_t rgid, \
+ linux_gid_t egid, linux_gid_t sgid); }
+171 STD { int linux_sys_getresgid16( linux_gid_t *rgid, \
+ linux_gid_t *egid, linux_gid_t *sgid); }
172 UNIMPL prctl
173 UNIMPL rt_sigreturn
;173 STD { int linux_sys_rt_sigreturn( \
@@ -310,8 +315,8 @@
size_t nbyte, linux_off_t offset); }
181 STD { int linux_sys_pwrite(int fd, char *buf, \
size_t nbyte, linux_off_t offset); }
-182 STD { int linux_sys_chown16(const char *path, int uid, \
- int gid); }
+182 STD { int linux_sys_chown16(const char *path, \
+ linux_uid_t uid, linux_gid_t gid); }
183 NOARGS { int sys___getcwd(char *bufp, size_t length); }
184 UNIMPL capget
185 UNIMPL capset
@@ -354,13 +359,13 @@
gid_t *gidset); }
207 NOARGS fchown32 { int sys___posix_fchown(int fd, uid_t uid, \
gid_t gid); }
-208 NOARGS setresuid32 { int linux_sys_setresuid(uid_t ruid, \
+208 STD setresuid32 { int linux_sys_setresuid(uid_t ruid, \
uid_t euid, uid_t suid); }
-209 NOARGS getresuid32 { int linux_sys_getresuid(uid_t *ruid, \
+209 STD getresuid32 { int linux_sys_getresuid(uid_t *ruid, \
uid_t *euid, uid_t *suid); }
-210 NOARGS setresgid32 { int linux_sys_setresgid(gid_t rgid, \
+210 STD setresgid32 { int linux_sys_setresgid(gid_t rgid, \
gid_t egid, gid_t sgid); }
-211 NOARGS getresgid32 { int linux_sys_getresgid(gid_t *rgid, \
+211 STD getresgid32 { int linux_sys_getresgid(gid_t *rgid, \
gid_t *egid, gid_t *sgid); }
212 NOARGS chown32 { int sys___posix_chown(const char *path, \
uid_t uid, gid_t gid); }
Index: sys/compat/linux/arch/i386/linux_commons.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/arch/i386/linux_commons.c,v
retrieving revision 1.10
diff -u -p -r1.10 linux_commons.c
--- sys/compat/linux/arch/i386/linux_commons.c 15 Aug 2007 12:07:29 -0000
1.10
+++ sys/compat/linux/arch/i386/linux_commons.c 4 Jan 2008 13:06:01 -0000
@@ -41,3 +41,4 @@ __KERNEL_RCSID(1, "$NetBSD: linux_common
#include "../../common/linux_oldselect.c"
#include "../../common/linux_olduname.c"
#include "../../common/linux_oldolduname.c"
+#include "../../common/linux_uid16.c"
Index: sys/compat/linux/arch/i386/syscalls.master
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/arch/i386/syscalls.master,v
retrieving revision 1.88
diff -u -p -r1.88 syscalls.master
--- sys/compat/linux/arch/i386/syscalls.master 24 Dec 2007 14:17:18 -0000
1.88
+++ sys/compat/linux/arch/i386/syscalls.master 4 Jan 2008 13:06:01 -0000
@@ -75,7 +75,7 @@
int dev); }
15 NOARGS { int sys_chmod(const char *path, int mode); }
16 STD { int linux_sys_lchown16(const char *path, \
- int uid, int gid); }
+ linux_uid_t uid, linux_gid_t gid); }
;17 - no longer in linux source.
17 STD { int linux_sys_break(char *nsize); }
18 OBSOL ostat
@@ -147,8 +147,10 @@
struct linux_old_sigaction *osa); }
68 STD { int linux_sys_siggetmask(void); }
69 STD { int linux_sys_sigsetmask(linux_old_sigset_t mask); }
-70 STD { int linux_sys_setreuid16(int ruid, int euid); }
-71 STD { int linux_sys_setregid16(int rgid, int egid); }
+70 STD { int linux_sys_setreuid16(linux_uid_t ruid, \
+ linux_uid_t euid); }
+71 STD { int linux_sys_setregid16(linux_gid_t rgid, \
+ linux_gid_t egid); }
72 STD { int linux_sys_sigsuspend(void *restart, \
int oldmask, int mask); }
73 STD { int linux_sys_sigpending(linux_old_sigset_t *set); }
@@ -163,7 +165,8 @@
struct timezone *tzp); }
79 STD { int linux_sys_settimeofday(struct timeval *tp, \
struct timezone *tzp); }
-80 STD { int linux_sys_getgroups16(int gidsetsize, linux_gid_t
*gidset); }
+80 STD { int linux_sys_getgroups16(int gidsetsize, \
+ linux_gid_t *gidset); }
81 STD { int linux_sys_setgroups16(int gidsetsize, \
linux_gid_t *gidset); }
82 STD { int linux_sys_oldselect(struct linux_oldselect *lsp);
}
@@ -188,7 +191,8 @@
long length); }
93 NOARGS { int compat_43_sys_ftruncate(int fd, long length); }
94 NOARGS { int sys_fchmod(int fd, int mode); }
-95 STD { int linux_sys_fchown16(int fd, int uid, int gid); }
+95 STD { int linux_sys_fchown16(int fd, linux_uid_t uid, \
+ linux_gid_t gid); }
96 STD { int linux_sys_getpriority(int which, int who); }
97 NOARGS { int sys_setpriority(int which, int who, int prio); }
98 NOARGS { int sys_profil(void *samples, u_int size, \
@@ -284,19 +288,19 @@
struct timespec *rmtp); }
163 STD { void *linux_sys_mremap(void *old_address, \
size_t old_size, size_t new_size, u_long flags); }
-164 STD { int linux_sys_setresuid16(uid_t ruid, uid_t euid, \
- uid_t suid); }
-165 NOARGS linux_getresuid16 { int linux_sys_getresuid( \
- uid_t *ruid, uid_t *euid, uid_t *suid); }
+164 STD { int linux_sys_setresuid16(linux_uid_t ruid, \
+ linux_uid_t euid, linux_uid_t suid); }
+165 STD { int linux_sys_getresuid16( linux_uid_t *ruid, \
+ linux_uid_t *euid, linux_uid_t *suid); }
166 UNIMPL vm86
167 UNIMPL query_module
168 NOARGS { int sys_poll(struct pollfd *fds, u_int nfds, \
int timeout); }
169 UNIMPL nfsservctl
-170 STD { int linux_sys_setresgid16(gid_t rgid, gid_t egid, \
- gid_t sgid); }
-171 NOARGS linux_getresgid16 { int linux_sys_getresgid( \
- gid_t *rgid, gid_t *egid, gid_t *sgid); }
+170 STD { int linux_sys_setresgid16(linux_gid_t rgid, \
+ linux_gid_t egid, linux_gid_t sgid); }
+171 STD { int linux_sys_getresgid16( linux_gid_t *rgid, \
+ linux_gid_t *egid, linux_gid_t *sgid); }
172 UNIMPL prctl
173 STD { int linux_sys_rt_sigreturn( \
struct linux_ucontext *ucp); }
@@ -321,8 +325,8 @@
size_t nbyte, linux_off_t offset); }
181 STD { int linux_sys_pwrite(int fd, char *buf, \
size_t nbyte, linux_off_t offset); }
-182 STD { int linux_sys_chown16(const char *path, int uid, \
- int gid); }
+182 STD { int linux_sys_chown16(const char *path, \
+ linux_uid_t uid, linux_gid_t gid); }
183 NOARGS { int sys___getcwd(char *bufp, size_t length); }
184 UNIMPL capget
185 UNIMPL capset
Index: sys/compat/linux/arch/m68k/files.linux_m68k
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/arch/m68k/files.linux_m68k,v
retrieving revision 1.3
diff -u -p -r1.3 files.linux_m68k
--- sys/compat/linux/arch/m68k/files.linux_m68k 31 Mar 2002 22:40:17 -0000
1.3
+++ sys/compat/linux/arch/m68k/files.linux_m68k 4 Jan 2008 13:06:01 -0000
@@ -17,3 +17,4 @@ file compat/linux/common/linux_socketcal
file compat/linux/common/linux_llseek.c compat_linux
file compat/linux/common/linux_oldmmap.c compat_linux
file compat/linux/common/linux_oldselect.c compat_linux
+file compat/linux/common/linux_uid16.c compat_linux
Index: sys/compat/linux/arch/m68k/syscalls.master
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/arch/m68k/syscalls.master,v
retrieving revision 1.58
diff -u -p -r1.58 syscalls.master
--- sys/compat/linux/arch/m68k/syscalls.master 24 Dec 2007 14:17:18 -0000
1.58
+++ sys/compat/linux/arch/m68k/syscalls.master 4 Jan 2008 13:06:01 -0000
@@ -77,7 +77,7 @@
15 NOARGS { int sys_chmod(const char *path, int mode); }
;16 lchown on i386; chown on m68k.
16 STD { int linux_sys_chown16(const char *path, \
- int uid, int gid); }
+ linux_uid_t uid, linux_gid_t gid); }
17 OBSOL break
18 OBSOL ostat
#if !defined(_KERNEL) || defined(COMPAT_43)
@@ -143,8 +143,10 @@
struct linux_old_sigaction *osa); }
68 STD { int linux_sys_siggetmask(void); }
69 STD { int linux_sys_sigsetmask(linux_old_sigset_t mask); }
-70 STD { int linux_sys_setreuid16(int ruid, int euid); }
-71 STD { int linux_sys_setregid16(int rgid, int egid); }
+70 STD { int linux_sys_setreuid16(linux_uid_t ruid, \
+ linux_uid_t euid); }
+71 STD { int linux_sys_setregid16(linux_gid_t rgid, \
+ linux_gid_t egid); }
72 STD { int linux_sys_sigsuspend(void *restart, \
int oldmask, int mask); }
73 STD { int linux_sys_sigpending(linux_old_sigset_t *set); }
@@ -163,8 +165,10 @@
struct timezone *tzp); }
79 STD { int linux_sys_settimeofday(struct timeval *tp, \
struct timezone *tzp); }
-80 STD { int linux_sys_getgroups16(u_int gidsetsize,
linux_gid_t *gidset); }
-81 STD { int linux_sys_setgroups16(u_int gidsetsize,
linux_gid_t *gidset); }
+80 STD { int linux_sys_getgroups16(int gidsetsize, \
+ linux_gid_t *gidset); }
+81 STD { int linux_sys_setgroups16(int gidsetsize, \
+ linux_gid_t *gidset); }
82 STD { int linux_sys_oldselect(struct linux_oldselect *lsp);
}
83 NOARGS { int sys_symlink(const char *path, const char *to); }
#if !defined(_KERNEL) || defined(COMPAT_43)
@@ -195,7 +199,8 @@
93 UNIMPL compat_43_sys_ftruncate
#endif
94 NOARGS { int sys_fchmod(int fd, int mode); }
-95 STD { int linux_sys_fchown16(int fd, int uid, int gid); }
+95 STD { int linux_sys_fchown16(int fd, linux_uid_t uid, \
+ linux_gid_t gid); }
96 STD { int linux_sys_getpriority(int which, int who); }
97 NOARGS { int sys_setpriority(int which, int who, int prio); }
98 NOARGS { int sys_profil(void *samples, u_int size, \
@@ -289,19 +294,19 @@
struct timespec *rmtp); }
163 STD { void *linux_sys_mremap(void *old_address, \
size_t old_size, size_t new_size, u_long flags); }
-164 STD { int linux_sys_setresuid16(uid_t ruid, uid_t euid, \
- uid_t suid); }
-165 NOARGS linux_getresuid16 { int linux_sys_getresuid( \
- uid_t *ruid, uid_t *euid, uid_t *suid); }
+164 STD { int linux_sys_setresuid16(linux_uid_t ruid, \
+ linux_uid_t euid, linux_uid_t suid); }
+165 STD { int linux_sys_getresuid16( linux_uid_t *ruid, \
+ linux_uid_t *euid, linux_uid_t *suid); }
166 UNIMPL vm86
167 UNIMPL query_module
168 NOARGS { int sys_poll(struct pollfd *fds, u_int nfds, \
int timeout); }
169 UNIMPL nfsservctl
-170 STD { int linux_sys_setresgid16(gid_t rgid, gid_t egid, \
- gid_t sgid); }
-171 NOARGS linux_getresgid16 { int linux_sys_getresgid( \
- gid_t *rgid, gid_t *egid, gid_t *sgid); }
+170 STD { int linux_sys_setresgid16(linux_gid_t rgid, \
+ linux_gid_t egid, linux_gid_t sgid); }
+171 STD { int linux_sys_getresgid16( linux_gid_t *rgid, \
+ linux_gid_t *egid, linux_gid_t *sgid); }
172 UNIMPL prctl
173 STD { int linux_sys_rt_sigreturn(void); }
174 STD { int linux_sys_rt_sigaction(int signum, \
@@ -326,8 +331,8 @@
181 STD { int linux_sys_pwrite(int fd, char *buf, \
size_t nbyte, linux_off_t offset); }
;182 chown on i386; lchown on m68k.
-182 STD { int linux_sys_lchown16(const char *path, int uid, \
- int gid); }
+182 STD { int linux_sys_lchown16(const char *path, \
+ linux_uid_t uid, linux_gid_t gid); }
183 NOARGS { int sys___getcwd(char *bufp, size_t length); }
184 UNIMPL capget
185 UNIMPL capset
Index: sys/compat/linux/common/linux_file.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_file.c,v
retrieving revision 1.90
diff -u -p -r1.90 linux_file.c
--- sys/compat/linux/common/linux_file.c 20 Dec 2007 23:02:54 -0000
1.90
+++ sys/compat/linux/common/linux_file.c 4 Jan 2008 13:06:01 -0000
@@ -623,66 +623,6 @@ linux_sys_mknod(struct lwp *l, const str
}
}
-#if defined(__i386__) || defined(__m68k__) || \
- defined(__arm__)
-int
-linux_sys_chown16(struct lwp *l, const struct linux_sys_chown16_args *uap,
register_t *retval)
-{
- /* {
- syscallarg(const char *) path;
- syscallarg(int) uid;
- syscallarg(int) gid;
- } */
- struct sys___posix_chown_args bca;
-
- SCARG(&bca, path) = SCARG(uap, path);
- SCARG(&bca, uid) = ((linux_uid_t)SCARG(uap, uid) == (linux_uid_t)-1) ?
- (uid_t)-1 : SCARG(uap, uid);
- SCARG(&bca, gid) = ((linux_gid_t)SCARG(uap, gid) == (linux_gid_t)-1) ?
- (gid_t)-1 : SCARG(uap, gid);
-
- return sys___posix_chown(l, &bca, retval);
-}
-
-int
-linux_sys_fchown16(struct lwp *l, const struct linux_sys_fchown16_args *uap,
register_t *retval)
-{
- /* {
- syscallarg(int) fd;
- syscallarg(int) uid;
- syscallarg(int) gid;
- } */
- struct sys___posix_fchown_args bfa;
-
- SCARG(&bfa, fd) = SCARG(uap, fd);
- SCARG(&bfa, uid) = ((linux_uid_t)SCARG(uap, uid) == (linux_uid_t)-1) ?
- (uid_t)-1 : SCARG(uap, uid);
- SCARG(&bfa, gid) = ((linux_gid_t)SCARG(uap, gid) == (linux_gid_t)-1) ?
- (gid_t)-1 : SCARG(uap, gid);
-
- return sys___posix_fchown(l, &bfa, retval);
-}
-
-int
-linux_sys_lchown16(struct lwp *l, const struct linux_sys_lchown16_args *uap,
register_t *retval)
-{
- /* {
- syscallarg(char *) path;
- syscallarg(int) uid;
- syscallarg(int) gid;
- } */
- struct sys___posix_lchown_args bla;
-
- SCARG(&bla, path) = SCARG(uap, path);
- SCARG(&bla, uid) = ((linux_uid_t)SCARG(uap, uid) == (linux_uid_t)-1) ?
- (uid_t)-1 : SCARG(uap, uid);
- SCARG(&bla, gid) = ((linux_gid_t)SCARG(uap, gid) == (linux_gid_t)-1) ?
- (gid_t)-1 : SCARG(uap, gid);
-
- return sys___posix_lchown(l, &bla, retval);
-}
-#endif /* __i386__ || __m68k__ || __arm__ || __amd64__ */
-
/*
* This is just fsync() for now (just as it is in the Linux kernel)
* Note: this is not implemented under Linux on Alpha and Arm
Index: sys/compat/linux/common/linux_misc.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_misc.c,v
retrieving revision 1.192
diff -u -p -r1.192 linux_misc.c
--- sys/compat/linux/common/linux_misc.c 24 Dec 2007 14:17:18 -0000
1.192
+++ sys/compat/linux/common/linux_misc.c 4 Jan 2008 13:06:01 -0000
@@ -960,166 +960,7 @@ linux_sys_personality(struct lwp *l, con
retval[0] = 0;
return 0;
}
-#endif /* !COMPAT_LINUX32 */
-
-#if defined(__i386__) || defined(__m68k__) || defined(COMPAT_LINUX32)
-/*
- * The calls are here because of type conversions.
- */
-#ifndef COMPAT_LINUX32
-int
-linux_sys_setreuid16(struct lwp *l, const struct linux_sys_setreuid16_args
*uap, register_t *retval)
-{
- /* {
- syscallarg(int) ruid;
- syscallarg(int) euid;
- } */
- struct sys_setreuid_args bsa;
-
- SCARG(&bsa, ruid) = ((linux_uid_t)SCARG(uap, ruid) == (linux_uid_t)-1) ?
- (uid_t)-1 : SCARG(uap, ruid);
- SCARG(&bsa, euid) = ((linux_uid_t)SCARG(uap, euid) == (linux_uid_t)-1) ?
- (uid_t)-1 : SCARG(uap, euid);
-
- return sys_setreuid(l, &bsa, retval);
-}
-
-int
-linux_sys_setregid16(struct lwp *l, const struct linux_sys_setregid16_args
*uap, register_t *retval)
-{
- /* {
- syscallarg(int) rgid;
- syscallarg(int) egid;
- } */
- struct sys_setregid_args bsa;
-
- SCARG(&bsa, rgid) = ((linux_gid_t)SCARG(uap, rgid) == (linux_gid_t)-1) ?
- (uid_t)-1 : SCARG(uap, rgid);
- SCARG(&bsa, egid) = ((linux_gid_t)SCARG(uap, egid) == (linux_gid_t)-1) ?
- (uid_t)-1 : SCARG(uap, egid);
-
- return sys_setregid(l, &bsa, retval);
-}
-
-int
-linux_sys_setresuid16(struct lwp *l, const struct linux_sys_setresuid16_args
*uap, register_t *retval)
-{
- /* {
- syscallarg(uid_t) ruid;
- syscallarg(uid_t) euid;
- syscallarg(uid_t) suid;
- } */
- struct linux_sys_setresuid_args lsa;
-
- SCARG(&lsa, ruid) = ((linux_uid_t)SCARG(uap, ruid) == (linux_uid_t)-1) ?
- (uid_t)-1 : SCARG(uap, ruid);
- SCARG(&lsa, euid) = ((linux_uid_t)SCARG(uap, euid) == (linux_uid_t)-1) ?
- (uid_t)-1 : SCARG(uap, euid);
- SCARG(&lsa, suid) = ((linux_uid_t)SCARG(uap, suid) == (linux_uid_t)-1) ?
- (uid_t)-1 : SCARG(uap, suid);
-
- return linux_sys_setresuid(l, &lsa, retval);
-}
-
-int
-linux_sys_setresgid16(struct lwp *l, const struct linux_sys_setresgid16_args
*uap, register_t *retval)
-{
- /* {
- syscallarg(gid_t) rgid;
- syscallarg(gid_t) egid;
- syscallarg(gid_t) sgid;
- } */
- struct linux_sys_setresgid_args lsa;
-
- SCARG(&lsa, rgid) = ((linux_gid_t)SCARG(uap, rgid) == (linux_gid_t)-1) ?
- (gid_t)-1 : SCARG(uap, rgid);
- SCARG(&lsa, egid) = ((linux_gid_t)SCARG(uap, egid) == (linux_gid_t)-1) ?
- (gid_t)-1 : SCARG(uap, egid);
- SCARG(&lsa, sgid) = ((linux_gid_t)SCARG(uap, sgid) == (linux_gid_t)-1) ?
- (gid_t)-1 : SCARG(uap, sgid);
-
- return linux_sys_setresgid(l, &lsa, retval);
-}
-#endif /* COMPAT_LINUX32 */
-
-int
-linux_sys_getgroups16(struct lwp *l, const struct linux_sys_getgroups16_args
*uap, register_t *retval)
-{
- /* {
- syscallarg(int) gidsetsize;
- syscallarg(linux_gid_t *) gidset;
- } */
- linux_gid_t lset[16];
- linux_gid_t *gidset;
- unsigned int ngrps;
- int i, n, j;
- int error;
-
- ngrps = kauth_cred_ngroups(l->l_cred);
- *retval = ngrps;
- if (SCARG(uap, gidsetsize) == 0)
- return 0;
- if (SCARG(uap, gidsetsize) < ngrps)
- return EINVAL;
-
- gidset = SCARG(uap, gidset);
- for (i = 0; i < (n = ngrps); i += n, gidset += n) {
- n -= i;
- if (n > __arraycount(lset))
- n = __arraycount(lset);
- for (j = 0; j < n; j++)
- lset[j] = kauth_cred_group(l->l_cred, i + j);
- error = copyout(lset, gidset, n * sizeof(lset[0]));
- if (error != 0)
- return error;
- }
-
- return 0;
-}
-
-/*
- * It is very unlikly that any problem using 16bit groups is written
- * to allow for more than 16 of them, so don't bother trying to
- * support that.
- */
-#define COMPAT_NGROUPS16 16
-
-int
-linux_sys_setgroups16(struct lwp *l, const struct linux_sys_setgroups16_args
*uap, register_t *retval)
-{
- /* {
- syscallarg(int) gidsetsize;
- syscallarg(linux_gid_t *) gidset;
- } */
- linux_gid_t lset[COMPAT_NGROUPS16];
- kauth_cred_t ncred;
- int error;
- gid_t grbuf[COMPAT_NGROUPS16];
- unsigned int i, ngroups = SCARG(uap, gidsetsize);
-
- if (ngroups > COMPAT_NGROUPS16)
- return EINVAL;
- error = copyin(SCARG(uap, gidset), lset, ngroups);
- if (error != 0)
- return error;
-
- for (i = 0; i < ngroups; i++)
- grbuf[i] = lset[i];
-
- ncred = kauth_cred_alloc();
- error = kauth_cred_setgroups(ncred, grbuf, SCARG(uap, gidsetsize),
- -1, UIO_SYSSPACE);
- if (error != 0) {
- kauth_cred_free(ncred);
- return error;
- }
-
- return kauth_proc_setgroups(l, ncred);
-}
-
-#endif /* __i386__ || __m68k__ || COMPAT_LINUX32 */
-#ifndef COMPAT_LINUX32
/*
* We have nonexistent fsuid equal to uid.
* If modification is requested, refuse.
Index: sys/compat/linux/common/linux_uid16.c
===================================================================
RCS file: sys/compat/linux/common/linux_uid16.c
diff -N sys/compat/linux/common/linux_uid16.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sys/compat/linux/common/linux_uid16.c 4 Jan 2008 13:06:01 -0000
@@ -0,0 +1,307 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Frank van der Linden and Eric Haszlakiewicz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD$");
+
+#include <sys/param.h>
+#include <sys/proc.h>
+#include <sys/kauth.h>
+#include <sys/syscallargs.h>
+
+#include <compat/linux/common/linux_types.h>
+#include <compat/linux/common/linux_signal.h>
+#include <compat/linux/linux_syscallargs.h>
+
+#define LINUXTOBSD_UID(u) \
+ (((linux_uid_t)(u) == (linux_uid_t)-1) ? (uid_t)-1 : (uid_t)(u))
+#define LINUXTOBSD_GID(g) \
+ (((linux_gid_t)(g) == (linux_gid_t)-1) ? (gid_t)-1 : (gid_t)(g))
+
+#define BSDTOLINUX_UID(u) \
+ (((u) & ~0xffff) ? (linux_uid_t)65534 : (linux_uid_t)(u))
+#define BSDTOLINUX_GID(g) \
+ (((g) & ~0xffff) ? (linux_gid_t)65534 : (linux_gid_t)(g))
+
+#ifndef COMPAT_LINUX32
+int
+linux_sys_chown16(struct lwp *l, const struct linux_sys_chown16_args *uap,
register_t *retval)
+{
+ /* {
+ syscallarg(const char *) path;
+ syscallarg(linux_uid_t) uid;
+ syscallarg(linux_gid_t) gid;
+ } */
+ struct sys___posix_chown_args bca;
+
+ SCARG(&bca, path) = SCARG(uap, path);
+ SCARG(&bca, uid) = LINUXTOBSD_UID(SCARG(uap, uid));
+ SCARG(&bca, gid) = LINUXTOBSD_GID(SCARG(uap, gid));
+
+ return sys___posix_chown(l, &bca, retval);
+}
+
+int
+linux_sys_fchown16(struct lwp *l, const struct linux_sys_fchown16_args *uap,
register_t *retval)
+{
+ /* {
+ syscallarg(int) fd;
+ syscallarg(linux_uid_t) uid;
+ syscallarg(linux_gid_t) gid;
+ } */
+ struct sys___posix_fchown_args bfa;
+
+ SCARG(&bfa, fd) = SCARG(uap, fd);
+ SCARG(&bfa, uid) = LINUXTOBSD_UID(SCARG(uap, uid));
+ SCARG(&bfa, gid) = LINUXTOBSD_GID(SCARG(uap, gid));
+
+ return sys___posix_fchown(l, &bfa, retval);
+}
+
+int
+linux_sys_lchown16(struct lwp *l, const struct linux_sys_lchown16_args *uap,
register_t *retval)
+{
+ /* {
+ syscallarg(char *) path;
+ syscallarg(linux_uid_t) uid;
+ syscallarg(linux_gid_t) gid;
+ } */
+ struct sys___posix_lchown_args bla;
+
+ SCARG(&bla, path) = SCARG(uap, path);
+ SCARG(&bla, uid) = LINUXTOBSD_UID(SCARG(uap, uid));
+ SCARG(&bla, gid) = LINUXTOBSD_GID(SCARG(uap, gid));
+
+ return sys___posix_lchown(l, &bla, retval);
+}
+
+int
+linux_sys_setreuid16(struct lwp *l, const struct linux_sys_setreuid16_args
*uap, register_t *retval)
+{
+ /* {
+ syscallarg(linux_uid_t) ruid;
+ syscallarg(linux_uid_t) euid;
+ } */
+ struct sys_setreuid_args bsa;
+
+ SCARG(&bsa, ruid) = LINUXTOBSD_UID(SCARG(uap, ruid));
+ SCARG(&bsa, euid) = LINUXTOBSD_UID(SCARG(uap, euid));
+
+ return sys_setreuid(l, &bsa, retval);
+}
+
+int
+linux_sys_setregid16(struct lwp *l, const struct linux_sys_setregid16_args
*uap, register_t *retval)
+{
+ /* {
+ syscallarg(linux_gid_t) rgid;
+ syscallarg(linux_gid_t) egid;
+ } */
+ struct sys_setregid_args bsa;
+
+ SCARG(&bsa, rgid) = LINUXTOBSD_GID(SCARG(uap, rgid));
+ SCARG(&bsa, egid) = LINUXTOBSD_GID(SCARG(uap, egid));
+
+ return sys_setregid(l, &bsa, retval);
+}
+
+int
+linux_sys_setresuid16(struct lwp *l, const struct linux_sys_setresuid16_args
*uap, register_t *retval)
+{
+ /* {
+ syscallarg(linux_uid_t) ruid;
+ syscallarg(linux_uid_t) euid;
+ syscallarg(linux_uid_t) suid;
+ } */
+ struct linux_sys_setresuid_args lsa;
+
+ SCARG(&lsa, ruid) = LINUXTOBSD_UID(SCARG(uap, ruid));
+ SCARG(&lsa, euid) = LINUXTOBSD_UID(SCARG(uap, euid));
+ SCARG(&lsa, suid) = LINUXTOBSD_UID(SCARG(uap, suid));
+
+ return linux_sys_setresuid(l, &lsa, retval);
+}
+
+int
+linux_sys_setresgid16(struct lwp *l, const struct linux_sys_setresgid16_args
*uap, register_t *retval)
+{
+ /* {
+ syscallarg(linux_gid_t) rgid;
+ syscallarg(linux_gid_t) egid;
+ syscallarg(linux_gid_t) sgid;
+ } */
+ struct linux_sys_setresgid_args lsa;
+
+ SCARG(&lsa, rgid) = LINUXTOBSD_GID(SCARG(uap, rgid));
+ SCARG(&lsa, egid) = LINUXTOBSD_GID(SCARG(uap, egid));
+ SCARG(&lsa, sgid) = LINUXTOBSD_GID(SCARG(uap, sgid));
+
+ return linux_sys_setresgid(l, &lsa, retval);
+}
+
+int
+linux_sys_getresuid16(struct lwp *l, const struct linux_sys_getresuid16_args
*uap, register_t *retval)
+{
+ /* {
+ syscallarg(linux_uid_t) ruid;
+ syscallarg(linux_uid_t) euid;
+ syscallarg(linux_uid_t) suid;
+ } */
+ kauth_cred_t pc = l->l_cred;
+ int error;
+ uid_t buid;
+ linux_uid_t luid;
+
+ buid = kauth_cred_getuid(pc);
+ luid = BSDTOLINUX_UID(buid);
+ if ((error = copyout(&luid, SCARG(uap, ruid), sizeof(luid))) != 0)
+ return error;
+
+ buid = kauth_cred_geteuid(pc);
+ luid = BSDTOLINUX_UID(buid);
+ if ((error = copyout(&luid, SCARG(uap, euid), sizeof(luid))) != 0)
+ return error;
+
+ buid = kauth_cred_getsvuid(pc);
+ luid = BSDTOLINUX_UID(buid);
+ return (copyout(&luid, SCARG(uap, suid), sizeof(luid)));
+}
+
+int
+linux_sys_getresgid16(struct lwp *l, const struct linux_sys_getresgid16_args
*uap, register_t *retval)
+{
+ /* {
+ syscallarg(linux_gid_t) rgid;
+ syscallarg(linux_gid_t) egid;
+ syscallarg(linux_gid_t) sgid;
+ } */
+ kauth_cred_t pc = l->l_cred;
+ int error;
+ gid_t bgid;
+ linux_gid_t lgid;
+
+ bgid = kauth_cred_getgid(pc);
+ lgid = BSDTOLINUX_GID(bgid);
+ if ((error = copyout(&lgid, SCARG(uap, rgid), sizeof(lgid))) != 0)
+ return error;
+
+ bgid = kauth_cred_getegid(pc);
+ lgid = BSDTOLINUX_GID(bgid);
+ if ((error = copyout(&lgid, SCARG(uap, egid), sizeof(lgid))) != 0)
+ return error;
+
+ bgid = kauth_cred_getsvgid(pc);
+ lgid = BSDTOLINUX_GID(bgid);
+ return (copyout(&lgid, SCARG(uap, sgid), sizeof(lgid)));
+}
+#endif /* !COMPAT_LINUX32 */
+
+int
+linux_sys_getgroups16(struct lwp *l, const struct linux_sys_getgroups16_args
*uap, register_t *retval)
+{
+ /* {
+ syscallarg(int) gidsetsize;
+ syscallarg(linux_gid_t *) gidset;
+ } */
+ linux_gid_t lset[16];
+ linux_gid_t *gidset;
+ unsigned int ngrps;
+ int i, n, j;
+ int error;
+
+ ngrps = kauth_cred_ngroups(l->l_cred);
+ *retval = ngrps;
+ if (SCARG(uap, gidsetsize) == 0)
+ return 0;
+ if (SCARG(uap, gidsetsize) < ngrps)
+ return EINVAL;
+
+ gidset = SCARG(uap, gidset);
+ for (i = 0; i < (n = ngrps); i += n, gidset += n) {
+ n -= i;
+ if (n > __arraycount(lset))
+ n = __arraycount(lset);
+ for (j = 0; j < n; j++)
+ lset[j] = kauth_cred_group(l->l_cred, i + j);
+ error = copyout(lset, gidset, n * sizeof(lset[0]));
+ if (error != 0)
+ return error;
+ }
+
+ return 0;
+}
+
+/*
+ * It is very unlikly that any problem using 16bit groups is written
+ * to allow for more than 16 of them, so don't bother trying to
+ * support that.
+ */
+#define COMPAT_NGROUPS16 16
+
+int
+linux_sys_setgroups16(struct lwp *l, const struct linux_sys_setgroups16_args
*uap, register_t *retval)
+{
+ /* {
+ syscallarg(int) gidsetsize;
+ syscallarg(linux_gid_t *) gidset;
+ } */
+ linux_gid_t lset[COMPAT_NGROUPS16];
+ kauth_cred_t ncred;
+ int error;
+ gid_t grbuf[COMPAT_NGROUPS16];
+ unsigned int i, ngroups = SCARG(uap, gidsetsize);
+
+ if (ngroups > COMPAT_NGROUPS16)
+ return EINVAL;
+ error = copyin(SCARG(uap, gidset), lset, ngroups);
+ if (error != 0)
+ return error;
+
+ for (i = 0; i < ngroups; i++)
+ grbuf[i] = lset[i];
+
+ ncred = kauth_cred_alloc();
+ error = kauth_cred_setgroups(ncred, grbuf, SCARG(uap, gidsetsize),
+ -1, UIO_SYSSPACE);
+ if (error != 0) {
+ kauth_cred_free(ncred);
+ return error;
+ }
+
+ return kauth_proc_setgroups(l, ncred);
+}
Index: sys/compat/linux32/arch/amd64/files.linux32_amd64
===================================================================
RCS file: /cvsroot/src/sys/compat/linux32/arch/amd64/files.linux32_amd64,v
retrieving revision 1.1
diff -u -p -r1.1 files.linux32_amd64
--- sys/compat/linux32/arch/amd64/files.linux32_amd64 9 Feb 2006 19:18:57
-0000 1.1
+++ sys/compat/linux32/arch/amd64/files.linux32_amd64 4 Jan 2008 13:06:01
-0000
@@ -7,4 +7,6 @@ file compat/linux32/arch/amd64/linux32_s
file compat/linux32/arch/amd64/linux32_machdep.c compat_linux32
file compat/linux32/arch/amd64/linux32_missing.c compat_linux32
+file compat/linux32/common/linux32_uid16.c compat_linux32
+
file compat/linux/common/linux_oldmmap.c compat_linux32
Index: sys/compat/linux32/arch/amd64/linux32_missing.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux32/arch/amd64/linux32_missing.c,v
retrieving revision 1.3
diff -u -p -r1.3 linux32_missing.c
--- sys/compat/linux32/arch/amd64/linux32_missing.c 19 Jul 2007 22:17:23
-0000 1.3
+++ sys/compat/linux32/arch/amd64/linux32_missing.c 4 Jan 2008 13:06:01
-0000
@@ -25,3 +25,4 @@
#include <compat/linux/common/linux_llseek.c>
#include <compat/linux/common/linux_misc_notalpha.c>
#include <compat/linux/common/linux_misc.c>
+#include <compat/linux/common/linux_uid16.c>
Index: sys/compat/linux32/arch/amd64/syscalls.master
===================================================================
RCS file: /cvsroot/src/sys/compat/linux32/arch/amd64/syscalls.master,v
retrieving revision 1.25
diff -u -p -r1.25 syscalls.master
--- sys/compat/linux32/arch/amd64/syscalls.master 26 Dec 2007 13:50:48
-0000 1.25
+++ sys/compat/linux32/arch/amd64/syscalls.master 4 Jan 2008 13:06:01
-0000
@@ -86,7 +86,7 @@
int mode, int dev); }
15 NOARGS { int netbsd32_chmod(const netbsd32_charp path, int mode); }
16 STD { int linux32_sys_lchown16(const netbsd32_charp path, \
- int uid, int gid); }
+ linux32_uid_t uid, linux32_gid_t gid); }
17 STD { int linux32_sys_break(netbsd32_charp nsize); }
18 OBSOL ostat
19 NOARGS { netbsd32_long compat_43_netbsd32_olseek(int fd, \
@@ -148,8 +148,10 @@
67 UNIMPL sigaction
68 UNIMPL siggetmask
69 UNIMPL sigsetmask
-70 STD { int linux32_sys_setreuid16(int ruid, int euid); }
-71 STD { int linux32_sys_setregid16(int rgid, int egid); }
+70 STD { int linux32_sys_setreuid16(linux32_uid_t ruid, \
+ linux32_uid_t euid); }
+71 STD { int linux32_sys_setregid16(linux32_gid_t rgid, \
+ linux32_gid_t egid); }
72 UNIMPL sigsuspend
73 UNIMPL sigpending
74 NOARGS { int compat_43_netbsd32_osethostname(netbsd32_charp hostname, \
@@ -188,7 +190,8 @@
93 NOARGS { int compat_43_netbsd32_oftruncate(int fd, \
netbsd32_long length); }
94 NOARGS { int netbsd32_fchmod(int fd, int mode); }
-95 STD { int linux32_sys_fchown16(int fd, int uid, int gid); }
+95 STD { int linux32_sys_fchown16(int fd, linux32_uid_t uid, \
+ linux32_gid_t gid); }
96 STD { int linux32_sys_getpriority(int which, int who); }
97 STD { int linux32_sys_setpriority(int which, int who, int prio); }
98 UNIMPL profil
@@ -276,17 +279,19 @@
163 STD { int linux32_sys_mremap(netbsd32_voidp old_address, \
netbsd32_size_t old_size , netbsd32_size_t new_size, \
netbsd32_u_long flags); }
-164 STD { int linux32_sys_setresuid16(uid_t ruid, uid_t euid, \
- uid_t suid); }
-165 UNIMPL getresuid16
+164 STD { int linux32_sys_setresuid16(linux32_uid_t ruid, \
+ linux32_uid_t euid, linux32_uid_t suid); }
+165 STD { int linux32_sys_getresuid16(linux32_uidp_t ruid, \
+ linux32_uidp_t euid, linux32_uidp_t suid); }
166 UNIMPL vm86
167 UNIMPL query_module
168 NOARGS { int netbsd32_poll(netbsd32_pollfdp_t fds, u_int nfds, \
- int timeout); }
+ int timeout); }
169 UNIMPL nfsservctl
-170 STD { int linux32_sys_setresgid16(gid_t rgid, gid_t egid, \
- gid_t sgid); }
-171 UNIMPL int
+170 STD { int linux32_sys_setresgid16(linux32_gid_t rgid, \
+ linux32_gid_t egid, linux32_gid_t sgid); }
+171 STD { int linux32_sys_getresgid16(linux32_gidp_t rgid, \
+ linux32_gidp_t egid, linux32_gidp_t sgid); }
172 UNIMPL prctl
173 STD { int linux32_sys_rt_sigreturn(linux32_ucontextp_t ucp); }
174 STD { int linux32_sys_rt_sigaction(int signum, \
@@ -305,7 +310,7 @@
180 UNIMPL pread
181 UNIMPL pwrite
182 STD { int linux32_sys_chown16(const netbsd32_charp path, \
- int uid, int gid); }
+ linux32_uid_t uid, linux32_gid_t gid); }
183 NOARGS { int netbsd32___getcwd(netbsd32_charp bufp, \
netbsd32_size_t length); }
184 UNIMPL capget
Index: sys/compat/linux32/common/linux32_types.h
===================================================================
RCS file: /cvsroot/src/sys/compat/linux32/common/linux32_types.h,v
retrieving revision 1.5
diff -u -p -r1.5 linux32_types.h
--- sys/compat/linux32/common/linux32_types.h 24 Dec 2007 15:56:21 -0000
1.5
+++ sys/compat/linux32/common/linux32_types.h 4 Jan 2008 13:06:01 -0000
@@ -53,6 +53,7 @@ typedef netbsd32_pointer_t linux32_tmsp_
typedef netbsd32_pointer_t linux32_sched_paramp_t;
typedef netbsd32_pointer_t linux32_utimbufp_t;
typedef netbsd32_pointer_t linux32_oldold_utsnamep_t;
+typedef netbsd32_pointer_t linux32_uidp_t;
typedef netbsd32_pointer_t linux32_gidp_t;
typedef netbsd32_pointer_t linux32_oldselectp_t;
typedef netbsd32_pointer_t linux32_sysinfop_t;
Index: sys/compat/linux32/common/linux32_uid16.c
===================================================================
RCS file: sys/compat/linux32/common/linux32_uid16.c
diff -N sys/compat/linux32/common/linux32_uid16.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sys/compat/linux32/common/linux32_uid16.c 4 Jan 2008 13:06:01 -0000
@@ -0,0 +1,262 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
+ * Copyright (c) 2008 Nicolas Joly, all rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Emmanuel Dreyfus
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD$");
+
+#include <sys/param.h>
+#include <sys/proc.h>
+#include <sys/kauth.h>
+
+#include <compat/netbsd32/netbsd32.h>
+
+#include <compat/linux/common/linux_types.h>
+#include <compat/linux/common/linux_signal.h>
+#include <compat/linux/linux_syscallargs.h>
+
+#include <compat/linux32/common/linux32_types.h>
+#include <compat/linux32/common/linux32_signal.h>
+#include <compat/linux32/common/linux32_machdep.h>
+#include <compat/linux32/linux32_syscallargs.h>
+
+#define LINUX32TOBSD_UID(u) \
+ (((linux32_uid_t)(u) == (linux32_uid_t)-1) ? (uid_t)-1 : (uid_t)(u))
+#define LINUX32TOBSD_GID(g) \
+ (((linux32_gid_t)(g) == (linux32_gid_t)-1) ? (gid_t)-1 : (gid_t)(g))
+
+#define BSDTOLINUX32_UID(u) \
+ (((u) & ~0xffff) ? (linux32_uid_t)65534 : (linux32_uid_t)(u))
+#define BSDTOLINUX32_GID(g) \
+ (((g) & ~0xffff) ? (linux32_gid_t)65534 : (linux32_gid_t)(g))
+
+int
+linux32_sys_chown16(struct lwp *l, const struct linux32_sys_chown16_args *uap,
register_t *retval)
+{
+ /* {
+ syscallarg(const netbsd32_charp) path;
+ syscallarg(linux32_uid_t) uid;
+ syscallarg(linux32_gid_t) gid;
+ } */
+ struct sys___posix_chown_args ua;
+
+ NETBSD32TOP_UAP(path, const char);
+ SCARG(&ua, uid) = LINUX32TOBSD_UID(SCARG(uap, uid));
+ SCARG(&ua, gid) = LINUX32TOBSD_GID(SCARG(uap, gid));
+
+ return sys___posix_chown(l, &ua, retval);
+}
+
+int
+linux32_sys_lchown16(struct lwp *l, const struct linux32_sys_lchown16_args
*uap, register_t *retval)
+{
+ /* {
+ syscallarg(const netbsd32_charp) path;
+ syscallarg(linux32_uid_t) uid;
+ syscallarg(linux32_gid_t) gid;
+ } */
+ struct sys___posix_lchown_args ua;
+
+ NETBSD32TOP_UAP(path, const char);
+ SCARG(&ua, uid) = LINUX32TOBSD_UID(SCARG(uap, uid));
+ SCARG(&ua, gid) = LINUX32TOBSD_GID(SCARG(uap, gid));
+
+ return sys___posix_lchown(l, &ua, retval);
+}
+
+int
+linux32_sys_fchown16(struct lwp *l, const struct linux32_sys_fchown16_args
*uap, register_t *retval)
+{
+ /* {
+ syscallarg(int) fd;
+ syscallarg(linux32_uid_t) uid;
+ syscallarg(linux32_gid_t) gid;
+ } */
+ struct sys___posix_fchown_args ua;
+
+ SCARG(&ua, fd) = SCARG(uap, fd);
+ SCARG(&ua, uid) = LINUX32TOBSD_UID(SCARG(uap, uid));
+ SCARG(&ua, gid) = LINUX32TOBSD_GID(SCARG(uap, gid));
+
+ return sys___posix_fchown(l, &ua, retval);
+}
+
+int
+linux32_sys_getgroups16(struct lwp *l, const struct
linux32_sys_getgroups16_args *uap, register_t *retval)
+{
+ /* {
+ syscallarg(int) gidsetsize;
+ syscallarg(linux32_gidp_t) gidset;
+ } */
+ struct linux_sys_getgroups16_args ua;
+
+ NETBSD32TO64_UAP(gidsetsize);
+ NETBSD32TOP_UAP(gidset, linux_gid_t);
+
+ return linux_sys_getgroups16(l, &ua, retval);
+}
+
+int
+linux32_sys_setgroups16(struct lwp *l, const struct
linux32_sys_setgroups16_args *uap, register_t *retval)
+{
+ /* {
+ syscallarg(int) gidsetsize;
+ syscallarg(linux32_gidp_t) gidset;
+ } */
+ struct linux_sys_setgroups16_args ua;
+
+ NETBSD32TO64_UAP(gidsetsize);
+ NETBSD32TOP_UAP(gidset, linux_gid_t);
+
+ return linux_sys_setgroups16(l, &ua, retval);
+}
+
+int
+linux32_sys_setreuid16(struct lwp *l, const struct linux32_sys_setreuid16_args
*uap, register_t *retval)
+{
+ /* {
+ syscallarg(linux32_uid_t) ruid;
+ syscallarg(linux32_uid_t) euid;
+ } */
+ struct sys_setreuid_args bsa;
+
+ SCARG(&bsa, ruid) = LINUX32TOBSD_UID(SCARG(uap, ruid));
+ SCARG(&bsa, euid) = LINUX32TOBSD_UID(SCARG(uap, euid));
+
+ return sys_setreuid(l, &bsa, retval);
+}
+
+int
+linux32_sys_setregid16(struct lwp *l, const struct linux32_sys_setregid16_args
*uap, register_t *retval)
+{
+ /* {
+ syscallarg(linux32_gid_t) rgid;
+ syscallarg(linux32_gid_t) egid;
+ } */
+ struct sys_setregid_args bsa;
+
+ SCARG(&bsa, rgid) = LINUX32TOBSD_GID(SCARG(uap, rgid));
+ SCARG(&bsa, egid) = LINUX32TOBSD_GID(SCARG(uap, egid));
+
+ return sys_setregid(l, &bsa, retval);
+}
+
+int
+linux32_sys_setresuid16(struct lwp *l, const struct
linux32_sys_setresuid16_args *uap, register_t *retval)
+{
+ /* {
+ syscallarg(linux32_uid_t) ruid;
+ syscallarg(linux32_uid_t) euid;
+ syscallarg(linux32_uid_t) suid;
+ } */
+ struct linux32_sys_setresuid_args lsa;
+
+ SCARG(&lsa, ruid) = LINUX32TOBSD_UID(SCARG(uap, ruid));
+ SCARG(&lsa, euid) = LINUX32TOBSD_UID(SCARG(uap, euid));
+ SCARG(&lsa, suid) = LINUX32TOBSD_UID(SCARG(uap, suid));
+
+ return linux32_sys_setresuid(l, &lsa, retval);
+}
+
+int
+linux32_sys_setresgid16(struct lwp *l, const struct
linux32_sys_setresgid16_args *uap, register_t *retval)
+{
+ /* {
+ syscallarg(linux32_gid_t) rgid;
+ syscallarg(linux32_gid_t) egid;
+ syscallarg(linux32_gid_t) sgid;
+ } */
+ struct linux32_sys_setresgid_args lsa;
+
+ SCARG(&lsa, rgid) = LINUX32TOBSD_GID(SCARG(uap, rgid));
+ SCARG(&lsa, egid) = LINUX32TOBSD_GID(SCARG(uap, egid));
+ SCARG(&lsa, sgid) = LINUX32TOBSD_GID(SCARG(uap, sgid));
+
+ return linux32_sys_setresgid(l, &lsa, retval);
+}
+
+int
+linux32_sys_getresuid16(struct lwp *l, const struct
linux32_sys_getresuid16_args *uap, register_t *retval)
+{
+ /* {
+ syscallarg(linux32_uidp_t) ruid;
+ syscallarg(linux32_uidp_t) euid;
+ syscallarg(linux32_uidp_t) suid;
+ } */
+ kauth_cred_t pc = l->l_cred;
+ int error;
+ uid_t buid;
+ linux32_uid_t luid;
+
+ buid = kauth_cred_getuid(pc);
+ luid = BSDTOLINUX32_UID(buid);
+ if ((error = copyout(&luid, SCARG_P32(uap, ruid), sizeof(luid))) != 0)
+ return error;
+
+ buid = kauth_cred_geteuid(pc);
+ luid = BSDTOLINUX32_UID(buid);
+ if ((error = copyout(&luid, SCARG_P32(uap, euid), sizeof(luid))) != 0)
+ return error;
+
+ buid = kauth_cred_getsvuid(pc);
+ luid = BSDTOLINUX32_UID(buid);
+ return (copyout(&luid, SCARG_P32(uap, suid), sizeof(luid)));
+}
+
+int
+linux32_sys_getresgid16(struct lwp *l, const struct
linux32_sys_getresgid16_args *uap, register_t *retval)
+{
+ /* {
+ syscallarg(linux32_gidp_t) rgid;
+ syscallarg(linux32_gidp_t) egid;
+ syscallarg(linux32_gidp_t) sgid;
+ } */
+ kauth_cred_t pc = l->l_cred;
+ int error;
+ gid_t bgid;
+ linux32_gid_t lgid;
+
+ bgid = kauth_cred_getgid(pc);
+ lgid = BSDTOLINUX32_GID(bgid);
+ if ((error = copyout(&lgid, SCARG_P32(uap, rgid), sizeof(lgid))) != 0)
+ return error;
+
+ bgid = kauth_cred_getegid(pc);
+ lgid = BSDTOLINUX32_GID(bgid);
+ if ((error = copyout(&lgid, SCARG_P32(uap, egid), sizeof(lgid))) != 0)
+ return error;
+
+ bgid = kauth_cred_getsvgid(pc);
+ lgid = BSDTOLINUX32_GID(bgid);
+ return (copyout(&lgid, SCARG_P32(uap, sgid), sizeof(lgid)));
+}
Index: sys/compat/linux32/common/linux32_unistd.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux32/common/linux32_unistd.c,v
retrieving revision 1.18
diff -u -p -r1.18 linux32_unistd.c
--- sys/compat/linux32/common/linux32_unistd.c 21 Dec 2007 22:26:22 -0000
1.18
+++ sys/compat/linux32/common/linux32_unistd.c 4 Jan 2008 13:06:01 -0000
@@ -293,56 +293,6 @@ linux32_sys_mknod(struct lwp *l, const s
}
int
-linux32_sys_chown16(struct lwp *l, const struct linux32_sys_chown16_args *uap,
register_t *retval)
-{
- /* {
- syscallarg(const netbsd32_charp) path;
- syscallarg(int) uid;
- syscallarg(int) gid;
- } */
- struct sys___posix_chown_args ua;
-
- NETBSD32TOP_UAP(path, const char);
-
- if ((linux32_uid_t)SCARG(uap, uid) == (linux32_uid_t)-1)
- SCARG(&ua, uid) = (uid_t)-1;
- else
- SCARG(&ua, uid) = SCARG(uap, uid);
-
- if ((linux32_gid_t)SCARG(uap, gid) == (linux32_gid_t)-1)
- SCARG(&ua, gid) = (gid_t)-1;
- else
- SCARG(&ua, gid) = SCARG(uap, gid);
-
- return sys___posix_chown(l, &ua, retval);
-}
-
-int
-linux32_sys_lchown16(struct lwp *l, const struct linux32_sys_lchown16_args
*uap, register_t *retval)
-{
- /* {
- syscallarg(const netbsd32_charp) path;
- syscallarg(int) uid;
- syscallarg(int) gid;
- } */
- struct sys___posix_lchown_args ua;
-
- NETBSD32TOP_UAP(path, const char);
-
- if ((linux32_uid_t)SCARG(uap, uid) == (linux32_uid_t)-1)
- SCARG(&ua, uid) = (uid_t)-1;
- else
- SCARG(&ua, uid) = SCARG(uap, uid);
-
- if ((linux32_gid_t)SCARG(uap, gid) == (linux32_gid_t)-1)
- SCARG(&ua, gid) = (gid_t)-1;
- else
- SCARG(&ua, gid) = SCARG(uap, gid);
-
- return sys___posix_lchown(l, &ua, retval);
-}
-
-int
linux32_sys_break(struct lwp *l, const struct linux32_sys_break_args *uap,
register_t *retval)
{
#if 0
@@ -370,36 +320,6 @@ linux32_sys_rename(struct lwp *l, const
}
int
-linux32_sys_getgroups16(struct lwp *l, const struct
linux32_sys_getgroups16_args *uap, register_t *retval)
-{
- /* {
- syscallarg(int) gidsetsize;
- syscallarg(linux32_gidp_t) gidset;
- } */
- struct linux_sys_getgroups16_args ua;
-
- NETBSD32TO64_UAP(gidsetsize);
- NETBSD32TOP_UAP(gidset, linux_gid_t);
-
- return linux_sys_getgroups16(l, &ua, retval);
-}
-
-int
-linux32_sys_setgroups16(struct lwp *l, const struct
linux32_sys_setgroups16_args *uap, register_t *retval)
-{
- /* {
- syscallarg(int) gidsetsize;
- syscallarg(linux32_gidp_t) gidset;
- } */
- struct linux_sys_setgroups16_args ua;
-
- NETBSD32TO64_UAP(gidsetsize);
- NETBSD32TOP_UAP(gidset, linux_gid_t);
-
- return linux_sys_setgroups16(l, &ua, retval);
-}
-
-int
linux32_sys_swapon(struct lwp *l, const struct linux32_sys_swapon_args *uap,
register_t *retval)
{
/* {
@@ -464,31 +384,6 @@ linux32_sys_truncate(struct lwp *l, cons
}
int
-linux32_sys_fchown16(struct lwp *l, const struct linux32_sys_fchown16_args
*uap, register_t *retval)
-{
- /* {
- syscallarg(int) fd;
- syscallarg(int) uid;
- syscallarg(int) gid;
- } */
- struct sys___posix_fchown_args ua;
-
- SCARG(&ua, fd) = SCARG(uap, fd);
-
- if ((linux32_uid_t)SCARG(uap, uid) == (linux32_uid_t)-1)
- SCARG(&ua, uid) = (uid_t)-1;
- else
- SCARG(&ua, uid) = SCARG(uap, uid);
-
- if ((linux32_gid_t)SCARG(uap, gid) == (linux32_gid_t)-1)
- SCARG(&ua, gid) = (gid_t)-1;
- else
- SCARG(&ua, gid) = SCARG(uap, gid);
-
- return sys___posix_fchown(l, &ua, retval);
-}
-
-int
linux32_sys_setresuid(struct lwp *l, const struct linux32_sys_setresuid_args
*uap, register_t *retval)
{
/* {
@@ -588,97 +483,3 @@ linux32_sys_setfsgid(struct lwp *l, cons
return linux_sys_setfsgid(l, &ua, retval);
}
-
-int
-linux32_sys_setreuid16(struct lwp *l, const struct linux32_sys_setreuid16_args
*uap, register_t *retval)
-{
- /* {
- syscallarg(int) ruid;
- syscallarg(int) euid;
- } */
- struct sys_setreuid_args bsa;
-
- if ((linux32_uid_t)SCARG(uap, ruid) == (linux32_uid_t)-1)
- SCARG(&bsa, ruid) = (uid_t)-1;
- else
- SCARG(&bsa, ruid) = SCARG(uap, ruid);
- if ((linux32_uid_t)SCARG(uap, euid) == (linux32_uid_t)-1)
- SCARG(&bsa, euid) = (uid_t)-1;
- else
- SCARG(&bsa, euid) = SCARG(uap, euid);
-
- return sys_setreuid(l, &bsa, retval);
-}
-
-int
-linux32_sys_setregid16(struct lwp *l, const struct linux32_sys_setregid16_args
*uap, register_t *retval)
-{
- /* {
- syscallarg(int) rgid;
- syscallarg(int) egid;
- } */
- struct sys_setregid_args bsa;
-
- if ((linux32_gid_t)SCARG(uap, rgid) == (linux32_gid_t)-1)
- SCARG(&bsa, rgid) = (gid_t)-1;
- else
- SCARG(&bsa, rgid) = SCARG(uap, rgid);
- if ((linux32_gid_t)SCARG(uap, egid) == (linux32_gid_t)-1)
- SCARG(&bsa, egid) = (gid_t)-1;
- else
- SCARG(&bsa, egid) = SCARG(uap, egid);
-
- return sys_setregid(l, &bsa, retval);
-}
-
-int
-linux32_sys_setresuid16(struct lwp *l, const struct
linux32_sys_setresuid16_args *uap, register_t *retval)
-{
- /* {
- syscallarg(uid_t) ruid;
- syscallarg(uid_t) euid;
- syscallarg(uid_t) suid;
- } */
- struct linux32_sys_setresuid_args lsa;
-
- if ((linux32_uid_t)SCARG(uap, ruid) == (linux32_uid_t)-1)
- SCARG(&lsa, ruid) = (uid_t)-1;
- else
- SCARG(&lsa, ruid) = SCARG(uap, ruid);
- if ((linux32_uid_t)SCARG(uap, euid) == (linux32_uid_t)-1)
- SCARG(&lsa, euid) = (uid_t)-1;
- else
- SCARG(&lsa, euid) = SCARG(uap, euid);
- if ((linux32_uid_t)SCARG(uap, suid) == (linux32_uid_t)-1)
- SCARG(&lsa, suid) = (uid_t)-1;
- else
- SCARG(&lsa, suid) = SCARG(uap, euid);
-
- return linux32_sys_setresuid(l, &lsa, retval);
-}
-
-int
-linux32_sys_setresgid16(struct lwp *l, const struct
linux32_sys_setresgid16_args *uap, register_t *retval)
-{
- /* {
- syscallarg(gid_t) rgid;
- syscallarg(gid_t) egid;
- syscallarg(gid_t) sgid;
- } */
- struct linux32_sys_setresgid_args lsa;
-
- if ((linux32_gid_t)SCARG(uap, rgid) == (linux32_gid_t)-1)
- SCARG(&lsa, rgid) = (gid_t)-1;
- else
- SCARG(&lsa, rgid) = SCARG(uap, rgid);
- if ((linux32_gid_t)SCARG(uap, egid) == (linux32_gid_t)-1)
- SCARG(&lsa, egid) = (gid_t)-1;
- else
- SCARG(&lsa, egid) = SCARG(uap, egid);
- if ((linux32_gid_t)SCARG(uap, sgid) == (linux32_gid_t)-1)
- SCARG(&lsa, sgid) = (gid_t)-1;
- else
- SCARG(&lsa, sgid) = SCARG(uap, sgid);
-
- return linux32_sys_setresgid(l, &lsa, retval);
-}
Home |
Main Index |
Thread Index |
Old Index