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 2A0AFC43334 for ; Thu, 9 Jun 2022 18:32:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A4E908D0040; Thu, 9 Jun 2022 14:32:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9FD668D0034; Thu, 9 Jun 2022 14:32:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8ECD98D0040; Thu, 9 Jun 2022 14:32:53 -0400 (EDT) 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 7ECB28D0034 for ; Thu, 9 Jun 2022 14:32:53 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 53E6535A38 for ; Thu, 9 Jun 2022 18:32:53 +0000 (UTC) X-FDA: 79559543826.26.A30BC0C Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf04.hostedemail.com (Postfix) with ESMTP id CB41340068 for ; Thu, 9 Jun 2022 18:32:52 +0000 (UTC) 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 ams.source.kernel.org (Postfix) with ESMTPS id 74E07B82FC7; Thu, 9 Jun 2022 18:32:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68B3DC34114; Thu, 9 Jun 2022 18:32:48 +0000 (UTC) Date: Thu, 9 Jun 2022 19:32:44 +0100 From: Catalin Marinas To: Andrey Konovalov Cc: Andrey Ryabinin , Will Deacon , Vincenzo Frascino , Peter Collingbourne , kasan-dev , Linux Memory Management List , Linux ARM Subject: Re: [PATCH 0/3] kasan: Fix ordering between MTE tag colouring and page->flags Message-ID: References: <20220517180945.756303-1-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1654799573; 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; bh=W3NEPlZRtdoJE5gZr//+f3onrus2x6Ltw/Knl3Z38go=; b=PzVYR62tFE62lYidEkIIkW8mAxNZmGnxUBvzl8IF/zp+gAwPD1G7wpydTrvzOrA51k3gja wgTU19HizbpRqMN0ccs81cqmaCDb29OENvl2mk06CNOIjpMf4s+Xe+W3bItx8I5I8G83Dr 3YafLWFJsqCQXcAX+kg+9YQTGrMtHs8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1654799573; a=rsa-sha256; cv=none; b=apsZus4tSDzTAoaqpCFa7ANp7+QZpsD5sNBpd3XRVyJzYv93NzAiAp6fe7kZd667tCjKOl u+bbVFo1h9Blfy1BqwBUhDIi8gH2YnC2pEBH7uBthH84+0A5XAKsaAuhRSvvXU/ECoqt4e h6MqWzayo5uYeGifaOl6kXNWoCN/g+Q= 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 145.40.68.75 as permitted sender) smtp.mailfrom=cmarinas@kernel.org X-Rspam-User: 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 145.40.68.75 as permitted sender) smtp.mailfrom=cmarinas@kernel.org X-Rspamd-Server: rspam03 X-Stat-Signature: ozwxgwpoyiwrqpdae58z5mst8nwbkouh X-Rspamd-Queue-Id: CB41340068 X-HE-Tag: 1654799572-177243 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: Hi Andrey, Sorry, I got distracted by the merging window. On Tue, May 31, 2022 at 07:16:03PM +0200, Andrey Konovalov wrote: > On Thu, May 26, 2022 at 2:24 PM Catalin Marinas wrote: > > If we skip unpoisoning (not just poisoning as we already do) for user > > pages, we should reset the tags in page->flags. Whether __GFP_ZEROTAGS > > is passed is complementary, depending on the reason for allocation. > > [...] > > > Currently if __GFP_ZEROTAGS is passed, the unpoisoning is skipped but I > > think we should have just added __GFP_SKIP_KASAN_UNPOISON instead and > > not add a new argument to should_skip_kasan_unpoison(). If we decide to > > always skip unpoisoning, something like below on top of the vanilla > > kernel: > > [...] > > > With the above, we can wire up page_kasan_tag_reset() to the > > __GFP_SKIP_KASAN_UNPOISON check without any additional flags. > > This would make __GFP_SKIP_KASAN_UNPOISON do two logically unrelated > things: skip setting memory tags and reset page tags. This seems > weird. Not entirely weird, it depends on how you look at it. After allocation, you expect the accesses to page_address() to work, irrespective of the GFP flags. __kasan_unpoison_pages() ensures that the page->flags match the written tag without a new GFP flag to set the page->flags. If you skip the unpoisoning something should reset the page->flags tag to ensure an accessible page_address(). I find it weirder that you need another GFP flag to pretty much say 'give me an accessible page'. > I think it makes more sense to split __GFP_ZEROTAGS into > __GFP_ZERO_MEMORY_TAGS and __GFP_ZERO_PAGE_TAGS: the first one does > tag_clear_highpage() without page_kasan_tag_reset() and the second one > does page_kasan_tag_reset() in post_alloc_hook(). Then, add > __GFP_ZERO_PAGE_TAGS to GFP_HIGHUSER_MOVABLE along with > __GFP_SKIP_KASAN_UNPOISON and __GFP_SKIP_KASAN_POISON. And replace > __GFP_ZEROTAGS with __GFP_ZERO_MEMORY_TAGS in > alloc_zeroed_user_highpage_movable(). As above, my preference would be to avoid a new flag, just wire this up to __GFP_SKIP_KASAN_UNPOISON. But if you do want fine-grained control, I can add the above. Thanks. -- Catalin