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 13132C05027 for ; Fri, 17 Feb 2023 10:05:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77E7F6B0074; Fri, 17 Feb 2023 05:05:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 72E0A6B0075; Fri, 17 Feb 2023 05:05:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CEB06B0078; Fri, 17 Feb 2023 05:05:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 4F30C6B0074 for ; Fri, 17 Feb 2023 05:05:15 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 26A8281656 for ; Fri, 17 Feb 2023 10:05:15 +0000 (UTC) X-FDA: 80476350990.04.70ABE30 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf25.hostedemail.com (Postfix) with ESMTP id 51665A000E for ; Fri, 17 Feb 2023 10:05:13 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=i7htHyT0; spf=pass (imf25.hostedemail.com: domain of andreyknvl@gmail.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=andreyknvl@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676628313; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xgo06j9ahnzor5Mr6mVoN2N31xaczjU8L11cr2e3IBE=; b=ctffK1d6vOfJt1wmwWJimH5sr9SDyqlq0n8GUWtNBkta7ddrSHzyIDsuEHz6cGjmTqkh8T wvPQgRDBXK7JzAcJL6836r7F4DgDOpZqwCILzyisySQ3Zm0xrYWu4CeOCrZ9kiQQ/fAnhj DiG5htM+07QgXyuZ5KovSADnc4GwjKQ= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=i7htHyT0; spf=pass (imf25.hostedemail.com: domain of andreyknvl@gmail.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=andreyknvl@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676628313; a=rsa-sha256; cv=none; b=KHtfMaPIiVosT704EyDBC7pKliHZK/N7wFTikg4HK4JlmwyVShFdGKk1TsRRWORlnZx0Qd HqwMEVm8VPbaiw3/D3A9acy9IHjbRoTA/Ovjp8aM4TbdTKDTkKAWR8iHdveNri9jmSvfru RDoZUds1nXjC0QWp5q30mNx6vkENFHo= Received: by mail-pg1-f173.google.com with SMTP id k3so446439pgq.3 for ; Fri, 17 Feb 2023 02:05:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=xgo06j9ahnzor5Mr6mVoN2N31xaczjU8L11cr2e3IBE=; b=i7htHyT0x/ZVkHVFb7jVG7XxuWs0FA9xl+1C1AipGHVQ3ak+FpFRGJp/CeoDZaWj8Q G4rs+DEZIQZe0xXmgSz3fOx6Y1BK0tecqpI/9D3xtiNxk7fvST2VboeM6hyBRn4QhLUO LVE4dGTvgCBjF/tl9wourWjp84dvb2RHT8m9jhxMLn9mZIQpjw4h0MldRKnKURuKr0Jo UlJtuc8neVHymBEYzUJEPYEyQngNZH6iwQ5eflG1rPFzVhNI4AJSIU+A4yav6BEhjtyp WkS5HYEqjhE+DuqF2s5h0Hfvz3QFiV6WoHgfvny2YUvKp9Y/Y4Q8My6bEuDI932nlGux epOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=xgo06j9ahnzor5Mr6mVoN2N31xaczjU8L11cr2e3IBE=; b=WIm5K/Rkv1bex9zj/lblkRRlmXbTeg8XnfGznfpSJbt+YiUVNEmxtIBhIuQrqAlDHT 1dvMkphWAPzfgCC7+fzFE6Okucu4nie+oE1KPZme+JbPF7f/zrHbv8TwciL2fR1N3yLs xNEpFira/f6mJ2mWXpGOTH/NoO2oOfoTLhCWPVdy/3mS9vDxRnZzY6Dm1GQVmHwlRFmz Z5vIeX9yM4qxqJFF4ipXZsRy/byev5z/ZnpmDjro2v5I771sHn+lLLOH4fm2lxkvEFRB ju5v6lzNcpggNE3PXUtds/VBiIGxn4gzd3icS/FU/sZ0tS6ZYhs28JqXwvwEAqa4P9c6 Y3Jg== X-Gm-Message-State: AO0yUKURrUox8ix9U3qPDffs5FBJPv2aiy/YvDCYljlFw0dO8ZZw7bUk 2UjBCzEAwVDNNjF2dSUMSsGq1x36ZmkRADpguz4= X-Google-Smtp-Source: AK7set+RWZOPMzd39MoBeQ74y8NdaYRMTr1w1yYrhc2pNVe/5/Nxb18l5XRIKUqk3HkhJK85HyHSrVeDTQt/adskIaU= X-Received: by 2002:a65:6050:0:b0:4f1:1bbc:be70 with SMTP id a16-20020a656050000000b004f11bbcbe70mr687528pgp.6.1676628312200; Fri, 17 Feb 2023 02:05:12 -0800 (PST) MIME-Version: 1.0 References: <20230214015214.747873-1-pcc@google.com> In-Reply-To: From: Andrey Konovalov Date: Fri, 17 Feb 2023 11:05:01 +0100 Message-ID: Subject: Re: [PATCH] arm64: Reset KASAN tag in copy_highpage with HW tags only To: Peter Collingbourne , Catalin Marinas Cc: =?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" X-Stat-Signature: iwffs1ua34d1rbwhkg4meq9nhu1jerfn X-Rspam-User: X-Rspamd-Queue-Id: 51665A000E X-Rspamd-Server: rspam06 X-HE-Tag: 1676628313-494200 X-HE-Meta: U2FsdGVkX186eFsoh2I95NrRpDdisdL/avvGIphdySyi1I2gZy2WB2t0oPKT58TV/RuWlKprH3F8j3ueiBQHDXl7bO6q5ZPee5itpTw9JAFEHGitr+sJWZ4D9YEZBIhNZYpk8GOO+e2QNjiLKwcuRY2kxUcFd2FiJk0dIbEg2DsPG6jrbT5qIVGGc3/+MJAne4RJCNTRbf4dz2iFqq6Y74HRr7V275W8bUTIrMhBZobsqQ+VBRCTQO2UCbsUR8r7Bny8FU44yjHTFHBXEqkgPIIYjJ/fT0FxYGU/feEL+y6wBQrik0O8ZtY55PcaiFmlPXyhVPFCUwxORpUx0/V4YJG/TSRrkaarIYaU9yRrAVloYDDazsJH/a6vFXuqH3THT5WaioT/g/6hET/iZ1pklzN40ftDuWpp31W6drAmIgvFDnUwrg3xx6lQZa0cES6LO0shpYMSAoU7jLLLQNg5ty9ZvykfGG9IUD37WRJWeb4FU8AGKmO237wyLL0dC6xKZngNjDVH8CtIMT7GDtiJYcq3WYhCkzxdKqvfM+SkS5oL9ZBC7FyQd92ZPe4FDLprjrmOPyBB5B3n6pA4W+DcVGSY919mSBGVzR2XqbUDtRcOEVD4cyVYgW6XSeqE464u5+moOVNEG+wVNWf6cHBDT3Aih06Epa/HGkMoSK4D/CMgFTacnF8FalwQPmFgMdUxTQrwNF4sewLsel8/+2cGaIQ673kqrzw0fcThnbV2rsUxncfq5cLevDZCk0sFWdiqDVf1HBn9WxJtDWQiSlkvfVbgtRVKD7yMgstLiAM4hCcL9uQDFGnyswDhz5JvyUc9kO9ptH7/U/mg5+Lcf7ODCl7GsguUgfZ+qFKM9tUm0ZylTFbSEMXvx37XQoiIAUrPgraPetnbRwppgM0fbpLTNMV3P4AU/9n+2FtxnQre6hfLkPk+OQLOm//CaPZO3ImiCEAce5t2g3E/HuYXuo9 qF/uhVK3 6I67v97GAUc5d+ElE0xeiIqnmafy2Qye7M28wBHVllz2LiV5WwhpcLF1LsaS5yaofMBquaObowzIv1wwucYhUY4hNe+ezUBcOPqZu6lBUvSMagwJcB4UH0IRucIqgYLxcVfpQGHBy1g+RxBfvPZBRe4xRLEYyB8Pqyc/N2ARTwOv8GiexN0ewJvMjyHsCk5de3sQjiCWqpK8dUzMuOvRB8U6NP+H/JIrLSAEH7o+z2QoUg6TXg96d7GysHiR2wEOQnV+FkicMRJ7JkcIvAatvx19nbUN5bHwvq3pI/BdryBiAeqacZWmiQd0ozeWJy47u+P+/4DXOA+1w/dHtlRRWhXRHkmV5A877GD4XvRjv/mGRkQ6aapdoABeFigQbqcXDHx7PaNl4mdVbksnzFWwKKS+jHTtpiMH5ApeYpwijciHzDyyRKYE0GICc261WApu0oKgoULQvEiliWXb2+pyxDGzb5U9joSqPj70iKUoKdVrijuwFdh4FCneQi6KEdzxfS26E3XbTzwHUlrCUO+JMXPq3qMUhPQ4wlweS+5MlY7y4WQjfbXwg2i7WhPynoRP9FEMP 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 Wed, Feb 15, 2023 at 5:44 AM Peter Collingbourne wrote: > > On Tue, Feb 14, 2023 at 9:54 AM Catalin Marinas wrote: > > > > 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? > > 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. All the other page_kasan_tag_reset() are related to both SW and HW_TAGS.