From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: xen-devel@lists.xenproject.org,
Ross Lagerwall <ross.lagerwall@citrix.com>
Subject: Re: [PATCH 2/3] xen/livepatch: do Xen build-id check earlier
Date: Mon, 23 Sep 2024 18:02:38 +0200 [thread overview]
Message-ID: <ZvGRHjWVQvi1Yf2I@macbook.local> (raw)
In-Reply-To: <9ca4d235-5e6a-4ee0-9cc4-721b761572d3@citrix.com>
On Mon, Sep 23, 2024 at 12:04:30PM +0100, Andrew Cooper wrote:
> On 20/09/2024 10:36 am, Roger Pau Monne wrote:
> > The check against the expected Xen build ID should be done ahead of attempting
> > to apply the alternatives contained in the livepatch.
> >
> > If the CPUID in the alternatives patching data is out of the scope of the
> > running Xen featureset the BUG() in _apply_alternatives() will trigger thus
> > bringing the system down. Note the layout of struct alt_instr could also
> > change between versions. It's also possible for struct exception_table_entry
> > to have changed format, hence possibly leading to other errors.
> >
> > Move the Xen build ID check to be done ahead of any processing of the livepatch
> > payload sections.
> >
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > ---
> > xen/common/livepatch.c | 9 +++++----
> > 1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
> > index cea47ffe4c84..3e4fce036a1c 100644
> > --- a/xen/common/livepatch.c
> > +++ b/xen/common/livepatch.c
> > @@ -767,6 +767,11 @@ static int prepare_payload(struct payload *payload,
> > if ( rc )
> > return rc;
> >
> > + /* Perform the Xen build-id check ahead of doing any more processing. */
> > + rc = xen_build_id_dep(payload);
> > + if ( rc )
> > + return rc;
> > +
>
> While a step in the right direction, I think this needs to be moved far
> earlier. Even here, it's behind the processing of the livepatch func
> state, which is something that can also change like alt_instr.
>
> The buildid checks need to be as early as possible. Looking through the
> logic (which doesn't have great names/splits), I'd say the buildid
> checks want to be between livepatch_elf_load() (which parses the
> structure of the ELF), and move_payload() (which starts copying it into
> place).
>
> That would involve moving check_special_sections() too, but I think it's
> the right thing to do.
My plan would be to move check_special_sections() ahead and expand its
logic to also check that the expected buildid matches the running
hypervisor one.
Thanks, Roger.
next prev parent reply other threads:[~2024-09-23 16:02 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-20 9:36 [PATCH 0/3] xen/livepatch: improvements to loading Roger Pau Monne
2024-09-20 9:36 ` [PATCH 1/3] xen/livepatch: simplify and unify logic in prepare_payload() Roger Pau Monne
2024-09-22 9:19 ` Andrew Cooper
2024-09-23 7:46 ` Roger Pau Monné
2024-09-23 9:43 ` Andrew Cooper
2024-09-23 11:00 ` Jan Beulich
2024-09-23 11:01 ` Jan Beulich
2024-09-23 13:10 ` Roger Pau Monné
2024-09-20 9:36 ` [PATCH 2/3] xen/livepatch: do Xen build-id check earlier Roger Pau Monne
2024-09-23 11:04 ` Jan Beulich
2024-09-23 11:04 ` Andrew Cooper
2024-09-23 11:55 ` Andrew Cooper
2024-09-23 16:02 ` Roger Pau Monné [this message]
2024-09-20 9:36 ` [PATCH 2/3] xen/livepatch: do " Roger Pau Monne
2024-09-20 9:56 ` Roger Pau Monné
2024-09-20 9:36 ` [PATCH 3/3] x86/alternatives: relax apply BUGs during runtime Roger Pau Monne
2024-09-23 11:12 ` Jan Beulich
2024-09-23 11:17 ` Andrew Cooper
2024-09-23 13:06 ` Roger Pau Monné
2024-09-23 13:12 ` Andrew Cooper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZvGRHjWVQvi1Yf2I@macbook.local \
--to=roger.pau@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=ross.lagerwall@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.