aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 0039055b1fc6..721a29929511 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1349,7 +1349,7 @@ EXPORT_SYMBOL(remove_arg_zero);
1349/* 1349/*
1350 * cycle the list of binary formats handler, until one recognizes the image 1350 * cycle the list of binary formats handler, until one recognizes the image
1351 */ 1351 */
1352int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs) 1352int search_binary_handler(struct linux_binprm *bprm)
1353{ 1353{
1354 unsigned int depth = bprm->recursion_depth; 1354 unsigned int depth = bprm->recursion_depth;
1355 int try,retval; 1355 int try,retval;
@@ -1374,13 +1374,13 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
1374 for (try=0; try<2; try++) { 1374 for (try=0; try<2; try++) {
1375 read_lock(&binfmt_lock); 1375 read_lock(&binfmt_lock);
1376 list_for_each_entry(fmt, &formats, lh) { 1376 list_for_each_entry(fmt, &formats, lh) {
1377 int (*fn)(struct linux_binprm *, struct pt_regs *) = fmt->load_binary; 1377 int (*fn)(struct linux_binprm *) = fmt->load_binary;
1378 if (!fn) 1378 if (!fn)
1379 continue; 1379 continue;
1380 if (!try_module_get(fmt->module)) 1380 if (!try_module_get(fmt->module))
1381 continue; 1381 continue;
1382 read_unlock(&binfmt_lock); 1382 read_unlock(&binfmt_lock);
1383 retval = fn(bprm, regs); 1383 retval = fn(bprm);
1384 /* 1384 /*
1385 * Restore the depth counter to its starting value 1385 * Restore the depth counter to its starting value
1386 * in this call, so we don't have to rely on every 1386 * in this call, so we don't have to rely on every
@@ -1439,8 +1439,7 @@ EXPORT_SYMBOL(search_binary_handler);
1439 */ 1439 */
1440static int do_execve_common(const char *filename, 1440static int do_execve_common(const char *filename,
1441 struct user_arg_ptr argv, 1441 struct user_arg_ptr argv,
1442 struct user_arg_ptr envp, 1442 struct user_arg_ptr envp)
1443 struct pt_regs *regs)
1444{ 1443{
1445 struct linux_binprm *bprm; 1444 struct linux_binprm *bprm;
1446 struct file *file; 1445 struct file *file;
@@ -1524,7 +1523,7 @@ static int do_execve_common(const char *filename,
1524 if (retval < 0) 1523 if (retval < 0)
1525 goto out; 1524 goto out;
1526 1525
1527 retval = search_binary_handler(bprm,regs); 1526 retval = search_binary_handler(bprm);
1528 if (retval < 0) 1527 if (retval < 0)
1529 goto out; 1528 goto out;
1530 1529
@@ -1566,19 +1565,17 @@ out_ret:
1566 1565
1567int do_execve(const char *filename, 1566int do_execve(const char *filename,
1568 const char __user *const __user *__argv, 1567 const char __user *const __user *__argv,
1569 const char __user *const __user *__envp, 1568 const char __user *const __user *__envp)
1570 struct pt_regs *regs)
1571{ 1569{
1572 struct user_arg_ptr argv = { .ptr.native = __argv }; 1570 struct user_arg_ptr argv = { .ptr.native = __argv };
1573 struct user_arg_ptr envp = { .ptr.native = __envp }; 1571 struct user_arg_ptr envp = { .ptr.native = __envp };
1574 return do_execve_common(filename, argv, envp, regs); 1572 return do_execve_common(filename, argv, envp);
1575} 1573}
1576 1574
1577#ifdef CONFIG_COMPAT 1575#ifdef CONFIG_COMPAT
1578int compat_do_execve(const char *filename, 1576static int compat_do_execve(const char *filename,
1579 const compat_uptr_t __user *__argv, 1577 const compat_uptr_t __user *__argv,
1580 const compat_uptr_t __user *__envp, 1578 const compat_uptr_t __user *__envp)
1581 struct pt_regs *regs)
1582{ 1579{
1583 struct user_arg_ptr argv = { 1580 struct user_arg_ptr argv = {
1584 .is_compat = true, 1581 .is_compat = true,
@@ -1588,7 +1585,7 @@ int compat_do_execve(const char *filename,
1588 .is_compat = true, 1585 .is_compat = true,
1589 .ptr.compat = __envp, 1586 .ptr.compat = __envp,
1590 }; 1587 };
1591 return do_execve_common(filename, argv, envp, regs); 1588 return do_execve_common(filename, argv, envp);
1592} 1589}
1593#endif 1590#endif
1594 1591
@@ -1669,7 +1666,7 @@ SYSCALL_DEFINE3(execve,
1669 struct filename *path = getname(filename); 1666 struct filename *path = getname(filename);
1670 int error = PTR_ERR(path); 1667 int error = PTR_ERR(path);
1671 if (!IS_ERR(path)) { 1668 if (!IS_ERR(path)) {
1672 error = do_execve(path->name, argv, envp, current_pt_regs()); 1669 error = do_execve(path->name, argv, envp);
1673 putname(path); 1670 putname(path);
1674 } 1671 }
1675 return error; 1672 return error;
@@ -1682,8 +1679,7 @@ asmlinkage long compat_sys_execve(const char __user * filename,
1682 struct filename *path = getname(filename); 1679 struct filename *path = getname(filename);
1683 int error = PTR_ERR(path); 1680 int error = PTR_ERR(path);
1684 if (!IS_ERR(path)) { 1681 if (!IS_ERR(path)) {
1685 error = compat_do_execve(path->name, argv, envp, 1682 error = compat_do_execve(path->name, argv, envp);
1686 current_pt_regs());
1687 putname(path); 1683 putname(path);
1688 } 1684 }
1689 return error; 1685 return error;
@@ -1696,12 +1692,9 @@ int kernel_execve(const char *filename,
1696 const char *const argv[], 1692 const char *const argv[],
1697 const char *const envp[]) 1693 const char *const envp[])
1698{ 1694{
1699 struct pt_regs *p = current_pt_regs(); 1695 int ret = do_execve(filename,
1700 int ret;
1701
1702 ret = do_execve(filename,
1703 (const char __user *const __user *)argv, 1696 (const char __user *const __user *)argv,
1704 (const char __user *const __user *)envp, p); 1697 (const char __user *const __user *)envp);
1705 if (ret < 0) 1698 if (ret < 0)
1706 return ret; 1699 return ret;
1707 1700
@@ -1709,6 +1702,6 @@ int kernel_execve(const char *filename,
1709 * We were successful. We won't be returning to our caller, but 1702 * We were successful. We won't be returning to our caller, but
1710 * instead to user space by manipulating the kernel stack. 1703 * instead to user space by manipulating the kernel stack.
1711 */ 1704 */
1712 ret_from_kernel_execve(p); 1705 ret_from_kernel_execve(current_pt_regs());
1713} 1706}
1714#endif 1707#endif