[PATCH v2] audit: Force audit_context() to be always inlined

Jinjie Ruan <[email protected]> Tue, 21 Jul 2026 12:01:18 +0800
Newsgroups org.kernel.vger.audit,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
commit 6f25517010dd ("entry: Rework syscall_audit_enter()") relies on
dead code elimination to remove the call to syscall_enter_audit() when
CONFIG_AUDITSYSCALL is disabled. However, with s390 GCC 13.4.0 +
CONFIG_KASAN, audit_context() is not inlined despite being marked
inline, causing an undefined reference to syscall_enter_audit().

Force audit_context() to be __always_inline to ensure the conditional
can be constant-folded and dead code elimination works correctly.

Signed-off-by: Jinjie Ruan <[email protected]>
Suggested-by: Thomas Gleixner <[email protected]>
Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
---
 include/linux/audit.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 45abb3722d30..d79df1b75e74 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -343,7 +343,7 @@ static inline void audit_set_context(struct task_struct *task, struct audit_cont
 	task->audit_context = ctx;
 }
 
-static inline struct audit_context *audit_context(void)
+static __always_inline struct audit_context *audit_context(void)
 {
 	return current->audit_context;
 }
@@ -623,7 +623,7 @@ static inline bool audit_dummy_context(void)
 }
 static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx)
 { }
-static inline struct audit_context *audit_context(void)
+static __always_inline struct audit_context *audit_context(void)
 {
 	return NULL;
 }
-- 
2.34.1