Skip to content

Commit 2bf509d

Browse files
Menglong Dongtorvalds
authored andcommitted
coredump: fix core_pattern parse error
'format_corename()' will splite 'core_pattern' on spaces when it is in pipe mode, and take helper_argv[0] as the path to usermode executable. It works fine in most cases. However, if there is a space between '|' and '/file/path', such as '| /usr/lib/systemd/systemd-coredump %P %u %g', then helper_argv[0] will be parsed as '', and users will get a 'Core dump to | disabled'. It is not friendly to users, as the pattern above was valid previously. Fix this by ignoring the spaces between '|' and '/file/path'. Fixes: 315c692 ("coredump: split pipe command whitespace before expanding template") Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Paul Wise <pabs3@bonedaddy.net> Cc: Jakub Wilk <jwilk@jwilk.net> [https://bugs.debian.org/924398] Cc: Neil Horman <nhorman@tuxdriver.com> Cc: <stable@vger.kernel.org> Link: https://lkml.kernel.org/r/5fb62870.1c69fb81.8ef5d.af76@mx.google.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 11fb479 commit 2bf509d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/coredump.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm,
229229
*/
230230
if (ispipe) {
231231
if (isspace(*pat_ptr)) {
232-
was_space = true;
232+
if (cn->used != 0)
233+
was_space = true;
233234
pat_ptr++;
234235
continue;
235236
} else if (was_space) {

0 commit comments

Comments
 (0)