From patchwork Fri Feb 24 06:15:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 13150952 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 8603EC677F1 for ; Fri, 24 Feb 2023 06:17:22 +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:Cc:To:From:Subject:Mime-Version: Message-Id:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=e8lKXIloaTLh/15OvySbrYnR8Qi4UdQ5wQ+4Y0zmQhM=; b=TNA yfzb1qcc9XH4aSvy2tao7oO1wCb5kiJ48THcCs57YZ/vxwPHflpdSc2cRt4+gHqF8MO8qS7BteRO8 db3QnpD5YKh/1HCFzQGbeamxHSBLRnlzl1CXy6Hu+qqpCdn9dS/FIIUIduGsuHpIwpOyhcD3yC5Dg ozwDnV9wxf7iShIQY1Y8XsIPUZTzK3ESYeG+BOqbeflWAFBz5zXVwn554u1vvruUCCdlu22TGMZYd 2ZxbXLRr1voA2LjRT2VU5z2q3JdaIRTfJedgkjbnpmMs35Jbbrx1/CaJSBvvAD0Kyit/SOcQ5gwdA L1lbzBoNr+PEw72x8CJXN8g/M+isdAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVRNF-001K9j-RP; Fri, 24 Feb 2023 06:16:05 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVRNC-001K90-9o for linux-arm-kernel@lists.infradead.org; Fri, 24 Feb 2023 06:16:03 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-536bfec4a66so167303517b3.5 for ; Thu, 23 Feb 2023 22:16:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=DwUBlkJdKPYrehLUGi744iL0IslrZEMB0ydUaeQ3WSw=; b=JlyeV/p0QjEx8SYggR2ieckT3UiY7lDmRK7MzmToATKYoSEkz9Lg+ltSn3alAt+UXu lttz3DIybKvFENCXmSOHi9WbKtrubK/C6WkI7AajUD5Al5Hsw0Nla1iwtk4kXcfeMZIx IiBtEN5nIWIai1s1CS7xSFyFxPLF3+kUjERmbMv6Iclc3b2RlJVVt9tVXokz0/Dpkani RpzEXbuCDo3Z+5hfRoZyrVsEius1sV5JGAXj6mm+jGONUKj8Siwr91app6J/fINIMjZz F2ND/AtvQkvVsdzZEfIT4+iyKMnOXkOmG2Ux/V9JdPltPf4650II1Hd1pcW/NsDlVKYV aVXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=DwUBlkJdKPYrehLUGi744iL0IslrZEMB0ydUaeQ3WSw=; b=6XlKcjJgRNlyhDhu13fxaKvsqpxzC2mB3xpaWTn0X9D7JlTeRtGnjbAZYVsL9Fx5er 4xvrKeTfjGjONwXvrPDjuYxqcsfbX5eOxVp229AprHkeELsJ5pW+98s6tOsx3KlgAwWJ ErbzQYVg/yjUR4u87Ox3qaXnjbOyU0PV1Nzi625pJ3padPbPp/TL2M4HKMNFy6AjFKpC WlAJAEQi/LNFnTxuN92De4HUHRipQAV1SJaoRPQ8YPOxWZFqBH/LgkPQjQgf8QST/jEe 1A+qALerEHrbwqprgD5JOHFCnCeYjaDhG/idAzVf53POqA5hfTnyY+tdjK2UlHDdSmDY 1bfQ== X-Gm-Message-State: AO0yUKWFkZ4zn6uUxolt51dzFtCdIHRa0nJVPKYtuCFnR44VoYTOiOUE QsS8Mw10P+Uiue9JYqYdtpyqH1U= X-Google-Smtp-Source: AK7set980H5+lupKiI0rohV3ZTtUpPk7o29Hq6Ej0eY1Cz9l9P/5Lh8CyHaeEoW2BHDaXSVs1SjuKy8= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2d3:205:d302:b63f:24c7:8a65]) (user=pcc job=sendgmr) by 2002:a05:6902:154b:b0:9f5:af6b:6f69 with SMTP id r11-20020a056902154b00b009f5af6b6f69mr4862249ybu.5.1677219359839; Thu, 23 Feb 2023 22:15:59 -0800 (PST) Date: Thu, 23 Feb 2023 22:15:50 -0800 Message-Id: <20230224061550.177541-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Subject: [PATCH] Revert "kasan: drop skip_kasan_poison variable in free_pages_prepare" From: Peter Collingbourne To: catalin.marinas@arm.com, andreyknvl@gmail.com Cc: Peter Collingbourne , linux-mm@kvack.org, kasan-dev@googlegroups.com, ryabinin.a.a@gmail.com, linux-arm-kernel@lists.infradead.org, vincenzo.frascino@arm.com, will@kernel.org, eugenis@google.com, stable@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230223_221602_402219_4BC6D35C X-CRM114-Status: GOOD ( 12.77 ) 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 This reverts commit 487a32ec24be819e747af8c2ab0d5c515508086a. The should_skip_kasan_poison() function reads the PG_skip_kasan_poison flag from page->flags. However, this line of code in free_pages_prepare(): page->flags &= ~PAGE_FLAGS_CHECK_AT_PREP; clears most of page->flags, including PG_skip_kasan_poison, before calling should_skip_kasan_poison(), which meant that it would never return true as a result of the page flag being set. Therefore, fix the code to call should_skip_kasan_poison() before clearing the flags, as we were doing before the reverted patch. Signed-off-by: Peter Collingbourne Fixes: 487a32ec24be ("kasan: drop skip_kasan_poison variable in free_pages_prepare") Cc: # 6.1 Link: https://linux-review.googlesource.com/id/Ic4f13affeebd20548758438bb9ed9ca40e312b79 Reviewed-by: Andrey Konovalov --- mm/page_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ac1fc986af44..7136c36c5d01 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1398,6 +1398,7 @@ static __always_inline bool free_pages_prepare(struct page *page, unsigned int order, bool check_free, fpi_t fpi_flags) { int bad = 0; + bool skip_kasan_poison = should_skip_kasan_poison(page, fpi_flags); bool init = want_init_on_free(); VM_BUG_ON_PAGE(PageTail(page), page); @@ -1470,7 +1471,7 @@ static __always_inline bool free_pages_prepare(struct page *page, * With hardware tag-based KASAN, memory tags must be set before the * page becomes unavailable via debug_pagealloc or arch_free_page. */ - if (!should_skip_kasan_poison(page, fpi_flags)) { + if (!skip_kasan_poison) { kasan_poison_pages(page, order, init); /* Memory is already initialized if KASAN did it internally. */