While trying to build 6.14.7-rc1 with CONFIG_CPU_MITIGATIONS unset:
LD .tmp_vmlinux1 ld: arch/x86/net/bpf_jit_comp.o: in function `emit_indirect_jump': /tmp/linux-6.14.7/arch/x86/net/bpf_jit_comp.c:660:(.text+0x97e): undefined reference to `__x86_indirect_its_thunk_array' make[2]: *** [scripts/Makefile.vmlinux:77: vmlinux] Error 1 make[1]: *** [/tmp/linux-6.14.7/Makefile:1234: vmlinux] Error 2 make: *** [Makefile:251: __sub-make] Error 2
- applying 9f35e33144ae aka "x86/its: Fix build errors when CONFIG_MODULES=n" did not help
- mainline at 9f35e33144ae does not have this problem (same config)
Are we missing a commit in stable?
I temporarily threw "if (IS_ENABLED(CONFIG_MITIGATION_ITS))" around the problematic feature check and that made it work, but I get the feeling that cpu_feature_enabled(X86_FEATURE_INDIRECT_THUNK_ITS) is implemented differently than the other feature checks and/or is missing something.
thanks Holger
cc: peterz
On 2025-05-14 09:45, Holger Hoffstätte wrote:
While trying to build 6.14.7-rc1 with CONFIG_CPU_MITIGATIONS unset:
LD .tmp_vmlinux1 ld: arch/x86/net/bpf_jit_comp.o: in function `emit_indirect_jump': /tmp/linux-6.14.7/arch/x86/net/bpf_jit_comp.c:660:(.text+0x97e): undefined reference to `__x86_indirect_its_thunk_array' make[2]: *** [scripts/Makefile.vmlinux:77: vmlinux] Error 1 make[1]: *** [/tmp/linux-6.14.7/Makefile:1234: vmlinux] Error 2 make: *** [Makefile:251: __sub-make] Error 2
- applying 9f35e33144ae aka "x86/its: Fix build errors when CONFIG_MODULES=n"
did not help
- mainline at 9f35e33144ae does not have this problem (same config)
Are we missing a commit in stable?
It seems commit e52c1dc7455d ("x86/its: FineIBT-paranoid vs ITS") [1] is missing in the stable queue. It replaces the direct array reference in bpf_jit_comp.c:emit_indirect_jump() with a mostly-empty function stub when !CONFIG_MITIGATION_ITS, which is why mainline built and -stable does not.
Unfortunately it does not seem to apply on top of 6.14.7-rc1 at all. Any good suggestions?
thanks Holger
[1] https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commi...
On Wed, May 14, 2025 at 12:13:29PM +0200, Holger Hoffstätte wrote:
cc: peterz
On 2025-05-14 09:45, Holger Hoffstätte wrote:
While trying to build 6.14.7-rc1 with CONFIG_CPU_MITIGATIONS unset:
LD .tmp_vmlinux1 ld: arch/x86/net/bpf_jit_comp.o: in function `emit_indirect_jump': /tmp/linux-6.14.7/arch/x86/net/bpf_jit_comp.c:660:(.text+0x97e): undefined reference to `__x86_indirect_its_thunk_array' make[2]: *** [scripts/Makefile.vmlinux:77: vmlinux] Error 1 make[1]: *** [/tmp/linux-6.14.7/Makefile:1234: vmlinux] Error 2 make: *** [Makefile:251: __sub-make] Error 2
- applying 9f35e33144ae aka "x86/its: Fix build errors when CONFIG_MODULES=n"
did not help
- mainline at 9f35e33144ae does not have this problem (same config)
Are we missing a commit in stable?
It seems commit e52c1dc7455d ("x86/its: FineIBT-paranoid vs ITS") [1] is missing in the stable queue. It replaces the direct array reference in bpf_jit_comp.c:emit_indirect_jump() with a mostly-empty function stub when !CONFIG_MITIGATION_ITS, which is why mainline built and -stable does not.
Unfortunately it does not seem to apply on top of 6.14.7-rc1 at all. Any good suggestions?
thanks Holger
[1] https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commi...
Right, this is forever the problem with these embargoed things that side-step the normal development cycle and need to be backported to hell :/
Let me go update this stable.git thing.
/me twiddles thumbs for a bit, this is one fat tree it is..
Argh, I needed stable-rc.git
more thumb twiddling ...
simply picking the few hunks from that fineibt commit should do the trick I think.
/me stomps on it some ... voila! Not the prettiest thing, but definilty good enough I suppose. Builds now, must be perfect etc.. :-)
---
diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index 47948ebbb409..f2294784babc 100644 --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -6,6 +6,7 @@ #include <linux/stringify.h> #include <linux/objtool.h> #include <asm/asm.h> +#include <asm/bug.h>
#define ALT_FLAGS_SHIFT 16
@@ -128,10 +129,17 @@ static __always_inline int x86_call_depth_emit_accounting(u8 **pprog, extern void its_init_mod(struct module *mod); extern void its_fini_mod(struct module *mod); extern void its_free_mod(struct module *mod); +extern u8 *its_static_thunk(int reg); #else /* CONFIG_MITIGATION_ITS */ static inline void its_init_mod(struct module *mod) { } static inline void its_fini_mod(struct module *mod) { } static inline void its_free_mod(struct module *mod) { } +static inline u8 *its_static_thunk(int reg) +{ + WARN_ONCE(1, "ITS not compiled in"); + + return NULL; +} #endif
#if defined(CONFIG_MITIGATION_RETHUNK) && defined(CONFIG_OBJTOOL) diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 7a10e3ed5d0b..48fd04e90114 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -240,6 +272,13 @@ static void *its_allocate_thunk(int reg) return its_init_thunk(thunk, reg); }
+u8 *its_static_thunk(int reg) +{ + u8 *thunk = __x86_indirect_its_thunk_array[reg]; + + return thunk; +} + #endif
/* diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index a5b65c09910b..a31e58c6d89e 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -663,7 +663,7 @@ static void emit_indirect_jump(u8 **pprog, int reg, u8 *ip)
if (cpu_feature_enabled(X86_FEATURE_INDIRECT_THUNK_ITS)) { OPTIMIZER_HIDE_VAR(reg); - emit_jump(&prog, &__x86_indirect_its_thunk_array[reg], ip); + emit_jump(&prog, its_static_thunk(reg), ip); } else if (cpu_feature_enabled(X86_FEATURE_RETPOLINE_LFENCE)) { EMIT_LFENCE(); EMIT2(0xFF, 0xE0 + reg);
On 2025-05-14 13:39, Peter Zijlstra wrote:
On Wed, May 14, 2025 at 12:13:29PM +0200, Holger Hoffstätte wrote:
cc: peterz
On 2025-05-14 09:45, Holger Hoffstätte wrote:
While trying to build 6.14.7-rc1 with CONFIG_CPU_MITIGATIONS unset:
LD .tmp_vmlinux1 ld: arch/x86/net/bpf_jit_comp.o: in function `emit_indirect_jump': /tmp/linux-6.14.7/arch/x86/net/bpf_jit_comp.c:660:(.text+0x97e): undefined reference to `__x86_indirect_its_thunk_array' make[2]: *** [scripts/Makefile.vmlinux:77: vmlinux] Error 1 make[1]: *** [/tmp/linux-6.14.7/Makefile:1234: vmlinux] Error 2 make: *** [Makefile:251: __sub-make] Error 2
- applying 9f35e33144ae aka "x86/its: Fix build errors when CONFIG_MODULES=n"
did not help
- mainline at 9f35e33144ae does not have this problem (same config)
Are we missing a commit in stable?
It seems commit e52c1dc7455d ("x86/its: FineIBT-paranoid vs ITS") [1] is missing in the stable queue. It replaces the direct array reference in bpf_jit_comp.c:emit_indirect_jump() with a mostly-empty function stub when !CONFIG_MITIGATION_ITS, which is why mainline built and -stable does not.
Unfortunately it does not seem to apply on top of 6.14.7-rc1 at all. Any good suggestions?
thanks Holger
[1] https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commi...
Right, this is forever the problem with these embargoed things that side-step the normal development cycle and need to be backported to hell :/
Let me go update this stable.git thing.
/me twiddles thumbs for a bit, this is one fat tree it is..
Argh, I needed stable-rc.git
more thumb twiddling ...
simply picking the few hunks from that fineibt commit should do the trick I think.
/me stomps on it some ... voila! Not the prettiest thing, but definilty good enough I suppose. Builds now, must be perfect etc.. :-)
diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index 47948ebbb409..f2294784babc 100644 --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -6,6 +6,7 @@ #include <linux/stringify.h> #include <linux/objtool.h> #include <asm/asm.h> +#include <asm/bug.h> #define ALT_FLAGS_SHIFT 16 @@ -128,10 +129,17 @@ static __always_inline int x86_call_depth_emit_accounting(u8 **pprog, extern void its_init_mod(struct module *mod); extern void its_fini_mod(struct module *mod); extern void its_free_mod(struct module *mod); +extern u8 *its_static_thunk(int reg); #else /* CONFIG_MITIGATION_ITS */ static inline void its_init_mod(struct module *mod) { } static inline void its_fini_mod(struct module *mod) { } static inline void its_free_mod(struct module *mod) { } +static inline u8 *its_static_thunk(int reg) +{
- WARN_ONCE(1, "ITS not compiled in");
- return NULL;
+} #endif #if defined(CONFIG_MITIGATION_RETHUNK) && defined(CONFIG_OBJTOOL) diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 7a10e3ed5d0b..48fd04e90114 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -240,6 +272,13 @@ static void *its_allocate_thunk(int reg) return its_init_thunk(thunk, reg); } +u8 *its_static_thunk(int reg) +{
- u8 *thunk = __x86_indirect_its_thunk_array[reg];
- return thunk;
+}
- #endif
/* diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index a5b65c09910b..a31e58c6d89e 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -663,7 +663,7 @@ static void emit_indirect_jump(u8 **pprog, int reg, u8 *ip) if (cpu_feature_enabled(X86_FEATURE_INDIRECT_THUNK_ITS)) { OPTIMIZER_HIDE_VAR(reg);
emit_jump(&prog, &__x86_indirect_its_thunk_array[reg], ip);
} else if (cpu_feature_enabled(X86_FEATURE_RETPOLINE_LFENCE)) { EMIT_LFENCE(); EMIT2(0xFF, 0xE0 + reg);emit_jump(&prog, its_static_thunk(reg), ip);
Can confirm that it now links, as expected. Just in case:
Tested-by: Holger Hoffstätte holger@applied-asynchrony.com
Thank you!
cheers Holger
On Wed, May 14, 2025 at 02:11:26PM +0200, Holger Hoffstätte wrote:
On 2025-05-14 13:39, Peter Zijlstra wrote:
On Wed, May 14, 2025 at 12:13:29PM +0200, Holger Hoffstätte wrote:
cc: peterz
On 2025-05-14 09:45, Holger Hoffstätte wrote:
While trying to build 6.14.7-rc1 with CONFIG_CPU_MITIGATIONS unset:
LD .tmp_vmlinux1 ld: arch/x86/net/bpf_jit_comp.o: in function `emit_indirect_jump': /tmp/linux-6.14.7/arch/x86/net/bpf_jit_comp.c:660:(.text+0x97e): undefined reference to `__x86_indirect_its_thunk_array' make[2]: *** [scripts/Makefile.vmlinux:77: vmlinux] Error 1 make[1]: *** [/tmp/linux-6.14.7/Makefile:1234: vmlinux] Error 2 make: *** [Makefile:251: __sub-make] Error 2
- applying 9f35e33144ae aka "x86/its: Fix build errors when CONFIG_MODULES=n"
did not help
- mainline at 9f35e33144ae does not have this problem (same config)
Are we missing a commit in stable?
It seems commit e52c1dc7455d ("x86/its: FineIBT-paranoid vs ITS") [1] is missing in the stable queue. It replaces the direct array reference in bpf_jit_comp.c:emit_indirect_jump() with a mostly-empty function stub when !CONFIG_MITIGATION_ITS, which is why mainline built and -stable does not.
Unfortunately it does not seem to apply on top of 6.14.7-rc1 at all. Any good suggestions?
thanks Holger
[1] https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commi...
Right, this is forever the problem with these embargoed things that side-step the normal development cycle and need to be backported to hell :/
Let me go update this stable.git thing.
/me twiddles thumbs for a bit, this is one fat tree it is..
Argh, I needed stable-rc.git
more thumb twiddling ...
simply picking the few hunks from that fineibt commit should do the trick I think.
/me stomps on it some ... voila! Not the prettiest thing, but definilty good enough I suppose. Builds now, must be perfect etc.. :-)
diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index 47948ebbb409..f2294784babc 100644 --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -6,6 +6,7 @@ #include <linux/stringify.h> #include <linux/objtool.h> #include <asm/asm.h> +#include <asm/bug.h> #define ALT_FLAGS_SHIFT 16 @@ -128,10 +129,17 @@ static __always_inline int x86_call_depth_emit_accounting(u8 **pprog, extern void its_init_mod(struct module *mod); extern void its_fini_mod(struct module *mod); extern void its_free_mod(struct module *mod); +extern u8 *its_static_thunk(int reg); #else /* CONFIG_MITIGATION_ITS */ static inline void its_init_mod(struct module *mod) { } static inline void its_fini_mod(struct module *mod) { } static inline void its_free_mod(struct module *mod) { } +static inline u8 *its_static_thunk(int reg) +{
- WARN_ONCE(1, "ITS not compiled in");
- return NULL;
+} #endif #if defined(CONFIG_MITIGATION_RETHUNK) && defined(CONFIG_OBJTOOL) diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 7a10e3ed5d0b..48fd04e90114 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -240,6 +272,13 @@ static void *its_allocate_thunk(int reg) return its_init_thunk(thunk, reg); } +u8 *its_static_thunk(int reg) +{
- u8 *thunk = __x86_indirect_its_thunk_array[reg];
- return thunk;
+}
- #endif /*
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index a5b65c09910b..a31e58c6d89e 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -663,7 +663,7 @@ static void emit_indirect_jump(u8 **pprog, int reg, u8 *ip) if (cpu_feature_enabled(X86_FEATURE_INDIRECT_THUNK_ITS)) { OPTIMIZER_HIDE_VAR(reg);
emit_jump(&prog, &__x86_indirect_its_thunk_array[reg], ip);
} else if (cpu_feature_enabled(X86_FEATURE_RETPOLINE_LFENCE)) { EMIT_LFENCE(); EMIT2(0xFF, 0xE0 + reg);emit_jump(&prog, its_static_thunk(reg), ip);
Can confirm that it now links, as expected. Just in case:
Tested-by: Holger Hoffstätte holger@applied-asynchrony.com
Wonderful, thanks for testing!
greg k-h
On Wed, May 14, 2025 at 01:39:52PM +0200, Peter Zijlstra wrote:
On Wed, May 14, 2025 at 12:13:29PM +0200, Holger Hoffstätte wrote:
cc: peterz
On 2025-05-14 09:45, Holger Hoffstätte wrote:
While trying to build 6.14.7-rc1 with CONFIG_CPU_MITIGATIONS unset:
LD .tmp_vmlinux1 ld: arch/x86/net/bpf_jit_comp.o: in function `emit_indirect_jump': /tmp/linux-6.14.7/arch/x86/net/bpf_jit_comp.c:660:(.text+0x97e): undefined reference to `__x86_indirect_its_thunk_array' make[2]: *** [scripts/Makefile.vmlinux:77: vmlinux] Error 1 make[1]: *** [/tmp/linux-6.14.7/Makefile:1234: vmlinux] Error 2 make: *** [Makefile:251: __sub-make] Error 2
- applying 9f35e33144ae aka "x86/its: Fix build errors when CONFIG_MODULES=n"
did not help
- mainline at 9f35e33144ae does not have this problem (same config)
Are we missing a commit in stable?
It seems commit e52c1dc7455d ("x86/its: FineIBT-paranoid vs ITS") [1] is missing in the stable queue. It replaces the direct array reference in bpf_jit_comp.c:emit_indirect_jump() with a mostly-empty function stub when !CONFIG_MITIGATION_ITS, which is why mainline built and -stable does not.
Unfortunately it does not seem to apply on top of 6.14.7-rc1 at all. Any good suggestions?
thanks Holger
[1] https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commi...
Right, this is forever the problem with these embargoed things that side-step the normal development cycle and need to be backported to hell :/
Let me go update this stable.git thing.
/me twiddles thumbs for a bit, this is one fat tree it is..
Argh, I needed stable-rc.git
more thumb twiddling ...
simply picking the few hunks from that fineibt commit should do the trick I think.
/me stomps on it some ... voila! Not the prettiest thing, but definilty good enough I suppose. Builds now, must be perfect etc.. :-)
diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index 47948ebbb409..f2294784babc 100644 --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -6,6 +6,7 @@ #include <linux/stringify.h> #include <linux/objtool.h> #include <asm/asm.h> +#include <asm/bug.h> #define ALT_FLAGS_SHIFT 16 @@ -128,10 +129,17 @@ static __always_inline int x86_call_depth_emit_accounting(u8 **pprog, extern void its_init_mod(struct module *mod); extern void its_fini_mod(struct module *mod); extern void its_free_mod(struct module *mod); +extern u8 *its_static_thunk(int reg); #else /* CONFIG_MITIGATION_ITS */ static inline void its_init_mod(struct module *mod) { } static inline void its_fini_mod(struct module *mod) { } static inline void its_free_mod(struct module *mod) { } +static inline u8 *its_static_thunk(int reg) +{
- WARN_ONCE(1, "ITS not compiled in");
- return NULL;
+} #endif #if defined(CONFIG_MITIGATION_RETHUNK) && defined(CONFIG_OBJTOOL) diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 7a10e3ed5d0b..48fd04e90114 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -240,6 +272,13 @@ static void *its_allocate_thunk(int reg) return its_init_thunk(thunk, reg); } +u8 *its_static_thunk(int reg) +{
- u8 *thunk = __x86_indirect_its_thunk_array[reg];
- return thunk;
+}
#endif /* diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index a5b65c09910b..a31e58c6d89e 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -663,7 +663,7 @@ static void emit_indirect_jump(u8 **pprog, int reg, u8 *ip) if (cpu_feature_enabled(X86_FEATURE_INDIRECT_THUNK_ITS)) { OPTIMIZER_HIDE_VAR(reg);
emit_jump(&prog, &__x86_indirect_its_thunk_array[reg], ip);
} else if (cpu_feature_enabled(X86_FEATURE_RETPOLINE_LFENCE)) { EMIT_LFENCE(); EMIT2(0xFF, 0xE0 + reg);emit_jump(&prog, its_static_thunk(reg), ip);
Thanks, I've taken this version now. I'm at a conference now and can't do build testing, so I'll push out a -rc2 and see how that goes...
greg k-h
linux-stable-mirror@lists.linaro.org