Subject: Re: linux-next: bott test warning

From: Joel Granados <[email-masked]>
Date: Tue, 23 May 2023 13:20:01 +0200

On Tue, May 23, 2023 at 01:57:39PM +1000, Stephen Rothwell wrote:
> Hi all,
> 
> Today's linux-next boot test (powerpc pseries_le_defconfig) produced
> this warning:
> 
> sysctl table check failed: kernel/usermodehelper Not a file
> sysctl table check failed: kernel/usermodehelper No proc_handler
> sysctl table check failed: kernel/usermodehelper bogus .mode 0555
> sysctl table check failed: kernel/keys Not a file
> sysctl table check failed: kernel/keys No proc_handler
> sysctl table check failed: kernel/keys bogus .mode 0555
> CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.4.0-rc3-04222-g1999c5d1802e #1
> Hardware name: IBM pSeries (emulated by qemu) POWER8 (raw) 0x4d0200 0xf000004 of:SLOF,HEAD pSeries
> Call Trace:
> [c0000000028bfd40] [c00000000113ea2c] dump_stack_lvl+0x70/0xa0 (unreliable)
> [c0000000028bfd70] [c0000000006166f0] __register_sysctl_table+0x7f0/0x9e0
> [c0000000028bfe50] [c00000000204e650] __register_sysctl_init+0x40/0x78
> [c0000000028bfec0] [c00000000202d660] sysctl_init_bases+0x40/0xb4
> [c0000000028bfef0] [c00000000204e6dc] proc_sys_init+0x54/0x68
> [c0000000028bff10] [c00000000204dff4] proc_root_init+0xb8/0xdc
> [c0000000028bff30] [c0000000020045d8] start_kernel+0x7f8/0x834
> [c0000000028bffe0] [c00000000000e998] start_here_common+0x1c/0x20
> failed when register_sysctl kern_table to kernel
> 
> I am not sure exactly which commit caused this.
> 
> -- 
> Cheers,
> Stephen Rothwell
Does the attached patch solve the issue?

-- 

Joel Granados
From c5e439534a8b493679e517616c631af277fcad26 Mon Sep 17 00:00:00 2001
From: Joel Granados <[email-masked]>
Date: Tue, 23 May 2023 13:15:02 +0200
Subject: [PATCH] sysctl: add missing kernel subdir nodes

The "kernel/usermodehelper" and "kernel/keys" paths are directories with
sysctl tables of their own; add them to the sysctl_init call.

Signed-off-by: Joel Granados <[email-masked]>
Tested-by: Stephen Rothwell <[email-masked]>
---
 kernel/sysctl.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index fa2aa8bd32b6..73fa9cf7ee11 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1782,11 +1782,6 @@ static struct ctl_table kern_table[] = {
 		.mode		= 0644,
 		.proc_handler	= sysctl_max_threads,
 	},
-	{
-		.procname	= "usermodehelper",
-		.mode		= 0555,
-		.child		= usermodehelper_table,
-	},
 	{
 		.procname	= "overflowuid",
 		.data		= &overflowuid,
@@ -1962,13 +1957,6 @@ static struct ctl_table kern_table[] = {
 		.proc_handler	= proc_dointvec,
 	},
 #endif
-#ifdef CONFIG_KEYS
-	{
-		.procname	= "keys",
-		.mode		= 0555,
-		.child		= key_sysctls,
-	},
-#endif
 #ifdef CONFIG_PERF_EVENTS
 	/*
 	 * User-space scripts rely on the existence of this file
@@ -2351,6 +2339,11 @@ static struct ctl_table dev_table[] = {
 int __init sysctl_init_bases(void)
 {
 	register_sysctl_init("kernel", kern_table);
+	register_sysctl_init("kernel/usermodehelper", usermodehelper_table);
+#ifdef CONFIG_KEYS
+	register_sysctl_init("kernel/keys", key_sysctls);
+#endif
+
 	register_sysctl_init("vm", vm_table);
 	register_sysctl_init("debug", debug_table);
 	register_sysctl_init("dev", dev_table);
-- 
2.30.2