Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3681849lfo; Mon, 23 May 2022 11:16:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTXgu1lxSKoGlQsnbj1EOhCdWEuuvL6pOuWoeN8ucPCoCyGTbgnDBiurcWINoyEnpWRgg9 X-Received: by 2002:a63:4545:0:b0:3fa:9d25:91b8 with SMTP id u5-20020a634545000000b003fa9d2591b8mr936675pgk.80.1653329783757; Mon, 23 May 2022 11:16:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653329783; cv=none; d=google.com; s=arc-20160816; b=VNxRzusYY/ldYDW3bvfvkHOy5sLFJaJf6/5dNJd3MxKjG91wnWK9J55GyiM4nF01DT zMvKlPsCTTzxTj+XxEzYAoUIM0DP0447cp0p7WqyeS8H5IdFAh7rPvCchj6UH8WKuT2L yjmkRApjL8NXeOsQsXM1xMKYCGDO2siWwf1hUq36lp/2pHFfNLLJ/S2f06M3okHbC2J2 Qgx/OP3orb0F4qPLOHYRVdV2x0tXNBgheqV4CNUBFlWcySKpmLauiOVUEGJQVTHVw5/1 V1T33Xp2mOZwAQBae7hyL+GcupBTsqBxFbGDVWBI7JlqVb1s8TSSFeGoqvX/oGD6c0ad Pz/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HnD1e3UNd1H9ZqxEX5k3nrOatNKx2aFzSnQpY8Efzzs=; b=ZpF+xpu/vYjLKn07ELBrRDjD4IE0bevH7u4QiLIx37TmvPpSla5MKEDWWF7sXbZ9qw d0x/VuXTyh6kLgcqJ+zirSxBggsn0B4oIOQycRAd94OYlPlCLauOYh9QTk2VkldTa3Fz dJkgLzVUWhyi5V67sMop8zCmpwtV+dDikRWAf5rM+C8aeauIGO1zSiOXLPD4jyD34Adg ++JVNQjYarHcpnSzMFOpB/26Mjb4yasgMJASiDjGagiK3U2MCBzMphngr7o6m3rHvcMc pBYJi1oKLLN2tRb5/m9cr98aLq1b9IKNMK7wrnf1pfu7cu4NZPvHFJC/Y33KNXaiU6Ps iNbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TO9V08fj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c20-20020a63d514000000b003c1fa069da0si10984901pgg.656.2022.05.23.11.16.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 11:16:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TO9V08fj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5C7411668AF; Mon, 23 May 2022 11:15:00 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244899AbiEWSMA (ORCPT + 99 others); Mon, 23 May 2022 14:12:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242219AbiEWRhZ (ORCPT ); Mon, 23 May 2022 13:37:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B93E040A16; Mon, 23 May 2022 10:31:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B5BD2B81205; Mon, 23 May 2022 17:28:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04721C385AA; Mon, 23 May 2022 17:28:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653326925; bh=DSR1P9eMEbqr022sQ4Ij9ftumFVsISbPwh2VF5Wpa1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TO9V08fjKWr/xwUGCk75DkAkjA1uykf1WguxQ1KJkPYPJrcZzkugajDHG52bTM3fn 40C8aA5RcFv5yVlUB7qdGQVRJY0UPhFSv0+ExxT83nToXK/dnwqh8tOx17ykDaQXDR K5yVue073/5+5rGZRtvHMp8qmNO3lWT3BBkqrbWU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Catalin Marinas , Vladimir Murzin , Will Deacon , Steven Price Subject: [PATCH 5.17 059/158] arm64: mte: Ensure the cleared tags are visible before setting the PTE Date: Mon, 23 May 2022 19:03:36 +0200 Message-Id: <20220523165840.601102547@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165830.581652127@linuxfoundation.org> References: <20220523165830.581652127@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Catalin Marinas commit 1d0cb4c8864addc362bae98e8ffa5500c87e1227 upstream. 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 Fixes: 34bfeea4a9e9 ("arm64: mte: Clear the tags when a page is mapped in user-space with PROT_MTE") Cc: # 5.10.x Reported-by: Vladimir Murzin Cc: Will Deacon Reviewed-by: Steven Price Tested-by: Vladimir Murzin Link: https://lore.kernel.org/r/20220517093532.127095-1-catalin.marinas@arm.com Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/mte.c | 3 +++ 1 file changed, 3 insertions(+) --- a/arch/arm64/kernel/mte.c +++ b/arch/arm64/kernel/mte.c @@ -76,6 +76,9 @@ void mte_sync_tags(pte_t old_pte, pte_t 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)