Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6831479rwn; Tue, 13 Sep 2022 09:32:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR5zBapryB407v1blW1wC5xTcbF3LGE11pl+NZD6ARIYHS/QwWV+S8CnSPHAE5B0x6D+243Y X-Received: by 2002:a63:5a46:0:b0:434:e36b:438f with SMTP id k6-20020a635a46000000b00434e36b438fmr28253229pgm.351.1663086777270; Tue, 13 Sep 2022 09:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663086777; cv=none; d=google.com; s=arc-20160816; b=JVlh7dZx+z7086p0Dy60+//CR9Tvt9xB/wj3GG+rVGb+9Py8qYq9Wtn29Gmi9cpUBf QWA1krRvgV1XUYs+pMBR0NKKd3KcSmCqSqzWMbgEaXwhafEwLKM6p6gefD0DLA2unkQn zCECGfMQA/givVD45UB4GZUmyeZp6dWLkhFsb6K01KWV745Sd7iFmHyfBpvxoQgjZpnC xCc82IzA36sGBAZi1BN8nqbaT7bQdWEIyZj1Hun0z7wlDhq9jEEyHqZBt2IGp1RHNM/5 kLElqr8LOrT5e0TPsIVVTdbsNUjqcegv+Xjz5D0RdJ07CBV0rynD2Y6ct4Y7OTjFPQC5 CcoQ== 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=l8IOjOesfuvQ8O4rny+LNQE2FwmxOpFMGxrJm4m+eGI=; b=yp4GAS5fmRxdE2lekt5AQyDyJzdY8S1dZ/AWRHp/uKKC72xOMQ+NApjtfMB2f3fUkJ Rmu8mNunTOD4tqU9FPiPVJDRYUc0cGAqgYnJ2Gaw/cuRU78MyTaU53lloOveBGVX9/xV BukpiLlDGergWTDrYr4rEJUSNyV8prBn5Zqa8gK3irE//nNPKmURG7EMRgcXeg+r/eia m3cd06ggnddmZ4unEpoQRa4D2w43SRmGoFUlvLLDXhCeHP8O1xPcjfy9XMfnkWAat77s lgzw+csCU+uXkN/u1vqOilPRzi+Tz16Ab4t5XxqYUS0zkRwSXuoaHFTSovmBkRR5dN9m qrtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=F8HPEKA7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l7-20020a633e07000000b004198bf16b5fsi13785880pga.172.2022.09.13.09.32.41; Tue, 13 Sep 2022 09:32:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=F8HPEKA7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233998AbiIMOa7 (ORCPT + 99 others); Tue, 13 Sep 2022 10:30:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233953AbiIMO2t (ORCPT ); Tue, 13 Sep 2022 10:28:49 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F686696F2; Tue, 13 Sep 2022 07:17:53 -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 sin.source.kernel.org (Postfix) with ESMTPS id 3878CCE1275; Tue, 13 Sep 2022 14:15:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20FF2C433C1; Tue, 13 Sep 2022 14:15:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663078544; bh=UhhhPffRGwfwZRKJbIMhFTEm7QuvdDRQ2HMjxH+0Rqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F8HPEKA7eaVTxJEg6l+WtzyZfp/lLkrkbIqfUj0jKq+Fr0VEdYZtI5ySPVujpZ2tz 4tLISkXlFq6pNaeQF76Ua24aPQfA0sMwO5ESwOEHpzNuSRcwkFwTkFnhkWSclZ39ip vnMQ9z+hma02dGAhzuauLe/P7wagMEeT2Uo3xLsU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sasha Levin Subject: [PATCH 5.19 181/192] Revert "arm64: kasan: Revert "arm64: mte: reset the page tag in page->flags"" Date: Tue, 13 Sep 2022 16:04:47 +0200 Message-Id: <20220913140419.071856698@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140410.043243217@linuxfoundation.org> References: <20220913140410.043243217@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 This reverts commit add4bc9281e8704e5ab15616b429576c84f453a2. On Mon, Sep 12, 2022 at 10:52:45AM +0100, Catalin Marinas wrote: >I missed this (holidays) and it looks like it's in stable already. On >its own it will likely break kasan_hw if used together with user-space >MTE as this change relies on two previous commits: > >70c248aca9e7 ("mm: kasan: Skip unpoisoning of user pages") >6d05141a3930 ("mm: kasan: Skip page unpoisoning only if __GFP_SKIP_KASAN_UNPOISON") > >The reason I did not cc stable is that there are other dependencies in >this area. The potential issues without the above commits were rather >theoretical, so take these patches rather as clean-ups/refactoring than >fixes. Signed-off-by: Sasha Levin --- arch/arm64/kernel/hibernate.c | 5 +++++ arch/arm64/kernel/mte.c | 9 +++++++++ arch/arm64/mm/copypage.c | 9 +++++++++ arch/arm64/mm/mteswap.c | 9 +++++++++ 4 files changed, 32 insertions(+) diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c index af5df48ba915b..2e248342476ea 100644 --- a/arch/arm64/kernel/hibernate.c +++ b/arch/arm64/kernel/hibernate.c @@ -300,6 +300,11 @@ static void swsusp_mte_restore_tags(void) unsigned long pfn = xa_state.xa_index; struct page *page = pfn_to_online_page(pfn); + /* + * It is not required to invoke page_kasan_tag_reset(page) + * at this point since the tags stored in page->flags are + * already restored. + */ mte_restore_page_tags(page_address(page), tags); mte_free_tag_storage(tags); diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c index b2b730233274b..f6b00743c3994 100644 --- a/arch/arm64/kernel/mte.c +++ b/arch/arm64/kernel/mte.c @@ -48,6 +48,15 @@ static void mte_sync_page_tags(struct page *page, pte_t old_pte, if (!pte_is_tagged) return; + page_kasan_tag_reset(page); + /* + * We need smp_wmb() in between setting the flags and clearing the + * tags because if another thread reads page->flags and builds a + * tagged address out of it, there is an actual dependency to the + * memory access, but on the current thread we do not guarantee that + * the new page->flags are visible before the tags were updated. + */ + smp_wmb(); mte_clear_page_tags(page_address(page)); } diff --git a/arch/arm64/mm/copypage.c b/arch/arm64/mm/copypage.c index 24913271e898c..0dea80bf6de46 100644 --- a/arch/arm64/mm/copypage.c +++ b/arch/arm64/mm/copypage.c @@ -23,6 +23,15 @@ void copy_highpage(struct page *to, struct page *from) if (system_supports_mte() && test_bit(PG_mte_tagged, &from->flags)) { set_bit(PG_mte_tagged, &to->flags); + page_kasan_tag_reset(to); + /* + * We need smp_wmb() in between setting the flags and clearing the + * tags because if another thread reads page->flags and builds a + * tagged address out of it, there is an actual dependency to the + * memory access, but on the current thread we do not guarantee that + * the new page->flags are visible before the tags were updated. + */ + smp_wmb(); mte_copy_page_tags(kto, kfrom); } } diff --git a/arch/arm64/mm/mteswap.c b/arch/arm64/mm/mteswap.c index 4334dec93bd44..a9e50e930484a 100644 --- a/arch/arm64/mm/mteswap.c +++ b/arch/arm64/mm/mteswap.c @@ -53,6 +53,15 @@ bool mte_restore_tags(swp_entry_t entry, struct page *page) if (!tags) return false; + page_kasan_tag_reset(page); + /* + * We need smp_wmb() in between setting the flags and clearing the + * tags because if another thread reads page->flags and builds a + * tagged address out of it, there is an actual dependency to the + * memory access, but on the current thread we do not guarantee that + * the new page->flags are visible before the tags were updated. + */ + smp_wmb(); mte_restore_page_tags(page_address(page), tags); return true; -- 2.35.1