Tue Nov 2 18:18:07 2010 UTC ()
personality() now interprets its parameter as having
the base personality type in the low byte and
various flags in the upper bytes.  for now just mask off
the flags to make sure the base type is one we accept.
store the current personality in the emuldata so that
we can return the expected value for PER_QUERY.


(chs)
diff -r1.17 -r1.18 src/sys/compat/linux/common/linux_emuldata.h
diff -r1.217 -r1.218 src/sys/compat/linux/common/linux_misc.c
diff -r1.19 -r1.20 src/sys/compat/linux/common/linux_misc.h
diff -r1.20 -r1.21 src/sys/compat/linux32/common/linux32_misc.c

cvs diff -r1.17 -r1.18 src/sys/compat/linux/common/linux_emuldata.h (expand / switch to unified diff)

--- src/sys/compat/linux/common/linux_emuldata.h 2010/07/07 01:30:35 1.17
+++ src/sys/compat/linux/common/linux_emuldata.h 2010/11/02 18:18:07 1.18
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: linux_emuldata.h,v 1.17 2010/07/07 01:30:35 chs Exp $ */ 1/* $NetBSD: linux_emuldata.h,v 1.18 2010/11/02 18:18:07 chs Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998,2002 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998,2002 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Eric Haszlakiewicz. 8 * by Eric Haszlakiewicz.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -38,16 +38,17 @@ @@ -38,16 +38,17 @@
38 * This is auxillary data the linux compat code 38 * This is auxillary data the linux compat code
39 * needs to do its work. A pointer to it is 39 * needs to do its work. A pointer to it is
40 * stored in the emuldata field of the proc 40 * stored in the emuldata field of the proc
41 * structure. 41 * structure.
42 */ 42 */
43 43
44struct linux_emuldata { 44struct linux_emuldata {
45 int led_debugreg[8]; /* GDB information for ptrace - for use, */ 45 int led_debugreg[8]; /* GDB information for ptrace - for use, */
46 /* see ../arch/i386/linux_ptrace.c */ 46 /* see ../arch/i386/linux_ptrace.c */
47 47
48 void *led_child_tidptr; /* Used during clone() */ 48 void *led_child_tidptr; /* Used during clone() */
49 void *led_clear_tid; /* Own TID to clear on exit */ 49 void *led_clear_tid; /* Own TID to clear on exit */
50 struct linux_robust_list_head *led_robust_head; 50 struct linux_robust_list_head *led_robust_head;
 51 long led_personality;
51}; 52};
52 53
53#endif /* !_COMMON_LINUX_EMULDATA_H */ 54#endif /* !_COMMON_LINUX_EMULDATA_H */

cvs diff -r1.217 -r1.218 src/sys/compat/linux/common/linux_misc.c (expand / switch to unified diff)

