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 4C6B8C433FE for ; Wed, 25 May 2022 15:46:23 +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=tXLGp8Yml2wRw+hb+hOQOITNrPE6lHrExyguwmrI0sA=; b=F/njUpX//Yo7yy aDglpO7qWyhQVPtqFyJZ5qLEnjvvLpTAhGy9bZOvv2/EFUu/C3hk+vEU1H1dUA8U37A6kDDaGDIk+ c4lt2vifnI9QsZSrWSPmHO7HXVjDyejubATQ/ivWxemUI9cwrUGnMAr9Ri6MX13Lix2tSHiizWuOq 0HqYZdiHRu2elkTVFG//o8lZpH09JKgC5J0mqAqX8QUb3hiLzmPXYYFHuyyGM1UmylrAyyBStlHH3 nQqaqd6ukUiUUyBBDhiwdT2zn8lQq3zyUE5op4xSzLjF3iuqvAGjsqC4pdKuzsQcL5m+vbNyVGgXK R978RC+tEqMxhQ4ks6jQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nttCG-00Be2H-6A; Wed, 25 May 2022 15:45:16 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nttCC-00BdzS-Fk for linux-arm-kernel@lists.infradead.org; Wed, 25 May 2022 15:45:14 +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 2443EB81C3B; Wed, 25 May 2022 15:45:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59743C385B8; Wed, 25 May 2022 15:45:08 +0000 (UTC) Date: Wed, 25 May 2022 16:45:04 +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-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220525_084512_698109_A276373D X-CRM114-Status: GOOD ( 29.14 ) 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 Sun, May 22, 2022 at 12:20:26AM +0200, Andrey Konovalov wrote: > On Fri, May 20, 2022 at 3:01 PM Catalin Marinas wrote: > > > This will reset the tags for all kinds of GFP_USER allocations, not > > > only for the ones intended for MAP_ANONYMOUS and RAM-based file > > > mappings, for which userspace can set tags, right? This will thus > > > weaken in-kernel MTE for pages whose tags can't even be set by > > > userspace. Is there a way to deal with this? > > > > That's correct, it will weaken some of the allocations where the user > > doesn't care about MTE. > > Well, while this is unfortunate, I don't mind the change. > > I've left some comments on the patches. Thanks. I'll update and post at -rc1. > > > > Since clearing the flags in the arch code doesn't work, try to do this > > > > at page allocation time by a new flag added to GFP_USER. > > Does this have to be GFP_USER? Can we add new flags to > GFP_HIGHUSER_MOVABLE instead? > > For instance, Peter added __GFP_SKIP_KASAN_POISON to > GFP_HIGHUSER_MOVABLE in c275c5c6d50a0. The above commit was a performance improvement. Here we need to address the correctness. However, looking through the GFP_USER cases, I don't think any of them is at risk of ending up in user space with PROT_MTE. There are places where GFP_USER is passed to kmalloc() for in-kernel objects that would never be mapped to user, though the new gfp flag won't be taken into account. I'm ok to move the new flag to the GFP_HIGHUSER_MOVABLE but probably still keep a page_kasan_tag_reset() on the set_pte_at() path together with a WARN_ON_ONCE() if we miss anything. > > > > Could we > > > > instead add __GFP_SKIP_KASAN_UNPOISON rather than a new flag? > > Adding __GFP_SKIP_KASAN_UNPOISON makes sense, but we still need to > reset the tag in page->flags. My thought was to reset the tag in page->flags based on 'unpoison' alone without any extra flags. We use this flag for vmalloc() pages but it seems we don't reset the page tags (as we do via kasan_poison_slab()). -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel