From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 83CC7C25B07 for ; Mon, 8 Aug 2022 01:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7QQ7ZztyvHQT1GXUS8V5bF46UcuLcEvLEtv1P9YDSPk=; b=Q+Y3LBnwqsGujO +oGZghrW7PUb0yOVYy0RVKfODQdFRgEB/zypTk4hGAg9Kwmsuiq/bEgso3yfaEsd07/hcoo+AqVVg kDDRtJd8nu9RqzMCoehOa2OOebgQv4rfK2O2NyuNI4QWAuo2POBQ+wRy4rUbQdC+0vx8uzm6qD6gZ +wBBiVg9VbzsiyJSrG39QAqsBoqglb4OxhiaNV6ZOxo+UX0oSENpsPsUARQfez+zOURrc6Etif5+Q ovqi6qTbVQXK7c3HwWuEnxX8EWrDHuSZgIHJ4I3PQBi/4xgq/5W+N5zHbC875X41Hmshy+4KBVB93 w6skPA/+NGu8yvsVnz1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oKre3-007c9W-1N; Mon, 08 Aug 2022 01:33:27 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oKrcm-007bSq-5s for linux-arm-kernel@lists.infradead.org; Mon, 08 Aug 2022 01:32:10 +0000 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 63EBCCE0F6E; Mon, 8 Aug 2022 01:32:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92420C433D6; Mon, 8 Aug 2022 01:32:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659922324; bh=zR12wUi8RY0WfdWWtyBQpmxoI/kb8IcDNKjQXmqjbSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mhMalInAR0Oewih73p7i3b/pMR06z+3JDRxC5qewGmpsoLIAzFdg1XRDs4l3yIGXW E9uMx3BrVLAHVRe5Rg+t8bMxWKnJTRQ72ExYL8oQivF64MWU+bp/iJVacUrmylUrSG PyA9kqJRYzpdt5+D7Yw79jM+sOWou/lgdoU1pFTVIrENfezOLTjzKdHu8+sZ1xNZT5 MA44gevD41Ca231aY9Lc7lq2tlKhwew3W4xja4mXDfyU2t+XfwAvb5jyq4jQsJiFMb JU2x5RGl2/Ww7ZQY/yqhSUH0/1XS8KMo/uf1C6OAPmpBLc01O8d82mDy0NDgkYP+XC DxJLCXlHsF78Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Catalin Marinas , Andrey Ryabinin , Andrey Konovalov , Peter Collingbourne , Vincenzo Frascino , Will Deacon , Sasha Levin , mark.rutland@arm.com, broonie@kernel.org, ebiederm@xmission.com, zhengqi.arch@bytedance.com, alexandru.elisei@arm.com, peterx@redhat.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org Subject: [PATCH AUTOSEL 5.19 11/58] mm: kasan: Skip unpoisoning of user pages Date: Sun, 7 Aug 2022 21:30:29 -0400 Message-Id: <20220808013118.313965-11-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220808013118.313965-1-sashal@kernel.org> References: <20220808013118.313965-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220807_183208_606405_D34EE29A X-CRM114-Status: GOOD ( 16.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Catalin Marinas [ Upstream commit 70c248aca9e7efa85a6664d5ab56c17c326c958f ] Commit c275c5c6d50a ("kasan: disable freed user page poisoning with HW tags") added __GFP_SKIP_KASAN_POISON to GFP_HIGHUSER_MOVABLE. A similar argument can be made about unpoisoning, so also add __GFP_SKIP_KASAN_UNPOISON to user pages. To ensure the user page is still accessible via page_address() without a kasan fault, reset the page->flags tag. With the above changes, there is no need for the arm64 tag_clear_highpage() to reset the page->flags tag. Signed-off-by: Catalin Marinas Cc: Andrey Ryabinin Cc: Andrey Konovalov Cc: Peter Collingbourne Cc: Vincenzo Frascino Reviewed-by: Vincenzo Frascino Reviewed-by: Andrey Konovalov Link: https://lore.kernel.org/r/20220610152141.2148929-3-catalin.marinas@arm.com Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/mm/fault.c | 1 - include/linux/gfp.h | 2 +- mm/page_alloc.c | 7 +++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index c5e11768e5c1..cdf3ffa0c223 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -927,6 +927,5 @@ struct page *alloc_zeroed_user_highpage_movable(struct vm_area_struct *vma, void tag_clear_highpage(struct page *page) { mte_zero_clear_page_tags(page_address(page)); - page_kasan_tag_reset(page); set_bit(PG_mte_tagged, &page->flags); } diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 2d2ccae933c2..0ace7759acd2 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -348,7 +348,7 @@ struct vm_area_struct; #define GFP_DMA32 __GFP_DMA32 #define GFP_HIGHUSER (GFP_USER | __GFP_HIGHMEM) #define GFP_HIGHUSER_MOVABLE (GFP_HIGHUSER | __GFP_MOVABLE | \ - __GFP_SKIP_KASAN_POISON) + __GFP_SKIP_KASAN_POISON | __GFP_SKIP_KASAN_UNPOISON) #define GFP_TRANSHUGE_LIGHT ((GFP_HIGHUSER_MOVABLE | __GFP_COMP | \ __GFP_NOMEMALLOC | __GFP_NOWARN) & ~__GFP_RECLAIM) #define GFP_TRANSHUGE (GFP_TRANSHUGE_LIGHT | __GFP_DIRECT_RECLAIM) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b5b14b78c4fd..4d5c30dc757f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2397,6 +2397,7 @@ inline void post_alloc_hook(struct page *page, unsigned int order, bool init = !want_init_on_free() && want_init_on_alloc(gfp_flags) && !should_skip_init(gfp_flags); bool init_tags = init && (gfp_flags & __GFP_ZEROTAGS); + int i; set_page_private(page, 0); set_page_refcounted(page); @@ -2422,8 +2423,6 @@ inline void post_alloc_hook(struct page *page, unsigned int order, * should be initialized as well). */ if (init_tags) { - int i; - /* Initialize both memory and tags. */ for (i = 0; i != 1 << order; ++i) tag_clear_highpage(page + i); @@ -2438,6 +2437,10 @@ inline void post_alloc_hook(struct page *page, unsigned int order, /* Note that memory is already initialized by KASAN. */ if (kasan_has_integrated_init()) init = false; + } else { + /* Ensure page_address() dereferencing does not fault. */ + for (i = 0; i != 1 << order; ++i) + page_kasan_tag_reset(page + i); } /* If memory is still not initialized, do it now. */ if (init) -- 2.35.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel