Re: [PATCH 10/12] sysctl: Move sysctl_panic_on_stackoverflow to kernel/panic.c

From: Kees Cook
Date: Fri May 09 2025 - 13:05:03 EST


On Fri, May 09, 2025 at 02:54:14PM +0200, Joel Granados wrote:
> This is part of a greater effort to move ctl tables into their
> respective subsystems which will reduce the merge conflicts in
> kernel/sysctl.c.
>
> Signed-off-by: Joel Granados <joel.granados@xxxxxxxxxx>

Another undocumented sysctl. ;) This one should be called
"panic_on_stack_exhaustion", but so be it. :)

Reviewed-by: Kees Cook <kees@xxxxxxxxxx>

> ---
> kernel/panic.c | 10 ++++++++++
> kernel/sysctl.c | 10 ----------
> 2 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/kernel/panic.c b/kernel/panic.c
> index 213c6c9d6a750ff3d17f3cf530b37c619cd816f4..401f0997f654797acc3351040bbbda1845ce00c1 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -183,6 +183,16 @@ static const struct ctl_table kern_panic_table[] = {
> .mode = 0644,
> .proc_handler = proc_douintvec,
> },
> +#if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
> + defined(CONFIG_DEBUG_STACKOVERFLOW)
> + {
> + .procname = "panic_on_stackoverflow",
> + .data = &sysctl_panic_on_stackoverflow,
> + .maxlen = sizeof(int),
> + .mode = 0644,
> + .proc_handler = proc_dointvec,
> + },
> +#endif
> };
>
> static __init int kernel_panic_sysctls_init(void)
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index d5bebdd02cd4f1def7d9dd2b85454a9022b600b7..446d77ec44f57a4929389b64fc23d3b180f550b4 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -1552,16 +1552,6 @@ static const struct ctl_table kern_table[] = {
> .mode = 0444,
> .proc_handler = proc_dointvec,
> },
> -#if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
> - defined(CONFIG_DEBUG_STACKOVERFLOW)
> - {
> - .procname = "panic_on_stackoverflow",
> - .data = &sysctl_panic_on_stackoverflow,
> - .maxlen = sizeof(int),
> - .mode = 0644,
> - .proc_handler = proc_dointvec,
> - },
> -#endif
> #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
> {
> .procname = "ignore-unaligned-usertrap",
>
> --
> 2.47.2
>
>

--
Kees Cook