]> www.infradead.org Git - users/hch/misc.git/commitdiff
coredump: fix core_pattern input validation
authorChristian Brauner <brauner@kernel.org>
Tue, 7 Oct 2025 09:32:42 +0000 (11:32 +0200)
committerChristian Brauner <brauner@kernel.org>
Tue, 7 Oct 2025 11:12:46 +0000 (13:12 +0200)
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>
fs/coredump.c
fs/exec.c

index b5fc06a092a44f6f40d266ff6fa5605c407a4938..5c1c381ee380693c0d3e0f1eacd98cb3d8339986 100644 (file)
@@ -1468,7 +1468,7 @@ static int proc_dostring_coredump(const struct ctl_table *table, int write,
        ssize_t retval;
        char old_core_pattern[CORENAME_MAX_SIZE];
 
-       if (write)
+       if (!write)
                return proc_dostring(table, write, buffer, lenp, ppos);
 
        retval = strscpy(old_core_pattern, core_pattern, CORENAME_MAX_SIZE);
index 6b70c6726d3165bde1fd1387814a9a52658ec477..4298e7e08d5d78ea327c10e9e962780b3d976e1a 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -2048,7 +2048,7 @@ static int proc_dointvec_minmax_coredump(const struct ctl_table *table, int writ
 {
        int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
 
-       if (!error && !write)
+       if (!error && write)
                validate_coredump_safety();
        return error;
 }