Re: [PATCH v6 3/9] arm64, kfence: enable KFENCE for ARM64
From: Mark Rutland
Date: Fri Oct 30 2020 - 12:00:16 EST
On Fri, Oct 30, 2020 at 03:49:26AM +0100, Jann Horn wrote:
> On Thu, Oct 29, 2020 at 2:17 PM Marco Elver <elver@xxxxxxxxxx> wrote:
> > @@ -312,6 +313,9 @@ static void __do_kernel_fault(unsigned long addr, unsigned int esr,
> > "Ignoring spurious kernel translation fault at virtual address %016lx\n", addr))
> > return;
> >
> > + if (kfence_handle_page_fault(addr))
> > + return;
>
> As in the X86 case, we may want to ensure that this doesn't run for
> permission faults, only for non-present pages. Maybe move this down
> into the third branch of the "if" block below (neither permission
> fault nor NULL deref)?
I think that'd make sense. Those cases *should* be mutually exclusive,
but it'd be more robust to do the KFENCE checks in that last block so
that if something goes wrong wrong within KFENCE we can't get stuck in a
loop failing to service an instruction abort or similar.
Either that, or factor out an is_el1_translation_fault() and only do the
KFENCE check and is_spurious_el1_translation_fault() check under that.
Thanks,
Mark.