summaryrefslogtreecommitdiffstats
path: root/fs/coredump.c
diff options
context:
space:
mode:
authorMenglong Dong <dong.menglong@zte.com.cn>2020-12-05 22:14:42 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-12-11 13:23:30 +0100
commit42ccf9d14ede72dd005d3ed97bddb7e29d8570b7 (patch)
tree11cdbb6453b02b37a5d4e52f1620b7226d47f954 /fs/coredump.c
parent579c977253b61672ecc9f361913171bc8f3091fe (diff)
downloadlinux-stable-42ccf9d14ede72dd005d3ed97bddb7e29d8570b7.tar.gz
linux-stable-42ccf9d14ede72dd005d3ed97bddb7e29d8570b7.tar.bz2
linux-stable-42ccf9d14ede72dd005d3ed97bddb7e29d8570b7.zip
coredump: fix core_pattern parse error
commit 2bf509d96d84c3336d08375e8af34d1b85ee71c8 upstream. '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: 315c69261dd3 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/coredump.c')
-rw-r--r--fs/coredump.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/coredump.c b/fs/coredump.c
index 5c0375e7440f..f34767eedf38 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -224,7 +224,8 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm,
*/
if (ispipe) {
if (isspace(*pat_ptr)) {
- was_space = true;
+ if (cn->used != 0)
+ was_space = true;
pat_ptr++;
continue;
} else if (was_space) {