--- src/sys/compat/linux/common/linux_misc.c 2010/09/11 20:53:04 1.217
+++ src/sys/compat/linux/common/linux_misc.c 2010/11/02 18:18:07 1.218
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: linux_misc.c,v 1.217 2010/09/11 20:53:04 chs Exp $ */ 1/* $NetBSD: linux_misc.c,v 1.218 2010/11/02 18:18:07 chs Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Frank van der Linden and Eric Haszlakiewicz; by Jason R. Thorpe 8 * by Frank van der Linden and Eric Haszlakiewicz; by Jason R. Thorpe
9 * of the Numerical Aerospace Simulation Facility, NASA Ames Research Center. 9 * of the Numerical Aerospace Simulation Facility, NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -47,27 +47,27 @@ @@ -47,27 +47,27 @@
47 * linux_sys_readdir : linux_misc_notalpha.c 47 * linux_sys_readdir : linux_misc_notalpha.c
48 * linux_sys_setresgid : linux_misc_notalpha.c 48 * linux_sys_setresgid : linux_misc_notalpha.c
49 * linux_sys_time : linux_misc_notalpha.c 49 * linux_sys_time : linux_misc_notalpha.c
50 * linux_sys_utime : linux_misc_notalpha.c 50 * linux_sys_utime : linux_misc_notalpha.c
51 * linux_sys_waitpid : linux_misc_notalpha.c 51 * linux_sys_waitpid : linux_misc_notalpha.c
52 * linux_sys_old_mmap : linux_oldmmap.c 52 * linux_sys_old_mmap : linux_oldmmap.c
53 * linux_sys_oldolduname : linux_oldolduname.c 53 * linux_sys_oldolduname : linux_oldolduname.c
54 * linux_sys_oldselect : linux_oldselect.c 54 * linux_sys_oldselect : linux_oldselect.c
55 * linux_sys_olduname : linux_olduname.c 55 * linux_sys_olduname : linux_olduname.c
56 * linux_sys_pipe : linux_pipe.c 56 * linux_sys_pipe : linux_pipe.c
57 */ 57 */
58 58
59#include <sys/cdefs.h> 59#include <sys/cdefs.h>
60__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.217 2010/09/11 20:53:04 chs Exp $"); 60__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.218 2010/11/02 18:18:07 chs Exp $");
61 61
62#include <sys/param.h> 62#include <sys/param.h>
63#include <sys/systm.h> 63#include <sys/systm.h>
64#include <sys/namei.h> 64#include <sys/namei.h>
65#include <sys/proc.h> 65#include <sys/proc.h>
66#include <sys/dirent.h> 66#include <sys/dirent.h>
67#include <sys/file.h> 67#include <sys/file.h>
68#include <sys/stat.h> 68#include <sys/stat.h>
69#include <sys/filedesc.h> 69#include <sys/filedesc.h>
70#include <sys/ioctl.h> 70#include <sys/ioctl.h>
71#include <sys/kernel.h> 71#include <sys/kernel.h>
72#include <sys/malloc.h> 72#include <sys/malloc.h>
73#include <sys/mbuf.h> 73#include <sys/mbuf.h>
@@ -919,36 +919,47 @@ linux_select1(struct lwp *l, register_t  @@ -919,36 +919,47 @@ linux_select1(struct lwp *l, register_t
919 919
920/* 920/*
921 * Set the 'personality' (emulation mode) for the current process. Only 921 * Set the 'personality' (emulation mode) for the current process. Only
922 * accept the Linux personality here (0). This call is needed because 922 * accept the Linux personality here (0). This call is needed because
923 * the Linux ELF crt0 issues it in an ugly kludge to make sure that 923 * the Linux ELF crt0 issues it in an ugly kludge to make sure that
924 * ELF binaries run in Linux mode, not SVR4 mode. 924 * ELF binaries run in Linux mode, not SVR4 mode.
925 */ 925 */
926int 926int
927linux_sys_personality(struct lwp *l, const struct linux_sys_personality_args *uap, register_t *retval) 927linux_sys_personality(struct lwp *l, const struct linux_sys_personality_args *uap, register_t *retval)
928{ 928{
929 /* { 929 /* {
930 syscallarg(unsigned long) per; 930 syscallarg(unsigned long) per;
931 } */ 931 } */
 932 struct linux_emuldata *led;
 933 int per;
932 934
933 switch (SCARG(uap, per)) { 935 per = SCARG(uap, per);
 936 led = l->l_emuldata;
 937 if (per == LINUX_PER_QUERY) {
 938 retval[0] = led->led_personality;
 939 return 0;
 940 }
 941
 942 switch (per & LINUX_PER_MASK) {
934 case LINUX_PER_LINUX: 943 case LINUX_PER_LINUX:
935 case LINUX_PER_QUERY: 944 case LINUX_PER_LINUX32:
 945 led->led_personality = per;
936 break; 946 break;
 947
937 default: 948 default:
938 return EINVAL; 949 return EINVAL;
939 } 950 }
940 951
941 retval[0] = LINUX_PER_LINUX; 952 retval[0] = per;
942 return 0; 953 return 0;
943} 954}
944 955
945/* 956/*
946 * We have nonexistent fsuid equal to uid. 957 * We have nonexistent fsuid equal to uid.
947 * If modification is requested, refuse. 958 * If modification is requested, refuse.
948 */ 959 */
949int 960int
950linux_sys_setfsuid(struct lwp *l, const struct linux_sys_setfsuid_args *uap, register_t *retval) 961linux_sys_setfsuid(struct lwp *l, const struct linux_sys_setfsuid_args *uap, register_t *retval)
951{ 962{
952 /* { 963 /* {
953 syscallarg(uid_t) uid; 964 syscallarg(uid_t) uid;
954 } */ 965 } */

cvs diff -r1.19 -r1.20 src/sys/compat/linux/common/linux_misc.h (expand / switch to unified diff)

--- src/sys/compat/linux/common/linux_misc.h 2009/01/19 13:31:40 1.19
+++ src/sys/compat/linux/common/linux_misc.h 2010/11/02 18:18:07 1.20
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: linux_misc.h,v 1.19 2009/01/19 13:31:40 njoly Exp $ */ 1/* $NetBSD: linux_misc.h,v 1.20 2010/11/02 18:18:07 chs Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Eric Haszlakiewicz. 8 * by Eric Haszlakiewicz.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -113,26 +113,30 @@ struct linux_sysinfo { @@ -113,26 +113,30 @@ struct linux_sysinfo {
113#define LINUX_TMPFS_SUPER_MAGIC 0x01021994 113#define LINUX_TMPFS_SUPER_MAGIC 0x01021994
114#define LINUX_USBDEVICE_SUPER_MAGIC 0x00009fa2 114#define LINUX_USBDEVICE_SUPER_MAGIC 0x00009fa2
115#define LINUX_DEVPTS_SUPER_MAGIC 0x00001cd1 115#define LINUX_DEVPTS_SUPER_MAGIC 0x00001cd1
116#define LINUX_XENIX_SUPER_MAGIC (LINUX_SYSV_MAGIC_BASE + 1) 116#define LINUX_XENIX_SUPER_MAGIC (LINUX_SYSV_MAGIC_BASE + 1)
117 117
118struct linux_mnttypes { 118struct linux_mnttypes {
119 const char *bsd; 119 const char *bsd;
120 int linux; 120 int linux;
121}; 121};
122extern const struct linux_mnttypes linux_fstypes[]; 122extern const struct linux_mnttypes linux_fstypes[];
123extern const int linux_fstypes_cnt; 123extern const int linux_fstypes_cnt;
124 124
125/* Personality types. */ 125/* Personality types. */
126#define LINUX_PER_LINUX 0x00000000 
127#define LINUX_PER_LINUX32 0x00000008 
128#define LINUX_PER_QUERY 0xffffffff 126#define LINUX_PER_QUERY 0xffffffff
 127#define LINUX_PER_LINUX 0x00
 128#define LINUX_PER_LINUX32 0x08
 129#define LINUX_PER_MASK 0xff
 130
 131/* Personality flags. */
 132#define LINUX_PER_ADDR_NO_RANDOMIZE 0x00040000
129 133
130#ifdef _KERNEL 134#ifdef _KERNEL
131__BEGIN_DECLS 135__BEGIN_DECLS
132int bsd_to_linux_wstat(int); 136int bsd_to_linux_wstat(int);
133int linux_select1(struct lwp *, register_t *, int, fd_set *, fd_set *, 137int linux_select1(struct lwp *, register_t *, int, fd_set *, fd_set *,
134 fd_set *, struct linux_timeval *); 138 fd_set *, struct linux_timeval *);
135__END_DECLS 139__END_DECLS
136#endif /* !_KERNEL */ 140#endif /* !_KERNEL */
137 141
138#endif /* !_LINUX_MISC_H */ 142#endif /* !_LINUX_MISC_H */

cvs diff -r1.20 -r1.21 src/sys/compat/linux32/common/linux32_misc.c (expand / switch to unified diff)

--- src/sys/compat/linux32/common/linux32_misc.c 2010/11/02 18:14:06 1.20
+++ src/sys/compat/linux32/common/linux32_misc.c 2010/11/02 18:18:07 1.21
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: linux32_misc.c,v 1.20 2010/11/02 18:14:06 chs Exp $ */ 1/* $NetBSD: linux32_misc.c,v 1.21 2010/11/02 18:18:07 chs Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc. 4 * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Frank van der Linden and Eric Haszlakiewicz; by Jason R. Thorpe 8 * by Frank van der Linden and Eric Haszlakiewicz; by Jason R. Thorpe
9 * of the Numerical Aerospace Simulation Facility, NASA Ames Research Center; 9 * of the Numerical Aerospace Simulation Facility, NASA Ames Research Center;
10 * by Edgar Fu\ss, Mathematisches Institut der Uni Bonn. 10 * by Edgar Fu\ss, Mathematisches Institut der Uni Bonn.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE. 31 * POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__KERNEL_RCSID(0, "$NetBSD: linux32_misc.c,v 1.20 2010/11/02 18:14:06 chs Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: linux32_misc.c,v 1.21 2010/11/02 18:18:07 chs Exp $");
36 36
37#include <sys/param.h> 37#include <sys/param.h>
38#include <sys/proc.h> 38#include <sys/proc.h>
39#include <sys/time.h> 39#include <sys/time.h>
40#include <sys/types.h> 40#include <sys/types.h>
41#include <sys/malloc.h> 41#include <sys/malloc.h>
42#include <sys/fstypes.h> 42#include <sys/fstypes.h>
43#include <sys/vfs_syscalls.h> 43#include <sys/vfs_syscalls.h>
44#include <sys/ptrace.h> 44#include <sys/ptrace.h>
45#include <sys/syscall.h> 45#include <sys/syscall.h>
46 46
47#include <compat/netbsd32/netbsd32.h> 47#include <compat/netbsd32/netbsd32.h>
48#include <compat/netbsd32/netbsd32_syscallargs.h> 48#include <compat/netbsd32/netbsd32_syscallargs.h>
@@ -213,38 +213,30 @@ linux32_sys_ptrace(struct lwp *l, const  @@ -213,38 +213,30 @@ linux32_sys_ptrace(struct lwp *l, const
213 } 213 }
214 else 214 else
215 ptr++; 215 ptr++;
216 216
217 return EIO; 217 return EIO;
218} 218}
219 219
220int 220int
221linux32_sys_personality(struct lwp *l, const struct linux32_sys_personality_args *uap, register_t *retval) 221linux32_sys_personality(struct lwp *l, const struct linux32_sys_personality_args *uap, register_t *retval)
222{ 222{
223 /* { 223 /* {
224 syscallarg(netbsd32_u_long) per; 224 syscallarg(netbsd32_u_long) per;
225 } */ 225 } */
 226 struct linux_sys_personality_args ua;
226 227
227 switch (SCARG(uap, per)) { 228 NETBSD32TOX_UAP(per, long);
228 case LINUX_PER_LINUX: 229 return linux_sys_personality(l, &ua, retval);
229 case LINUX_PER_LINUX32: 
230 case LINUX_PER_QUERY: 
231 break; 
232 default: 
233 return EINVAL; 
234 } 
235 
236 retval[0] = LINUX_PER_LINUX; 
237 return 0; 
238} 230}
239 231
240int 232int
241linux32_sys_futex(struct lwp *l, 233linux32_sys_futex(struct lwp *l,
242 const struct linux32_sys_futex_args *uap, register_t *retval) 234 const struct linux32_sys_futex_args *uap, register_t *retval)
243{ 235{
244 /* { 236 /* {
245 syscallarg(linux32_intp_t) uaddr; 237 syscallarg(linux32_intp_t) uaddr;
246 syscallarg(int) op; 238 syscallarg(int) op;
247 syscallarg(int) val; 239 syscallarg(int) val;
248 syscallarg(linux32_timespecp_t) timeout; 240 syscallarg(linux32_timespecp_t) timeout;
249 syscallarg(linux32_intp_t) uaddr2; 241 syscallarg(linux32_intp_t) uaddr2;
250 syscallarg(int) val3; 242 syscallarg(int) val3;