Re: [PATCH 10/18] objtool: Extricate ibt from stack validation

From: Josh Poimboeuf
Date: Thu Apr 14 2022 - 15:08:02 EST


On Thu, Apr 14, 2022 at 09:01:56PM +0200, Peter Zijlstra wrote:
> > diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
> > index ecb2049c1273..b7dfd60243b7 100644
> > --- a/arch/x86/lib/putuser.S
> > +++ b/arch/x86/lib/putuser.S
> > @@ -48,6 +48,7 @@ SYM_FUNC_START(__put_user_1)
> > cmp %_ASM_BX,%_ASM_CX
> > jae .Lbad_put_user
> > SYM_INNER_LABEL(__put_user_nocheck_1, SYM_L_GLOBAL)
> > + ENDBR
> > ASM_STAC
> > 1: movb %al,(%_ASM_CX)
> > xor %ecx,%ecx
> > @@ -62,6 +63,7 @@ SYM_FUNC_START(__put_user_2)
> > cmp %_ASM_BX,%_ASM_CX
> > jae .Lbad_put_user
> > SYM_INNER_LABEL(__put_user_nocheck_2, SYM_L_GLOBAL)
> > + ENDBR
> > ASM_STAC
> > 2: movw %ax,(%_ASM_CX)
> > xor %ecx,%ecx
> > @@ -76,6 +78,7 @@ SYM_FUNC_START(__put_user_4)
> > cmp %_ASM_BX,%_ASM_CX
> > jae .Lbad_put_user
> > SYM_INNER_LABEL(__put_user_nocheck_4, SYM_L_GLOBAL)
> > + ENDBR
> > ASM_STAC
> > 3: movl %eax,(%_ASM_CX)
> > xor %ecx,%ecx
> > @@ -90,6 +93,7 @@ SYM_FUNC_START(__put_user_8)
> > cmp %_ASM_BX,%_ASM_CX
> > jae .Lbad_put_user
> > SYM_INNER_LABEL(__put_user_nocheck_8, SYM_L_GLOBAL)
> > + ENDBR
> > ASM_STAC
> > 4: mov %_ASM_AX,(%_ASM_CX)
> > #ifdef CONFIG_X86_32
>
> Hmm, how did those go missing?

Because the current code only warns about references from .data/.rodata.
This patch changes that.

> > diff --git a/arch/x86/lib/retpoline.S b/arch/x86/lib/retpoline.S
> > index 5f87bab4fb8d..b2b2366885a2 100644
> > --- a/arch/x86/lib/retpoline.S
> > +++ b/arch/x86/lib/retpoline.S
> > @@ -31,6 +31,7 @@
> > .align RETPOLINE_THUNK_SIZE
> > SYM_INNER_LABEL(__x86_indirect_thunk_\reg, SYM_L_GLOBAL)
> > UNWIND_HINT_EMPTY
> > + ANNOTATE_NOENDBR
> >
> > ALTERNATIVE_2 __stringify(ANNOTATE_RETPOLINE_SAFE; jmp *%\reg), \
> > __stringify(RETPOLINE \reg), X86_FEATURE_RETPOLINE, \
> > @@ -55,7 +56,6 @@ SYM_INNER_LABEL(__x86_indirect_thunk_\reg, SYM_L_GLOBAL)
> >
> > .align RETPOLINE_THUNK_SIZE
> > SYM_CODE_START(__x86_indirect_thunk_array)
> > - ANNOTATE_NOENDBR // apply_retpolines
> >
> > #define GEN(reg) THUNK reg
> > #include <asm/GEN-for-each-reg.h>
>
> Hmm, where does that come from? Do you have commit be8a096521ca
> ("x86,bpf: Avoid IBT objtool warning")?

Same answer as above, this patch now warns about exported symbols with
missing ENDBR.

--
Josh