All of lore.kernel.org
 help / color / mirror / Atom feed
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 v2 2/2] livepatch: refuse to resolve symbols that belong to init sections
Date: Fri, 19 Apr 2024 12:48:13 +0200	[thread overview]
Message-ID: <ZiJL7bKCUwMr36LQ@macbook> (raw)
In-Reply-To: <96bb1fbb-0b4c-42ac-9c3b-16700a65130d@citrix.com>

On Fri, Apr 19, 2024 at 11:10:33AM +0100, Andrew Cooper wrote:
> On 19/04/2024 11:02 am, 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.
> >
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> 
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>, although ...
> 
> > ---
> > Changes since v1:
> >  - Fix off-by-one in range checking.
> > ---
> >  xen/common/livepatch_elf.c | 16 ++++++++++++++++
> >  1 file changed, 16 insertions(+)
> >
> > diff --git a/xen/common/livepatch_elf.c b/xen/common/livepatch_elf.c
> > index 45d73912a3cd..a67101eadc02 100644
> > --- a/xen/common/livepatch_elf.c
> > +++ b/xen/common/livepatch_elf.c
> > @@ -4,6 +4,7 @@
> >  
> >  #include <xen/errno.h>
> >  #include <xen/lib.h>
> > +#include <xen/sections.h>
> >  #include <xen/symbols.h>
> >  #include <xen/livepatch_elf.h>
> >  #include <xen/livepatch.h>
> > @@ -310,6 +311,21 @@ int livepatch_elf_resolve_symbols(struct livepatch_elf *elf)
> >                      break;
> >                  }
> >              }
> > +
> > +            /*
> > +             * Ensure not an init symbol.  Only applicable to Xen symbols, as
> > +             * livepatch payloads don't have init sections or equivalent.
> > +             */
> > +            else if ( st_value >= (uintptr_t)&__init_begin &&
> > +                      st_value < (uintptr_t)&__init_end )
> 
> ... I normally vertically the (casts) in cases like this for improved
> legibility.  Happy to fold on commit.

Did this, but reverted afterwards because I wasn't sure whether it
would go against the coding style.  Aligning would be my preference
also.

Thanks, Roger.


  reply	other threads:[~2024-04-19 10:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19 10:02 [PATCH v2 0/2] livepatch: make symbol resolution more robust Roger Pau Monne
2024-04-19 10:02 ` [PATCH v2 1/2] xen: introduce header file with section related symbols Roger Pau Monne
2024-04-19 10:08   ` Andrew Cooper
2024-04-19 10:12     ` Jan Beulich
2024-04-19 10:16       ` Andrew Cooper
2024-04-19 14:32         ` Jan Beulich
2024-04-23 12:25   ` Jan Beulich
2024-04-23 13:17     ` Roger Pau Monné
2024-04-19 10:02 ` [PATCH v2 2/2] livepatch: refuse to resolve symbols that belong to init sections Roger Pau Monne
2024-04-19 10:10   ` Andrew Cooper
2024-04-19 10:48     ` Roger Pau Monné [this message]
2024-04-19 10:15   ` Jan Beulich
2024-04-19 10:50     ` Roger Pau Monné
2024-04-19 14:34       ` Jan Beulich
2024-04-22  7:54         ` Roger Pau Monné
2024-04-22  8:25           ` Jan Beulich
2024-04-22 10:49             ` Roger Pau Monné
2024-04-22 10:57               ` Jan Beulich
2024-04-22 11:34                 ` Roger Pau Monné
2024-04-22 11:51                   ` Jan Beulich

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=ZiJL7bKCUwMr36LQ@macbook \
    --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.