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 65FFAC636D4 for ; Wed, 15 Feb 2023 04:44:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 734A96B0072; Tue, 14 Feb 2023 23:44:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 693E46B0073; Tue, 14 Feb 2023 23:44:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50D2F6B0074; Tue, 14 Feb 2023 23:44:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3BA986B0072 for ; Tue, 14 Feb 2023 23:44:52 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0E6E4AACB5 for ; Wed, 15 Feb 2023 04:44:52 +0000 (UTC) X-FDA: 80468286024.29.ECFCFBA Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) by imf04.hostedemail.com (Postfix) with ESMTP id 57B9440065 for ; Wed, 15 Feb 2023 04:44:49 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=D2G98lGO; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf04.hostedemail.com: domain of pcc@google.com designates 209.85.166.169 as permitted sender) smtp.mailfrom=pcc@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676436289; 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:dkim-signature; bh=aNl+bTrdiuBtPF/dZkoqbIPBqUd172UM9PQytiAg0FU=; b=gks81492zRfSLuKgcB3fVvk9XnY7gnWs/f44tWSrdSLKR1wNycuJzH5rTDBEwu3EB2WbhJ rlUd5I3y2GRonYBQF3wGARx0qm5gsrGtM+PMypfiWsxvCdJKIx0cwR2RhlZcO2nLXBvFBW iSRU0yETeafS9jkfM54VU+Q/Kqz/bPA= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=D2G98lGO; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf04.hostedemail.com: domain of pcc@google.com designates 209.85.166.169 as permitted sender) smtp.mailfrom=pcc@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676436289; a=rsa-sha256; cv=none; b=Lajp5hNkdkFQ8EmVLuRB9wH3fKyJjhZ4Sbc2tX9gSyPKRsmVWp4gcylRCM/x6X5Nu9SWT5 Z/CzbACsno6uL0Dov0tAbrIz5ZFDv5tekbszD5NTSELqlJjzNQr4RyD/mVFCtDdJ+MwrGf WlzvNFeuU2bLcPFMHAWbFh0Pt02WPc4= Received: by mail-il1-f169.google.com with SMTP id g14so444144ild.8 for ; Tue, 14 Feb 2023 20:44:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=aNl+bTrdiuBtPF/dZkoqbIPBqUd172UM9PQytiAg0FU=; b=D2G98lGOMTBRIJ1x4dBdUgWK3SxCQ6sbqqGxh2DD6N68ZaAWWSIt9/4mLjXsykZ6Ob Ii2D0xnzmp90+mjiQV+iNeRXVGivW94q58EhZhrLXYYECTm36G+oSQhPfmkesgRN9YFS 0RKOiLDbSZYKz2uPpIsuUzPCrPOb96rmSG0bz4/37H1byEBDQ6EoY46cVwkDrRIvtgfe 142s7zCy5eW2fILmcrSsiWxsHOKRx1kOibGKDhKXi8+MKpx2EKE1Si/vP3G/IYzwwsUR 8Bm4imKesxjpouqksDJnhHn1y3R6HICkXHEhYOFkiJg1dz5/HIlOZBL281VnI2yA63he 1leA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aNl+bTrdiuBtPF/dZkoqbIPBqUd172UM9PQytiAg0FU=; b=7mmUUhvuNcd32DPiazmEx74Xqxjg42kfAHYcuFkrFXUfZp19FqvP2Nx4uwVGpfEyup Ie6NwSNDmhucjqqfMEIUVVEMYw2wPeiiLcqQoy7NhJMRK98wIUR+hBViq1UFBSl3vuqI 5L8L3FNTxybl8iRtHZebQc74DFmsRz+Lr2SfPmMKiOXxom4gnMaA7qfWm7Ad7V31eQc2 OinQ21cLGdaqbI0zxxw3QyRnzTYyPPU8NrbdXvLih0w1wuk0b+bC8l8TvdjWIJWUOi+T V21mzKBu0Ekuf2WaeeC5QtlDIlQj847xTvzSvsq2V8pgzA2EfajKj0ukMVup5/ExGwR3 g53g== X-Gm-Message-State: AO0yUKVDMqV9nxpL4OVhZG2Rl3nF4KpofqRBo3fk9aO54lVd07p97Lg/ v1g1Z1IbNU6RQqrIlFCFra/GPZrWNFtt4n3O2ChSmg== X-Google-Smtp-Source: AK7set+p76YrnWaluJsyhx7p7Xy30z77TI6rE4c6cpC9xEItMkP2M5yNYdFMFp9zT1lFbOQP62+MsZyqfG85hQMkcTI= X-Received: by 2002:a92:8e04:0:b0:310:9d77:6063 with SMTP id c4-20020a928e04000000b003109d776063mr318042ild.5.1676436288254; Tue, 14 Feb 2023 20:44:48 -0800 (PST) MIME-Version: 1.0 References: <20230214015214.747873-1-pcc@google.com> In-Reply-To: From: Peter Collingbourne Date: Tue, 14 Feb 2023 20:44:36 -0800 Message-ID: Subject: Re: [PATCH] arm64: Reset KASAN tag in copy_highpage with HW tags only To: Catalin Marinas Cc: andreyknvl@gmail.com, =?UTF-8?B?UXVuLXdlaSBMaW4gKOael+e+pOW0tCk=?= , =?UTF-8?B?R3Vhbmd5ZSBZYW5nICjmnajlhYnkuJop?= , linux-mm@kvack.org, =?UTF-8?B?Q2hpbndlbiBDaGFuZyAo5by16Yym5paHKQ==?= , 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, =?UTF-8?B?S3Vhbi1ZaW5nIExlZSAo5p2O5Yag56mOKQ==?= , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 57B9440065 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 3mpykk47pfwtra3t7n1gj9c67ea5oef3 X-HE-Tag: 1676436289-548418 X-HE-Meta: U2FsdGVkX19rE3gmYX9HBKl94tjb68ahv7ItyLpLjxCLHiDAzNXGngqRQBLLsrDqMzI98VQ5NZBI0opZNedyXEkXt02jvDs72OEXWhp79pId3HeipY/Cgx+pQWr2iFp6KWm0CqGxyl84ARj5lPN4pRmKk9FcKF9S+DB2qpcb/KZfIMQEuZRk7eFTQG4Yx8fFG2+syX6oLiP5wQCKDBfrYq7Yk2nM6LXUra97t4/KEUVN6iBCmp/PFOnNQIpbuttMJ6RNBGRQVttyz3M4rfp8lOKdfrfuSNGjOzYEvMIaPG2VVQu4U5EljsNRZeRy+tXhQCHbG2W+qFmmw66VkFHYivwk5Vriwe0+ktRnOMK+OWxOKs9gUho52uWgH+UkZF/In60sHX9Z+bTEAeGR7siXOAlKpuRgqEJH9QJ705T17TVffefj+QGI1yYzoH1VXiSK+jR4gCHPeqC488XWNA19PlmXTDbkgWAmop/2RnmA5KOuF/Vp2bmYvwoB22bUjqkAO9aNN77Ta59u1NPUvoDR88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ufgeKyw== 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 Tue, Feb 14, 2023 at 9:54 AM Catalin Marinas w= rote: > > 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 th= e > > 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. Therefor= e, > > 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 ("arm= 64: > > 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 b= e > > unnecessary at the time. Because SW tags KASAN uses separate tag storag= e, > > update the code to only reset the tags when HW tags KASAN is enabled. > > Does KASAN_SW_TAGS work together with MTE? Yes, it works fine. One of my usual kernel patch tests runs an MTE-utilizing userspace program under a kernel with KASAN_SW_TAGS. > In theory they should but I > wonder whether we have other places calling page_kasan_tag_reset() > without the kasan_hw_tags_enabled() check. It's unclear to me whether any of the other references are specifically related to KASAN_HW_TAGS or not. Because KASAN_SW_TAGS also uses all-ones as a match-all tag, I wouldn't expect calling page_kasan_tag_reset() to cause any problems aside from false negatives. > > Signed-off-by: Peter Collingbourne > > Link: https://linux-review.googlesource.com/id/If303d8a709438d3ff5af5fd= 85706505830f52e0c > > Reported-by: "Kuan-Ying Lee (=E6=9D=8E=E5=86=A0=E7=A9=8E)" > > Cc: # 6.1 > > What are we trying to fix? The removal of page_kasan_tag_reset() in > copy_highpage()? Yes. > If yes, I think we should use: > > Fixes: 20794545c146 ("arm64: kasan: Revert "arm64: mte: reset the page ta= g in page->flags"") > Cc: # 6.0.x I agree with the Fixes tag, but are you sure that 6.0.y is still supported as a stable kernel release? kernel.org only lists 6.1, and I don't see any updates to Greg's linux-6.0.y branch since January 12. I'm having some email trouble at the moment so I can't send a v2, so please feel free to add the Fixes tag yourself. Peter