mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Michael Olbrich <m.olbrich@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] efi: let the generic relocate code handle all relocations
Date: Thu, 7 Apr 2016 07:30:57 +0200	[thread overview]
Message-ID: <20160407053057.GF9102@pengutronix.de> (raw)
In-Reply-To: <1459841605-8850-1-git-send-email-m.olbrich@pengutronix.de>

On Tue, Apr 05, 2016 at 09:33:25AM +0200, Michael Olbrich wrote:
> Part of the barebox code and variables are put in separate sections
> (.barebox* and .initcall*). When this code is compiled as position
> independent code then the compiler creates corresponding .rela.barebox* and
> .rela.initcall* sections with the relocation table entries.
> These sections don't match the .rela.data* wildcard in the linker script.
> As a result, they are not added to the .rela section during linking but are
> added individually after it instead. And when the EFI binary is created
> from the ELF binary, these sections are not copied.
> This has two side effects:
> 
> 1. The corresponding relocations are not handled by the generic relocation
> code. 'fixup_tables()' was added to do these relocations manually.
> 
> 2. In the DYNAMIC section, the RELASZ entry contains the total size of
> relocations in bytes. This includes the .rela.barebox* and .rela.initcall*
> sections. This value is not modified when the EFI binary is created. So the
> value is too large.
> The generic relocation code in _relocate() used this value when iterating
> over all relocation entries. With the wrong RELASZ value it iterates beyond
> the end of the .rela section into uninitialized memory. After power-on this
> memory is zero and the relocation code interprets this as 'nothing to do',
> so there is no visible effect. After a soft reset, random data in that area
> may produce a seemingly valid relocation entry, a random address is
> modified and barebox crashes.
> 
> This patch adds the .rela.barebox* and .rela.initcall* sections to the
> normal .rela section. The RELASZ now contains the correct size and the
> generic relocation code works correctly. 'fixup_tables()' must be removed
> at the same time to avoid relocating these entries twice.
> 
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> ---
>  arch/efi/efi/efi.c                | 42 ---------------------------------------
>  arch/efi/lib/elf_x86_64_efi.lds.S |  2 ++
>  2 files changed, 2 insertions(+), 42 deletions(-)

Applied, thanks. And thanks for finally fixing this issue :)

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2016-04-07  5:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-05  7:33 Michael Olbrich
2016-04-07  5:30 ` Sascha Hauer [this message]

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=20160407053057.GF9102@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.olbrich@pengutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox