[PATCH RFC v2 01/13] keys, pidns, fs/verity, riscv/vector: reorder '#include <linux/sysctl.h>'

Mauricio Faria de Oliveira mfo at igalia.com
Tue Aug 18 19:28:00 PDT 2026


Fix an include loop error in preparation for sysctl.h to include module.h:

    CC [M]  arch/x86/events/amd/uncore.o
  In file included from .../include/linux/fs.h:44,         <<<
                   from .../include/linux/compat.h:17,
                   from .../arch/x86/include/asm/ia32.h:7,
                   from .../arch/x86/include/asm/elf.h:10,
                   from .../include/linux/elf.h:6,
                   from .../include/linux/module.h:20,     <<<
                   from .../include/linux/sysctl.h:245,    <<<
                   from .../include/linux/key.h:17,        <<<
                   from .../include/linux/cred.h:13,       <<<
                   from .../include/linux/sched/signal.h:10,
                   from .../include/linux/ptrace.h:7,
                   from .../include/uapi/asm-generic/bpf_perf_event.h:4,
                   from ./arch/x86/include/generated/uapi/asm/
                        bpf_perf_event.h:1,
                   from .../include/uapi/linux/bpf_perf_event.h:11,
                   from .../include/linux/perf_event.h:18,
                   from .../arch/x86/events/amd/uncore.c:8:
  .../include/linux/mnt_idmapping.h: In function ‘mapped_fsuid’:
  .../include/linux/mnt_idmapping.h:231:59: error: implicit declaration
    of function ‘current_fsuid’ [-Wimplicit-function-declaration]

Reason:
 - cred.h includes key.h *before* defining current_fsuid();
 - key.h includes sysctl.h;
 - sysctl.h includes module.h;
 - module.h includes fs.h via elf.h > asm/elf.h > asm/ia32.h > compat.h;
 - fs.h includes mnt_idmapping.h, which uses *undefined* current_fsuid().

Note that fs.h does include cred.h (which defines current_fsuid()) right
before mnt_idmapping.h (which uses it), but it is not parsed because the
include guard of cred.h is defined earlier.

Address this by removing sysctl.h from key.h, which does not need it,
and adding it to files that actually need it.

Signed-off-by: Mauricio Faria de Oliveira <mfo at igalia.com>
---
 arch/riscv/kernel/vector.c    | 1 +
 fs/verity/init.c              | 1 +
 include/linux/key.h           | 1 -
 include/linux/pid_namespace.h | 1 +
 4 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/vector.c b/arch/riscv/kernel/vector.c
index b112166d51e9f584f84c52d0f84feb92ccd60df1..9eac47c99f114304521fdc539018f3f84507e75f 100644
--- a/arch/riscv/kernel/vector.c
+++ b/arch/riscv/kernel/vector.c
@@ -10,6 +10,7 @@
 #include <linux/sched.h>
 #include <linux/uaccess.h>
 #include <linux/prctl.h>
+#include <linux/sysctl.h>
 
 #include <asm/thread_info.h>
 #include <asm/processor.h>
diff --git a/fs/verity/init.c b/fs/verity/init.c
index 3aa55dec88fc919792a2cb4be476f8481ef78a9e..d460eef74fcfe49f6cf69974a8194a65de486819 100644
--- a/fs/verity/init.c
+++ b/fs/verity/init.c
@@ -9,6 +9,7 @@
 #include "fsverity_private.h"
 
 #include <linux/ratelimit.h>
+#include <linux/sysctl.h>
 
 #ifdef CONFIG_SYSCTL
 static const struct ctl_table fsverity_sysctl_table[] = {
diff --git a/include/linux/key.h b/include/linux/key.h
index 81b8f05c68985c6f0a5c5bbe0f1fd6661912c618..a74f8f1b7936d6ede584c0a8cd520f858f6a9758 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -14,7 +14,6 @@
 #include <linux/list.h>
 #include <linux/rbtree.h>
 #include <linux/rcupdate.h>
-#include <linux/sysctl.h>
 #include <linux/rwsem.h>
 #include <linux/atomic.h>
 #include <linux/assoc_array.h>
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
index b20baaa7e62b755e7e561fcd8018e2b61213503e..94b23471c7dec135e24c4c0c1fdbf841cea2e5de 100644
--- a/include/linux/pid_namespace.h
+++ b/include/linux/pid_namespace.h
@@ -10,6 +10,7 @@
 #include <linux/nsproxy.h>
 #include <linux/ns_common.h>
 #include <linux/idr.h>
+#include <linux/sysctl.h>
 
 /* MAX_PID_NS_LEVEL is needed for limiting size of 'struct pid' */
 #define MAX_PID_NS_LEVEL 32

-- 
2.47.3




More information about the linux-riscv mailing list