From: Konrad Rzeszutek Wilk <konrad@kernel.org>
To: Jan Beulich <JBeulich@suse.com>
Cc: andrew.cooper3@citrix.com, julien.grall@arm.com,
sstabellini@kernel.org, xen-devel@lists.xenproject.org
Subject: Re: [PATCH v2 3/5] xen/livepatch/ARM32: Don't load and crash on livepatches loaded with wrong alignment.
Date: Sat, 9 Sep 2017 08:05:30 -0400 [thread overview]
Message-ID: <20170909120529.GA19614@localhost.localdomain> (raw)
In-Reply-To: <59B27F3F0200007800178AC9@prv-mh.provo.novell.com>
On Fri, Sep 08, 2017 at 03:30:07AM -0600, Jan Beulich wrote:
> >>> On 07.09.17 at 19:36, <konrad@kernel.org> wrote:
> > On Wed, Aug 02, 2017 at 03:20:05AM -0600, Jan Beulich wrote:
> >> >>> Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> 07/31/17 6:04 PM >>>
> >> >On Mon, Jul 31, 2017 at 07:55:34AM -0600, Jan Beulich wrote:
> >> >> >>> Konrad Rzeszutek Wilk <konrad@kernel.org> 07/26/17 9:50 PM >>>
> >> >> >--- a/docs/misc/livepatch.markdown
> >> >> >+++ b/docs/misc/livepatch.markdown
> >> >> >@@ -279,6 +279,10 @@ It may also have some architecture-specific sections.
> > For example:
> >> >> >* Exception tables.
> >> >> >* Relocations for each of these sections.
> >> >> >
> >> >> >+Note that on ARM 32 the sections SHOULD be four byte aligned. Otherwise
> >> >> >+we risk hitting Data Abort exception as un-aligned manipulation of data is
> >> >> >+prohibited on ARM 32.
> >> >>
> >> >> This (and hence the rest of the patch) is not in line with the outcome of
> > the
> >> >> earlier discussion we had. Nothing is wrong with a section having smaller
> >> >> alignment, as long as there are no 32-bit (or wider, but I don't think there
> >> >> are any such) relocations against such a section. And even if there were, I
> >> >> think it should rather be the code doing the relocations needing to cope,
> > as
> >> >> I don't think the ARM ELF ABI imposes any such restriction.
> >> >
> >> >The idea behind this patch is to give advance warnings. Akin to what
> >> >2ff229643b739e2fd0cd0536ee9fca506cfa92f8
> >> >"xen/livepatch: Don't crash on encountering STN_UNDEF relocations" did.
> >> >
> >> >The other patches in this series fix the alignment issues.
> >> >
> >> >The ARM ELF ABI
> > (http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044f/IHI0044F_aaelf.pdf
> > )
> >> >
> >> >says:
> >> >
> >> >4.3.5 Section Alignment
> >> >There is no minimum alignment required for a section. However, sections
> > containing thumb code must be at least
> >> >16-bit aligned and sections containing ARM code must be at least 32-bit
> > aligned.
> >> >Platform standards may set a limit on the maximum alignment that they can
> > guarantee (normally the page size).
> >>
> >> Note the "thumb code" and "ARM code" in here - iirc you're checking _all_
> >> sections, not just ones containing code.
> >
> > I can fix the code to only do the check for 'X' ones:
> >
> > [ 2] .text PROGBITS 0000000000000000 00000070
> > 00000000000000ca 0000000000000000 AX 0 0 16
> > [ 4] .altinstr_replace PROGBITS 0000000000000000 0000013c
> > 000000000000000b 0000000000000000 AX 0 0 4
> > [ 5] .fixup PROGBITS 0000000000000000 00000147
> > 000000000000000d 0000000000000000 AX 0 0 1
> >
> >
> > And also have the check in the relocation - which right now are
> > 32-bit: R_ARM_ABS32, R_ARM_REL32, R_ARM_MOVW_ABS_NC, R_ARM_MOVT_ABS,
> > R_ARM_CALL, R_ARM_JUMP24 so will leave the code as in
> > arch_livepatch_perform.
>
> Relocations applicable to code only _may_ be acceptable to have
> such an alignment check (but I could see cases where even that
> might be too aggressive), but afaik R_ARM_ABS32 isn't a code
> only one (out of the set listed above), so I doubt this should have
> an alignment check.
>
> > But neither one of those is going to help in catching livepatches
> > that have the wrong alignment without relocations and not executable.
> > For example .livepatch.depends
>
> What does "wrong alignment" mean when there's no code involved?
Anything which we try to access as a structure, or unsigned int,
that is not aligned to four bytes.
For example accessing .livepatch.depends from memory and blowing
up (hypervisor crashes) b/c it does not start at an four byte aligned
location.
> I think what you want to detect simply can't be detected reliably,
> without risking false positives.
>
> Jan
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-09-09 12:05 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-26 19:47 [PATCH v2] Livepatch fixes for v4.10 (v2) Konrad Rzeszutek Wilk
2017-07-26 19:47 ` [PATCH v2 1/5] livepatch: Tighten alignment checks Konrad Rzeszutek Wilk
2017-07-31 13:46 ` Jan Beulich
2017-07-26 19:47 ` [PATCH v2 2/5] livepatch: Include sizes when an mismatch occurs Konrad Rzeszutek Wilk
2017-07-31 13:51 ` Jan Beulich
2017-07-26 19:47 ` [PATCH v2 3/5] xen/livepatch/ARM32: Don't load and crash on livepatches loaded with wrong alignment Konrad Rzeszutek Wilk
2017-07-26 22:27 ` Andrew Cooper
2017-07-31 13:55 ` Jan Beulich
2017-07-31 16:04 ` Konrad Rzeszutek Wilk
2017-08-02 9:20 ` Jan Beulich
2017-09-07 17:36 ` Konrad Rzeszutek Wilk
2017-09-08 9:30 ` Jan Beulich
2017-09-09 12:05 ` Konrad Rzeszutek Wilk [this message]
2017-09-11 9:01 ` Jan Beulich
2017-09-12 0:22 ` Konrad Rzeszutek Wilk
2017-09-12 8:57 ` Jan Beulich
2017-09-18 19:37 ` Konrad Rzeszutek Wilk
2017-09-19 15:04 ` Jan Beulich
2017-09-20 15:12 ` Konrad Rzeszutek Wilk
2017-09-20 15:51 ` Jan Beulich
2017-07-26 19:47 ` [PATCH v2 4/5] alternative/x86/arm32: Align altinstructions (and altinstr_replacement) sections Konrad Rzeszutek Wilk
2017-07-31 14:01 ` Jan Beulich
2017-09-11 18:59 ` Konrad Rzeszutek Wilk
2017-07-26 19:47 ` [PATCH v2 5/5] livepatch: Declare live patching as a supported feature Konrad Rzeszutek Wilk
2017-07-31 14:03 ` 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=20170909120529.GA19614@localhost.localdomain \
--to=konrad@kernel.org \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=julien.grall@arm.com \
--cc=sstabellini@kernel.org \
--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.