Commit 6e16d89bcd668a95eb22add24c02d80890232b66

Authored by H. Peter Anvin
Committed by Linus Torvalds
1 parent ed7b1889da

Sanitize the type of struct user.u_ar0

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@vger.kernel.org>
Cc: Bryan Wu <bryan.wu@analog.com>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Lennert Buytenhek <kernel@wantstofly.org>
Cc: Håvard Skinnemoen <hskinnemoen@atmel.com>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Hirokazu Takata <takata@linux-m32r.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 18 changed files with 18 additions and 22 deletions Side-by-side Diff

arch/x86/ia32/ia32_aout.c
... ... @@ -172,8 +172,7 @@
172 172 has_dumped = 1;
173 173 current->flags |= PF_DUMPCORE;
174 174 strncpy(dump.u_comm, current->comm, sizeof(current->comm));
175   - dump.u_ar0 = (u32)(((unsigned long)(&dump.regs)) -
176   - ((unsigned long)(&dump)));
  175 + dump.u_ar0 = offsetof(struct user32, regs);
177 176 dump.signal = signr;
178 177 dump_thread32(regs, &dump);
179 178  
... ... @@ -115,7 +115,7 @@
115 115 current->flags |= PF_DUMPCORE;
116 116 strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm));
117 117 #ifndef __sparc__
118   - dump.u_ar0 = (void *)(((unsigned long)(&dump.regs)) - ((unsigned long)(&dump)));
  118 + dump.u_ar0 = offsetof(struct user, regs);
119 119 #endif
120 120 dump.signal = signr;
121 121 dump_thread(regs, &dump);
include/asm-alpha/user.h
... ... @@ -39,7 +39,7 @@
39 39 unsigned long start_data; /* data starting address */
40 40 unsigned long start_stack; /* stack starting address */
41 41 long int signal; /* signal causing core dump */
42   - struct regs * u_ar0; /* help gdb find registers */
  42 + unsigned long u_ar0; /* help gdb find registers */
43 43 unsigned long magic; /* identifies a core file */
44 44 char u_comm[32]; /* user command name */
45 45 };
include/asm-arm/user.h
... ... @@ -67,7 +67,7 @@
67 67 esp register. */
68 68 long int signal; /* Signal that caused the core dump. */
69 69 int reserved; /* No longer used */
70   - struct pt_regs * u_ar0; /* Used by gdb to help find the values for */
  70 + unsigned long u_ar0; /* Used by gdb to help find the values for */
71 71 /* the registers. */
72 72 unsigned long magic; /* To uniquely identify a core file */
73 73 char u_comm[32]; /* User command that was responsible */
include/asm-avr32/user.h
... ... @@ -51,7 +51,7 @@
51 51 unsigned long start_data; /* data starting address */
52 52 unsigned long start_stack; /* stack starting address */
53 53 long int signal; /* signal causing core dump */
54   - struct regs * u_ar0; /* help gdb find registers */
  54 + unsigned long u_ar0; /* help gdb find registers */
55 55 unsigned long magic; /* identifies a core file */
56 56 char u_comm[32]; /* user command name */
57 57 };
include/asm-blackfin/user.h
... ... @@ -75,7 +75,7 @@
75 75 esp register. */
76 76 long int signal; /* Signal that caused the core dump. */
77 77 int reserved; /* No longer used */
78   - struct user_regs_struct *u_ar0;
  78 + unsigned long u_ar0;
79 79 /* Used by gdb to help find the values for */
80 80 /* the registers. */
81 81 unsigned long magic; /* To uniquely identify a core file */
include/asm-cris/user.h
... ... @@ -38,7 +38,7 @@
38 38 unsigned long start_data; /* data starting address */
39 39 unsigned long start_stack; /* stack starting address */
40 40 long int signal; /* signal causing core dump */
41   - struct regs * u_ar0; /* help gdb find registers */
  41 + unsigned long u_ar0; /* help gdb find registers */
42 42 unsigned long magic; /* identifies a core file */
43 43 char u_comm[32]; /* user command name */
44 44 };
include/asm-h8300/user.h
... ... @@ -62,8 +62,7 @@
62 62 esp register. */
63 63 long int signal; /* Signal that caused the core dump. */
64 64 int reserved; /* No longer used */
65   - struct user_regs_struct *u_ar0;
66   - /* Used by gdb to help find the values for */
  65 + unsigned long u_ar0; /* Used by gdb to help find the values for */
67 66 /* the registers. */
68 67 unsigned long magic; /* To uniquely identify a core file */
69 68 char u_comm[32]; /* User command that was responsible */
include/asm-ia64/user.h
... ... @@ -44,7 +44,7 @@
44 44 unsigned long start_data; /* data starting address */
45 45 unsigned long start_stack; /* stack starting address */
46 46 long int signal; /* signal causing core dump */
47   - struct regs * u_ar0; /* help gdb find registers */
  47 + unsigned long u_ar0; /* help gdb find registers */
