aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorNeil Horman <nhorman@tuxdriver.com>2007-10-17 02:26:34 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-17 11:42:50 -0400
commit7dc0b22e3c54f1f4730354fef84a20f5944f6c5e (patch)
tree8b281ed3315699eb0b21f00b5933b6222add5b5a /arch
parent8e2b705649e294f43a8cd1ea79e4c594c0bd1d9d (diff)
core_pattern: ignore RLIMIT_CORE if core_pattern is a pipe
For some time /proc/sys/kernel/core_pattern has been able to set its output destination as a pipe, allowing a user space helper to receive and intellegently process a core. This infrastructure however has some shortcommings which can be enhanced. Specifically: 1) The coredump code in the kernel should ignore RLIMIT_CORE limitation when core_pattern is a pipe, since file system resources are not being consumed in this case, unless the user application wishes to save the core, at which point the app is restricted by usual file system limits and restrictions. 2) The core_pattern code should be able to parse and pass options to the user space helper as an argv array. The real core limit of the uid of the crashing proces should also be passable to the user space helper (since it is overridden to zero when called). 3) Some miscellaneous bugs need to be cleaned up (specifically the recognition of a recursive core dump, should the user mode helper itself crash. Also, the core dump code in the kernel should not wait for the user mode helper to exit, since the same context is responsible for writing to the pipe, and a read of the pipe by the user mode helper will result in a deadlock. This patch: Remove the check of RLIMIT_CORE if core_pattern is a pipe. In the event that core_pattern is a pipe, the entire core will be fed to the user mode helper. 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 'arch')
-rw-r--r--arch/mips/kernel/irixelf.c5
-rw-r--r--arch/sparc64/kernel/binfmt_aout32.c10
-rw-r--r--arch/x86/ia32/ia32_aout.c10
3 files changed, 10 insertions, 15 deletions
diff --git a/arch/mips/kernel/irixelf.c b/arch/mips/kernel/irixelf.c
index 5a3fe43e3019..b997af713eb3 100644
--- a/arch/mips/kernel/irixelf.c
+++ b/arch/mips/kernel/irixelf.c
@@ -44,7 +44,7 @@
44static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs); 44static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs);
45static int load_irix_library(struct file *); 45static int load_irix_library(struct file *);
46static int irix_core_dump(long signr, struct pt_regs * regs, 46static int irix_core_dump(long signr, struct pt_regs * regs,
47 struct file *file); 47 struct file *file, unsigned long limit);
48 48
49static struct linux_binfmt irix_format = { 49static struct linux_binfmt irix_format = {
50 .module = THIS_MODULE, 50 .module = THIS_MODULE,
@@ -1091,7 +1091,7 @@ end_coredump:
1091 * and then they are actually written out. If we run out of core limit 1091 * and then they are actually written out. If we run out of core limit
1092 * we just truncate. 1092 * we just truncate.
1093 */ 1093 */
1094static int irix_core_dump(long signr, struct pt_regs * regs, struct file *file) 1094static int irix_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit)
1095{ 1095{
1096 int has_dumped = 0; 1096 int has_dumped = 0;
1097 mm_segment_t fs; 1097 mm_segment_t fs;
@@ -1101,7 +1101,6 @@ static int irix_core_dump(long signr, struct pt_regs * regs, struct file *file)
1101 struct vm_area_struct *vma; 1101 struct vm_area_struct *vma;
1102 struct elfhdr elf; 1102 struct elfhdr elf;
1103 off_t offset = 0, dataoff; 1103 off_t offset = 0, dataoff;
1104 int limit = current->signal->rlim[RLIMIT_CORE].rlim_cur;
1105 int numnote = 3; 1104 int numnote = 3;
1106 struct memelfnote notes[3]; 1105 struct memelfnote notes[3];
1107 struct elf_prstatus prstatus; /* NT_PRSTATUS */ 1106 struct elf_prstatus prstatus; /* NT_PRSTATUS */
diff --git a/arch/sparc64/kernel/binfmt_aout32.c b/arch/sparc64/kernel/binfmt_aout32.c
index c8acbeab49b4..92c1b36a2e16 100644
--- a/arch/sparc64/kernel/binfmt_aout32.c
+++ b/arch/sparc64/kernel/binfmt_aout32.c
@@ -35,7 +35,7 @@
35 35
36static int load_aout32_binary(struct linux_binprm *, struct pt_regs * regs); 36static int load_aout32_binary(struct linux_binprm *, struct pt_regs * regs);
37static int load_aout32_library(struct file*); 37static int load_aout32_library(struct file*);
38static int aout32_core_dump(long signr, struct pt_regs * regs, struct file *file); 38static int aout32_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit);
39 39
40static struct linux_binfmt aout32_format = { 40static struct linux_binfmt aout32_format = {
41 .module = THIS_MODULE, 41 .module = THIS_MODULE,
@@ -86,7 +86,7 @@ if (file->f_op->llseek) { \
86 * dumping of the process results in another error.. 86 * dumping of the process results in another error..
87 */ 87 */
88 88
89static int aout32_core_dump(long signr, struct pt_regs *regs, struct file *file) 89static int aout32_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit)
90{ 90{
91 mm_segment_t fs; 91 mm_segment_t fs;
92 int has_dumped = 0; 92 int has_dumped = 0;
@@ -105,13 +105,11 @@ static int aout32_core_dump(long signr, struct pt_regs *regs, struct file *file)
105 105
106/* If the size of the dump file exceeds the rlimit, then see what would happen 106/* If the size of the dump file exceeds the rlimit, then see what would happen
107 if we wrote the stack, but not the data area. */ 107 if we wrote the stack, but not the data area. */
108 if ((dump.u_dsize+dump.u_ssize) > 108 if (dump.u_dsize + dump.u_ssize > limit)
109 current->signal->rlim[RLIMIT_CORE].rlim_cur)
110 dump.u_dsize = 0; 109 dump.u_dsize = 0;
111 110
112/* Make sure we have enough room to write the stack and data areas. */ 111/* Make sure we have enough room to write the stack and data areas. */
113 if ((dump.u_ssize) > 112 if (dump.u_ssize > limit)
114 current->signal->rlim[RLIMIT_CORE].rlim_cur)
115 dump.u_ssize = 0; 113 dump.u_ssize = 0;
116 114
117/* make sure we actually have a data and stack area to dump */ 115/* make sure we actually have a data and stack area to dump */
diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
index 08781370256d..7cf1c29bf90e 100644
--- a/arch/x86/ia32/ia32_aout.c
+++ b/arch/x86/ia32/ia32_aout.c
@@ -40,7 +40,7 @@ static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs);
40static int load_aout_library(struct file*); 40static int load_aout_library(struct file*);
41 41
42#ifdef CORE_DUMP 42#ifdef CORE_DUMP
43static int aout_core_dump(long signr, struct pt_regs * regs, struct file *file); 43static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit);
44 44
45/* 45/*
46 * fill in the user structure for a core dump.. 46 * fill in the user structure for a core dump..
@@ -148,7 +148,7 @@ if (file->f_op->llseek) { \
148 * dumping of the process results in another error.. 148 * dumping of the process results in another error..
149 */ 149 */
150 150
151static int aout_core_dump(long signr, struct pt_regs * regs, struct file *file) 151static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit)
152{ 152{
153 mm_segment_t fs; 153 mm_segment_t fs;
154 int has_dumped = 0; 154 int has_dumped = 0;
@@ -168,13 +168,11 @@ static int aout_core_dump(long signr, struct pt_regs * regs, struct file *file)
168 168
169/* If the size of the dump file exceeds the rlimit, then see what would happen 169/* If the size of the dump file exceeds the rlimit, then see what would happen
170 if we wrote the stack, but not the data area. */ 170 if we wrote the stack, but not the data area. */
171 if ((dump.u_dsize+dump.u_ssize+1) * PAGE_SIZE > 171 if ((dump.u_dsize + dump.u_ssize + 1) * PAGE_SIZE > limit)
172 current->signal->rlim[RLIMIT_CORE].rlim_cur)
173 dump.u_dsize = 0; 172 dump.u_dsize = 0;
174 173
175/* Make sure we have enough room to write the stack and data areas. */ 174/* Make sure we have enough room to write the stack and data areas. */
176 if ((dump.u_ssize+1) * PAGE_SIZE > 175 if ((dump.u_ssize + 1) * PAGE_SIZE > limit)
177 current->signal->rlim[RLIMIT_CORE].rlim_cur)
178 dump.u_ssize = 0; 176 dump.u_ssize = 0;
179 177
180/* make sure we actually have a data and stack area to dump */ 178/* make sure we actually have a data and stack area to dump */