objtool: Fixes
Subsystems (6)
Peter Zijlstra
maintainercover objtool: Fixes
Fix various objtool whinges:
lib/strnlen_user.o: warning: objtool: strnlen_user()+0x33: call to do_strnlen_user() with UACCESS enabled lib/strncpy_from_user.o: warning: objtool: strncpy_from_user()+0x33: call to do_strncpy_from_user() with UACCESS enabled
vmlinux.o: warning: objtool: pvh_start_xen()+0x0: unreachable vmlinux.o: warning: objtool: start_secondary()+0x10e: unreachable vmlinux.o: warning: objtool: asm_exc_xen_unknown_trap()+0x16: unreachable instruction
Peter Zijlstra
maintainerPATCH 1/4 lib/strn*,objtool: Enforce user_access_begin() rules
Apparently GCC can fail to inline a 'static inline' single caller function:
lib/strnlen_user.o: warning: objtool: strnlen_user()+0x33: call to do_strnlen_user() with UACCESS enabled lib/strncpy_from_user.o: warning: objtool: strncpy_from_user()+0x33: call to do_strncpy_from_user() with UACCESS enabled
--- lib/strncpy_from_user.c | 2 +- lib/strnlen_user.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
lib/strncpy_from_user.c +1 -1
@@ -25,7 +25,7 @@* hit it), 'max' is the address space maximum (and we return * -EFAULT if we hit it). */ -static inline long do_strncpy_from_user (char *dst,const char __user *src, +static __always_inline long do_strncpy_from_user (char *dst,const char __user *src,unsigned long count,unsigned long max) {const struct word_at_a_time constants =WORD_AT_A_TIME_CONSTANTS ;
lib/strnlen_user.c +1 -1
@@ -20,7 +20,7 @@* if it fits in a aligned 'long'. The caller needs to check * the return value against "> max". */ -static inline long do_strnlen_user (const char __user *src,unsigned long count,unsigned long max) +static __always_inline long do_strnlen_user (const char __user *src,unsigned long count,unsigned long max) {const struct word_at_a_time constants =WORD_AT_A_TIME_CONSTANTS ;unsigned long align, res =0 ;
Re: [PATCH 1/4] lib/strn*,objtool: Enforce user_access_begin() rules
Quoted 8 lines · Peter Zijlstra
Apparently GCC can fail to inline a 'static inline' single caller function:
lib/strnlen_user.o: warning: objtool: strnlen_user()+0x33: call todo_strnlen_user()with UACCESS enabledlib/strncpy_from_user.o: warning: objtool: strncpy_from_user()+0x33: call todo_strncpy_from_user()with UACCESS enabledReported-by Thomas Gleixner <[email protected]>Signed-off-by Peter Zijlstra (Intel) <[email protected]>
Presumably because of
ifdef CONFIG_DEBUG_SECTION_MISMATCH KBUILD_CFLAGS += -fno-inline-functions-called-once endif
which I've been wanting to remove since its only true purpose seems to be creating countless __always_inline patches...
Signature · 1 line
Josh
[tip: x86/urgent] lib/strn*,objtool: Enforce user_access_begin() rules
In reply to Peter ZijlstraThe following commit has been merged into the x86/urgent branch of tip:
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 226d44acf6dfe71c9df5804b82364e93cf908b53 Gitweb: https://git.kernel.org/tip/226d44acf6dfe71c9df5804b82364e93cf908b53 Author: Peter Zijlstra <[email protected]> AuthorDate: Fri, 08 Apr 2022 11:45:53 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Tue, 19 Apr 2022 21:58:47 +02:00
lib/strn*,objtool: Enforce user_access_begin() rules
Apparently GCC can fail to inline a 'static inline' single caller function:
lib/strnlen_user.o: warning: objtool: strnlen_user()+0x33: call to do_strnlen_user() with UACCESS enabled lib/strncpy_from_user.o: warning: objtool: strncpy_from_user()+0x33: call to do_strncpy_from_user() with UACCESS enabled
--- lib/strncpy_from_user.c | 2 +- lib/strnlen_user.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
lib/strncpy_from_user.c +1 -1
@@ -25,7 +25,7 @@* hit it), 'max' is the address space maximum (and we return * -EFAULT if we hit it). */ -static inline long do_strncpy_from_user (char *dst,const char __user *src, +static __always_inline long do_strncpy_from_user (char *dst,const char __user *src,unsigned long count,unsigned long max) {const struct word_at_a_time constants =WORD_AT_A_TIME_CONSTANTS ;
lib/strnlen_user.c +1 -1
@@ -20,7 +20,7 @@* if it fits in a aligned 'long'. The caller needs to check * the return value against "> max". */ -static inline long do_strnlen_user (const char __user *src,unsigned long count,unsigned long max) +static __always_inline long do_strnlen_user (const char __user *src,unsigned long count,unsigned long max) {const struct word_at_a_time constants =WORD_AT_A_TIME_CONSTANTS ;unsigned long align, res =0 ;
Peter Zijlstra
maintainerPATCH 2/4 x86,xen,objtool: Add UNWIND hint
In reply to Peter ZijlstraSYM_CODE_START*() doesn't get auto-validated and needs an UNWIND hint to get checked, add one.
vmlinux.o: warning: objtool: pvh_start_xen()+0x0: unreachable
--- arch/x86/platform/pvh/head.S | 1 + 1 file changed, 1 insertion(+)
arch/x86/platform/pvh/head.S +1 -0
@@ -50,6 +50,7 @@ #define PVH_DS_SEL (PVH_GDT_ENTRY_DS * 8) SYM_CODE_START_LOCAL(pvh_start_xen) + UNWIND_HINT_EMPTY cld lgdt (_pa(gdt))
[tip: x86/urgent] x86,xen,objtool: Add UNWIND hint
The following commit has been merged into the x86/urgent branch of tip:
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 2730d3c14a85617c177337f2e2af2108bf82c4ca Gitweb: https://git.kernel.org/tip/2730d3c14a85617c177337f2e2af2108bf82c4ca Author: Peter Zijlstra <[email protected]> AuthorDate: Fri, 08 Apr 2022 11:45:54 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Tue, 19 Apr 2022 21:58:47 +02:00
x86,xen,objtool: Add UNWIND hint
SYM_CODE_START*() doesn't get auto-validated and needs an UNWIND hint to get checked, add one.
vmlinux.o: warning: objtool: pvh_start_xen()+0x0: unreachable
--- arch/x86/platform/pvh/head.S | 1 + 1 file changed, 1 insertion(+)
arch/x86/platform/pvh/head.S +1 -0
@@ -50,6 +50,7 @@ #define PVH_DS_SEL (PVH_GDT_ENTRY_DS * 8) SYM_CODE_START_LOCAL(pvh_start_xen) + UNWIND_HINT_EMPTY cld lgdt (_pa(gdt))
Peter Zijlstra
maintainerPATCH 3/4 x86,objtool: Mark cpu_startup_entry() __noreturn
In reply to Peter ZijlstraGCC-8 isn't clever enough to figure out that cpu_start_entry() is a noreturn while objtool is. This results in code after the call in start_secondary(). Give GCC a hand so that they all agree on things.
vmlinux.o: warning: objtool: start_secondary()+0x10e: unreachable
--- include/linux/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/cpu.h +1 -1
@@ -167,7 +167,7 @@ static inline int suspend_disable_secondstatic inline void suspend_enable_secondary_cpus (void ) { }#endif /* !CONFIG_PM_SLEEP_SMP */ -void cpu_startup_entry (enum cpuhp_state state); +void __noreturn cpu_startup_entry (enum cpuhp_state state);void cpu_idle_poll_ctrl (bool enable);
Re: [PATCH 3/4] x86,objtool: Mark cpu_startup_entry() __noreturn
Quoted 15 lines · Peter Zijlstra
GCC-8 isn't clever enough to figure out that
cpu_start_entry()is a noreturn while objtool is. This results in code after the call instart_secondary(). Give GCC a hand so that they all agree on things.vmlinux.o: warning: objtool: start_secondary()+0x10e: unreachable
Reported-by Rick Edgecombe <[email protected]>Signed-off-by Peter Zijlstra (Intel) <[email protected]>--- include/linux/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/cpu.h static inline int suspend_disable_second · line 172
Quoted 7 lines
include/linux/cpu.h +1
-1@@ -167,7 +167,7 @@ static inline int suspend_disable_secondstatic inline void suspend_enable_secondary_cpus (void ) { }#endif /* !CONFIG_PM_SLEEP_SMP */ -void cpu_startup_entry (enum cpuhp_state state); +void __noreturn cpu_startup_entry (enum cpuhp_state state);void cpu_idle_poll_ctrl (bool enable);
I just ran into this:
init/main.o: warning: objtool: rest_init() falls through to next function kernel_init()
so we need this as well:
tools/objtool/check.c +1 -0
@@ -184,6 +184,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"do_group_exit" ,"stop_this_cpu" ,"__invalid_creds" , + "cpu_startup_entry", };if (!func)
Re: [PATCH 3/4] x86,objtool: Mark cpu_startup_entry() __noreturn
In reply to Peter ZijlstraQuoted 15 lines · Peter Zijlstra
GCC-8 isn't clever enough to figure out that
cpu_start_entry()is a noreturn while objtool is. This results in code after the call instart_secondary(). Give GCC a hand so that they all agree on things.vmlinux.o: warning: objtool: start_secondary()+0x10e: unreachable
Reported-by Rick Edgecombe <[email protected]>Signed-off-by Peter Zijlstra (Intel) <[email protected]>--- include/linux/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/cpu.h static inline int suspend_disable_second · line 172
Quoted 7 lines
include/linux/cpu.h +1
-1@@ -167,7 +167,7 @@ static inline int suspend_disable_secondstatic inline void suspend_enable_secondary_cpus (void ) { }#endif /* !CONFIG_PM_SLEEP_SMP */ -void cpu_startup_entry (enum cpuhp_state state); +void __noreturn cpu_startup_entry (enum cpuhp_state state);void cpu_idle_poll_ctrl (bool enable);
Also needs added to the objtool noreturn list.
Signature · 1 line
Josh
[tip: x86/urgent] x86,objtool: Mark cpu_startup_entry() __noreturn
In reply to Peter ZijlstraThe following commit has been merged into the x86/urgent branch of tip:
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: d4e5268a08b211b536fed29beb24271ecd85187e Gitweb: https://git.kernel.org/tip/d4e5268a08b211b536fed29beb24271ecd85187e Author: Peter Zijlstra <[email protected]> AuthorDate: Fri, 08 Apr 2022 11:45:55 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Tue, 19 Apr 2022 21:58:48 +02:00
x86,objtool: Mark cpu_startup_entry() __noreturn
GCC-8 isn't clever enough to figure out that cpu_start_entry() is a noreturn while objtool is. This results in code after the call in start_secondary(). Give GCC a hand so that they all agree on things.
vmlinux.o: warning: objtool: start_secondary()+0x10e: unreachable
--- include/linux/cpu.h | 2 +- tools/objtool/check.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
include/linux/cpu.h +1 -1
@@ -167,7 +167,7 @@ static inline int suspend_disable_secondary_cpus(void) { return 0; }static inline void suspend_enable_secondary_cpus (void ) { }#endif /* !CONFIG_PM_SLEEP_SMP */ -void cpu_startup_entry (enum cpuhp_state state); +void __noreturn cpu_startup_entry (enum cpuhp_state state);void cpu_idle_poll_ctrl (bool enable);
tools/objtool/check.c +1 -0
@@ -184,6 +184,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"do_group_exit" ,"stop_this_cpu" ,"__invalid_creds" , + "cpu_startup_entry", };if (!func)
Peter Zijlstra
maintainerPATCH 4/4 x86,objtool: Explicitly mark idtentry_body()s tail REACHABLE
In reply to Peter ZijlstraObjtool can figure out that some \cfunc()s are noreturn and then complains about certain instances having unreachable tails:
vmlinux.o: warning: objtool: asm_exc_xen_unknown_trap()+0x16: unreachable instruction
--- arch/x86/entry/entry_64.S | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/entry/entry_64.S +3 -0
@@ -337,6 +337,9 @@ SYM_CODE_END(ret_from_fork) call \cfunc + /* For some configurations \cfunc ends up being a noreturn. */ + REACHABLE + jmp error_return .endm
[tip: x86/urgent] x86,objtool: Explicitly mark idtentry_body()s tail REACHABLE
The following commit has been merged into the x86/urgent branch of tip:
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: d66e9d50ea5cd76b2c4875c758efad665283d7ad Gitweb: https://git.kernel.org/tip/d66e9d50ea5cd76b2c4875c758efad665283d7ad Author: Peter Zijlstra <[email protected]> AuthorDate: Fri, 08 Apr 2022 11:45:56 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Tue, 19 Apr 2022 21:58:48 +02:00
x86,objtool: Explicitly mark idtentry_body()s tail REACHABLE
Objtool can figure out that some \cfunc()s are noreturn and then complains about certain instances having unreachable tails:
vmlinux.o: warning: objtool: asm_exc_xen_unknown_trap()+0x16: unreachable instruction
--- arch/x86/entry/entry_64.S | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/entry/entry_64.S +3 -0
@@ -337,6 +337,9 @@ SYM_CODE_END(ret_from_fork) call \cfunc + /* For some configurations \cfunc ends up being a noreturn. */ + REACHABLE + jmp error_return .endm
Quoted 8 lines · Peter Zijlstra
Fix various objtool whinges:
lib/strnlen_user.o: warning: objtool: strnlen_user()+0x33: call todo_strnlen_user()with UACCESS enabledlib/strncpy_from_user.o: warning: objtool: strncpy_from_user()+0x33: call todo_strncpy_from_user()with UACCESS enabledvmlinux.o: warning: objtool: pvh_start_xen()+0x0: unreachable vmlinux.o: warning: objtool: start_secondary()+0x10e: unreachable vmlinux.o: warning: objtool: asm_exc_xen_unknown_trap()+0x16: unreachable instruction
Signature · 1 line
Josh