[patch 159/208] Sanitize the type of struct user.u_ar0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "H. Peter Anvin" <hpa@xxxxxxxxx>

struct user.u_ar0 is defined to contain a pointer offset on all
architectures in which it is defined (all architectures which define an
a.out format except SPARC.) However, it has a pointer type in the headers,
which is pointless -- <asm/user.h> is not exported to userspace, and it
just makes the code messy.

Redefine the field as "unsigned long" (which is the same size as a pointer
on all Linux architectures) and change the setting code to user offsetof()
instead of hand-coded arithmetic.

Cc: Linux Arch Mailing List <linux-arch@xxxxxxxxxxxxxxx>
Cc: Bryan Wu <bryan.wu@xxxxxxxxxx>
Cc: Roman Zippel <zippel@xxxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Richard Henderson <rth@xxxxxxxxxxx>
Cc: Ivan Kokshaysky <ink@xxxxxxxxxxxxxxxxxxxx>
Cc: Russell King <rmk@xxxxxxxxxxxxxxxx>
Cc: Lennert Buytenhek <kernel@xxxxxxxxxxxxxx>
Cc: HÃ¥vard Skinnemoen <hskinnemoen@xxxxxxxxx>
Cc: Mikael Starvik <starvik@xxxxxxxx>
Cc: Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx>
Cc: Tony Luck <tony.luck@xxxxxxxxx>
Cc: Hirokazu Takata <takata@xxxxxxxxxxxxxx>
Cc: Ralf Baechle <ralf@xxxxxxxxxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Martin Schwidefsky <schwidefsky@xxxxxxxxxx>
Cc: Heiko Carstens <heiko.carstens@xxxxxxxxxx>
Cc: Paul Mundt <lethal@xxxxxxxxxxxx>
Signed-off-by: H. Peter Anvin <hpa@xxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 arch/x86/ia32/ia32_aout.c   |    3 +--
 fs/binfmt_aout.c            |    2 +-
 include/asm-alpha/user.h    |    2 +-
 include/asm-arm/user.h      |    2 +-
 include/asm-avr32/user.h    |    2 +-
 include/asm-blackfin/user.h |    2 +-
 include/asm-cris/user.h     |    2 +-
 include/asm-h8300/user.h    |    3 +--
 include/asm-ia64/user.h     |    2 +-
 include/asm-m32r/user.h     |    2 +-
 include/asm-m68k/user.h     |    3 +--
 include/asm-mips/user.h     |    2 +-
 include/asm-powerpc/user.h  |    2 +-
 include/asm-s390/user.h     |    3 +--
 include/asm-sh/user.h       |    2 +-
 include/asm-v850/user.h     |    2 +-
 include/asm-x86/user_32.h   |    2 +-
 include/asm-x86/user_64.h   |    2 +-
 18 files changed, 18 insertions(+), 22 deletions(-)

diff -puN arch/x86/ia32/ia32_aout.c~sanitize-the-type-of-struct-useru_ar0 arch/x86/ia32/ia32_aout.c
--- a/arch/x86/ia32/ia32_aout.c~sanitize-the-type-of-struct-useru_ar0
+++ a/arch/x86/ia32/ia32_aout.c
@@ -172,8 +172,7 @@ static int aout_core_dump(long signr, st
 	has_dumped = 1;
 	current->flags |= PF_DUMPCORE;
 	strncpy(dump.u_comm, current->comm, sizeof(current->comm));
-	dump.u_ar0 = (u32)(((unsigned long)(&dump.regs)) -
-			   ((unsigned long)(&dump)));
+	dump.u_ar0 = offsetof(struct user32, regs);
 	dump.signal = signr;
 	dump_thread32(regs, &dump);
 
diff -puN fs/binfmt_aout.c~sanitize-the-type-of-struct-useru_ar0 fs/binfmt_aout.c
--- a/fs/binfmt_aout.c~sanitize-the-type-of-struct-useru_ar0
+++ a/fs/binfmt_aout.c
@@ -115,7 +115,7 @@ static int aout_core_dump(long signr, st
 	current->flags |= PF_DUMPCORE;
        	strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm));
 #ifndef __sparc__
