On Wed, Apr 24, 2024 at 10:19:56AM +0200, Roger Pau Monne wrote:
> Livepatch payloads containing symbols that belong to init sections can only
> lead to page faults later on, as by the time the livepatch is loaded init
> sections have already been freed.
> 
> Refuse to resolve such symbols and return an error instead.
> 
> Note such resolutions are only relevant for symbols that point to undefined
> sections (SHN_UNDEF), as that implies the symbol is not in the current payload
> and hence must either be a Xen or a different livepatch payload symbol.
> 
> Do not allow to resolve symbols that point to __init_begin, as that address is
> also unmapped.  On the other hand, __init_end is not unmapped, and hence allow
> resolutions against it.
> 
> Since __init_begin can alias other symbols (like _erodata for example)
> allow the force flag to override the check and resolve the symbol anyway.

I've been thinking more about this, and it has further corner cases,
for example with this patch applied attempting to livepatch a function
that contains a rune like:

if ( system_state < SYS_STATE_active )
    call_init_function();

Will now fail as Xen will refuse to resolve the call_init_function
symbol.

I however don't have any better ideas about how to solve this.  Maybe
it's fine to require such patches to use the --force option, as
refusing to resolve init symbols adds a bit more safety to
livepatches.

Thanks, Roger.

Reply via email to