Skip to content

Commit 753e8ab

Browse files
Ard Biesheuvelctmarinas
Ard Biesheuvel
authored andcommitted
arm64: mm: fix thinko in non-global page table attribute check
The routine pgattr_change_is_safe() was extended in commit 4e60205 ("arm64: mm: Permit transitioning from Global to Non-Global without BBM") to permit changing the nG attribute from not set to set, but did so in a way that inadvertently disallows such changes if other permitted attribute changes take place at the same time. So update the code to take this into account. Fixes: 4e60205 ("arm64: mm: Permit transitioning from Global to ...") Cc: <[email protected]> # 4.14.x- Acked-by: Mark Rutland <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Acked-by: Will Deacon <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Catalin Marinas <[email protected]>
1 parent 4a3928c commit 753e8ab

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/arm64/mm/mmu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static bool pgattr_change_is_safe(u64 old, u64 new)
108108
* The following mapping attributes may be updated in live
109109
* kernel mappings without the need for break-before-make.
110110
*/
111-
static const pteval_t mask = PTE_PXN | PTE_RDONLY | PTE_WRITE;
111+
static const pteval_t mask = PTE_PXN | PTE_RDONLY | PTE_WRITE | PTE_NG;
112112

113113
/* creating or taking down mappings is always safe */
114114
if (old == 0 || new == 0)
@@ -118,9 +118,9 @@ static bool pgattr_change_is_safe(u64 old, u64 new)
118118
if ((old | new) & PTE_CONT)
119119
return false;
120120

121-
/* Transitioning from Global to Non-Global is safe */
122-
if (((old ^ new) == PTE_NG) && (new & PTE_NG))
123-
return true;
121+
/* Transitioning from Non-Global to Global is unsafe */
122+
if (old & ~new & PTE_NG)
123+
return false;
124124

125125
return ((old ^ new) & ~mask) == 0;
126126
}

0 commit comments

Comments
 (0)