Skip to content

Commit 1d0cb4c

Browse files
ctmarinaswilldeacon
authored andcommitted
arm64: mte: Ensure the cleared tags are visible before setting the PTE
As an optimisation, only pages mapped with PROT_MTE in user space have the MTE tags zeroed. This is done lazily at the set_pte_at() time via mte_sync_tags(). However, this function is missing a barrier and another CPU may see the PTE updated before the zeroed tags are visible. Add an smp_wmb() barrier if the mapping is Normal Tagged. Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Fixes: 34bfeea ("arm64: mte: Clear the tags when a page is mapped in user-space with PROT_MTE") Cc: <stable@vger.kernel.org> # 5.10.x Reported-by: Vladimir Murzin <vladimir.murzin@arm.com> Cc: Will Deacon <will@kernel.org> Reviewed-by: Steven Price <steven.price@arm.com> Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> Link: https://lore.kernel.org/r/20220517093532.127095-1-catalin.marinas@arm.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent eb3d8ea commit 1d0cb4c

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

arch/arm64/kernel/mte.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ void mte_sync_tags(pte_t old_pte, pte_t pte)
7676
mte_sync_page_tags(page, old_pte, check_swap,
7777
pte_is_tagged);
7878
}
79+
80+
/* ensure the tags are visible before the PTE is set */
81+
smp_wmb();
7982
}
8083

8184
int memcmp_pages(struct page *page1, struct page *page2)

0 commit comments

Comments
 (0)