aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-02-07 03:15:57 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 11:42:30 -0500
commit6e16d89bcd668a95eb22add24c02d80890232b66 (patch)
tree8d5fcab14edac7d36c67e8a57abb5025cfaa2c2d
parented7b1889da256977574663689b598d88950bbd23 (diff)
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>
-rw-r--r--arch/x86/ia32/ia32_aout.c3
-rw-r--r--fs/binfmt_aout.c2
-rw-r--r--include/asm-alpha/user.h2
-rw-r--r--include/asm-arm/user.h2
-rw-r--r--include/asm-avr32/user.h2
-rw-r--r--include/asm-blackfin/user.h2
-rw-r--r--include/asm-cris/user.h2
-rw-r--r--include/asm-h8300/user.h3
-rw-r--r--include/asm-ia64/user.h2
-rw-r--r--include/asm-m32r/user.h2
-rw-r--r--include/asm-m68k/user.h3
-rw-r--r--include/asm-mips/user.h2
-rw-r--r--include/asm-powerpc/user.h2
-rw-r--r--include/asm-s390/user.h3
-rw-r--r--include/asm-sh/user.h2
-rw-r--r--include/asm-v850/user.h2
-rw-r--r--include/asm-x86/user_32.h2
-rw-r--r--include/asm-x86/user_64.h2
18 files changed, 18 insertions, 22 deletions
diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
index e4c12079171b..58cccb6483b0 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,
172 has_dumped = 1; 172 has_dumped = 1;
173 current->flags |= PF_DUMPCORE; 173 current->flags |= PF_DUMPCORE;
174 strncpy(dump.u_comm, current->comm, sizeof(current->comm)); 174 strncpy(dump.u_comm, current->comm, sizeof(current->comm));
175 dump.u_ar0 = (u32)(((unsigned long)(&dump.regs)) - 175 dump.u_ar0 = offsetof(struct user32, regs);
176 ((unsigned long)(&dump)));
177 dump.signal = signr; 176 dump.signal = signr;
178 dump_thread32(regs, &dump); 177 dump_thread32(regs, &dump);
179 178
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
index 7596e1e94cde..7f65e71bf859 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
115 current->flags |= PF_DUMPCORE; 115 current->flags |= PF_DUMPCORE;
116 strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm)); 116 strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm));
117#ifndef __sparc__ 117#ifndef __sparc__
118 dump.u_ar0 = (void *)(((unsigned long)(&dump.regs)) - ((unsigned long)(&dump))); 118 dump.u_ar0 = offsetof(struct user, regs);
119#endif 119#endif
120 dump.signal = signr; 120 dump.signal = signr;
121 dump_thread(regs, &dump); 121 dump_thread(regs, &dump);
diff --git a/include/asm-alpha/user.h b/include/asm-alpha/user.h
index 7e417fc9d491..a4eb6a4ca8d1 100644
--- a/include/asm-alpha/user.h
+++ b/include/asm-alpha/user.h
@@ -39,7 +39,7 @@ struct user {
39 unsigned long start_data; /* data starting address */ 39 unsigned long start_data; /* data starting address */
40 unsigned long start_stack; /* stack starting address */ 40 unsigned long start_stack; /* stack starting address */
41 long int signal; /* signal causing core dump */ 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 unsigned long magic; /* identifies a core file */ 43 unsigned long magic; /* identifies a core file */
44 char u_comm[32]; /* user command name */ 44 char u_comm[32]; /* user command name */
45}; 45};
diff --git a/include/asm-arm/user.h b/include/asm-arm/user.h
index 3e8b0f879159..825c1e7c582d 100644
--- a/include/asm-arm/user.h
+++ b/include/asm-arm/user.h
@@ -67,7 +67,7 @@ struct user{
67 esp register. */ 67 esp register. */
68 long int signal; /* Signal that caused the core dump. */ 68 long int signal; /* Signal that caused the core dump. */
69 int reserved; /* No longer used */ 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 /* the registers. */ 71 /* the registers. */
72 unsigned long magic; /* To uniquely identify a core file */ 72 unsigned long magic; /* To uniquely identify a core file */
73 char u_comm[32]; /* User command that was responsible */ 73 char u_comm[32]; /* User command that was responsible */
diff --git a/include/asm-avr32/user.h b/include/asm-avr32/user.h
index 060fb3acee49..7e9152f81f5e 100644
--- a/include/asm-avr32/user.h
+++ b/include/asm-avr32/user.h
@@ -51,7 +51,7 @@ struct user {
51 unsigned long start_data; /* data starting address */ 51 unsigned long start_data; /* data starting address */
52 unsigned long start_stack; /* stack starting address */ 52 unsigned long start_stack; /* stack starting address */
53 long int signal; /* signal causing core dump */ 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 unsigned long magic; /* identifies a core file */ 55 unsigned long magic; /* identifies a core file */
56 char u_comm[32]; /* user command name */ 56 char u_comm[32]; /* user command name */
57}; 57};
diff --git a/include/asm-blackfin/user.h b/include/asm-blackfin/user.h
index abc34629bd59..afe6a0e1f7ce 100644
--- a/include/asm-blackfin/user.h
+++ b/include/asm-blackfin/user.h
@@ -75,7 +75,7 @@ struct user {
75 esp register. */ 75 esp register. */
76 long int signal; /* Signal that caused the core dump. */ 76 long int signal; /* Signal that caused the core dump. */
77 int reserved; /* No longer used */ 77 int reserved; /* No longer used */
78 struct user_regs_struct *u_ar0; 78 unsigned long u_ar0;
79 /* Used by gdb to help find the values for */ 79 /* Used by gdb to help find the values for */
80 /* the registers. */ 80 /* the registers. */
81 unsigned long magic; /* To uniquely identify a core file */ 81 unsigned long magic; /* To uniquely identify a core file */
diff --git a/include/asm-cris/user.h b/include/asm-cris/user.h
index 2538e2a003df..73e60fcbcf38 100644
--- a/include/asm-cris/user.h
+++ b/include/asm-cris/user.h
@@ -38,7 +38,7 @@ struct user {
38 unsigned long start_data; /* data starting address */ 38 unsigned long start_data; /* data starting address */
39 unsigned long start_stack; /* stack starting address */ 39 unsigned long start_stack; /* stack starting address */
40 long int signal; /* signal causing core dump */ 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 unsigned long magic; /* identifies a core file */ 42 unsigned long magic; /* identifies a core file */
43 char u_comm[32]; /* user command name */ 43 char u_comm[32]; /* user command name */
44}; 44};
diff --git a/include/asm-h8300/user.h b/include/asm-h8300/user.h
index 6c64f99af3e1..14a9e18950f1 100644
--- a/include/asm-h8300/user.h
+++ b/include/asm-h8300/user.h
@@ -62,8 +62,7 @@ struct user{
62 esp register. */ 62 esp register. */
63 long int signal; /* Signal that caused the core dump. */ 63 long int signal; /* Signal that caused the core dump. */
64 int reserved; /* No longer used */ 64 int reserved; /* No longer used */
65 struct user_regs_struct *u_ar0; 65 unsigned long u_ar0; /* Used by gdb to help find the values for */
66 /* Used by gdb to help find the values for */
67 /* the registers. */ 66 /* the registers. */
68 unsigned long magic; /* To uniquely identify a core file */ 67 unsigned long magic; /* To uniquely identify a core file */
69 char u_comm[32]; /* User command that was responsible */ 68 char u_comm[32]; /* User command that was responsible */
diff --git a/include/asm-ia64/user.h b/include/asm-ia64/user.h
index 78e5a20140aa..8b9821110348 100644
--- a/include/asm-ia64/user.h
+++ b/include/asm-ia64/user.h
@@ -44,7 +44,7 @@ struct user {
44 unsigned long start_data; /* data starting address */ 44 unsigned long start_data; /* data starting address */
45 unsigned long start_stack; /* stack starting address */ 45 unsigned long start_stack; /* stack starting address */
46 long int signal; /* signal causing core dump */ 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 unsigned long magic; /* identifies a core file */ 48 unsigned long magic; /* identifies a core file */
49 char u_comm[32]; /* user command name */ 49 char u_comm[32]; /* user command name */
50}; 50};
diff --git a/include/asm-m32r/user.h b/include/asm-m32r/user.h
index 035258d713d0..03b3c11c2aff 100644
--- a/include/asm-m32r/user.h
+++ b/include/asm-m32r/user.h
@@ -38,7 +38,7 @@ struct user {
38 unsigned long start_data; /* data starting address */ 38 unsigned long start_data; /* data starting address */
39 unsigned long start_stack; /* stack starting address */ 39 unsigned long start_stack; /* stack starting address */
40 long int signal; /* signal causing core dump */ 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 unsigned long magic; /* identifies a core file */ 42 unsigned long magic; /* identifies a core file */
43 char u_comm[32]; /* user command name */ 43 char u_comm[32]; /* user command name */
44}; 44};
diff --git a/include/asm-m68k/user.h b/include/asm-m68k/user.h
index 8c56ccab4849..f1f478d6e050 100644
--- a/include/asm-m68k/user.h
+++ b/include/asm-m68k/user.h
@@ -72,8 +72,7 @@ struct user{
72 esp register. */ 72 esp register. */
73 long int signal; /* Signal that caused the core dump. */ 73 long int signal; /* Signal that caused the core dump. */
74 int reserved; /* No longer used */ 74 int reserved; /* No longer used */
75 struct user_regs_struct *u_ar0; 75 unsigned long u_ar0; /* Used by gdb to help find the values for */
76 /* Used by gdb to help find the values for */
77 /* the registers. */ 76 /* the registers. */
78 struct user_m68kfp_struct* u_fpstate; /* Math Co-processor pointer. */ 77 struct user_m68kfp_struct* u_fpstate; /* Math Co-processor pointer. */
79 unsigned long magic; /* To uniquely identify a core file */ 78 unsigned long magic; /* To uniquely identify a core file */
diff --git a/include/asm-mips/user.h b/include/asm-mips/user.h
index 89bf8b4cab3c..afa83a4c1888 100644
--- a/include/asm-mips/user.h
+++ b/include/asm-mips/user.h
@@ -44,7 +44,7 @@ struct user {
44 unsigned long start_data; /* data starting address */ 44 unsigned long start_data; /* data starting address */
45 unsigned long start_stack; /* stack starting address */ 45 unsigned long start_stack; /* stack starting address */
46 long int signal; /* signal causing core dump */ 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 unsigned long magic; /* identifies a core file */ 48 unsigned long magic; /* identifies a core file */
49 char u_comm[32]; /* user command name */ 49 char u_comm[32]; /* user command name */
50}; 50};
diff --git a/include/asm-powerpc/user.h b/include/asm-powerpc/user.h
index ba8dd4c12d96..3fd4545dd74e 100644
--- a/include/asm-powerpc/user.h
+++ b/include/asm-powerpc/user.h
@@ -38,7 +38,7 @@ struct user {
38 unsigned long start_data; /* data starting address */ 38 unsigned long start_data; /* data starting address */
39 unsigned long start_stack; /* stack starting address */ 39 unsigned long start_stack; /* stack starting address */
40 long int signal; /* signal causing core dump */ 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 unsigned long magic; /* identifies a core file */ 42 unsigned long magic; /* identifies a core file */
43 char u_comm[32]; /* user command name */ 43 char u_comm[32]; /* user command name */
44}; 44};
diff --git a/include/asm-s390/user.h b/include/asm-s390/user.h
index 1dc74baf03c4..1b050e35fdc6 100644
--- a/include/asm-s390/user.h
+++ b/include/asm-s390/user.h
@@ -63,8 +63,7 @@ struct user {
63 the top of the stack is always found in the 63 the top of the stack is always found in the
64 esp register. */ 64 esp register. */
65 long int signal; /* Signal that caused the core dump. */ 65 long int signal; /* Signal that caused the core dump. */
66 struct user_regs_struct *u_ar0; 66 unsigned long u_ar0; /* Used by gdb to help find the values for */
67 /* Used by gdb to help find the values for */
68 /* the registers. */ 67 /* the registers. */
69 unsigned long magic; /* To uniquely identify a core file */ 68 unsigned long magic; /* To uniquely identify a core file */
70 char u_comm[32]; /* User command that was responsible */ 69 char u_comm[32]; /* User command that was responsible */
diff --git a/include/asm-sh/user.h b/include/asm-sh/user.h
index 1a4f43c75126..8fd3cf6c58d4 100644
--- a/include/asm-sh/user.h
+++ b/include/asm-sh/user.h
@@ -52,7 +52,7 @@ struct user {
52 unsigned long start_data; /* data starting address */ 52 unsigned long start_data; /* data starting address */
53 unsigned long start_stack; /* stack starting address */ 53 unsigned long start_stack; /* stack starting address */
54 long int signal; /* signal causing core dump */ 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 struct user_fpu_struct* u_fpstate; /* Math Co-processor pointer */ 56 struct user_fpu_struct* u_fpstate; /* Math Co-processor pointer */
57 unsigned long magic; /* identifies a core file */ 57 unsigned long magic; /* identifies a core file */
58 char u_comm[32]; /* user command name */ 58 char u_comm[32]; /* user command name */
diff --git a/include/asm-v850/user.h b/include/asm-v850/user.h
index be90eea5285b..63cdc567d272 100644
--- a/include/asm-v850/user.h
+++ b/include/asm-v850/user.h
@@ -38,7 +38,7 @@ struct user {
38 unsigned long start_data; /* data starting address */ 38 unsigned long start_data; /* data starting address */
39 unsigned long start_stack; /* stack starting address */ 39 unsigned long start_stack; /* stack starting address */
40 long int signal; /* signal causing core dump */ 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 unsigned long magic; /* identifies a core file */ 42 unsigned long magic; /* identifies a core file */
43 char u_comm[32]; /* user command name */ 43 char u_comm[32]; /* user command name */
44}; 44};
diff --git a/include/asm-x86/user_32.h b/include/asm-x86/user_32.h
index ed8b8fc6906c..6157da6f882c 100644
--- a/include/asm-x86/user_32.h
+++ b/include/asm-x86/user_32.h
@@ -116,7 +116,7 @@ struct user{
116 esp register. */ 116 esp register. */
117 long int signal; /* Signal that caused the core dump. */ 117 long int signal; /* Signal that caused the core dump. */
118 int reserved; /* No longer used */ 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 /* the registers. */ 120 /* the registers. */
121 struct user_i387_struct* u_fpstate; /* Math Co-processor pointer. */ 121 struct user_i387_struct* u_fpstate; /* Math Co-processor pointer. */
122 unsigned long magic; /* To uniquely identify a core file */ 122 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 a5449d456cc0..963616455609 100644
--- a/include/asm-x86/user_64.h
+++ b/include/asm-x86/user_64.h
@@ -118,7 +118,7 @@ struct user{
118 long int signal; /* Signal that caused the core dump. */ 118 long int signal; /* Signal that caused the core dump. */
119 int reserved; /* No longer used */ 119 int reserved; /* No longer used */
120 int pad1; 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 /* the registers. */ 122 /* the registers. */
123 struct user_i387_struct* u_fpstate; /* Math Co-processor pointer. */ 123 struct user_i387_struct* u_fpstate; /* Math Co-processor pointer. */
124 unsigned long magic; /* To uniquely identify a core file */ 124 unsigned long magic; /* To uniquely identify a core file */