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 3BEF5C43334 for ; Thu, 7 Jul 2022 11:45: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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kaXwgFhL9ilwru/wRU9i1OxnPku7nRTCshkw5o1sYYo=; b=Ok9wPvxp0xF+ET c4Td/uTTi+AmQguADklhyLDvCVrVGZkLyFPYCYq9xPdA7JyTA7H7DozEXG3K+ehlkfWfUJk9jNLl+ 2NhEQGX/2JtzlTYbFZFaMqoQ43Kpo7nwRPA2HP3JO5Ws3l6HaTc7Z6/2076MigMLYGcR7nWNvsV8s NQjKDgIEXWcKTHZd0H+HZjN4Nc73nc+Zb7pPCF/WdzOB6JJfGkfW+e6ccgZacLb5fPA1n7hL8PNC5 uCwm9VzoX7KRaieCgA/StmLkdwbXr+49BKxn0xIXIY7Pj6ExhTP4I6Nlqh/9Zto38M9xmVzEV06IY 7IT4jkZq2WepNKAz6yWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9Pw0-00Fs2W-KU; Thu, 07 Jul 2022 11:44:40 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9Pvx-00Fs0w-6Q for linux-arm-kernel@lists.infradead.org; Thu, 07 Jul 2022 11:44:38 +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 ams.source.kernel.org (Postfix) with ESMTPS id 9B686B82139; Thu, 7 Jul 2022 11:44:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EE3CC3411E; Thu, 7 Jul 2022 11:44:32 +0000 (UTC) Date: Thu, 7 Jul 2022 12:44:29 +0100 From: Catalin Marinas To: Will Deacon Cc: Andrey Ryabinin , Andrey Konovalov , Vincenzo Frascino , Peter Collingbourne , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 1/4] mm: kasan: Ensure the tags are visible before the tag in page->flags Message-ID: References: <20220610152141.2148929-1-catalin.marinas@arm.com> <20220610152141.2148929-2-catalin.marinas@arm.com> <20220707092236.GB4133@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220707092236.GB4133@willie-the-truck> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220707_044437_402033_78231A63 X-CRM114-Status: GOOD ( 24.24 ) 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 On Thu, Jul 07, 2022 at 10:22:37AM +0100, Will Deacon wrote: > On Fri, Jun 10, 2022 at 04:21:38PM +0100, Catalin Marinas wrote: > > __kasan_unpoison_pages() colours the memory with a random tag and stores > > it in page->flags in order to re-create the tagged pointer via > > page_to_virt() later. When the tag from the page->flags is read, ensure > > that the in-memory tags are already visible by re-ordering the > > page_kasan_tag_set() after kasan_unpoison(). The former already has > > barriers in place through try_cmpxchg(). On the reader side, the order > > is ensured by the address dependency between page->flags and the memory > > access. > > > > Signed-off-by: Catalin Marinas > > Reviewed-by: Andrey Konovalov > > Cc: Andrey Ryabinin > > Cc: Vincenzo Frascino > > --- > > mm/kasan/common.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/mm/kasan/common.c b/mm/kasan/common.c > > index c40c0e7b3b5f..78be2beb7453 100644 > > --- a/mm/kasan/common.c > > +++ b/mm/kasan/common.c > > @@ -108,9 +108,10 @@ void __kasan_unpoison_pages(struct page *page, unsigned int order, bool init) > > return; > > > > tag = kasan_random_tag(); > > + kasan_unpoison(set_tag(page_address(page), tag), > > + PAGE_SIZE << order, init); > > for (i = 0; i < (1 << order); i++) > > page_kasan_tag_set(page + i, tag); > > - kasan_unpoison(page_address(page), PAGE_SIZE << order, init); > > This looks good to me, but after reading the cover letter I'm wondering > whether the try_cmpxchg() in page_kasan_tag_set() could be relaxed to > try_cmpxchg_release() as a separate optimisation? I think it can be a try_cmpxchg_release() (I did not realise we have one). I'll post a patch later today. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel