Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

H. Peter Anvin and committed by
Linus Torvalds
6e16d89b ed7b1889

+18 -22
+1 -2
arch/x86/ia32/ia32_aout.c
··· 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
+1 -1
fs/binfmt_aout.c
··· 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);
+1 -1
include/asm-alpha/user.h
··· 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 };
+1 -1
include/asm-arm/user.h
··· 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 */
+1 -1
include/asm-avr32/user.h
··· 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 };
+1 -1
include/asm-blackfin/user.h
··· 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 */
+1 -1
include/asm-cris/user.h
··· 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 };
+1 -2
include/asm-h8300/user.h
··· 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 */
+1 -1
include/asm-ia64/user.h
··· 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 };
+1 -1
include/asm-m32r/user.h
··· 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 };
+1 -2
include/asm-m68k/user.h
··· 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 */
+1 -1
include/asm-mips/user.h
··· 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 };
+1 -1
include/asm-powerpc/user.h
··· 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 };
+1 -2
include/asm-s390/user.h
··· 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 */
+1 -1
include/asm-sh/user.h
··· 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 */
+1 -1
include/asm-v850/user.h
··· 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 };
+1 -1
include/asm-x86/user_32.h
··· 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 */
+1 -1
include/asm-x86/user_64.h
··· 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 */