From patchwork Mon Dec 13 21:53:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 12695972 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 C3AE1C433EF for ; Mon, 13 Dec 2021 22:00: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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/ImrjaJYHdCKYoo022u/eVOj03qTZIGKKCMDaCN9TJg=; b=2oWygBHgtilTw/ g3xfs8XEWDjuc+Xsw9zQf89wD+NqpbLXza0wGRpZp/cw0z3dcJ2SmC8Owwimd+g3LhVPih5tRPLqU HnqpGDa2XV2OG5vGpJDG0NR4VTg/mM0bqA2o0DBrsNL7kJZLvvTGG5enwsNlmzOvhkOehj9EJnfuu RyPj1ngA2iFzoVGG0++eRWs0pI6nT6EtKC/Lhbj4abS3hrqj+AjghJN+qDYm/ir5QBwvaqCToN/05 At5rnEuLriaMLyx2Bukl7NB0hbbnvZsi9eA+ZneNbzi9x6wzQoB/ONi5xdtOMRqxvZgEyz8gWOhbl I+Z/uS1h08XuAzTakbyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwtLP-00BYR8-Lh; Mon, 13 Dec 2021 21:58:53 +0000 Received: from out0.migadu.com ([94.23.1.103]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwtGK-00BVoD-9L for linux-arm-kernel@lists.infradead.org; Mon, 13 Dec 2021 21:53:37 +0000 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=1639432414; 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=Fr6Bf66jzLxXXQKqa+ppYstGVfI+tdueVMrHQhxFEhI=; b=xEfGq1qUJKLqSod1Moa3/21+qyDsQIxsI5MWnvKs3DhBHI6gC5D80MvtZouCbsju5vVVMm 1Yqh+PsFnV4FYv5g2m64vpoUKnWNFP0r+2hy4PhtHEda+wVWGmmcf8mtwAaRvws0Jx9/fU a1Ja5mHyWofJaeSbcuBVvww4JMMX74U= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko , Andrew Morton Cc: Andrey Konovalov , 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 mm v3 12/38] kasan, page_alloc: move SetPageSkipKASanPoison in post_alloc_hook Date: Mon, 13 Dec 2021 22:53:02 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: andrey.konovalov@linux.dev X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211213_135336_539430_C10354F8 X-CRM114-Status: GOOD ( 10.88 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 CONFIG_KASAN_HW_TAGS 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 --- mm/page_alloc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2d1e63a01ed8..3dba92accfb7 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2434,9 +2434,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 { @@ -2445,6 +2442,10 @@ 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 (IS_ENABLED(CONFIG_KASAN_HW_TAGS) && + (gfp_flags & __GFP_SKIP_KASAN_POISON)) + SetPageSkipKASanPoison(page); set_page_owner(page, order, gfp_flags); page_table_check_alloc(page, order);