Re: [PATCH] entry: Provide stub for syscall_enter_audit() when auditing is disabled

From: Thomas Gleixner

Date: Mon Jul 20 2026 - 11:46:10 EST


On Mon, Jul 20 2026 at 17:49, Jinjie Ruan wrote:
> When CONFIG_AUDITSYSCALL is not set, syscall_enter_audit() is not
> defined, causing following undefined reference warning. So add an empty
> inline stub to resolve the missing symbol.
>
> include/linux/entry-common.h:109:(.noinstr.text+0x2e6): undefined reference to `syscall_enter_audit'
>
> Fixes: ff2b9a905930 ("entry: Rework syscall_audit_enter()")
> Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Closes: https://lore.kernel.org/oe-kbuild-all/202607181530.2nx8zb3J-lkp@xxxxxxxxx/

This does not make any sense at all.

The call site is:

if (audit_context())
syscall_enter_audit(....);

audit.h has:

#ifdef CONFIG_AUDITSYSCALL
...
#else
static inline struct audit_context *audit_context(void) { return NULL; }
#endif

which means the call to syscall_enter_audit() should not ever end up in
the linker phase due to dead code elimination.

Such constructs which rely on dead code elimination are not unique. The
kernel is full of them.

The .config in the report builds without problems with s390-linux-gcc
15.2.0 (I verified that before merging), but fails with the version used
by the robot:

compiler: s390-linux-gcc (GCC) 13.4.0

So that's a broken compiler and without understanding the actual root
cause we are not going to paper over it.

When I disable CONFIG_KASAN in that config the problem goes away....

I have no idea how that's related especially as the code in question is
non instrumentable to begin with.

Looking at the disassembly:

if (unlikely(audit_context()))
2da: c0 e5 00 00 00 00 brasl %r14,2da <__do_syscall+0x2da>
2dc: R_390_PLT32DBL audit_context+0x2

So dead code elimination does not work because the compiler puts the
stub return NULL inline out of line....

The proper fix is below. The fixes tag wants to be:

Fixes: s390 cross GCC 13.4.0 brainfart

Thanks,

tglx
---
include/linux/audit.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -343,7 +343,7 @@ static inline void audit_set_context(str
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(v
}
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;
}