* [PATCH] fs/coredump: reduce redundant log noise in validate_coredump_safety
@ 2026-04-10 8:09 lirongqing
2026-04-22 0:34 ` 答复: " Li,Rongqing(ACG CCN)
2026-04-22 12:44 ` Christian Brauner
0 siblings, 2 replies; 3+ messages in thread
From: lirongqing @ 2026-04-10 8:09 UTC (permalink / raw)
To: Alexander Viro, Christian Brauner, Jan Kara, Kees Cook,
linux-fsdevel, linux-kernel, linux-mm
Cc: Li RongQing
From: Li RongQing <lirongqing@baidu.com>
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>
---
fs/coredump.c | 3 ++-
fs/exec.c | 6 ++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/fs/coredump.c b/fs/coredump.c
index 29df8aa..9b357d2 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -1483,7 +1483,8 @@ static int proc_dostring_coredump(const struct ctl_table *table, int write,
return -EINVAL;
}
- validate_coredump_safety();
+ if (strncmp(old_core_pattern, core_pattern, CORENAME_MAX_SIZE))
+ validate_coredump_safety();
return error;
}
diff --git a/fs/exec.c b/fs/exec.c
index 9ea3a77..32b46e4 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;
}
--
2.9.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* 答复: [PATCH] fs/coredump: reduce redundant log noise in validate_coredump_safety
2026-04-10 8:09 [PATCH] fs/coredump: reduce redundant log noise in validate_coredump_safety lirongqing
@ 2026-04-22 0:34 ` Li,Rongqing(ACG CCN)
2026-04-22 12:44 ` Christian Brauner
1 sibling, 0 replies; 3+ messages in thread
From: Li,Rongqing(ACG CCN) @ 2026-04-22 0:34 UTC (permalink / raw)
To: Alexander Viro, Christian Brauner, Jan Kara, Kees Cook,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
> From: Li RongQing <lirongqing@baidu.com>
>
> 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>
> ---
> fs/coredump.c | 3 ++-
> fs/exec.c | 6 ++++--
> 2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/fs/coredump.c b/fs/coredump.c index 29df8aa..9b357d2 100644
> --- a/fs/coredump.c
> +++ b/fs/coredump.c
> @@ -1483,7 +1483,8 @@ static int proc_dostring_coredump(const struct
> ctl_table *table, int write,
> return -EINVAL;
> }
>
> - validate_coredump_safety();
> + if (strncmp(old_core_pattern, core_pattern, CORENAME_MAX_SIZE))
> + validate_coredump_safety();
> return error;
> }
>
> diff --git a/fs/exec.c b/fs/exec.c
> index 9ea3a77..32b46e4 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;
> }
> --
> 2.9.4
Ping
Thanks
[Li,Rongqing]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] fs/coredump: reduce redundant log noise in validate_coredump_safety
2026-04-10 8:09 [PATCH] fs/coredump: reduce redundant log noise in validate_coredump_safety lirongqing
2026-04-22 0:34 ` 答复: " Li,Rongqing(ACG CCN)
@ 2026-04-22 12:44 ` Christian Brauner
1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2026-04-22 12:44 UTC (permalink / raw)
To: lirongqing
Cc: Alexander Viro, Jan Kara, Kees Cook, linux-fsdevel, linux-kernel,
linux-mm
On Fri, Apr 10, 2026 at 04:09:18AM -0400, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
>
> 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>
> ---
That warning should very much serve as a reminder to not use that
completely unsafe pattern. So no, move to newer coredump infra or use
absolute paths, please.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-22 12:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-10 8:09 [PATCH] fs/coredump: reduce redundant log noise in validate_coredump_safety lirongqing
2026-04-22 0:34 ` 答复: " Li,Rongqing(ACG CCN)
2026-04-22 12:44 ` Christian Brauner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox