aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 550ae9b22f8d..86c455447bc8 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1697,6 +1697,7 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
1697 int fsuid = current->fsuid; 1697 int fsuid = current->fsuid;
1698 int flag = 0; 1698 int flag = 0;
1699 int ispipe = 0; 1699 int ispipe = 0;
1700 unsigned long core_limit = current->signal->rlim[RLIMIT_CORE].rlim_cur;
1700 1701
1701 audit_core_dumps(signr); 1702 audit_core_dumps(signr);
1702 1703
@@ -1730,9 +1731,6 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
1730 */ 1731 */
1731 clear_thread_flag(TIF_SIGPENDING); 1732 clear_thread_flag(TIF_SIGPENDING);
1732 1733
1733 if (current->signal->rlim[RLIMIT_CORE].rlim_cur < binfmt->min_coredump)
1734 goto fail_unlock;
1735
1736 /* 1734 /*
1737 * lock_kernel() because format_corename() is controlled by sysctl, which 1735 * lock_kernel() because format_corename() is controlled by sysctl, which
1738 * uses lock_kernel() 1736 * uses lock_kernel()
@@ -1740,7 +1738,20 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
1740 lock_kernel(); 1738 lock_kernel();
1741 ispipe = format_corename(corename, core_pattern, signr); 1739 ispipe = format_corename(corename, core_pattern, signr);
1742 unlock_kernel(); 1740 unlock_kernel();
1741 /*
1742 * Don't bother to check the RLIMIT_CORE value if core_pattern points
1743 * to a pipe. Since we're not writing directly to the filesystem
1744 * RLIMIT_CORE doesn't really apply, as no actual core file will be
1745 * created unless the pipe reader choses to write out the core file
1746 * at which point file size limits and permissions will be imposed
1747 * as it does with any other process
1748 */
1749 if ((!ispipe) &&
1750 (core_limit < binfmt->min_coredump))
1751 goto fail_unlock;
1752
1743 if (ispipe) { 1753 if (ispipe) {
1754 core_limit = RLIM_INFINITY;
1744 /* SIGPIPE can happen, but it's just never processed */ 1755 /* SIGPIPE can happen, but it's just never processed */
1745 if(call_usermodehelper_pipe(corename+1, NULL, NULL, &file)) { 1756 if(call_usermodehelper_pipe(corename+1, NULL, NULL, &file)) {
1746 printk(KERN_INFO "Core dump to %s pipe failed\n", 1757 printk(KERN_INFO "Core dump to %s pipe failed\n",
@@ -1770,7 +1781,7 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
1770 if (!ispipe && do_truncate(file->f_path.dentry, 0, 0, file) != 0) 1781 if (!ispipe && do_truncate(file->f_path.dentry, 0, 0, file) != 0)
1771 goto close_fail; 1782 goto close_fail;
1772 1783
1773 retval = binfmt->core_dump(signr, regs, file); 1784 retval = binfmt->core_dump(signr, regs, file, core_limit);
1774 1785
1775 if (retval) 1786 if (retval)
1776 current->signal->group_exit_code |= 0x80; 1787 current->signal->group_exit_code |= 0x80;