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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70266C61DA4 for ; Tue, 14 Feb 2023 17:54:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F28446B0071; Tue, 14 Feb 2023 12:54:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ED8396B0072; Tue, 14 Feb 2023 12:54:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DCA916B0075; Tue, 14 Feb 2023 12:54:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id CF9E36B0071 for ; Tue, 14 Feb 2023 12:54:26 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A22CB1C683F for ; Tue, 14 Feb 2023 17:54:26 +0000 (UTC) X-FDA: 80466646932.12.8F00B3C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf04.hostedemail.com (Postfix) with ESMTP id E60B740004 for ; Tue, 14 Feb 2023 17:54:24 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf04.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676397265; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4vrfRF2+j8chYU1CJ8BqfAG6vP9dgP33/j7x2xQS3iY=; b=jppHGeGkFOk4vt+GOM8Fh0BgyC3Xo5uvcneXUOJkr0ZMgXH0L1hvpQuA6MpMTkoQNDAEXt v8UXLBVjKnJe1FW8h3DzlZMxFpQjYg++FXwOyuAvFJziSZo5zfANT+SMkoFdmeniHkT3PY Zny9AiMQrpgcDZy9zhCDkR8JEdt7sIc= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf04.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676397265; a=rsa-sha256; cv=none; b=1k5Perw85qoTa2rm8MAAuk96zE7ujCYCeBqoG6yLV9mjOpx9RhflmYyVv745qyMsuBBuhS ocRdcyLJw6+KSNKlPRSD8h0WWVd9P1H8T0fZ8WuTKuQGNNyEhdmdBHAJ/Fi8M+xr9OfdiQ jWIKI739vDfbTkBTqV2AQWty4c6y/04= 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 dfw.source.kernel.org (Postfix) with ESMTPS id EF5AD617AC; Tue, 14 Feb 2023 17:54:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED906C433EF; Tue, 14 Feb 2023 17:54:20 +0000 (UTC) Date: Tue, 14 Feb 2023 17:54:17 +0000 From: Catalin Marinas To: Peter Collingbourne Cc: andreyknvl@gmail.com, Qun-wei Lin =?utf-8?B?KOael+e+pOW0tCk=?= , Guangye Yang =?utf-8?B?KOadqOWFieS4mik=?= , linux-mm@kvack.org, Chinwen Chang =?utf-8?B?KOW8temMpuaWhyk=?= , kasan-dev@googlegroups.com, ryabinin.a.a@gmail.com, linux-arm-kernel@lists.infradead.org, vincenzo.frascino@arm.com, will@kernel.org, eugenis@google.com, Kuan-Ying Lee =?utf-8?B?KOadjuWGoOepjik=?= , stable@vger.kernel.org Subject: Re: [PATCH] arm64: Reset KASAN tag in copy_highpage with HW tags only Message-ID: References: <20230214015214.747873-1-pcc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230214015214.747873-1-pcc@google.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: E60B740004 X-Stat-Signature: 3royir96i9y8hw19ry93wucgeej697p8 X-Rspam-User: X-HE-Tag: 1676397264-485156 X-HE-Meta: U2FsdGVkX1++9ZWe7dkWT052stYxNOO3M2iyvtCLaLZI2GUtnxXOMMrszMGHrClLgRYNsxJ6thhRNimpO35v5a3yYgX6nyV5fbPt1AtRGRP+qMVmBaAEXRQvo6bTghT8l09N0Ee/uyOrOjLnvIGf3ynHwOy9p6gML6dwFsQoLMVHHhLvMs3RpBDMBoSEAev72b/DLaf3oTV4B1SP1poDNNl7LcI1XxYfsiSUBJF6B8FieATp1XurPC+l2Zwz0TM4Q3xiP9zCQm+rXg7+sclLT6/k/ybZK7tfgzt8jGdWOSwAaScfqBlSLz0P1f2SghLy45VcLap/huCB3VcGmCRa1E7ypnG6ZtzQnnoc91KKEy1XbF40rG/aXofthZlqOwUZqb8bM0TuqD+fiUPzz3icRoFhXg84Wrvsbr09GTxxZ+CumroGuPqZnFBH/VISiV91yRtMjcX1eup5D2W533jRkMN1tiFME8NezRn75YsISW6VQEePQvJs+QSqADLxEzu0GAsbBDVNr17TL+a/S+H45Koj3JvoIbn+vSMcfGjcByX5G8MY/UYLnBgmr25n0tARTegXtBei8sHH3Q+YHucBc6IsQd70NhEFgnJsbH+yTXiinJ1Qej78w06VwvN2GCguaNHubI/wvv/fDvnoKYFSi9WMWTnhlTwrIBusOi1ad9z4sTKiWF/VMU118uEqwzJrjZeGLKw8035ETsJd8FUezh5ymJm9iMT+OePlirmQuVPhzr8HORRy4xG6bx64nvynKxfvbEVt+NmTskrzbJcVeWAbRxxwpSW8Et/LYKVeuItRFLF3wMFadlWbFISO36gc0Rq/VzQdpxuxm7sEjL6Ta0Pm9KBUQEftthxCvDZN0FXU180ZkJIGtjgHIbJh6j1uHor6B6YXJxu5d/rmPBO5ZW+21762gLfwZU3j0VhM112P0EwN/fgRZGUPGSDOm4eiWf96EuORcHWXBN7OBIm GsHbF7bW IN3PxDSqDOKGqLnWzMwCrksdaWIc1buzY9PV+djKpOBWGWDmqPKvGYF/nln6YlxpJ827XpTeEiWil4Cgw4bIIQ2wmBwLqsUiGk7UZH6CwffJOuPRuCOc4d7cEmHYwmo4DfS68g9o6ogz0AMo4GO6YMAwEg2cD3lmU54+mFdU+ISy5/JdHxhASLSOA5rLONd+ls80huETdR7GJ/j2ujqsPD34e7KlfrsR4ROobLNtAsMP2Z7w7wgZxNbi+s8P3XUsk0Akmbf17TM85LGYLZS5Ei33hsGk8M+NkS+/n8i5pvTgvdFlg5bGSEVeULTMwfA5IdVGhjOtF1nb/j747tvx+f5jvZM2PTJwv40DHx4NKq488cr1cxOdsVyQMfyas1AgX8BYY8cGEaW3+GYuPsozM6m9refa66NlsTAI7VV6/uh0+vmEpzUEqs8LikgHU3/7fluWPG0Bnw+9l0JP4cagVLqTYaxKn9Pi/RZ36zvSRVBzLrDIz+to4JB1FuiKh6U3OLF20VG3OZrNw+z3iN/cEo2YXPYb7IRkpWX3cnarXSvTTGKI34D/CoTpYn8iWBhxYH8RcAkg+cTVSKs2dwVZcp+yK6sYD1imvF0BzP8hMhwSiHp9yagcwkEMsNHGQiSV3zfbeR9bsdHbbxxZGKrQ+qoklBmeES+7usEPaThDymf3NJLj9hnInGwTjD6G0d9irMSvI8O+6zwykcDppfYYAdfFx1w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Feb 13, 2023 at 05:52:14PM -0800, Peter Collingbourne wrote: > During page migration, the copy_highpage function is used to copy the > page data to the target page. If the source page is a userspace page > with MTE tags, the KASAN tag of the target page must have the match-all > tag in order to avoid tag check faults during subsequent accesses to the > page by the kernel. However, the target page may have been allocated in > a number of ways, some of which will use the KASAN allocator and will > therefore end up setting the KASAN tag to a non-match-all tag. Therefore, > update the target page's KASAN tag to match the source page. > > We ended up unintentionally fixing this issue as a result of a bad > merge conflict resolution between commit e059853d14ca ("arm64: mte: > Fix/clarify the PG_mte_tagged semantics") and commit 20794545c146 ("arm64: > kasan: Revert "arm64: mte: reset the page tag in page->flags""), which > preserved a tag reset for PG_mte_tagged pages which was considered to be > unnecessary at the time. Because SW tags KASAN uses separate tag storage, > update the code to only reset the tags when HW tags KASAN is enabled. Does KASAN_SW_TAGS work together with MTE? In theory they should but I wonder whether we have other places calling page_kasan_tag_reset() without the kasan_hw_tags_enabled() check. > Signed-off-by: Peter Collingbourne > Link: https://linux-review.googlesource.com/id/If303d8a709438d3ff5af5fd85706505830f52e0c > Reported-by: "Kuan-Ying Lee (李冠穎)" > Cc: # 6.1 What are we trying to fix? The removal of page_kasan_tag_reset() in copy_highpage()? If yes, I think we should use: Fixes: 20794545c146 ("arm64: kasan: Revert "arm64: mte: reset the page tag in page->flags"") Cc: # 6.0.x -- Catalin