diff options
author | Ollie Wild <aaw@google.com> | 2007-07-19 04:48:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-19 13:04:45 -0400 |
commit | b6a2fea39318e43fee84fa7b0b90d68bed92d2ba (patch) | |
tree | c9c3619cb2730b5c10c7427b837146bce3d69156 /arch/ia64 | |
parent | bdf4c48af20a3b0f01671799ace345e3d49576da (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/ia64')
-rw-r--r-- | arch/ia64/ia32/binfmt_elf32.c | 67 |
1 files changed, 16 insertions, 51 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 | |||
198 | int | 204 | int |
199 | ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack) | 205 | ia32_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(¤t->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(¤t->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(¤t->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 | ||
256 | static void | 221 | static void |