Module Name:    src
Committed By:   chs
Date:           Tue Nov  2 18:18:07 UTC 2010

Modified Files:
        src/sys/compat/linux/common: linux_emuldata.h linux_misc.c linux_misc.h
        src/sys/compat/linux32/common: linux32_misc.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/compat/linux/common/linux_emuldata.h
cvs rdiff -u -r1.217 -r1.218 src/sys/compat/linux/common/linux_misc.c
cvs rdiff -u -r1.19 -r1.20 src/sys/compat/linux/common/linux_misc.h
cvs rdiff -u -r1.20 -r1.21 src/sys/compat/linux32/common/linux32_misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_emuldata.h
diff -u src/sys/compat/linux/common/linux_emuldata.h:1.17 src/sys/compat/linux/common/linux_emuldata.h:1.18
--- src/sys/compat/linux/common/linux_emuldata.h:1.17	Wed Jul  7 01:30:35 2010
+++ src/sys/compat/linux/common/linux_emuldata.h	Tue Nov  2 18:18:07 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_emuldata.h,v 1.17 2010/07/07 01:30:35 chs Exp $	*/
+/*	$NetBSD: linux_emuldata.h,v 1.18 2010/11/02 18:18:07 chs Exp $	*/
 
 /*-
  * Copyright (c) 1998,2002 The NetBSD Foundation, Inc.
@@ -48,6 +48,7 @@
 	void	*led_child_tidptr;	/* Used during clone() */
 	void	*led_clear_tid;		/* Own TID to clear on exit */
 	struct linux_robust_list_head *led_robust_head;
+	long	led_personality;
 };
 
 #endif /* !_COMMON_LINUX_EMULDATA_H */

Index: src/sys/compat/linux/common/linux_misc.c
diff -u src/sys/compat/linux/common/linux_misc.c:1.217 src/sys/compat/linux/common/linux_misc.c:1.218
--- src/sys/compat/linux/common/linux_misc.c:1.217	Sat Sep 11 20:53:04 2010
+++ src/sys/compat/linux/common/linux_misc.c	Tue Nov  2 18:18:07 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_misc.c,v 1.217 2010/09/11 20:53:04 chs Exp $	*/
+/*	$NetBSD: linux_misc.c,v 1.218 2010/11/02 18:18:07 chs Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.217 2010/09/11 20:53:04 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.218 2010/11/02 18:18:07 chs Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -929,16 +929,27 @@
 	/* {
 		syscallarg(unsigned long) per;
 	} */
+	struct linux_emuldata *led;
+	int per;
 
-	switch (SCARG(uap, per)) {
+	per = SCARG(uap, per);
+	led = l->l_emuldata;
+	if (per == LINUX_PER_QUERY) {
+		retval[0] = led->led_personality;
+		return 0;
+	}
+	 
+	switch (per & LINUX_PER_MASK) {
 	case LINUX_PER_LINUX:
-	case LINUX_PER_QUERY:
+	case LINUX_PER_LINUX32:
+		led->led_personality = per;
 		break;
+
 	default:
 		return EINVAL;
 	}
 
-	retval[0] = LINUX_PER_LINUX;
+	retval[0] = per;
 	return 0;
 }
 

Index: src/sys/compat/linux/common/linux_misc.h
diff -u src/sys/compat/linux/common/linux_misc.h:1.19 src/sys/compat/linux/common/linux_misc.h:1.20
--- src/sys/compat/linux/common/linux_misc.h:1.19	Mon Jan 19 13:31:40 2009
+++ src/sys/compat/linux/common/linux_misc.h	Tue Nov  2 18:18:07 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_misc.h,v 1.19 2009/01/19 13:31:40 njoly Exp $	*/
+/*	$NetBSD: linux_misc.h,v 1.20 2010/11/02 18:18:07 chs Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -123,9 +123,13 @@
 extern const int linux_fstypes_cnt;
 
 /* Personality types. */
-#define LINUX_PER_LINUX		0x00000000
-#define LINUX_PER_LINUX32	0x00000008
 #define LINUX_PER_QUERY		0xffffffff
+#define LINUX_PER_LINUX		0x00
+#define LINUX_PER_LINUX32	0x08
+#define LINUX_PER_MASK		0xff
+
+/* Personality flags. */
+#define LINUX_PER_ADDR_NO_RANDOMIZE	0x00040000
 
 #ifdef _KERNEL
 __BEGIN_DECLS

Index: src/sys/compat/linux32/common/linux32_misc.c
diff -u src/sys/compat/linux32/common/linux32_misc.c:1.20 src/sys/compat/linux32/common/linux32_misc.c:1.21
--- src/sys/compat/linux32/common/linux32_misc.c:1.20	Tue Nov  2 18:14:06 2010
+++ src/sys/compat/linux32/common/linux32_misc.c	Tue Nov  2 18:18:07 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux32_misc.c,v 1.20 2010/11/02 18:14:06 chs Exp $	*/
+/*	$NetBSD: linux32_misc.c,v 1.21 2010/11/02 18:18:07 chs Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux32_misc.c,v 1.20 2010/11/02 18:14:06 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_misc.c,v 1.21 2010/11/02 18:18:07 chs Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -223,18 +223,10 @@
 	/* {
 		syscallarg(netbsd32_u_long) per;
 	} */
+	struct linux_sys_personality_args ua;
 
-	switch (SCARG(uap, per)) {
-	case LINUX_PER_LINUX:
-	case LINUX_PER_LINUX32:
-	case LINUX_PER_QUERY:
-		break;
-	default:
-		return EINVAL;
-	}
-
-	retval[0] = LINUX_PER_LINUX;
-	return 0;
+	NETBSD32TOX_UAP(per, long);
+	return linux_sys_personality(l, &ua, retval);
 }
 
 int

Reply via email to