Commit 888ffc59 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds

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: default avatarOleg 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: default avatarNeil Horman <nhorman@tuxdriver.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 3ceadcf6
...@@ -165,13 +165,15 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm) ...@@ -165,13 +165,15 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
cn->corename = NULL; cn->corename = NULL;
if (expand_corename(cn, core_name_size)) if (expand_corename(cn, core_name_size))
return -ENOMEM; return -ENOMEM;
cn->corename[0] = '\0';
if (ispipe)
++pat_ptr;
/* Repeat as long as we have more pattern to process and more output /* Repeat as long as we have more pattern to process and more output
space */ space */
while (*pat_ptr) { while (*pat_ptr) {
if (*pat_ptr != '%') { if (*pat_ptr != '%') {
if (*pat_ptr == 0)
goto out;
err = cn_printf(cn, "%c", *pat_ptr++); err = cn_printf(cn, "%c", *pat_ptr++);
} else { } else {
switch (*++pat_ptr) { switch (*++pat_ptr) {
...@@ -240,6 +242,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm) ...@@ -240,6 +242,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
return err; return err;
} }
out:
/* Backward compatibility with core_uses_pid: /* Backward compatibility with core_uses_pid:
* *
* If core_pattern does not include a %p (as is the default) * 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,7 +253,6 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
if (err) if (err)
return err; return err;
} }
out:
return ispipe; return ispipe;
} }
...@@ -580,7 +582,7 @@ void do_coredump(siginfo_t *siginfo) ...@@ -580,7 +582,7 @@ void do_coredump(siginfo_t *siginfo)
goto fail_dropcount; goto fail_dropcount;
} }
helper_argv = argv_split(GFP_KERNEL, cn.corename+1, NULL); helper_argv = argv_split(GFP_KERNEL, cn.corename, NULL);
if (!helper_argv) { if (!helper_argv) {
printk(KERN_WARNING "%s failed to allocate memory\n", printk(KERN_WARNING "%s failed to allocate memory\n",
__func__); __func__);
...@@ -597,7 +599,7 @@ void do_coredump(siginfo_t *siginfo) ...@@ -597,7 +599,7 @@ void do_coredump(siginfo_t *siginfo)
argv_free(helper_argv); argv_free(helper_argv);
if (retval) { if (retval) {
printk(KERN_INFO "Core dump to %s pipe failed\n", printk(KERN_INFO "Core dump to |%s pipe failed\n",
cn.corename); cn.corename);
goto close_fail; goto close_fail;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment