Commit 60093d36 authored by David Howells's avatar David Howells Committed by Linus Torvalds

[PATCH] FRV: change setup_arg_pages() to take stack pointer

The attached patch changes setup_arg_pages() to take the proposed initial stack
top for the new executable image. This makes it easier for the binfmt to place
the stack at a non-fixed location, such as happens in !MMU configurations.
Signed-Off-By: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent c9b76af7
...@@ -36,7 +36,8 @@ ...@@ -36,7 +36,8 @@
#undef WARN_OLD #undef WARN_OLD
#undef CORE_DUMP /* probably broken */ #undef CORE_DUMP /* probably broken */
extern int ia32_setup_arg_pages(struct linux_binprm *bprm, int exec_stack); extern int ia32_setup_arg_pages(struct linux_binprm *bprm,
unsigned long stack_top, int exec_stack);
static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs); static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs);
static int load_aout_library(struct file*); static int load_aout_library(struct file*);
...@@ -397,7 +398,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs) ...@@ -397,7 +398,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
set_brk(current->mm->start_brk, current->mm->brk); set_brk(current->mm->start_brk, current->mm->brk);
retval = ia32_setup_arg_pages(bprm, EXSTACK_DEFAULT); retval = ia32_setup_arg_pages(bprm, IA32_STACK_TOP, EXSTACK_DEFAULT);
if (retval < 0) { if (retval < 0) {
/* Someone check-me: is this error path enough? */ /* Someone check-me: is this error path enough? */
send_sig(SIGKILL, current, 0); send_sig(SIGKILL, current, 0);
......
...@@ -273,8 +273,9 @@ do { \ ...@@ -273,8 +273,9 @@ do { \
#define load_elf_binary load_elf32_binary #define load_elf_binary load_elf32_binary
#define ELF_PLAT_INIT(r, load_addr) elf32_init(r) #define ELF_PLAT_INIT(r, load_addr) elf32_init(r)
#define setup_arg_pages(bprm, exec_stack) ia32_setup_arg_pages(bprm, exec_stack) #define setup_arg_pages(bprm, stack_top, exec_stack) \
int ia32_setup_arg_pages(struct linux_binprm *bprm, int executable_stack); ia32_setup_arg_pages(bprm, stack_top, exec_stack)
int ia32_setup_arg_pages(struct linux_binprm *bprm, unsigned long stack_top, int executable_stack);
#undef start_thread #undef start_thread
#define start_thread(regs,new_rip,new_rsp) do { \ #define start_thread(regs,new_rip,new_rsp) do { \
...@@ -329,7 +330,7 @@ static void elf32_init(struct pt_regs *regs) ...@@ -329,7 +330,7 @@ static void elf32_init(struct pt_regs *regs)
me->thread.es = __USER_DS; me->thread.es = __USER_DS;
} }
int setup_arg_pages(struct linux_binprm *bprm, int executable_stack) int setup_arg_pages(struct linux_binprm *bprm, unsigned long stack_top, int executable_stack)
{ {
unsigned long stack_base; unsigned long stack_base;
struct vm_area_struct *mpnt; struct vm_area_struct *mpnt;
......
...@@ -424,7 +424,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs) ...@@ -424,7 +424,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
return retval; return retval;
} }
retval = setup_arg_pages(bprm, EXSTACK_DEFAULT); retval = setup_arg_pages(bprm, STACK_TOP, EXSTACK_DEFAULT);
if (retval < 0) { if (retval < 0) {
/* Someone check-me: is this error path enough? */ /* Someone check-me: is this error path enough? */
send_sig(SIGKILL, current, 0); send_sig(SIGKILL, current, 0);
......
...@@ -736,7 +736,7 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs) ...@@ -736,7 +736,7 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
change some of these later */ change some of these later */
current->mm->rss = 0; current->mm->rss = 0;
current->mm->free_area_cache = current->mm->mmap_base; current->mm->free_area_cache = current->mm->mmap_base;
retval = setup_arg_pages(bprm, executable_stack); retval = setup_arg_pages(bprm, STACK_TOP, executable_stack);
if (retval < 0) { if (retval < 0) {
send_sig(SIGKILL, current, 0); send_sig(SIGKILL, current, 0);
goto out_free_dentry; goto out_free_dentry;
......
...@@ -254,7 +254,7 @@ load_som_binary(struct linux_binprm * bprm, struct pt_regs * regs) ...@@ -254,7 +254,7 @@ load_som_binary(struct linux_binprm * bprm, struct pt_regs * regs)
set_binfmt(&som_format); set_binfmt(&som_format);
compute_creds(bprm); compute_creds(bprm);
setup_arg_pages(bprm, EXSTACK_DEFAULT); setup_arg_pages(bprm, STACK_TOP, EXSTACK_DEFAULT);
create_som_tables(bprm); create_som_tables(bprm);
......
...@@ -343,7 +343,9 @@ void install_arg_page(struct vm_area_struct *vma, ...@@ -343,7 +343,9 @@ void install_arg_page(struct vm_area_struct *vma,
#define EXTRA_STACK_VM_PAGES 20 /* random */ #define EXTRA_STACK_VM_PAGES 20 /* random */
int setup_arg_pages(struct linux_binprm *bprm, int executable_stack) int setup_arg_pages(struct linux_binprm *bprm,
unsigned long stack_top,
int executable_stack)
{ {
unsigned long stack_base; unsigned long stack_base;
struct vm_area_struct *mpnt; struct vm_area_struct *mpnt;
...@@ -384,7 +386,7 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack) ...@@ -384,7 +386,7 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
stack_base = current->signal->rlim[RLIMIT_STACK].rlim_max; stack_base = current->signal->rlim[RLIMIT_STACK].rlim_max;
if (stack_base > (1 << 30)) if (stack_base > (1 << 30))
stack_base = 1 << 30; stack_base = 1 << 30;
stack_base = PAGE_ALIGN(STACK_TOP - stack_base); stack_base = PAGE_ALIGN(stack_top - stack_base);
/* Adjust bprm->p to point to the end of the strings. */ /* Adjust bprm->p to point to the end of the strings. */
bprm->p = stack_base + PAGE_SIZE * i - offset; bprm->p = stack_base + PAGE_SIZE * i - offset;
...@@ -396,10 +398,10 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack) ...@@ -396,10 +398,10 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
while (i < MAX_ARG_PAGES) while (i < MAX_ARG_PAGES)
bprm->page[i++] = NULL; bprm->page[i++] = NULL;
#else #else
stack_base = STACK_TOP - MAX_ARG_PAGES * PAGE_SIZE; stack_base = stack_top - MAX_ARG_PAGES * PAGE_SIZE;
bprm->p += stack_base; bprm->p += stack_base;
mm->arg_start = bprm->p; mm->arg_start = bprm->p;
arg_size = STACK_TOP - (PAGE_MASK & (unsigned long) mm->arg_start); arg_size = stack_top - (PAGE_MASK & (unsigned long) mm->arg_start);
#endif #endif
arg_size += EXTRA_STACK_VM_PAGES * PAGE_SIZE; arg_size += EXTRA_STACK_VM_PAGES * PAGE_SIZE;
...@@ -426,7 +428,7 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack) ...@@ -426,7 +428,7 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
mpnt->vm_start = stack_base; mpnt->vm_start = stack_base;
mpnt->vm_end = stack_base + arg_size; mpnt->vm_end = stack_base + arg_size;
#else #else
mpnt->vm_end = STACK_TOP; mpnt->vm_end = stack_top;
mpnt->vm_start = mpnt->vm_end - arg_size; mpnt->vm_start = mpnt->vm_end - arg_size;
#endif #endif
/* Adjust stack execute permissions; explicitly enable /* Adjust stack execute permissions; explicitly enable
......
...@@ -74,7 +74,9 @@ extern int flush_old_exec(struct linux_binprm * bprm); ...@@ -74,7 +74,9 @@ extern int flush_old_exec(struct linux_binprm * bprm);
#define EXSTACK_DISABLE_X 1 /* Disable executable stacks */ #define EXSTACK_DISABLE_X 1 /* Disable executable stacks */
#define EXSTACK_ENABLE_X 2 /* Enable executable stacks */ #define EXSTACK_ENABLE_X 2 /* Enable executable stacks */
extern int setup_arg_pages(struct linux_binprm * bprm, int executable_stack); extern int setup_arg_pages(struct linux_binprm * bprm,
unsigned long stack_top,
int executable_stack);
extern int copy_strings(int argc,char __user * __user * argv,struct linux_binprm *bprm); extern int copy_strings(int argc,char __user * __user * argv,struct linux_binprm *bprm);
extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm); extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm);
extern void compute_creds(struct linux_binprm *binprm); extern void compute_creds(struct linux_binprm *binprm);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment