aboutsummaryrefslogtreecommitdiffstats
path: root/fs/coredump.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2013-07-03 18:08:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 19:08:02 -0400
commit888ffc5923e4343a78575918ab781e85fa22d244 (patch)
treef90eb6f4266d1450bf23bfe45b5c322cbb38710a /fs/coredump.c
parent3ceadcf6d489650ade673b7197c11c521aecb038 (diff)
coredump: '% at the end' shouldn't bypass core_uses_pid logic
"goto end" should not bypass the "Backward compatibility with core_uses_pid" code, move this label up. While at it, - It is ugly to copy '|' into cn->corename and then inc the pointer for argv_split(). Change format_corename() to increment pat_ptr instead. - Remove the dead "if (*pat_ptr == 0)" in format_corename(), we already checked it is not zero. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: Colin Walters <walters@verbum.org> Cc: Denys Vlasenko <vda.linux@googlemail.com> Cc: Jiri Slaby <jslaby@suse.cz> Cc: Lennart Poettering <mzxreary@0pointer.de> Cc: Lucas De Marchi <lucas.de.marchi@gmail.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/coredump.c')
-rw-r--r--fs/coredump.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/coredump.c b/fs/coredump.c
index 56a9ab963a40..72f816d6cad9 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -165,13 +165,15 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
165 cn->corename = NULL; 165 cn->corename = NULL;
166 if (expand_corename(cn, core_name_size)) 166 if (expand_corename(cn, core_name_size))
167 return -ENOMEM; 167 return -ENOMEM;
168 cn->corename[0] = '\0';
169
170 if (ispipe)
171 ++pat_ptr;
168 172
169 /* Repeat as long as we have more pattern to process and more output 173 /* Repeat as long as we have more pattern to process and more output
170 space */ 174 space */
171 while (*pat_ptr) { 175 while (*pat_ptr) {
172 if (*pat_ptr != '%') { 176 if (*pat_ptr != '%') {
173 if (*pat_ptr == 0)
174 goto out;
175 err = cn_printf(cn, "%c", *pat_ptr++); 177 err = cn_printf(cn, "%c", *pat_ptr++);
176 } else { 178 } else {
177 switch (*++pat_ptr) { 179 switch (*++pat_ptr) {
@@ -240,6 +242,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
240 return err; 242 return err;
241 } 243 }
242 244
245out:
243 /* Backward compatibility with core_uses_pid: 246 /* Backward compatibility with core_uses_pid:
244 * 247 *
245 * If core_pattern does not include a %p (as is the default) 248 * If core_pattern does not include a %p (as is the default)
@@ -250,7 +253,6 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
250 if (err) 253 if (err)
251 return err; 254 return err;
252 } 255 }
253out:
254 return ispipe; 256 return ispipe;
255} 257}
256 258
@@ -580,7 +582,7 @@ void do_coredump(siginfo_t *siginfo)
580 goto fail_dropcount; 582 goto fail_dropcount;
581 } 583 }
582 584
583 helper_argv = argv_split(GFP_KERNEL, cn.corename+1, NULL); 585 helper_argv = argv_split(GFP_KERNEL, cn.corename, NULL);
584 if (!helper_argv) { 586 if (!helper_argv) {
585 printk(KERN_WARNING "%s failed to allocate memory\n", 587 printk(KERN_WARNING "%s failed to allocate memory\n",
586 __func__); 588 __func__);
@@ -597,7 +599,7 @@ void do_coredump(siginfo_t *siginfo)
597 599
598 argv_free(helper_argv); 600 argv_free(helper_argv);
599 if (retval) { 601 if (retval) {
600 printk(KERN_INFO "Core dump to %s pipe failed\n", 602 printk(KERN_INFO "Core dump to |%s pipe failed\n",
601 cn.corename); 603 cn.corename);
602 goto close_fail; 604 goto close_fail;
603 } 605 }