Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

coredump: fix core_pattern input validation

In be1e0283021e ("coredump: don't pointlessly check and spew warnings")
we tried to fix input validation so it only happens during a write to
core_pattern. This would avoid needlessly logging a lot of warnings
during a read operation. However the logic accidently got inverted in
this commit. Fix it so the input validation only happens on write and is
skipped on read.

Fixes: be1e0283021e ("coredump: don't pointlessly check and spew warnings")
Fixes: 16195d2c7dd2 ("coredump: validate socket name as it is written")
Reviewed-by: Jan Kara <jack@suse.cz>
Reported-by: Yu Watanabe <watanabe.yu@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>

+2 -2
+1 -1
fs/coredump.c
··· 1468 1468 ssize_t retval; 1469 1469 char old_core_pattern[CORENAME_MAX_SIZE]; 1470 1470 1471 - if (write) 1471 + if (!write) 1472 1472 return proc_dostring(table, write, buffer, lenp, ppos); 1473 1473 1474 1474 retval = strscpy(old_core_pattern, core_pattern, CORENAME_MAX_SIZE);
+1 -1
fs/exec.c
··· 2048 2048 { 2049 2049 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 2050 2050 2051 - if (!error && !write) 2051 + if (!error && write) 2052 2052 validate_coredump_safety(); 2053 2053 return error; 2054 2054 }