aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorNeil Horman <nhorman@tuxdriver.com>2007-10-17 02:26:35 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-17 11:42:50 -0400
commit74aadce986052f20088c2678f589ea0e8d3a4b59 (patch)
treee250181221f29e45e0b9d1e4175f569a66e639c4 /fs
parent7dc0b22e3c54f1f4730354fef84a20f5944f6c5e (diff)
core_pattern: allow passing of arguments to user mode helper when core_pattern is a pipe
A rewrite of my previous post for this enhancement. It uses jeremy's split_argv/free_argv library functions to translate core_pattern into an argv array to be passed to the user mode helper process. It also adds a translation to format_corename such that the origional value of RLIMIT_CORE can be passed to userspace as an argument. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> Cc: <martin.pitt@ubuntu.com> Cc: <wwoods@redhat.com> Cc: Jeremy Fitzhardinge <jeremy@goop.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/exec.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 86c455447bc8..6450157062ea 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -29,6 +29,7 @@
29#include <linux/stat.h> 29#include <linux/stat.h>
30#include <linux/fcntl.h> 30#include <linux/fcntl.h>
31#include <linux/smp_lock.h> 31#include <linux/smp_lock.h>
32#include <linux/string.h>
32#include <linux/init.h> 33#include <linux/init.h>
33#include <linux/pagemap.h> 34#include <linux/pagemap.h>
34#include <linux/highmem.h> 35#include <linux/highmem.h>
@@ -1514,6 +1515,14 @@ static int format_corename(char *corename, const char *pattern, long signr)
1514 goto out; 1515 goto out;
1515 out_ptr += rc; 1516 out_ptr += rc;
1516 break; 1517 break;
1518 /* core limit size */
1519 case 'c':
1520 rc = snprintf(out_ptr, out_end - out_ptr,
1521 "%lu", current->signal->rlim[RLIMIT_CORE].rlim_cur);
1522 if (rc > out_end - out_ptr)
1523 goto out;
1524 out_ptr += rc;
1525 break;
1517 default: 1526 default:
1518 break; 1527 break;
1519 } 1528 }
@@ -1698,6 +1707,9 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
1698 int flag = 0; 1707 int flag = 0;
1699 int ispipe = 0; 1708 int ispipe = 0;
1700 unsigned long core_limit = current->signal->rlim[RLIMIT_CORE].rlim_cur; 1709 unsigned long core_limit = current->signal->rlim[RLIMIT_CORE].rlim_cur;
1710 char **helper_argv = NULL;
1711 int helper_argc = 0;
1712 char *delimit;
1701 1713
1702 audit_core_dumps(signr); 1714 audit_core_dumps(signr);
1703 1715
@@ -1746,14 +1758,18 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
1746 * at which point file size limits and permissions will be imposed 1758 * at which point file size limits and permissions will be imposed
1747 * as it does with any other process 1759 * as it does with any other process
1748 */ 1760 */
1749 if ((!ispipe) && 1761 if ((!ispipe) && (core_limit < binfmt->min_coredump))
1750 (core_limit < binfmt->min_coredump))
1751 goto fail_unlock; 1762 goto fail_unlock;
1752 1763
1753 if (ispipe) { 1764 if (ispipe) {
1754 core_limit = RLIM_INFINITY; 1765 core_limit = RLIM_INFINITY;
1766 helper_argv = argv_split(GFP_KERNEL, corename+1, &helper_argc);
1767 /* Terminate the string before the first option */
1768 delimit = strchr(corename, ' ');
1769 if (delimit)
1770 *delimit = '\0';
1755 /* SIGPIPE can happen, but it's just never processed */ 1771 /* SIGPIPE can happen, but it's just never processed */
1756 if(call_usermodehelper_pipe(corename+1, NULL, NULL, &file)) { 1772 if(call_usermodehelper_pipe(corename+1, helper_argv, NULL, &file)) {
1757 printk(KERN_INFO "Core dump to %s pipe failed\n", 1773 printk(KERN_INFO "Core dump to %s pipe failed\n",
1758 corename); 1774 corename);
1759 goto fail_unlock; 1775 goto fail_unlock;
@@ -1788,6 +1804,9 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
1788close_fail: 1804close_fail:
1789 filp_close(file, NULL); 1805 filp_close(file, NULL);
1790fail_unlock: 1806fail_unlock:
1807 if (helper_argv)
1808 argv_free(helper_argv);
1809
1791 current->fsuid = fsuid; 1810 current->fsuid = fsuid;
1792 complete_all(&mm->core_done); 1811 complete_all(&mm->core_done);
1793fail: 1812fail: