mbox series

[v3,0/2] efi: Follow-up fixes for EFI runtime stack

Message ID 20230106174703.1883495-1-ardb@kernel.org (mailing list archive)
Headers show
Series efi: Follow-up fixes for EFI runtime stack | expand

Message

Ard Biesheuvel Jan. 6, 2023, 5:47 p.m. UTC
Commit ff7a167961d1b ("arm64: efi: Execute runtime services from a
dedicated stack") introduced a dedicated stack for EFI runtime services,
in an attempt to make the execution of EFI runtime services more robust,
given that they execute at the same privilege level as the kernel.

However, this stack needs to be declared to the stacktrace machinery,
which is careful not to walk the stack when it leads into memory regions
that are not known to be allocated for stack use.

Also, given that the ACPI code may invoke the low-level EFI runtime call
wrapper without using the dedicated kernel thread and workqueue, we
should take this into account when trying to gracefully handle
synchronous exceptions.

Changes since v2:
- clear efi_rt_stack_top[-1] from asm code, and use READ_ONCE() to read
  its value when not holding the spinlock, to ensure that all accesses
  are safe under concurrency;
- add Mark's ack to patch #2

Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Lee Jones <lee@kernel.org>

Ard Biesheuvel (2):
  arm64: efi: Avoid workqueue to check whether EFI runtime is live
  arm64: efi: Account for the EFI runtime stack in stack unwinder

 arch/arm64/include/asm/efi.h        |  9 +++++++++
 arch/arm64/include/asm/stacktrace.h | 15 +++++++++++++++
 arch/arm64/kernel/efi-rt-wrapper.S  |  6 ++++++
 arch/arm64/kernel/efi.c             |  3 ++-
 arch/arm64/kernel/stacktrace.c      | 12 ++++++++++++
 5 files changed, 44 insertions(+), 1 deletion(-)

Comments

Lee Jones Jan. 9, 2023, 10:38 a.m. UTC | #1
On Fri, 06 Jan 2023, Ard Biesheuvel wrote:

> Commit ff7a167961d1b ("arm64: efi: Execute runtime services from a
> dedicated stack") introduced a dedicated stack for EFI runtime services,
> in an attempt to make the execution of EFI runtime services more robust,
> given that they execute at the same privilege level as the kernel.
> 
> However, this stack needs to be declared to the stacktrace machinery,
> which is careful not to walk the stack when it leads into memory regions
> that are not known to be allocated for stack use.
> 
> Also, given that the ACPI code may invoke the low-level EFI runtime call
> wrapper without using the dedicated kernel thread and workqueue, we
> should take this into account when trying to gracefully handle
> synchronous exceptions.
> 
> Changes since v2:
> - clear efi_rt_stack_top[-1] from asm code, and use READ_ONCE() to read
>   its value when not holding the spinlock, to ensure that all accesses
>   are safe under concurrency;
> - add Mark's ack to patch #2
> 
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Lee Jones <lee@kernel.org>
> 
> Ard Biesheuvel (2):
>   arm64: efi: Avoid workqueue to check whether EFI runtime is live
>   arm64: efi: Account for the EFI runtime stack in stack unwinder

Should either / both of these be routed to Stable?

If so, we should probably Cc: them.

>  arch/arm64/include/asm/efi.h        |  9 +++++++++
>  arch/arm64/include/asm/stacktrace.h | 15 +++++++++++++++
>  arch/arm64/kernel/efi-rt-wrapper.S  |  6 ++++++
>  arch/arm64/kernel/efi.c             |  3 ++-
>  arch/arm64/kernel/stacktrace.c      | 12 ++++++++++++
>  5 files changed, 44 insertions(+), 1 deletion(-)
> 
> -- 
> 2.39.0
>
Ard Biesheuvel Jan. 9, 2023, 1:46 p.m. UTC | #2
On Mon, 9 Jan 2023 at 11:38, Lee Jones <lee@kernel.org> wrote:
>
> On Fri, 06 Jan 2023, Ard Biesheuvel wrote:
>
> > Commit ff7a167961d1b ("arm64: efi: Execute runtime services from a
> > dedicated stack") introduced a dedicated stack for EFI runtime services,
> > in an attempt to make the execution of EFI runtime services more robust,
> > given that they execute at the same privilege level as the kernel.
> >
> > However, this stack needs to be declared to the stacktrace machinery,
> > which is careful not to walk the stack when it leads into memory regions
> > that are not known to be allocated for stack use.
> >
> > Also, given that the ACPI code may invoke the low-level EFI runtime call
> > wrapper without using the dedicated kernel thread and workqueue, we
> > should take this into account when trying to gracefully handle
> > synchronous exceptions.
> >
> > Changes since v2:
> > - clear efi_rt_stack_top[-1] from asm code, and use READ_ONCE() to read
> >   its value when not holding the spinlock, to ensure that all accesses
> >   are safe under concurrency;
> > - add Mark's ack to patch #2
> >
> > Cc: Mark Rutland <mark.rutland@arm.com>
> > Cc: Lee Jones <lee@kernel.org>
> >
> > Ard Biesheuvel (2):
> >   arm64: efi: Avoid workqueue to check whether EFI runtime is live
> >   arm64: efi: Account for the EFI runtime stack in stack unwinder
>
> Should either / both of these be routed to Stable?
>
> If so, we should probably Cc: them.
>

I'll forward them to -stable by hand once all the bits and pieces land
in Linus's tree.

Feel free to remind in a week or so, though.

Thanks,
Ard.