-	dump.u_ar0 = (void *)(((unsigned long)(&dump.regs)) - ((unsigned long)(&dump)));
+	dump.u_ar0 = offsetof(struct user, regs);
 #endif
 	dump.signal = signr;
 	dump_thread(regs, &dump);
diff -puN include/asm-alpha/user.h~sanitize-the-type-of-struct-useru_ar0 include/asm-alpha/user.h
--- a/include/asm-alpha/user.h~sanitize-the-type-of-struct-useru_ar0
+++ a/include/asm-alpha/user.h
@@ -39,7 +39,7 @@ struct user {
 	unsigned long	start_data;		/* data starting address */
 	unsigned long	start_stack;		/* stack starting address */
 	long int	signal;			/* signal causing core dump */
-	struct regs *	u_ar0;			/* help gdb find registers */
+	unsigned long	u_ar0;			/* help gdb find registers */
 	unsigned long	magic;			/* identifies a core file */
 	char		u_comm[32];		/* user command name */
 };
diff -puN include/asm-arm/user.h~sanitize-the-type-of-struct-useru_ar0 include/asm-arm/user.h
--- a/include/asm-arm/user.h~sanitize-the-type-of-struct-useru_ar0
+++ a/include/asm-arm/user.h
@@ -67,7 +67,7 @@ struct user{
 				   esp register.  */
   long int signal;     		/* Signal that caused the core dump. */
   int reserved;			/* No longer used */
-  struct pt_regs * u_ar0;	/* Used by gdb to help find the values for */
+  unsigned long u_ar0;		/* Used by gdb to help find the values for */
 				/* the registers. */
   unsigned long magic;		/* To uniquely identify a core file */
   char u_comm[32];		/* User command that was responsible */
diff -puN include/asm-avr32/user.h~sanitize-the-type-of-struct-useru_ar0 include/asm-avr32/user.h
--- a/include/asm-avr32/user.h~sanitize-the-type-of-struct-useru_ar0
+++ a/include/asm-avr32/user.h
@@ -51,7 +51,7 @@ struct user {
 	unsigned long	start_data;		/* data starting address */
 	unsigned long	start_stack;		/* stack starting address */
 	long int	signal;			/* signal causing core dump */
-	struct regs *	u_ar0;			/* help gdb find registers */
+	unsigned long	u_ar0;			/* help gdb find registers */
 	unsigned long	magic;			/* identifies a core file */
 	char		u_comm[32];		/* user command name */
 };
diff -puN include/asm-blackfin/user.h~sanitize-the-type-of-struct-useru_ar0 include/asm-blackfin/user.h
--- a/include/asm-blackfin/user.h~sanitize-the-type-of-struct-useru_ar0
+++ a/include/asm-blackfin/user.h
@@ -75,7 +75,7 @@ struct user {
 					   esp register.  */
 	long int signal;	/* Signal that caused the core dump. */
 	int reserved;		/* No longer used */
-	struct user_regs_struct *u_ar0;
+	unsigned long u_ar0;
 	/* Used by gdb to help find the values for */
 	/* the registers. */
 	unsigned long magic;	/* To uniquely identify a core file */
diff -puN include/asm-cris/user.h~sanitize-the-type-of-struct-useru_ar0 include/asm-cris/user.h
--- a/include/asm-cris/user.h~sanitize-the-type-of-struct-useru_ar0
+++ a/include/asm-cris/user.h
@@ -38,7 +38,7 @@ struct user {
 	unsigned long	start_data;		/* data starting address */
 	unsigned long	start_stack;		/* stack starting address */
 	long int	signal;			/* signal causing core dump */
-	struct regs *	u_ar0;			/* help gdb find registers */
+	unsigned long	u_ar0;			/* help gdb find registers */
 	unsigned long	magic;			/* identifies a core file */
 	char		u_comm[32];		/* user command name */
 };
diff -puN include/asm-h8300/user.h~sanitize-the-type-of-struct-useru_ar0 include/asm-h8300/user.h
--- a/include/asm-h8300/user.h~sanitize-the-type-of-struct-useru_ar0
+++ a/include/asm-h8300/user.h
@@ -62,8 +62,7 @@ struct user{
 				   esp register.  */
   long int signal;     		/* Signal that caused the core dump. */
   int reserved;			/* No longer used */
-  struct user_regs_struct *u_ar0;
-				/* Used by gdb to help find the values for */
+  unsigned long u_ar0;		/* Used by gdb to help find the values for */
 				/* the registers. */
   unsigned long magic;		/* To uniquely identify a core file */
   char u_comm[32];		/* User command that was responsible */
diff -puN include/asm-ia64/user.h~sanitize-the-type-of-struct-useru_ar0 include/asm-ia64/user.h
--- a/include/asm-ia64/user.h~sanitize-the-type-of-struct-useru_ar0
+++ a/include/asm-ia64/user.h
@@ -44,7 +44,7 @@ struct user {
 	unsigned long	start_data;		/* data starting address */
 	unsigned long	start_stack;		/* stack starting address */
 	long int	signal;			/* signal causing core dump */
-	struct regs *	u_ar0;			/* help gdb find registers */
+	unsigned long	u_ar0;			/* help gdb find registers */
 	unsigned long	magic;			/* identifies a core file */
 	char		u_comm[32];		/* user command name */
 };
diff -puN include/asm-m32r/user.h~sanitize-the-type-of-struct-useru_ar0 include/asm-m32r/user.h
--- a/include/asm-m32r/user.h~sanitize-the-type-of-struct-useru_ar0
+++ a/include/asm-m32r/user.h
@@ -38,7 +38,7 @@ struct user {
 	unsigned long	start_data;		/* data starting address */
 	unsigned long	start_stack;		/* stack starting address */
 	long int	signal;			/* signal causing core dump */
-	struct regs *	u_ar0;			/* help gdb find registers */
+	unsigned long	u_ar0;			/* help gdb find registers */
 	unsigned long	magic;			/* identifies a core file */
 	char		u_comm[32];		/* user command name */
 };
diff -puN include/asm-m68k/user.h~sanitize-the-type-of-struct-useru_ar0 include/asm-m68k/user.h
--- a/include/asm-m68k/user.h~sanitize-the-type-of-struct-useru_ar0
+++ a/include/asm-m68k/user.h
@@ -72,8 +72,7 @@ struct user{
 				   esp register.  */
   long int signal;		/* Signal that caused the core dump. */
   int reserved;			/* No longer used */
-  struct user_regs_struct *u_ar0;
-				/* Used by gdb to help find the values for */
+  unsigned long u_ar0;		/* Used by gdb to help find the values for */
 				/* the registers. */
   struct user_m68kfp_struct* u_fpstate;	/* Math Co-processor pointer. */
   unsigned long magic;		/* To uniquely identify a core file */
diff -puN include/asm-mips/user.h~sanitize-the-type-of-struct-useru_ar0 include/asm-mips/user.h
--- a/include/asm-mips/user.h~sanitize-the-type-of-struct-useru_ar0
+++ a/include/asm-mips/user.h
@@ -44,7 +44,7 @@ struct user {
 	unsigned long	start_data;		/* data starting address */
 	unsigned long	start_stack;		/* stack starting address */
 	long int	signal;			/* signal causing core dump */
-	struct regs *	u_ar0;			/* help gdb find registers */
+	unsigned long	u_ar0;			/* help gdb find registers */
 	unsigned long	magic;			/* identifies a core file */
 	char		u_comm[32];		/* user command name */
 };
diff -puN include/asm-powerpc/user.h~sanitize-the-type-of-struct-useru_ar0 include/asm-powerpc/user.h
--- a/include/asm-powerpc/user.h~sanitize-the-type-of-struct-useru_ar0
+++ a/include/asm-powerpc/user.h
@@ -38,7 +38,7 @@ struct user {
 	unsigned long	start_data;		/* data starting address */
 	unsigned long	start_stack;		/* stack starting address */
 	long int	signal;			/* signal causing core dump */
-	struct regs *	u_ar0;			/* help gdb find registers */
+	unsigned long	u_ar0;			/* help gdb find registers */
 	unsigned long	magic;			/* identifies a core file */
 	char		u_comm[32];		/* user command name */
 };
diff -puN include/asm-s390/user.h~sanitize-the-type-of-struct-useru_ar0 include/asm-s390/user.h
--- a/include/asm-s390/user.h~sanitize-the-type-of-struct-useru_ar0
+++ a/include/asm-s390/user.h
@@ -63,8 +63,7 @@ struct user {
 				   the top of the stack is always found in the
 				   esp register.  */
   long int signal;     		/* Signal that caused the core dump. */
-  struct user_regs_struct *u_ar0;
-				/* Used by gdb to help find the values for */
+  unsigned long u_ar0;		/* Used by gdb to help find the values for */
 				/* the registers. */
   unsigned long magic;		/* To uniquely identify a core file */
   char u_comm[32];		/* User command that was responsible */
diff -puN include/asm-sh/user.h~sanitize-the-type-of-struct-useru_ar0 include/asm-sh/user.h
--- a/include/asm-sh/user.h~sanitize-the-type-of-struct-useru_ar0
+++ a/include/asm-sh/user.h
@@ -52,7 +52,7 @@ struct user {
 	unsigned long	start_data;		/* data starting address */
 	unsigned long	start_stack;		/* stack starting address */
 	long int	signal;			/* signal causing core dump */
-	struct regs *	u_ar0;			/* help gdb find registers */
+	unsigned long	u_ar0;			/* help gdb find registers */
 	struct user_fpu_struct* u_fpstate;	/* Math Co-processor pointer */
 	unsigned long	magic;			/* identifies a core file */
 	char		u_comm[32];		/* user command name */
diff -puN include/asm-v850/user.h~sanitize-the-type-of-struct-useru_ar0 include/asm-v850/user.h
--- a/include/asm-v850/user.h~sanitize-the-type-of-struct-useru_ar0
+++ a/include/asm-v850/user.h
@@ -38,7 +38,7 @@ struct user {
 	unsigned long	start_data;		/* data starting address */
 	unsigned long	start_stack;		/* stack starting address */
 	long int	signal;			/* signal causing core dump */
-	struct regs *	u_ar0;			/* help gdb find registers */
+	unsigned long	u_ar0;			/* help gdb find registers */
 	unsigned long	magic;			/* identifies a core file */
 	char		u_comm[32];		/* user command name */
 };
diff -puN include/asm-x86/user_32.h~sanitize-the-type-of-struct-useru_ar0 include/asm-x86/user_32.h
--- a/include/asm-x86/user_32.h~sanitize-the-type-of-struct-useru_ar0
+++ a/include/asm-x86/user_32.h
@@ -116,7 +116,7 @@ struct user{
 				   esp register.  */
   long int signal;     		/* Signal that caused the core dump. */
   int reserved;			/* No longer used */
-  struct user_pt_regs * u_ar0;	/* Used by gdb to help find the values for */
+  unsigned long u_ar0;		/* Used by gdb to help find the values for */
 				/* the registers. */
   struct user_i387_struct* u_fpstate;	/* Math Co-processor pointer. */
   unsigned long magic;		/* To uniquely identify a core file */
diff -puN include/asm-x86/user_64.h~sanitize-the-type-of-struct-useru_ar0 include/asm-x86/user_64.h
--- a/include/asm-x86/user_64.h~sanitize-the-type-of-struct-useru_ar0
+++ a/include/asm-x86/user_64.h
@@ -118,7 +118,7 @@ struct user{
   long int signal;		/* Signal that caused the core dump. */
   int reserved;			/* No longer used */
   int pad1;
-  struct user_pt_regs * u_ar0;	/* Used by gdb to help find the values for */
+  unsigned long u_ar0;		/* Used by gdb to help find the values for */
 				/* the registers. */
   struct user_i387_struct* u_fpstate;	/* Math Co-processor pointer. */
   unsigned long magic;		/* To uniquely identify a core file */
_
-
To unsubscribe from this list: send the line "unsubscribe linux-arch" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux