ARM: mm: fix reporting of read-only PMD bits
PATCH v4 1/1 ARM: mm: fix reporting of read-only PMD bits
On non-LPAE ARMv6+, read-only PMD bits are defined with the combination "PMD_SECT_APX | PMD_SECT_AP_WRITE". Adjusted the bit masks to correctly report this.
---
v4:
- clean up defines for CPU versions; Rob Herring.
v3:
- check for pre-v6 CPUs on the page table report.
v2:
- reorder bits, suggested by Olof.
--- arch/arm/mm/dump.c | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-)
arch/arm/mm/dump.c +32 -15
@@ -120,34 +120,51 @@ static const struct prot_bits pte_bits[] = { };static const struct prot_bits section_bits[] = { -#ifndef CONFIG_ARM_LPAE -/* These are approximate */ +#ifdef CONFIG_ARM_LPAE + { + .mask =PMD_SECT_USER , + .val =PMD_SECT_USER , + .set ="USR" , + }, { + .mask =PMD_SECT_RDONLY , + .val =PMD_SECT_RDONLY , + .set ="ro" , + .clear ="RW" , +#elif __LINUX_ARM_ARCH__ >= 6 { - .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , - .val =0 , + .mask =PMD_SECT_APX |PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .val =PMD_SECT_APX |PMD_SECT_AP_WRITE , .set =" ro" , }, { - .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .mask =PMD_SECT_APX |PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , .val =PMD_SECT_AP_WRITE , .set =" RW" , }, { - .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .mask =PMD_SECT_APX |PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , .val =PMD_SECT_AP_READ , .set ="USR ro" , }, { - .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .mask =PMD_SECT_APX |PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , .val =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , .set ="USR RW" , -#else +#else /* ARMv4/ARMv5 */ +/* These are approximate */ { - .mask =PMD_SECT_USER , - .val =PMD_SECT_USER , - .set ="USR" , + .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .val =0 , + .set =" ro" , }, { - .mask =PMD_SECT_RDONLY , - .val =PMD_SECT_RDONLY , - .set ="ro" , - .clear ="RW" , + .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .val =PMD_SECT_AP_WRITE , + .set =" RW" , + }, { + .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .val =PMD_SECT_AP_READ , + .set ="USR ro" , + }, { + .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .val =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .set ="USR RW" , #endif }, { .mask =PMD_SECT_XN ,
Signature · 6 lines
1.7.9.5 -- Kees Cook Chrome OS Security
Quoted 4 lines · Kees Cook
On non-LPAE ARMv6+, read-only PMD bits are defined with the combination "
PMD_SECT_APX|PMD_SECT_AP_WRITE". Adjusted the bit masks to correctly report this.
Quoted 8 lines
Signed-off-by Kees Cook <[email protected]>---
v4:
- clean up defines for CPU versions; Rob Herring.
v3:
- check for pre-v6 CPUs on the page table report.
v2:
- reorder bits, suggested by Olof.
Can anyone give this a test or ack? I've done build tests for all CPU combinations, and runtime tests on v6 and LPAE.
Thanks!
-Kees
Quoted 82 lines
--- arch/arm/mm/dump.c | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-)arch/arm/mm/dump.c +32
-16@@ -120,34 +120,51 @@ static const struct prot_bits pte_bits[] = { };static const struct prot_bits section_bits[] = { -#ifndef CONFIG_ARM_LPAE -/* These are approximate */ +#ifdef CONFIG_ARM_LPAE + { + .mask =PMD_SECT_USER , + .val =PMD_SECT_USER , + .set ="USR" , + }, { + .mask =PMD_SECT_RDONLY , + .val =PMD_SECT_RDONLY , + .set ="ro" , + .clear ="RW" , +#elif __LINUX_ARM_ARCH__ >= 6 { - .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , - .val =0 , + .mask =PMD_SECT_APX |PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .val =PMD_SECT_APX |PMD_SECT_AP_WRITE , .set =" ro" , }, { - .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .mask =PMD_SECT_APX |PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , .val =PMD_SECT_AP_WRITE , .set =" RW" , }, { - .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .mask =PMD_SECT_APX |PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , .val =PMD_SECT_AP_READ , .set ="USR ro" , }, { - .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .mask =PMD_SECT_APX |PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , .val =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , .set ="USR RW" , -#else +#else /* ARMv4/ARMv5 */ +/* These are approximate */ { - .mask =PMD_SECT_USER , - .val =PMD_SECT_USER , - .set ="USR" , + .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .val =0 , + .set =" ro" , }, { - .mask =PMD_SECT_RDONLY , - .val =PMD_SECT_RDONLY , - .set ="ro" , - .clear ="RW" , + .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .val =PMD_SECT_AP_WRITE , + .set =" RW" , + }, { + .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .val =PMD_SECT_AP_READ , + .set ="USR ro" , + }, { + .mask =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .val =PMD_SECT_AP_READ |PMD_SECT_AP_WRITE , + .set ="USR RW" , #endif }, { .mask =PMD_SECT_XN , --1.7.9.5
--
Kees Cook
Chrome OS Security
Signature · 2 lines
Kees Cook Chrome OS Security
Laura Abbott
Tested-byQuoted 14 lines · Kees Cook
Quoted 4 lines · Kees Cook
On non-LPAE ARMv6+, read-only PMD bits are defined with the combination "
PMD_SECT_APX|PMD_SECT_AP_WRITE". Adjusted the bit masks to correctly report this.Quoted 8 lines
Signed-off-by Kees Cook <[email protected]>---
v4:
- clean up defines for CPU versions; Rob Herring.
v3:
- check for pre-v6 CPUs on the page table report.
v2:
- reorder bits, suggested by Olof.
Quoted 7 lines
Can anyone give this a test or ack? I've done build tests for all CPU combinations, and runtime tests on v6 and LPAE.
Thanks!
-Kees
You are welcome to add
Laura
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation