Skip to contentSkip to conversation

ARM: mm: fix reporting of read-only PMD bits

PATCH Superseded Kees Cook 1 participant 2 messages Feb 12, 2014 – Mar 13, 2014 Arm (32-bit)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH v2 1/1 ARM: mm: fix reporting of read-only PMD bits

On non-LPAE, read-only PMD bits are defined with the combination "PMD_SECT_APX | PMD_SECT_AP_WRITE". Adjusted the bit masks to correctly detect this.

---
v2:
- reorder bits, suggested by Olof Johansson.

---
 arch/arm/mm/dump.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/arm/mm/dump.c +5 -5
index 2b3a56414271..2b342177f5de 100644
@@ -123,19 +123,19 @@ static const struct prot_bits section_bits[] = {
 #ifndef CONFIG_ARM_LPAE
 	/* These are approximate */
 	{
-		.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
Signature · 6 lines
1.7.9.5


-- 
Kees Cook
Chrome OS Security
author
#1 lore raw
Quoted 17 lines · Kees Cook

On non-LPAE, read-only PMD bits are defined with the combination "PMD_SECT_APX | PMD_SECT_AP_WRITE". Adjusted the bit masks to correctly detect this.

---
v2:
- reorder bits, suggested by Olof Johansson.

---
 arch/arm/mm/dump.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/arm/mm/dump.c +0 -0
index 2b3a56414271..2b342177f5de 100644

arch/arm/mm/dump.c static const struct prot_bits section_bits[] = { · line 129

Quoted 9 lines
arch/arm/mm/dump.c +2 -2
@@ -123,19 +123,19 @@ static const struct prot_bits section_bits[] = {
 #ifndef CONFIG_ARM_LPAE
        /* These are approximate */
        {
-               .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",
        }, {

As Russell pointed out, this won't be valid for pre-v6 CPUs. What's the best config for handling this? I'd like something like CONFIG_ARM_LPAE, but using the CPU_* stuff seems a bit sloppy:

#if !defined(CONFIG_ARM_CPU_V6) && !defined(CONFIG_ARM_CPU_V7) ...new masks...
#else
...old masks...
#endif

But that seems to be the only thing I can find. Is CPU_* good enough here?

-Kees

Quoted 22 lines
arch/arm/mm/dump.c +3 -4
-               .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
--

1.7.9.5

--
Kees Cook
Chrome OS Security

Signature · 2 lines
Kees Cook
Chrome OS Security