Re: [PATCH 01/14] x86/cfi: Wreck things...
From: Peter Zijlstra
Date: Sat Sep 28 2024 - 09:31:34 EST
On Fri, Sep 27, 2024 at 04:15:27PM -0700, Josh Poimboeuf wrote:
> On Fri, Sep 27, 2024 at 09:48:57PM +0200, Peter Zijlstra wrote:
> > vmlinux.o: warning: objtool: .export_symbol+0x3c9f0: data relocation to !ENDBR: entry_untrain_ret+0x0
> >
> > Which states that while these functions are exported and (directly)
> > callable, they cannot be called indirectly. There are two solutions:
>
> IIRC, exported symbols are by far the most common "need" for ENDBR. But
> presumably the vast majority of them aren't being indirect called.
>
> > - exclude the .export_symbol section from validation; effectively
> > saying that having linkable but not indirectly callable exports are
> > fine by default, or
>
> This is confusingly inconsistent IMO.
Yes. OTOH less indirectly callable functions is more better, no?
> > - make all of those use SYM_TYPED_FUNC_START to restore the
> > traditional (and expected, but less secure?) behaviour.
>
> Why not just make SYM_FUNC_START imply "typed"? That's consistent with
> what the compiler does anyway right?
It is indeed what the compiler does (unless __nocfi attribute is
employed), but it requires that there is a C declaration of the function
-- which is true for all exported functions but not necessary for all
SYM_FUNC_START() symbols per-se.
Also, it would make all ASM functions indirectly callable by default --
which I'm not sure is a good idea, I would much rather we keep this
explicit.
> Even better, require exported+indirect-called symbols to use
> EXPORT_SYMBOL_TYPED, otherwise they get sealed. I suppose we'd need to
> add some module-to-vmlinux ENDBR validation to make sure modules don't
> get broken by this.
So I like this idea. but yeah, this is going to be a bit tricky to
validate.
Anyway, I think I'll do an initial patch moving all the EXPORT'ed
symbols over to SYM_TYPED_FUNC_START() for now, and we can look at
adding extra EXPORT magic on top of all that later on.