diff options
| author | Li RongQing <lirongqing@baidu.com> | 2026-04-10 04:09:18 -0400 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-05-21 13:39:33 +0200 |
| commit | 9f93417af489f74739c9434c4c43557ccc07d222 (patch) | |
| tree | 027dedf472515445ea60a6ada1f03775b71d87a9 /fs/exec.c | |
| parent | 0447533faeeefc02c2979abf46c4dcbbbe6d9871 (diff) | |
fs/coredump: reduce redundant log noise in validate_coredump_safety
Currently, writing to 'core_pattern' or 'suid_dumpable' sysctl nodes
always triggers validate_coredump_safety(), even if the values have
not changed. This results in redundant warning messages in dmesg:
"Unsafe core_pattern used with fs.suid_dumpable=2..."
This patch optimizes the procfs handlers to only invoke the safety
validation when an actual change in the configuration is detected:
1. In proc_dostring_coredump(), compare the new core_pattern string
with the existing one using strncmp().
2. In proc_dointvec_minmax_coredump(), check if the new suid_dumpable
value differs from the previous one.
This keeps the kernel log clean from repetitive warnings when
re-applying the same sysctl settings.
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Link: https://patch.msgid.link/20260410080918.2319-1-lirongqing@baidu.com
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'fs/exec.c')
| -rw-r--r-- | fs/exec.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/exec.c b/fs/exec.c index ba12b4c466f6..2889b7cf808d 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1975,9 +1975,11 @@ COMPAT_SYSCALL_DEFINE5(execveat, int, fd, static int proc_dointvec_minmax_coredump(const struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { - int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos); + int error, old = READ_ONCE(suid_dumpable); - if (!error && write) + error = proc_dointvec_minmax(table, write, buffer, lenp, ppos); + + if (!error && write && (old != READ_ONCE(suid_dumpable))) validate_coredump_safety(); return error; } |
