aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/ia32
diff options
context:
space:
mode:
authorOllie Wild <aaw@google.com>2007-07-19 04:48:16 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-19 13:04:45 -0400
commitb6a2fea39318e43fee84fa7b0b90d68bed92d2ba (patch)
treec9c3619cb2730b5c10c7427b837146bce3d69156 /arch/x86_64/ia32
parentbdf4c48af20a3b0f01671799ace345e3d49576da (diff)
mm: variable length argument support
Remove the arg+env limit of MAX_ARG_PAGES by copying the strings directly from the old mm into the new mm. We create the new mm before the binfmt code runs, and place the new stack at the very top of the address space. Once the binfmt code runs and figures out where the stack should be, we move it downwards. It is a bit peculiar in that we have one task with two mm's, one of which is inactive. [a.p.zijlstra@chello.nl: limit stack size] Signed-off-by: Ollie Wild <aaw@google.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: <linux-arch@vger.kernel.org> Cc: Hugh Dickins <hugh@veritas.com> [bunk@stusta.de: unexport bprm_mm_init] Signed-off-by: Adrian Bunk <bunk@stusta.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86_64/ia32')
-rw-r--r--arch/x86_64/ia32/ia32_aout.c2
-rw-r--r--arch/x86_64/ia32/ia32_binfmt.c58
2 files changed, 1 insertions, 59 deletions
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>