From patchwork Wed Mar 1 00:35:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 13155398 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 D972AC7EE30 for ; Wed, 1 Mar 2023 00:37:15 +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=3AQygXwDErmos8K3KdpxuI2ua2 ciTMas4R9WZ/h1YkWsMhFYGOOqu+AH3LPQwvA9xhSLoFUEBcEKkFaQerVHmgOmEfPkxV8MYd5ohwp Jax7v6LWz1YvRX7yr6p7xu+TZTB9jfXwISIWFSTbYiRrY3+w8522OENIAMMnDzwyr/3S3nmxIJ7WF jBorH8wYaMY8QwhJQPFTQDHA6IvyVY5JoJvemTi/gwEahUisu4cUWUcRdNgwP7juQJgbRVBJ5ZHql wamTVO2N+i6htaQwklQaJ3eS4rOCrAUgcdtjXqKHT3m7rj9YSsS431CzApbM6yoJZld+T2AgRwZXa xu8MLWTw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pXASF-00Ef0s-FV; Wed, 01 Mar 2023 00:36:23 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pXARx-00Eex0-1K for linux-arm-kernel@lists.infradead.org; Wed, 01 Mar 2023 00:36:07 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-536cb268ab8so249420857b3.17 for ; Tue, 28 Feb 2023 16:35:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677630956; 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=N/rvOCTsechIvNmIOTnBhNoi5KZG22HeDohVgUqyzh51PuL1ed75xihZpysMdEVal2 wARbnZTqVLVUT+MMa3aUDPY8CUUtsciF2YtXI8mkQJo1j345YwGk2XVrdfDAeh9ROK6I dW93rejBHlQb9vozFjw+sZUkqGUcFWgkyukVF/jdROyet4Aln11AfIjPFQzQfkpNw5KB /O7No6saJ5dbQS/1E3L3sj7E357ESb11gEZmhJCkcQO/SUK59W1cL7oZha7+GE5qZeln AMYmyJIVmkWpUfAuGf2PT5aaBSj2iqDJNDL0NEqPy9OouRx/udkBAU7pQ7IA5WKbEXgT KjuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677630956; 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=W1s1ykkSWFi9mVtsiW4wRjzhJzds8egYlWBdGePOcUu81+pQUt7XZDtJQGwR5otqgd CHzFBJnqPZrjlDDilqrPspTO18ixWgAdUfubZ2NI578eMY1yc+6QipEep4bbsL0VhCj1 saIX1fZVaN6RtNS1vLHlUu45/jQiQzGASvqORExc523URHAI7vVvSupX/eu2emS38qp7 j1WVKzkoen2WASyYMvUfrsFvTM5QgfjMXCrj/zGWXEi9ZWFbmJaf/jacVSXQoYCiQPWf rrVL6Lklx6DmmoZvS8rFN0q6l7RIwWWlQlyAeCwbFQTyf4Y2RoCJOcDFM/zilMEvDGge TcXw== X-Gm-Message-State: AO0yUKU6cE9vYfGXxZGlCUSRth8eNnFaWFTeyFQ8zH5Xknu5zGA4qFTT mK5kMrTXOnv+JwVCA46OrHAukgk= X-Google-Smtp-Source: AK7set+WnI/8zx0zNX6UuAbKa7eTpm1PBQ2QsJBRGQ8Ke+NGGxZmEk1/EvIgBz5VBsB310OKC9gx0Ws= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2d3:205:cb8e:e6d0:b612:8d4c]) (user=pcc job=sendgmr) by 2002:a25:ec09:0:b0:aa3:f90f:369b with SMTP id j9-20020a25ec09000000b00aa3f90f369bmr193406ybh.6.1677630956042; Tue, 28 Feb 2023 16:35:56 -0800 (PST) Date: Tue, 28 Feb 2023 16:35:44 -0800 In-Reply-To: <20230301003545.282859-1-pcc@google.com> Message-Id: <20230301003545.282859-2-pcc@google.com> Mime-Version: 1.0 References: <20230301003545.282859-1-pcc@google.com> X-Mailer: git-send-email 2.39.2.722.g9855ee24e9-goog Subject: [PATCH v3 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-20230228_163605_088307_178E0B96 X-CRM114-Status: GOOD ( 13.70 ) 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. */