linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: james.morse@arm.com (James Morse)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] efi/libstub: arm/arm64: don't use TASK_SIZE when randomising the RT space
Date: Mon, 10 Apr 2017 12:34:42 +0100	[thread overview]
Message-ID: <58EB6DD2.1010102@arm.com> (raw)
In-Reply-To: <20170410104403.GC13899@leverpostej>

Hi Ard, Mark

On 10/04/17 11:44, Mark Rutland wrote:
> On Mon, Apr 10, 2017 at 11:30:38AM +0100, Ard Biesheuvel wrote:
>> As reported by James, Catalin and Mark, commit e69176d68d26
>> ("ef/libstub/arm/arm64: Randomize the base of the UEFI rt services
>> region") results in a crash in the firmware regardless of whether KASLR
>> is in effect or not, and whether the firmware implements EFI_RNG_PROTOCOL
>> or not.
>>
>> Mark has identified the root cause to be the inappropriate use of
>> TASK_SIZE in the stub, which arm64 defines as
>>
>>   #define TASK_SIZE             (test_thread_flag(TIF_32BIT) ? \
>>                                 TASK_SIZE_32 : TASK_SIZE_64)
>>
>> and testing thread flags at this point results in the dereference of
>> pointers in uninitialized structures.
>>
>> So instead, introduce a preprocessor symbol EFI_RT_VIRTUAL_LIMIT and
>> define it to TASK_SIZE_64 on arm64 and TASK_SIZE on ARM, both of which
>> are compile time constants. Also, change the 'headroom' variable to
>> static const to force an error if this changes in the future.
>>
>> Cc: James Morse <james.morse@arm.com>
>> Cc: Mark Rutland <mark.rutland@arm.com>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Matt Fleming <matt@codeblueprint.co.uk>
>> Cc: Ingo Molnar <mingo@kernel.org>
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> 
> With this patch applied atop of next-20170410, a defconfig arm64 kernel
> built with the Linaro 15.08 toolchain boots happily for me on Juno R1.

Likewise, this fixes the problem I was seeing on Seattle. If it's useful:
Tested-by: James Morse <james.morse@arm.com>

Thanks for debugging that so quickly Mark!


James

  reply	other threads:[~2017-04-10 11:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-10 10:30 [PATCH] efi/libstub: arm/arm64: don't use TASK_SIZE when randomising the RT space Ard Biesheuvel
2017-04-10 10:44 ` Mark Rutland
2017-04-10 11:34   ` James Morse [this message]
2017-04-10 14:42 ` Catalin Marinas

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=58EB6DD2.1010102@arm.com \
    --to=james.morse@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).