aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/ia64/ia32/binfmt_elf32.c67
-rw-r--r--arch/x86_64/ia32/ia32_aout.c2
-rw-r--r--arch/x86_64/ia32/ia32_binfmt.c58
3 files changed, 17 insertions, 110 deletions
diff --git a/arch/ia64/ia32/binfmt_elf32.c b/arch/ia64/ia32/binfmt_elf32.c
index 6f4d3d06f0ed..e1189ba1ca5e 100644
--- a/arch/ia64/ia32/binfmt_elf32.c
+++ b/arch/ia64/ia32/binfmt_elf32.c
@@ -195,62 +195,27 @@ ia64_elf32_init (struct pt_regs *regs)
195 ia32_load_state(current); 195 ia32_load_state(current);
196} 196}
197 197
198/*
199 * Undo the override of setup_arg_pages() without this ia32_setup_arg_pages()
200 * will suffer infinite self recursion.
201 */
202#undef setup_arg_pages
203
198int 204int
199ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack) 205ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack)
200{ 206{
201 unsigned long stack_base; 207 int ret;
202 struct vm_area_struct *mpnt; 208
203 struct mm_struct *mm = current->mm; 209 ret = setup_arg_pages(bprm, IA32_STACK_TOP, executable_stack);
204 int i, ret; 210 if (!ret) {
205 211 /*
206 stack_base = IA32_STACK_TOP - MAX_ARG_PAGES*PAGE_SIZE; 212 * Can't do it in ia64_elf32_init(). Needs to be done before
207 mm->arg_start = bprm->p + stack_base; 213 * calls to elf32_map()
208 214 */
209 bprm->p += stack_base; 215 current->thread.ppl = ia32_init_pp_list();
210 if (bprm->loader)
211 bprm->loader += stack_base;
212 bprm->exec += stack_base;
213
214 mpnt = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
215 if (!mpnt)
216 return -ENOMEM;
217
218 down_write(&current->mm->mmap_sem);
219 {
220 mpnt->vm_mm = current->mm;
221 mpnt->vm_start = PAGE_MASK & (unsigned long) bprm->p;
222 mpnt->vm_end = IA32_STACK_TOP;
223 if (executable_stack == EXSTACK_ENABLE_X)
224 mpnt->vm_flags = VM_STACK_FLAGS | VM_EXEC;
225 else if (executable_stack == EXSTACK_DISABLE_X)
226 mpnt->vm_flags = VM_STACK_FLAGS & ~VM_EXEC;
227 else
228 mpnt->vm_flags = VM_STACK_FLAGS;
229 mpnt->vm_page_prot = (mpnt->vm_flags & VM_EXEC)?
230 PAGE_COPY_EXEC: PAGE_COPY;
231 if ((ret = insert_vm_struct(current->mm, mpnt))) {
232 up_write(&current->mm->mmap_sem);
233 kmem_cache_free(vm_area_cachep, mpnt);
234 return ret;
235 }
236 current->mm->stack_vm = current->mm->total_vm = vma_pages(mpnt);
237 } 216 }
238 217
239 for (i = 0 ; i < MAX_ARG_PAGES ; i++) { 218 return ret;
240 struct page *page = bprm->page[i];
241 if (page) {
242 bprm->page[i] = NULL;
243 install_arg_page(mpnt, page, stack_base);
244 }
245 stack_base += PAGE_SIZE;
246 }
247 up_write(&current->mm->mmap_sem);
248
249 /* Can't do it in ia64_elf32_init(). Needs to be done before calls to
250 elf32_map() */
251 current->thread.ppl = ia32_init_pp_list();
252
253 return 0;
254} 219}
255 220
256static void 221static void
diff --git a/arch/x86_64/ia32/ia32_aout.c b/arch/x86_64/ia32/ia32_aout.c
index fe83edb93c10..08781370256d 100644
--- a/arch/x86_64/ia32/ia32_aout.c
+++ b/arch/x86_64/ia32/ia32_aout.c
@@ -404,7 +404,7 @@ beyond_if:
404 404
405 set_brk(current->mm->start_brk, current->mm->brk); 405 set_brk(current->mm->start_brk, current->mm->brk);
406 406
407 retval = ia32_setup_arg_pages(bprm, IA32_STACK_TOP, EXSTACK_DEFAULT); 407 retval = setup_arg_pages(bprm, IA32_STACK_TOP, EXSTACK_DEFAULT);
408 if (retval < 0) { 408 if (retval < 0) {
409 /* Someone check-me: is this error path enough? */ 409 /* Someone check-me: is this error path enough? */
410 send_sig(SIGKILL, current, 0); 410 send_sig(SIGKILL, current, 0);
diff --git a/arch/x86_64/ia32/ia32_binfmt.c b/arch/x86_64/ia32/ia32_binfmt.c
index 185399baaf6d..ed56a8806eab 100644
--- a/arch/x86_64/ia32/ia32_binfmt.c
+++ b/arch/x86_64/ia32/ia32_binfmt.c
@@ -232,9 +232,6 @@ do { \
232#define load_elf_binary load_elf32_binary 232#define load_elf_binary load_elf32_binary
233 233
234#define ELF_PLAT_INIT(r, load_addr) elf32_init(r) 234#define ELF_PLAT_INIT(r, load_addr) elf32_init(r)
235#define setup_arg_pages(bprm, stack_top, exec_stack) \
236 ia32_setup_arg_pages(bprm, stack_top, exec_stack)
237int ia32_setup_arg_pages(struct linux_binprm *bprm, unsigned long stack_top, int executable_stack);
238 235
239#undef start_thread 236#undef start_thread
240#define start_thread(regs,new_rip,new_rsp) do { \ 237#define start_thread(regs,new_rip,new_rsp) do { \
@@ -286,61 +283,6 @@ static void elf32_init(struct pt_regs *regs)
286 me->thread.es = __USER_DS; 283 me->thread.es = __USER_DS;
287} 284}
288 285
289int ia32_setup_arg_pages(struct linux_binprm *bprm, unsigned long stack_top,
290 int executable_stack)
291{
292 unsigned long stack_base;
293 struct vm_area_struct *mpnt;
294 struct mm_struct *mm = current->mm;
295 int i, ret;
296
297 stack_base = stack_top - MAX_ARG_PAGES * PAGE_SIZE;
298 mm->arg_start = bprm->p + stack_base;
299
300 bprm->p += stack_base;
301 if (bprm->loader)
302 bprm->loader += stack_base;
303 bprm->exec += stack_base;
304
305 mpnt = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
306 if (!mpnt)
307 return -ENOMEM;
308
309 down_write(&mm->mmap_sem);
310 {
311 mpnt->vm_mm = mm;
312 mpnt->vm_start = PAGE_MASK & (unsigned long) bprm->p;
313 mpnt->vm_end = stack_top;
314 if (executable_stack == EXSTACK_ENABLE_X)
315 mpnt->vm_flags = VM_STACK_FLAGS | VM_EXEC;
316 else if (executable_stack == EXSTACK_DISABLE_X)
317 mpnt->vm_flags = VM_STACK_FLAGS & ~VM_EXEC;
318 else
319 mpnt->vm_flags = VM_STACK_FLAGS;
320 mpnt->vm_page_prot = (mpnt->vm_flags & VM_EXEC) ?
321 PAGE_COPY_EXEC : PAGE_COPY;
322 if ((ret = insert_vm_struct(mm, mpnt))) {
323 up_write(&mm->mmap_sem);
324 kmem_cache_free(vm_area_cachep, mpnt);
325 return ret;
326 }
327 mm->stack_vm = mm->total_vm = vma_pages(mpnt);
328 }
329
330 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
331 struct page *page = bprm->page[i];
332 if (page) {
333 bprm->page[i] = NULL;
334 install_arg_page(mpnt, page, stack_base);
335 }
336 stack_base += PAGE_SIZE;
337 }
338 up_write(&mm->mmap_sem);
339
340 return 0;
341}
342EXPORT_SYMBOL(ia32_setup_arg_pages);
343
344#ifdef CONFIG_SYSCTL 286#ifdef CONFIG_SYSCTL
345/* Register vsyscall32 into the ABI table */ 287/* Register vsyscall32 into the ABI table */
346#include <linux/sysctl.h> 288#include <linux/sysctl.h>