From: H. Peter Anvin Date: Thu, 7 Feb 2008 08:15:57 +0000 (-0800) Subject: Sanitize the type of struct user.u_ar0 X-Git-Tag: v2.6.25-rc1~353 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e16d89bcd668a95eb22add24c02d80890232b66;p=linux-2.6 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 -- 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 Cc: Bryan Wu Cc: Roman Zippel Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Russell King Cc: Lennert Buytenhek Cc: HÃ¥vard Skinnemoen Cc: Mikael Starvik Cc: Yoshinori Sato Cc: Tony Luck Cc: Hirokazu Takata Cc: Ralf Baechle Cc: Paul Mackerras Cc: Martin Schwidefsky Cc: Heiko Carstens Cc: Paul Mundt Signed-off-by: H. Peter Anvin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c index e4c1207917..58cccb6483 100644 --- a/arch/x86/ia32/ia32_aout.c +++ b/arch/x86/ia32/ia32_aout.c @@ -172,8 +172,7 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, 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 --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c index 7596e1e94c..7f65e71bf8 100644 --- a/fs/binfmt_aout.c +++ b/fs/binfmt_aout.c @@ -115,7 +115,7 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, u 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 --git a/include/asm-alpha/user.h b/include/asm-alpha/user.h index 7e417fc9d4..a4eb6a4ca8 100644 --- a/include/asm-alpha/user.h +++ b/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 --git a/include/asm-arm/user.h b/include/asm-arm/user.h index 3e8b0f8791..825c1e7c58 100644 --- a/include/asm-arm/user.h +++ b/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 --git a/include/asm-avr32/user.h b/include/asm-avr32/user.h index 060fb3acee..7e9152f81f 100644 --- a/include/asm-avr32/user.h +++ b/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 --git a/include/asm-blackfin/user.h b/include/asm-blackfin/user.h index abc34629bd..afe6a0e1f7 100644 --- a/include/asm-blackfin/user.h +++ b/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 --git a/include/asm-cris/user.h b/include/asm-cris/user.h index 2538e2a003..73e60fcbcf 100644 --- a/include/asm-cris/user.h +++ b/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 --git a/include/asm-h8300/user.h b/include/asm-h8300/user.h index 6c64f99af3..14a9e18950 100644 --- a/include/asm-h8300/user.h +++ b/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 --git a/include/asm-ia64/user.h b/include/asm-ia64/user.h index 78e5a20140..8b98211103 100644 --- a/include/asm-ia64/user.h +++ b/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 --git a/include/asm-m32r/user.h b/include/asm-m32r/user.h index 035258d713..03b3c11c2a 100644 --- a/include/asm-m32r/user.h +++ b/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 --git a/include/asm-m68k/user.h b/include/asm-m68k/user.h index 8c56ccab48..f1f478d6e0 100644 --- a/include/asm-m68k/user.h +++ b/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 --git a/include/asm-mips/user.h b/include/asm-mips/user.h index 89bf8b4cab..afa83a4c18 100644 --- a/include/asm-mips/user.h +++ b/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 --git a/include/asm-powerpc/user.h b/include/asm-powerpc/user.h index ba8dd4c12d..3fd4545dd7 100644 --- a/include/asm-powerpc/user.h +++ b/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 --git a/include/asm-s390/user.h b/include/asm-s390/user.h index 1dc74baf03..1b050e35fd 100644 --- a/include/asm-s390/user.h +++ b/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 --git a/include/asm-sh/user.h b/include/asm-sh/user.h index 1a4f43c751..8fd3cf6c58 100644 --- a/include/asm-sh/user.h +++ b/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 --git a/include/asm-v850/user.h b/include/asm-v850/user.h index be90eea528..63cdc567d2 100644 --- a/include/asm-v850/user.h +++ b/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 --git a/include/asm-x86/user_32.h b/include/asm-x86/user_32.h index ed8b8fc690..6157da6f88 100644 --- a/include/asm-x86/user_32.h +++ b/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 --git a/include/asm-x86/user_64.h b/include/asm-x86/user_64.h index a5449d456c..9636164556 100644 --- a/include/asm-x86/user_64.h +++ b/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 */