[PATCH v2] arm64: mte: Ensure the cleared tags are visible before setting the PTE

Steven Price steven.price at arm.com
Tue May 17 03:23:30 PDT 2022


On 17/05/2022 10:35, Catalin Marinas wrote:
> 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 at arm.com>
> Fixes: 34bfeea4a9e9 ("arm64: mte: Clear the tags when a page is mapped in user-space with PROT_MTE")
> Cc: <stable at vger.kernel.org> # 5.10.x
> Reported-by: Vladimir Murzin <vladimir.murzin at arm.com>
> Cc: Will Deacon <will at kernel.org>

Reviewed-by: Steven Price <steven.price at arm.com>



> ---
> 
> Changes in v2:
> - make the barrier unconditional
> - not including reviewed-by, tested-by tags for v1 as the patch is slightly
>   different
> 
>  arch/arm64/kernel/mte.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c
> index 90994aca54f3..d565ae25e48f 100644
> --- a/arch/arm64/kernel/mte.c
> +++ b/arch/arm64/kernel/mte.c
> @@ -67,6 +67,9 @@ void mte_sync_tags(pte_t old_pte, pte_t pte)
>  			mte_sync_page_tags(page, old_pte, check_swap,
>  					   pte_is_tagged);
>  	}
> +
> +	/* ensure the tags are visible before the PTE is set */
> +	smp_wmb();
>  }
>  
>  int memcmp_pages(struct page *page1, struct page *page2)




More information about the linux-arm-kernel mailing list