Commit 90047b4b authored by Anton Blanchard's avatar Anton Blanchard

ppc64: Fix 32 bit execve to mirror recent generic changes

parent 1a982b3e
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
#include <asm/ppcdebug.h> #include <asm/ppcdebug.h>
#include <asm/time.h> #include <asm/time.h>
#include <asm/ppc32.h> #include <asm/ppc32.h>
#include <asm/mmu_context.h>
extern unsigned long wall_jiffies; extern unsigned long wall_jiffies;
#define USEC_PER_SEC (1000000) #define USEC_PER_SEC (1000000)
...@@ -3800,30 +3801,37 @@ static int do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_regs * ...@@ -3800,30 +3801,37 @@ static int do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_regs *
int retval; int retval;
int i; int i;
bprm.p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
memset(bprm.page, 0, MAX_ARG_PAGES * sizeof(bprm.page[0]));
file = open_exec(filename); file = open_exec(filename);
retval = PTR_ERR(file); retval = PTR_ERR(file);
if (IS_ERR(file)) if (IS_ERR(file))
return retval; return retval;
bprm.p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
memset(bprm.page, 0, MAX_ARG_PAGES * sizeof(bprm.page[0]));
bprm.file = file; bprm.file = file;
bprm.filename = filename; bprm.filename = filename;
bprm.sh_bang = 0; bprm.sh_bang = 0;
bprm.loader = 0; bprm.loader = 0;
bprm.exec = 0; bprm.exec = 0;
if ((bprm.argc = count32(argv, bprm.p / sizeof(u32))) < 0) {
allow_write_access(file); bprm.mm = mm_alloc();
fput(file); retval = -ENOMEM;
return bprm.argc; if (!bprm.mm)
} goto out_file;
if ((bprm.envc = count32(envp, bprm.p / sizeof(u32))) < 0) {
allow_write_access(file); retval = init_new_context(current, bprm.mm);
fput(file); if (retval < 0)
return bprm.argc; goto out_mm;
}
bprm.argc = count32(argv, bprm.p / sizeof(u32));
if ((retval = bprm.argc) < 0)
goto out_mm;
bprm.envc = count32(envp, bprm.p / sizeof(u32));
if ((retval = bprm.envc) < 0)
goto out_mm;
retval = prepare_binprm(&bprm); retval = prepare_binprm(&bprm);
if (retval < 0) if (retval < 0)
...@@ -3842,21 +3850,27 @@ static int do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_regs * ...@@ -3842,21 +3850,27 @@ static int do_execve32(char * filename, u32 * argv, u32 * envp, struct pt_regs *
if (retval < 0) if (retval < 0)
goto out; goto out;
retval = search_binary_handler(&bprm, regs); retval = search_binary_handler(&bprm,regs);
if (retval >= 0) if (retval >= 0)
/* execve success */ /* execve success */
return retval; return retval;
out: out:
/* Something went wrong, return the inode and free the argument pages*/ /* Something went wrong, return the inode and free the argument pages*/
allow_write_access(bprm.file); for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
if (bprm.file) struct page * page = bprm.page[i];
fput(bprm.file); if (page)
__free_page(page);
}
for (i=0 ; i<MAX_ARG_PAGES ; i++) out_mm:
if (bprm.page[i]) mmdrop(bprm.mm);
__free_page(bprm.page[i]);
out_file:
if (bprm.file) {
allow_write_access(bprm.file);
fput(bprm.file);
}
return retval; return retval;
} }
...@@ -3867,11 +3881,6 @@ asmlinkage long sys32_execve(unsigned long a0, unsigned long a1, unsigned long a ...@@ -3867,11 +3881,6 @@ asmlinkage long sys32_execve(unsigned long a0, unsigned long a1, unsigned long a
int error; int error;
char * filename; char * filename;
ifppcdebug(PPCDBG_SYS32) {
udbg_printf("sys32_execve - entered - pid=%ld, comm=%s \n", current->pid, current->comm);
//PPCDBG(PPCDBG_SYS32NI, " a0=%lx, a1=%lx, a2=%lx, a3=%lx, a4=%lx, a5=%lx, regs=%p \n", a0, a1, a2, a3, a4, a5, regs);
}
filename = getname((char *) a0); filename = getname((char *) a0);
error = PTR_ERR(filename); error = PTR_ERR(filename);
if (IS_ERR(filename)) if (IS_ERR(filename))
...@@ -3886,10 +3895,6 @@ asmlinkage long sys32_execve(unsigned long a0, unsigned long a1, unsigned long a ...@@ -3886,10 +3895,6 @@ asmlinkage long sys32_execve(unsigned long a0, unsigned long a1, unsigned long a
putname(filename); putname(filename);
out: out:
ifppcdebug(PPCDBG_SYS32) {
udbg_printf("sys32_execve - exited - returning %x - pid=%ld \n", error, current->pid);
//udbg_printf("sys32_execve - at exit - regs->gpr[1]=%lx, gpr[3]=%lx, gpr[4]=%lx, gpr[5]=%lx, gpr[6]=%lx \n", regs->gpr[1], regs->gpr[3], regs->gpr[4], regs->gpr[5], regs->gpr[6]);
}
return error; return error;
} }
......
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