Skip to contentSkip to conversation

coredump: fix core_pattern parse error

PATCH Applied [email protected] 2 participants 2 messages Nov 19, 2020 – Nov 24, 2020 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 coredump: fix core_pattern parse error

From: Menglong Dong <[email protected]>

'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', 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")
---
 fs/coredump.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/coredump.c +2 -1
index 0cd9056d79cc..c6acfc694f65 100644
@@ -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) {
Signature · 1 line
2.25.1
#1 lore raw
Quoted 20 lines · On Thu, 19 Nov 2020 03:08:43 -0500 [email protected] wrote:

From: Menglong Dong <[email protected]>

'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', 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'.

...

fs/coredump.c static int format_corename(struct core_name *cn, struct coredump_params *cprm, · line 236

Quoted 9 lines
fs/coredump.c +2 -1
@@ -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) {

Looks good to me. It's been a bit more than a year, but I'll add a cc:stable to this so that the earlier kernels get the fix.