include/linux/irq-entry-common.h:218: undefined reference to `syscall_enter_audit'
Subsystems (3)
kernel test robot
build bottree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 940de590b839f71d6dc846160534bf202401b8b7 commit: 6f25517010ddd3f8080d7e06b9b1cb1b64b73772 entry: Rework syscall_audit_enter() date: 6 weeks ago config: riscv-randconfig-r052-20260903 (https://download.01.org/0day-ci/archive/20260903/[email protected]/config) compiler: riscv64-linux-gcc (GCC) 8.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260903/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Fixes: 6f25517010dd ("entry: Rework syscall_audit_enter()")
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
riscv64-linux-ld: arch/riscv/kernel/traps.o: in function `__exit_to_user_mode_validate':
>> include/linux/irq-entry-common.h:218: undefined reference to `syscall_enter_audit'
vim +218 include/linux/irq-entry-common.h
a70e9f647f501e3 Jinjie Ruan 2025-06-24 212
70fe25a3bc53a89 Thomas Gleixner 2025-10-27 213 static __always_inline void __exit_to_user_mode_validate(void)
70fe25a3bc53a89 Thomas Gleixner 2025-10-27 214 {
a70e9f647f501e3 Jinjie Ruan 2025-06-24 215 /* Ensure that kernel state is sane for a return to userspace */
a70e9f647f501e3 Jinjie Ruan 2025-06-24 216 kmap_assert_nomap();
a70e9f647f501e3 Jinjie Ruan 2025-06-24 217 lockdep_assert_irqs_disabled();
a70e9f647f501e3 Jinjie Ruan 2025-06-24 @218 lockdep_sys_exit();
a70e9f647f501e3 Jinjie Ruan 2025-06-24 219 }
a70e9f647f501e3 Jinjie Ruan 2025-06-24 220 :::::: The code at line 218 was first introduced by commit
:::::: a70e9f647f501e36a6a092888b1ea7386b7c5664 entry: Split generic entry into generic exception and syscall entry
:::::: TO: Jinjie Ruan <[email protected]>
:::::: CC: Thomas Gleixner <[email protected]>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Thomas Gleixner
maintainerQuoted 10 lines · kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 940de590b839f71d6dc846160534bf202401b8b7 commit: 6f25517010ddd3f8080d7e06b9b1cb1b64b73772 entry: Rework syscall_audit_enter() date: 6 weeks ago config: riscv-randconfig-r052-20260903 (https://download.01.org/0day-ci/archive/20260903/[email protected]/config) compiler: riscv64-linux-gcc (GCC) 8.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260903/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
Quoted 8 lines
| Fixes: 6f25517010dd ("entry: Rework syscall_audit_enter()") | Reported-by: kernel test robot <[email protected]> | Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
riscv64-linux-ld:
arch/riscv/kernel/traps.o: in function `__exit_to_user_mode_validate':Quoted 1 line
Quoted 1 line
include/linux/irq-entry-common.h:218: undefined reference to `syscall_enter_audit'
Seriously?
Quoted 10 lines
vim +218
include/linux/irq-entry-common.ha70e9f647f501e3 Jinjie Ruan 2025-06-24 212 70fe25a3bc53a89 Thomas Gleixner 2025-10-27 213 static __always_inline void __exit_to_user_mode_validate(void) 70fe25a3bc53a89 Thomas Gleixner 2025-10-27 214 { a70e9f647f501e3 Jinjie Ruan 2025-06-24 215 /* Ensure that kernel state is sane for a return to userspace */ a70e9f647f501e3 Jinjie Ruan 2025-06-24 216 kmap_assert_nomap(); a70e9f647f501e3 Jinjie Ruan 2025-06-24 217 lockdep_assert_irqs_disabled();
a70e9f647f501e3Jinjie Ruan 2025-06-24 @218lockdep_sys_exit();
What the heck has line 218 to do with that failure?
This is getting stupid. It seems there is yet another compiler aside of s390 gcc which fails to do dead code elimination but this time it's worse it also points to the wrong place ....
Thanks,
tglx
Quoted 33 lines · Thomas Gleixner
Quoted 10 lines · kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 940de590b839f71d6dc846160534bf202401b8b7 commit: 6f25517010ddd3f8080d7e06b9b1cb1b64b73772 entry: Rework syscall_audit_enter() date: 6 weeks ago config: riscv-randconfig-r052-20260903 (https://download.01.org/0day-ci/archive/20260903/[email protected]/config) compiler: riscv64-linux-gcc (GCC) 8.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260903/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
Quoted 8 lines
| Fixes: 6f25517010dd ("entry: Rework syscall_audit_enter()") | Reported-by: kernel test robot <[email protected]> | Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
riscv64-linux-ld:
arch/riscv/kernel/traps.o: in function `__exit_to_user_mode_validate':Quoted 1 line
Quoted 1 line
include/linux/irq-entry-common.h:218: undefined reference to `syscall_enter_audit'Seriously?
Quoted 10 lines
vim +218
include/linux/irq-entry-common.ha70e9f647f501e3 Jinjie Ruan 2025-06-24 212 70fe25a3bc53a89 Thomas Gleixner 2025-10-27 213 static __always_inline void __exit_to_user_mode_validate(void) 70fe25a3bc53a89 Thomas Gleixner 2025-10-27 214 { a70e9f647f501e3 Jinjie Ruan 2025-06-24 215 /* Ensure that kernel state is sane for a return to userspace */ a70e9f647f501e3 Jinjie Ruan 2025-06-24 216 kmap_assert_nomap(); a70e9f647f501e3 Jinjie Ruan 2025-06-24 217 lockdep_assert_irqs_disabled();
a70e9f647f501e3Jinjie Ruan 2025-06-24 @218lockdep_sys_exit();
Quoted 5 lines
What the heck has line 218 to do with that failure?
This is getting stupid. It seems there is yet another compiler aside of s390 gcc which fails to do dead code elimination but this time it's worse it also points to the wrong place ....
Sorry for the confusion, I give a try with riscv gcc 12.5.0 for the same kconfig, the result is below
include/asm-generic/preempt.h:54:(.noinstr.text+0x1a20): undefined reference to 'syscall_enter_audit'
This is FYI, I will further think of how to provide better error info, probably favor newer compiler more during the bot testing.
Quoted 5 lines
Thanks,
tglx
Thomas Gleixner
maintainerQuoted 21 lines · Philip Li
Quoted 20 lines · Thomas Gleixner
Quoted 4 lines
All errors (new ones prefixed by >>):
riscv64-linux-ld:
arch/riscv/kernel/traps.o: in function `__exit_to_user_mode_validate':Quoted 1 line
Quoted 1 line
include/linux/irq-entry-common.h:218: undefined reference to `syscall_enter_audit'Seriously?
Quoted 10 lines
vim +218
include/linux/irq-entry-common.ha70e9f647f501e3 Jinjie Ruan 2025-06-24 212 70fe25a3bc53a89 Thomas Gleixner 2025-10-27 213 static __always_inline void __exit_to_user_mode_validate(void) 70fe25a3bc53a89 Thomas Gleixner 2025-10-27 214 { a70e9f647f501e3 Jinjie Ruan 2025-06-24 215 /* Ensure that kernel state is sane for a return to userspace */ a70e9f647f501e3 Jinjie Ruan 2025-06-24 216 kmap_assert_nomap(); a70e9f647f501e3 Jinjie Ruan 2025-06-24 217 lockdep_assert_irqs_disabled();
a70e9f647f501e3Jinjie Ruan 2025-06-24 @218lockdep_sys_exit();What the heck has line 218 to do with that failure?
Quoted 8 lines
Quoted 3 lines
This is getting stupid. It seems there is yet another compiler aside of s390 gcc which fails to do dead code elimination but this time it's worse it also points to the wrong place ....
Sorry for the confusion, I give a try with riscv gcc 12.5.0 for the same kconfig, the result is below
include/asm-generic/preempt.h:54:(.noinstr.text+0x1a20): undefined reference to 'syscall_enter_audit'
which has nothing to do with the unresolved reference either. preempt.h definitely does not invoke syscall_enter_audit(). I love broken tools.
IIRC I saw something like this before with some broken S390 compiler failing to eliminate the call because it out of lined the condition inline which when inlined causes the dead code elimination to get rid of it. I'll grab that config tomorrow and look at the output.
Thomas Gleixner
maintainerPATCH 1/1 entry: Guard syscall_enter_audit() invocation with CONFIG_AUDITSYSCALL
A bunch of older cross compilers notably RISCV64 and S390 fail to eliminate the dead code when CONFIG_AUDITSYSCALL=n. The code in question is:
if (unlikely(audit_context())
syscall_enter_audit(regs);and in case of CONFIG_AUDITSYSCALL=n:
static inline struct audit_context *audit_context(void)
{
return NULL;
}which should make the compiler eliminate the syscall_enter_audit() call. But a RISV64 GCC12 cross compiler translates that into:
if (unlikely(audit_context()))
1c34: 00000097 auipc ra,0x0
1c38: 000080e7 jalr ra # 1c34 <.L785>
1c3c: c511 beqz a0,1c48 <.L787>
syscall_enter_audit(regs);
1c3e: 8526 mv a0,s1
1c40: 00000097 auipc ra,0x0
1c44: 000080e7 jalr ra # 1c40 <.L785+0xc>and then claims in the failing link:
include/asm-generic/preempt.h:54:(.noinstr.text+0x1a20):
undefined reference to 'syscall_enter_audit'
which is obviously hallucination.
Add an explicit IS_ENABLED(CONFIG_AUDITSYSCALL) check into the condition to cure this compiler madness.
--- include/linux/entry-common.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
include/linux/entry-common.h +8 -1
@@ -102,7 +102,14 @@ static __always_inline long syscall_tracif (unlikely (work &SYSCALL_WORK_SYSCALL_TRACEPOINT ))trace_syscall_enter (regs); -if (unlikely (audit_context ())) +/* +* The config check works around broken compilers which fail to +* eliminate the dead code in case of CONFIG_AUDITSYSCALL=n as they +* insist on creating a always false runtime condition based on +* audit_context() which returns NULL in that case. The explicit +* IS_ENABLED() check makes that madness go away. +*/ +if (IS_ENABLED (CONFIG_AUDITSYSCALL ) &&unlikely (audit_context ()))syscall_enter_audit (regs);return true;
[tip: core/urgent] entry: Guard syscall_enter_audit() invocation with CONFIG_AUDITSYSCALL
The following commit has been merged into the core/urgent branch of tip:
The following commit has been merged into the core/urgent branch of tip:
Commit-ID: 954f7a48fa2ae7310c67729fb556caf726783436 Gitweb: https://git.kernel.org/tip/954f7a48fa2ae7310c67729fb556caf726783436 Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 05 Sep 2026 10:43:57 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Mon, 07 Sep 2026 11:17:54 +02:00
entry: Guard syscall_enter_audit() invocation with CONFIG_AUDITSYSCALL
A bunch of older cross compilers notably RISCV64 and S390 fail to eliminate the dead code when CONFIG_AUDITSYSCALL=n. The code in question is:
if (unlikely(audit_context())
syscall_enter_audit(regs);and in case of CONFIG_AUDITSYSCALL=n:
static inline struct audit_context *audit_context(void)
{
return NULL;
}which should make the compiler eliminate the syscall_enter_audit() call. But a RISV64 GCC12 cross compiler translates that into:
if (unlikely(audit_context()))
1c34: 00000097 auipc ra,0x0
1c38: 000080e7 jalr ra # 1c34 <.L785>
1c3c: c511 beqz a0,1c48 <.L787>
syscall_enter_audit(regs);
1c3e: 8526 mv a0,s1
1c40: 00000097 auipc ra,0x0
1c44: 000080e7 jalr ra # 1c40 <.L785+0xc>and then claims in the failing link:
include/asm-generic/preempt.h:54:(.noinstr.text+0x1a20):
undefined reference to 'syscall_enter_audit'
which is obviously hallucination.
Add an explicit IS_ENABLED(CONFIG_AUDITSYSCALL) check into the condition to cure this compiler madness.
--- include/linux/entry-common.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
include/linux/entry-common.h +8 -1
@@ -102,7 +102,14 @@ static __always_inline long syscall_trace_enter(struct pt_regs *regs, unsigned lif (unlikely (work &SYSCALL_WORK_SYSCALL_TRACEPOINT ))trace_syscall_enter (regs); -if (unlikely (audit_context ())) +/* +* The config check works around broken compilers which fail to +* eliminate the dead code in case of CONFIG_AUDITSYSCALL=n as they +* insist on creating a always false runtime condition based on +* audit_context() which returns NULL in that case. The explicit +* IS_ENABLED() check makes that madness go away. +*/ +if (IS_ENABLED (CONFIG_AUDITSYSCALL ) &&unlikely (audit_context ()))syscall_enter_audit (regs);return true;