[PATCH] mm/kasan: map KASAN zero page read only

Catalin Marinas catalin.marinas at arm.com
Thu Jan 7 01:51:28 PST 2016


On Wed, Jan 06, 2016 at 09:18:03PM +0100, Ard Biesheuvel wrote:
> On 6 January 2016 at 20:48, Andrey Ryabinin <ryabinin.a.a at gmail.com> wrote:
> > 2016-01-06 18:54 GMT+03:00 Ard Biesheuvel <ard.biesheuvel at linaro.org>:
> >> The original x86_64-only version of KASAN mapped its zero page
> >> read-only, but this got lost when the code was generalised and
> >> ported to arm64, since, at the time, the PAGE_KERNEL_RO define
> >> did not exist. It has been added to arm64 in the mean time, so
> >> let's use it.
> >>
> >
> > Read-only wasn't lost. Just look at the next line:
> >      zero_pte = pte_wrprotect(zero_pte);
> >
> > PAGE_KERNEL_RO is not available on all architectures, thus it would be better
> > to not use it in generic code.
> 
> OK, I didn't see that. For some reason, it is not working for me on
> arm64, though.

It's because the arm64 set_pte_at() doesn't bother checking for
!PTE_WRITE to set PTE_RDONLY when mapping kernel pages. It works fine
for user though. That's because usually all read-only kernel mappings
already have PTE_RDONLY set via PAGE_KERNEL_RO.

We may need to change the set_pte_at logic a bit to cover the above
case.

-- 
Catalin



More information about the linux-arm-kernel mailing list