aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMenglong Dong <[email protected]>2020-12-05 22:14:42 -0800
committerLinus Torvalds <[email protected]>2020-12-06 10:19:07 -0800
commit2bf509d96d84c3336d08375e8af34d1b85ee71c8 (patch)
treedc63503226e80f505583b21485c5fe329fc7028e
parent11fb479ff5d9872ddff02dd533c16d60372c86b2 (diff)
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: 315c69261dd3 ("coredump: split pipe command whitespace before expanding template") Signed-off-by: Menglong Dong <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Cc: Paul Wise <[email protected]> Cc: Jakub Wilk <[email protected]> [https://bugs.debian.org/924398] Cc: Neil Horman <[email protected]> Cc: <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--fs/coredump.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/coredump.c b/fs/coredump.c
index 0cd9056d79cc..c6acfc694f65 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -229,7 +229,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) {