|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 1/3] xen/livepatch: simplify and unify logic in prepare_payload()
On Sun, Sep 22, 2024 at 11:19:01AM +0200, Andrew Cooper wrote:
> On 20/09/2024 11:36 am, Roger Pau Monne wrote:
> > diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
> > index d93a556bcda2..cea47ffe4c84 100644
> > --- a/xen/common/livepatch.c
> > +++ b/xen/common/livepatch.c
> > @@ -647,15 +647,37 @@ static inline int livepatch_check_expectations(const
> > struct payload *payload)
> > nhooks = __sec->sec->sh_size / sizeof(*hook);
> > \
> > } while (0)
> >
> > +static int fetch_buildid(const struct livepatch_elf_sec *sec,
> > + struct livepatch_build_id *id)
>
> Is this really fetch? I'd describe it as parse, more than fetch.
I can indeed change the naming. I've used fetch because it 'fetches'
the contents of livepatch_build_id.
> > +{
> > + const Elf_Note *n = sec->load_addr;
> > + int rc;
> > +
> > + ASSERT(sec);
>
> This needs to turn back into a runtime check. Now, if a livepatch is
> missing one of the sections, we'll dereference NULL below, rather than
> leaving no data in the struct livepatch_build_id.
Loading should never get here without those sections being present,
check_special_sections() called earlier will return error if any of
the sections is not present, hence the ASSERT() is fine IMO.
I could do `if ( !sec ) { ASSERT_UNREACHABLE(); return -ENOENT; }`,
but given the code in check_special_sections() that checks the section
presence just ahead it seemed unnecessary convoluted.
Thanks, Roger.
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |