aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/binfmt_aout.c65
1 files changed, 1 insertions, 64 deletions
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
index f1f3f4192a60..8a3b32f5b781 100644
--- a/fs/binfmt_aout.c
+++ b/fs/binfmt_aout.c
@@ -99,88 +99,53 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, u
99# define START_DATA(u) (u.start_data) 99# define START_DATA(u) (u.start_data)
100#elif defined(__arm__) 100#elif defined(__arm__)
101# define START_DATA(u) ((u.u_tsize << PAGE_SHIFT) + u.start_code) 101# define START_DATA(u) ((u.u_tsize << PAGE_SHIFT) + u.start_code)
102#elif defined(__sparc__)
103# define START_DATA(u) (u.u_tsize)
104#elif defined(__i386__) || defined(__mc68000__) || defined(__arch_um__) 102#elif defined(__i386__) || defined(__mc68000__) || defined(__arch_um__)
105# define START_DATA(u) (u.u_tsize << PAGE_SHIFT) 103# define START_DATA(u) (u.u_tsize << PAGE_SHIFT)
106#endif 104#endif
107#ifdef __sparc__
108# define START_STACK(u) ((regs->u_regs[UREG_FP]) & ~(PAGE_SIZE - 1))
109#else
110# define START_STACK(u) (u.start_stack) 105# define START_STACK(u) (u.start_stack)
111#endif
112 106
113 fs = get_fs(); 107 fs = get_fs();
114 set_fs(KERNEL_DS); 108 set_fs(KERNEL_DS);
115 has_dumped = 1; 109 has_dumped = 1;
116 current->flags |= PF_DUMPCORE; 110 current->flags |= PF_DUMPCORE;
117 strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm)); 111 strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm));
118#ifndef __sparc__
119 dump.u_ar0 = offsetof(struct user, regs); 112 dump.u_ar0 = offsetof(struct user, regs);
120#endif
121 dump.signal = signr; 113 dump.signal = signr;
122 aout_dump_thread(regs, &dump); 114 aout_dump_thread(regs, &dump);
123 115
124/* If the size of the dump file exceeds the rlimit, then see what would happen 116/* If the size of the dump file exceeds the rlimit, then see what would happen
125 if we wrote the stack, but not the data area. */ 117 if we wrote the stack, but not the data area. */
126#ifdef __sparc__
127 if ((dump.u_dsize + dump.u_ssize) > limit)
128 dump.u_dsize = 0;
129#else
130 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > limit) 118 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > limit)
131 dump.u_dsize = 0; 119 dump.u_dsize = 0;
132#endif
133 120
134/* Make sure we have enough room to write the stack and data areas. */ 121/* Make sure we have enough room to write the stack and data areas. */
135#ifdef __sparc__
136 if (dump.u_ssize > limit)
137 dump.u_ssize = 0;
138#else
139 if ((dump.u_ssize + 1) * PAGE_SIZE > limit) 122 if ((dump.u_ssize + 1) * PAGE_SIZE > limit)
140 dump.u_ssize = 0; 123 dump.u_ssize = 0;
141#endif
142 124
143/* make sure we actually have a data and stack area to dump */ 125/* make sure we actually have a data and stack area to dump */
144 set_fs(USER_DS); 126 set_fs(USER_DS);
145#ifdef __sparc__
146 if (!access_ok(VERIFY_READ, (void __user *)START_DATA(dump), dump.u_dsize))
147 dump.u_dsize = 0;
148 if (!access_ok(VERIFY_READ, (void __user *)START_STACK(dump), dump.u_ssize))
149 dump.u_ssize = 0;
150#else
151 if (!access_ok(VERIFY_READ, (void __user *)START_DATA(dump), dump.u_dsize << PAGE_SHIFT)) 127 if (!access_ok(VERIFY_READ, (void __user *)START_DATA(dump), dump.u_dsize << PAGE_SHIFT))
152 dump.u_dsize = 0; 128 dump.u_dsize = 0;
153 if (!access_ok(VERIFY_READ, (void __user *)START_STACK(dump), dump.u_ssize << PAGE_SHIFT)) 129 if (!access_ok(VERIFY_READ, (void __user *)START_STACK(dump), dump.u_ssize << PAGE_SHIFT))
154 dump.u_ssize = 0; 130 dump.u_ssize = 0;
155#endif
156 131
157 set_fs(KERNEL_DS); 132 set_fs(KERNEL_DS);
158/* struct user */ 133/* struct user */
159 DUMP_WRITE(&dump,sizeof(dump)); 134 DUMP_WRITE(&dump,sizeof(dump));
160/* Now dump all of the user data. Include malloced stuff as well */ 135/* Now dump all of the user data. Include malloced stuff as well */
161#ifndef __sparc__
162 DUMP_SEEK(PAGE_SIZE); 136 DUMP_SEEK(PAGE_SIZE);
163#endif
164/* now we start writing out the user space info */ 137/* now we start writing out the user space info */
165 set_fs(USER_DS); 138 set_fs(USER_DS);
166/* Dump the data area */ 139/* Dump the data area */
167 if (dump.u_dsize != 0) { 140 if (dump.u_dsize != 0) {
168 dump_start = START_DATA(dump); 141 dump_start = START_DATA(dump);
169#ifdef __sparc__
170 dump_size = dump.u_dsize;
171#else
172 dump_size = dump.u_dsize << PAGE_SHIFT; 142 dump_size = dump.u_dsize << PAGE_SHIFT;
173#endif
174 DUMP_WRITE(dump_start,dump_size); 143 DUMP_WRITE(dump_start,dump_size);
175 } 144 }
176/* Now prepare to dump the stack area */ 145/* Now prepare to dump the stack area */
177 if (dump.u_ssize != 0) { 146 if (dump.u_ssize != 0) {
178 dump_start = START_STACK(dump); 147 dump_start = START_STACK(dump);
179#ifdef __sparc__
180 dump_size = dump.u_ssize;
181#else
182 dump_size = dump.u_ssize << PAGE_SHIFT; 148 dump_size = dump.u_ssize << PAGE_SHIFT;
183#endif
184 DUMP_WRITE(dump_start,dump_size); 149 DUMP_WRITE(dump_start,dump_size);
185 } 150 }
186/* Finally dump the task struct. Not be used by gdb, but could be useful */ 151/* Finally dump the task struct. Not be used by gdb, but could be useful */
@@ -205,11 +170,6 @@ static unsigned long __user *create_aout_tables(char __user *p, struct linux_bin
205 int envc = bprm->envc; 170 int envc = bprm->envc;
206 171
207 sp = (void __user *)((-(unsigned long)sizeof(char *)) & (unsigned long) p); 172 sp = (void __user *)((-(unsigned long)sizeof(char *)) & (unsigned long) p);
208#ifdef __sparc__
209 /* This imposes the proper stack alignment for a new process. */
210 sp = (void __user *) (((unsigned long) sp) & ~7);
211 if ((envc+argc+3)&1) --sp;
212#endif
213#ifdef __alpha__ 173#ifdef __alpha__
214/* whee.. test-programs are so much fun. */ 174/* whee.. test-programs are so much fun. */
215 put_user(0, --sp); 175 put_user(0, --sp);
@@ -302,11 +262,6 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
302 /* OK, This is the point of no return */ 262 /* OK, This is the point of no return */
303#if defined(__alpha__) 263#if defined(__alpha__)
304 SET_AOUT_PERSONALITY(bprm, ex); 264 SET_AOUT_PERSONALITY(bprm, ex);
305#elif defined(__sparc__)
306 set_personality(PER_SUNOS);
307#if !defined(__sparc_v9__)
308 memcpy(&current->thread.core_exec, &ex, sizeof(struct exec));
309#endif
310#else 265#else
311 set_personality(PER_LINUX); 266 set_personality(PER_LINUX);
312#endif 267#endif
@@ -322,24 +277,6 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
322 277
323 install_exec_creds(bprm); 278 install_exec_creds(bprm);
324 current->flags &= ~PF_FORKNOEXEC; 279 current->flags &= ~PF_FORKNOEXEC;
325#ifdef __sparc__
326 if (N_MAGIC(ex) == NMAGIC) {
327 loff_t pos = fd_offset;
328 /* Fuck me plenty... */
329 /* <AOL></AOL> */
330 down_write(&current->mm->mmap_sem);
331 error = do_brk(N_TXTADDR(ex), ex.a_text);
332 up_write(&current->mm->mmap_sem);
333 bprm->file->f_op->read(bprm->file, (char *) N_TXTADDR(ex),
334 ex.a_text, &pos);
335 down_write(&current->mm->mmap_sem);
336 error = do_brk(N_DATADDR(ex), ex.a_data);
337 up_write(&current->mm->mmap_sem);
338 bprm->file->f_op->read(bprm->file, (char *) N_DATADDR(ex),
339 ex.a_data, &pos);
340 goto beyond_if;
341 }
342#endif
343 280
344 if (N_MAGIC(ex) == OMAGIC) { 281 if (N_MAGIC(ex) == OMAGIC) {
345 unsigned long text_addr, map_size; 282 unsigned long text_addr, map_size;
@@ -347,7 +284,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
347 284
348 text_addr = N_TXTADDR(ex); 285 text_addr = N_TXTADDR(ex);
349 286
350#if defined(__alpha__) || defined(__sparc__) 287#ifdef __alpha__
351 pos = fd_offset; 288 pos = fd_offset;
352 map_size = ex.a_text+ex.a_data + PAGE_SIZE - 1; 289 map_size = ex.a_text+ex.a_data + PAGE_SIZE - 1;
353#else 290#else