]> www.infradead.org Git - users/hch/misc.git/commitdiff
coredump: don't pointlessly check and spew warnings
authorChristian Brauner <brauner@kernel.org>
Thu, 21 Aug 2025 11:50:47 +0000 (13:50 +0200)
committerChristian Brauner <brauner@kernel.org>
Thu, 21 Aug 2025 11:54:40 +0000 (13:54 +0200)
When a write happens it doesn't make sense to check perform checks on
the input. Skip them.

Whether a fixes tag is licensed is a bit of a gray area here but I'll
add one for the socket validation part I added recently.

Link: https://lore.kernel.org/20250821-moosbedeckt-denunziant-7908663f3563@brauner
Fixes: 16195d2c7dd2 ("coredump: validate socket name as it is written")
Reported-by: Brad Spengler <brad.spengler@opensrcsec.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/coredump.c
fs/exec.c

index 5dce257c67fc8bfc3d26fdeb77c8ea4ae6b0768a..60bc9685e14985d28d0a17f2d967281a1fcd17bf 100644 (file)
@@ -1466,11 +1466,15 @@ static int proc_dostring_coredump(const struct ctl_table *table, int write,
        ssize_t retval;
        char old_core_pattern[CORENAME_MAX_SIZE];
 
+       if (write)
+               return proc_dostring(table, write, buffer, lenp, ppos);
+
        retval = strscpy(old_core_pattern, core_pattern, CORENAME_MAX_SIZE);
 
        error = proc_dostring(table, write, buffer, lenp, ppos);
        if (error)
                return error;
+
        if (!check_coredump_socket()) {
                strscpy(core_pattern, old_core_pattern, retval + 1);
                return -EINVAL;
index 2a1e5e4042a14940fe749207361abb25130df3d4..e861a4b7ffda92b09de1b7ae4a4ec56b6242a51e 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)
+       if (!error && !write)
                validate_coredump_safety();
        return error;
 }