summaryrefslogtreecommitdiffstats
path: root/fs/binfmt_flat.c
diff options
context:
space:
mode:
authorNicolas Pitre <nicolas.pitre@linaro.org>2016-07-24 11:30:19 -0400
committerGreg Ungerer <gerg@linux-m68k.org>2016-07-25 02:51:55 -0400
commit687fd7738ec322ea5994a692c20301eed315899d (patch)
treebdbca358cf5dce78311da66c08397a1d8ba3580e /fs/binfmt_flat.c
parent7e7ec6a934349ef6983f06f7ac0da09cc8a42983 (diff)
binfmt_flat: use generic transfer_args_to_stack()
This gets rid of the rather ugly, open coded and suboptimal copy code. Signed-off-by: Nicolas Pitre <nico@linaro.org> Reviewed-by: Greg Ungerer <gerg@linux-m68k.org> Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
Diffstat (limited to 'fs/binfmt_flat.c')
-rw-r--r--fs/binfmt_flat.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 03301bad1f9b..a002e1a3b9e8 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -846,10 +846,8 @@ static int load_flat_binary(struct linux_binprm *bprm)
846{ 846{
847 struct lib_info libinfo; 847 struct lib_info libinfo;
848 struct pt_regs *regs = current_pt_regs(); 848 struct pt_regs *regs = current_pt_regs();
849 unsigned long p = bprm->p; 849 unsigned long sp, stack_len;
850 unsigned long stack_len;
851 unsigned long start_addr; 850 unsigned long start_addr;
852 unsigned long *sp;
853 int res; 851 int res;
854 int i, j; 852 int i, j;
855 853
@@ -884,15 +882,15 @@ static int load_flat_binary(struct linux_binprm *bprm)
884 882
885 set_binfmt(&flat_format); 883 set_binfmt(&flat_format);
886 884
887 p = ((current->mm->context.end_brk + stack_len + 3) & ~3) - 4; 885 sp = ((current->mm->context.end_brk + stack_len + 3) & ~3) - 4;
888 pr_debug("p=%lx\n", p); 886 pr_debug("sp=%lx\n", sp);
889 887
890 /* copy the arg pages onto the stack, this could be more efficient :-) */ 888 /* copy the arg pages onto the stack */
891 for (i = TOP_OF_ARGS - 1; i >= bprm->p; i--) 889 res = transfer_args_to_stack(bprm, &sp);
892 *(char *) --p = 890 if (res)
893 ((char *) page_address(bprm->page[i/PAGE_SIZE]))[i % PAGE_SIZE]; 891 return res;
894 892
895 sp = (unsigned long *) create_flat_tables(p, bprm); 893 sp = create_flat_tables(sp, bprm);
896 894
897 /* Fake some return addresses to ensure the call chain will 895 /* Fake some return addresses to ensure the call chain will
898 * initialise library in order for us. We are required to call 896 * initialise library in order for us. We are required to call
@@ -904,14 +902,14 @@ static int load_flat_binary(struct linux_binprm *bprm)
904 for (i = MAX_SHARED_LIBS-1; i > 0; i--) { 902 for (i = MAX_SHARED_LIBS-1; i > 0; i--) {
905 if (libinfo.lib_list[i].loaded) { 903 if (libinfo.lib_list[i].loaded) {
906 /* Push previos first to call address */ 904 /* Push previos first to call address */
907 --sp; put_user(start_addr, sp); 905 --sp; put_user(start_addr, (unsigned long *)sp);
908 start_addr = libinfo.lib_list[i].entry; 906 start_addr = libinfo.lib_list[i].entry;
909 } 907 }
910 } 908 }
911#endif 909#endif
912 910
913 /* Stash our initial stack pointer into the mm structure */ 911 /* Stash our initial stack pointer into the mm structure */
914 current->mm->start_stack = (unsigned long)sp; 912 current->mm->start_stack = sp;
915 913
916#ifdef FLAT_PLAT_INIT 914#ifdef FLAT_PLAT_INIT
917 FLAT_PLAT_INIT(regs); 915 FLAT_PLAT_INIT(regs);