From patchwork Tue Feb 28 06:32:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 13154444 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 B1546C64EC7 for ; Tue, 28 Feb 2023 06:33:56 +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:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=0YqYcVnOAJTtrzs9+9usumm6RCSvEbryUAv7TyE1IN0=; b=ell0nvGtsJWThkgVqyNNowXUCz jXjn1/9PgskyojiwhuE1HItcoSKy+jfdZPYxIICMejAj4KQMS0vh8c8xwBlIqZR/WWkWvqH11na+a NOEONZa5Ft3m9Bd0uj38s0ItIF1rVV1x8hD4HY7JP4KrP1VTE5HBj54gV9swGjiCKyssjBYyc2YaV nviZUEMyDmP9sOsaKSkim8ooHRiNzX4FoCPXByCwh/cFF4XXWxwZRuvgZyqChaDnxtlx3jnZ/8MM9 U+Zw8QgbOOBB+5l9NQvye3hxhriMhnURB6GN51wLmbnadtktvHZxqzxXzj2ukxOjogRuAAEavIFky 4BgrCt0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pWtXq-00C9aq-10; Tue, 28 Feb 2023 06:33:02 +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 1pWtXg-00C9Y7-Ek for linux-arm-kernel@lists.infradead.org; Tue, 28 Feb 2023 06:32:53 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-536b7eb9117so191045227b3.14 for ; Mon, 27 Feb 2023 22:32:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677565971; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=eey2bWIXShb0HJ2rZd6676jnb6hRL1sBGHfdZHZ/mnM=; b=exeEIY5fWGlcZGVP7LYpH20VWXe5Zd74N5MibMoNaGhfte0/m04wncsgkZ42c81G9u xjwSkbxN7lhKJw3/ZFJ330YJlKsDgfyX/pKH51okzeWO026l5lbQ+rBHN+YqTVoP8rHl Wk7FGb5O2F4gadUDHuF7XtjdA7lEYjFJOyhol0bSWbjAuVG6LwYUtM6TVxhR4UWI2vvE ygXcb6MhUbYAD0IPZ9mgdxdOC0NWpPGNq+N6hidb1kFjVoRDXSpvbF8s7I9f73F9DW/T HeIP7KXQ+Ci/dbBH8Y3O4rh6lswmAGQ71d2MsJoj8ViqLp7nuN3tp2j/0oBV85TCiKG8 xFzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677565971; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eey2bWIXShb0HJ2rZd6676jnb6hRL1sBGHfdZHZ/mnM=; b=WgFxlB98xBOiCoUlMN3xfu2ZGymZys/yvXPBETNy3ccVr4bR8GtHHxQu+to5yAfcTb 1VgTBLO5ezdQBgnnEznti3CFkBsYmMqdIypaziYVP/tYotsvyrLsipCdvHuECDHMBvfp EVF3wH7muRuPjdj/UuEIxB/Ckyhulf4HBE7zaxZnoXW6r7gT43kagoJ5f5ABccKIVKSR PG9Qwh+/NSaxyPeAlX68Gj3twKqA6oOXqFSKOb21DDge2Ck4V4JpfPTulwcFFbNyJU0n KFJ7vPtBJ2wAWVNeo2yW6Uex/TyjhJoCugX+GsgnnE49pywE4VtbNLDQsWHoaf3WCZma LE1g== X-Gm-Message-State: AO0yUKUhRL9xjywklsgEy3PxpSQo0W6QYzm/2dtug+QQ5HFOsa6eQ/Qg GT16r2LCpJa+61DwwWj0JSDp7Cg= X-Google-Smtp-Source: AK7set+57JSpmmONJa+F5jArhG3H6DN81OBajRlOxhpKK//us3HrP9vQLt/cDaarFzuIYJrI34YHm6Q= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2d3:205:cb8e:e6d0:b612:8d4c]) (user=pcc job=sendgmr) by 2002:a05:6902:1388:b0:855:fdcb:4467 with SMTP id x8-20020a056902138800b00855fdcb4467mr1957716ybu.0.1677565970984; Mon, 27 Feb 2023 22:32:50 -0800 (PST) Date: Mon, 27 Feb 2023 22:32:39 -0800 In-Reply-To: <20230228063240.3613139-1-pcc@google.com> Message-Id: <20230228063240.3613139-2-pcc@google.com> Mime-Version: 1.0 References: <20230228063240.3613139-1-pcc@google.com> X-Mailer: git-send-email 2.39.2.722.g9855ee24e9-goog Subject: [PATCH v2 1/2] 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-20230227_223252_513107_F9C58DCF X-CRM114-Status: GOOD ( 13.67 ) 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. */