48 48 unsigned long magic; /* identifies a core file */
49 49 char u_comm[32]; /* user command name */
50 50 };
include/asm-m32r/user.h
... ... @@ -38,7 +38,7 @@
38 38 unsigned long start_data; /* data starting address */
39 39 unsigned long start_stack; /* stack starting address */
40 40 long int signal; /* signal causing core dump */
41   - struct regs * u_ar0; /* help gdb find registers */
  41 + unsigned long u_ar0; /* help gdb find registers */
42 42 unsigned long magic; /* identifies a core file */
43 43 char u_comm[32]; /* user command name */
44 44 };
include/asm-m68k/user.h
... ... @@ -72,8 +72,7 @@
72 72 esp register. */
73 73 long int signal; /* Signal that caused the core dump. */
74 74 int reserved; /* No longer used */
75   - struct user_regs_struct *u_ar0;
76   - /* Used by gdb to help find the values for */
  75 + unsigned long u_ar0; /* Used by gdb to help find the values for */
77 76 /* the registers. */
78 77 struct user_m68kfp_struct* u_fpstate; /* Math Co-processor pointer. */
79 78 unsigned long magic; /* To uniquely identify a core file */
include/asm-mips/user.h
... ... @@ -44,7 +44,7 @@
44 44 unsigned long start_data; /* data starting address */
45 45 unsigned long start_stack; /* stack starting address */
46 46 long int signal; /* signal causing core dump */
47   - struct regs * u_ar0; /* help gdb find registers */
  47 + unsigned long u_ar0; /* help gdb find registers */
48 48 unsigned long magic; /* identifies a core file */
49 49 char u_comm[32]; /* user command name */
50 50 };
include/asm-powerpc/user.h
... ... @@ -38,7 +38,7 @@
38 38 unsigned long start_data; /* data starting address */
39 39 unsigned long start_stack; /* stack starting address */
40 40 long int signal; /* signal causing core dump */
41   - struct regs * u_ar0; /* help gdb find registers */
  41 + unsigned long u_ar0; /* help gdb find registers */
42 42 unsigned long magic; /* identifies a core file */
43 43 char u_comm[32]; /* user command name */
44 44 };
include/asm-s390/user.h
... ... @@ -63,8 +63,7 @@
63 63 the top of the stack is always found in the
64 64 esp register. */
65 65 long int signal; /* Signal that caused the core dump. */
66   - struct user_regs_struct *u_ar0;
67   - /* Used by gdb to help find the values for */
  66 + unsigned long u_ar0; /* Used by gdb to help find the values for */
68 67 /* the registers. */
69 68 unsigned long magic; /* To uniquely identify a core file */
70 69 char u_comm[32]; /* User command that was responsible */
include/asm-sh/user.h
... ... @@ -52,7 +52,7 @@
52 52 unsigned long start_data; /* data starting address */
53 53 unsigned long start_stack; /* stack starting address */
54 54 long int signal; /* signal causing core dump */
55   - struct regs * u_ar0; /* help gdb find registers */
  55 + unsigned long u_ar0; /* help gdb find registers */
56 56 struct user_fpu_struct* u_fpstate; /* Math Co-processor pointer */
57 57 unsigned long magic; /* identifies a core file */
58 58 char u_comm[32]; /* user command name */
include/asm-v850/user.h
... ... @@ -38,7 +38,7 @@
38 38 unsigned long start_data; /* data starting address */
39 39 unsigned long start_stack; /* stack starting address */
40 40 long int signal; /* signal causing core dump */
41   - struct regs * u_ar0; /* help gdb find registers */
  41 + unsigned long u_ar0; /* help gdb find registers */
42 42 unsigned long magic; /* identifies a core file */
43 43 char u_comm[32]; /* user command name */
44 44 };
include/asm-x86/user_32.h
... ... @@ -116,7 +116,7 @@
116 116 esp register. */
117 117 long int signal; /* Signal that caused the core dump. */
118 118 int reserved; /* No longer used */
119   - struct user_pt_regs * u_ar0; /* Used by gdb to help find the values for */
  119 + unsigned long u_ar0; /* Used by gdb to help find the values for */
120 120 /* the registers. */
121 121 struct user_i387_struct* u_fpstate; /* Math Co-processor pointer. */
122 122 unsigned long magic; /* To uniquely identify a core file */
include/asm-x86/user_64.h
... ... @@ -118,7 +118,7 @@
118 118 long int signal; /* Signal that caused the core dump. */
119 119 int reserved; /* No longer used */
120 120 int pad1;
121   - struct user_pt_regs * u_ar0; /* Used by gdb to help find the values for */
  121 + unsigned long u_ar0; /* Used by gdb to help find the values for */
122 122 /* the registers. */
123 123 struct user_i387_struct* u_fpstate; /* Math Co-processor pointer. */
124 124 unsigned long magic; /* To uniquely identify a core file */