Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3542164pxb; Mon, 24 Jan 2022 11:49:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwTxySRSCjrhuiaEqHa+2Qw2m5GGNQzxUZjh6HKCdRgIxSYcF/d2P+2ACDPldCB2CP8hoB8 X-Received: by 2002:a17:90b:1803:: with SMTP id lw3mr3403903pjb.124.1643053751035; Mon, 24 Jan 2022 11:49:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643053751; cv=none; d=google.com; s=arc-20160816; b=lccMy1vKuDy8GTupsRGpwdM/nNMtfzIB6pJAxtZCxfQL4dUpmIuDtS9Fa5EN02E+CI mo2k0be741Z0C8rFVsJ8VvqsOZEO3qNEHCyrZCgjqUXmwlW4symgnSrPAZOXKj30fzoa qRKaw7GBGQ9NSf7j2JV2GrtYVLEA7pLzGq4SJ3eX+lEs1q28C739LdICnFTU/mWcKYlK AbjyMygB58BqBz7HLjVVCMJ+1+Cmtd0XR9wlBaoGakxQj9K5WtEYoLnQSyGkiKxvYU4k ZyNqZx6x8ImYvcEEqp+ryCKMItHknENhP0VYdvsz41WCcR3auhJHRKXhuHQRkm7lgN6T paQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S5E8BX4t2WOGndjQQ7xLiyrqvsQHzLaEF763pxkUAQ8=; b=QaqGdbcoegGQ/lQdV9mNqC0WMTT2K6AxTllxXTNIM11BVPzRE6v02JjwrOJXb4nqLD B2XacpTDgA7xa7e4jT6tAW/XErGI0XgHxPO2y4C4iKJfE33UCZjeXkcIMnNGTmWo+zfg eRzixv5UB3WkUTgglvaBnydpUb0HNIukia2WWQ5V/66lmkfTeZWhPwzzLRaKljnfDTMh VzBW/n6GucHVA4TZD56AbEt2dWUYV/+d1X423UFzLe12+Uu0pj4Khf/n8ruw08twK84o fGM02EmA0KxC7704pqVoLAde9pN5sPgLPYXTP33M0krLS0Tgxqwn7G6mQNQj5wzaNInh kJTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=kLmRezKu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l9si16325062pfc.282.2022.01.24.11.48.57; Mon, 24 Jan 2022 11:49:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=kLmRezKu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244919AbiAXSEK (ORCPT + 99 others); Mon, 24 Jan 2022 13:04:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241754AbiAXSEF (ORCPT ); Mon, 24 Jan 2022 13:04:05 -0500 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 594D0C06173B for ; Mon, 24 Jan 2022 10:04:05 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1643047443; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S5E8BX4t2WOGndjQQ7xLiyrqvsQHzLaEF763pxkUAQ8=; b=kLmRezKuM11MDtsE1TpCxecTN/RV8oqE70/f0WX53dTir1+qa94QpDPJLCimkB9ePGV57A 3MXtGDvAzP7WfW28/bKSDn1uqjGbTczs+DwFuu/aHvskQ2BKOj57p8SmO/GZiufeUkbmag zTmWy8BZ5L+e4bU/XHqfjgoSQ1/TQVs= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, linux-mm@kvack.org, Vincenzo Frascino , Catalin Marinas , Will Deacon , Mark Rutland , linux-arm-kernel@lists.infradead.org, Peter Collingbourne , Evgenii Stepanov , linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH v6 12/39] kasan, page_alloc: move SetPageSkipKASanPoison in post_alloc_hook Date: Mon, 24 Jan 2022 19:02:20 +0100 Message-Id: <7214c1698b754ccfaa44a792113c95cc1f807c48.1643047180.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Konovalov Pull the SetPageSkipKASanPoison() call in post_alloc_hook() out of the big if clause for better code readability. This also allows for more simplifications in the following patches. Also turn the kasan_has_integrated_init() check into the proper kasan_hw_tags_enabled() one. These checks evaluate to the same value, but logically skipping kasan poisoning has nothing to do with integrated init. Signed-off-by: Andrey Konovalov --- Changes v3->v4: - Use proper kasan_hw_tags_enabled() check instead of IS_ENABLED(CONFIG_KASAN_HW_TAGS). --- mm/page_alloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b3959327e06c..c51d637cdab3 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2435,9 +2435,6 @@ inline void post_alloc_hook(struct page *page, unsigned int order, init = false; } if (kasan_has_integrated_init()) { - if (gfp_flags & __GFP_SKIP_KASAN_POISON) - SetPageSkipKASanPoison(page); - if (!init_tags) kasan_unpoison_pages(page, order, init); } else { @@ -2446,6 +2443,9 @@ inline void post_alloc_hook(struct page *page, unsigned int order, if (init) kernel_init_free_pages(page, 1 << order); } + /* Propagate __GFP_SKIP_KASAN_POISON to page flags. */ + if (kasan_hw_tags_enabled() && (gfp_flags & __GFP_SKIP_KASAN_POISON)) + SetPageSkipKASanPoison(page); set_page_owner(page, order, gfp_flags); page_table_check_alloc(page, order); -- 2.25.1