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: 13155387 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DA5FC64EC4 for ; Wed, 1 Mar 2023 00:36:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05AF56B0074; Tue, 28 Feb 2023 19:36:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 00B9D6B0075; Tue, 28 Feb 2023 19:35:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E15D96B0078; Tue, 28 Feb 2023 19:35:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D41DE6B0074 for ; Tue, 28 Feb 2023 19:35:59 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A05F2A0D21 for ; Wed, 1 Mar 2023 00:35:59 +0000 (UTC) X-FDA: 80518462038.16.C348393 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf29.hostedemail.com (Postfix) with ESMTP id EAB8A120012 for ; Wed, 1 Mar 2023 00:35:56 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="N/rvOCTs"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf29.hostedemail.com: domain of 37J3-YwMKCEk0nnrzzrwp.nzxwty58-xxv6lnv.z2r@flex--pcc.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=37J3-YwMKCEk0nnrzzrwp.nzxwty58-xxv6lnv.z2r@flex--pcc.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677630956; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eey2bWIXShb0HJ2rZd6676jnb6hRL1sBGHfdZHZ/mnM=; b=w4Doax6jXjxBGEPQKuwBnwHdyhZZ9DuC/US881PDwrPGbSt7/lp8yh+OTFlpnp2FwvNf6M UJKQOHtfeiIBxLSZ4PrSLX4EH6f1MJyry6LIyt8YS0potXU9b0jhbRsZu0WYxBjRHnw0E/ zQE/eCKcKUkjhB50g2GiFhDHtLd+NTo= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="N/rvOCTs"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf29.hostedemail.com: domain of 37J3-YwMKCEk0nnrzzrwp.nzxwty58-xxv6lnv.z2r@flex--pcc.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=37J3-YwMKCEk0nnrzzrwp.nzxwty58-xxv6lnv.z2r@flex--pcc.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677630957; a=rsa-sha256; cv=none; b=u0B8BF+FWrPSBGbrJjmm3GisJCD4M59W5SpVJJ2RMWI9I00C1cW7vN+tj4PGANK0OF6tRC XfxVzN5s0TG8St1U9QCcxVaWQE4Ap7DXBINAPz3dD3MfCnXkdJfa8Fr4T5/Mk+ug3uREcZ ulXKmS9UN9GANSU1TOqGtHsOIjFNr1k= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-536c02ed619so249300737b3.8 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=T05PqigQMNwiLze7yR6IrK5/zbAKwxaKczDsO3mluW6WAnGzy+yNBZdoxrCLvWCg2i T4t5eXa8NfgjtO1CHmHN1qdqeETnYJ6igGXDkdcH8LXvmM0W3U3MIKgULGiw4HA2Mgi/ XOnUv4kiN9unZoGf9XKx889yFNlajN5tXQEpWwzQG4xWx4tGT7Sf4HwDWM8IPX9np9pJ ae6j1tINaEq+2tzb4pdIkco6fut5gCeC8tf8GdY4Pt0+WJNxuggJt1PwNVEZ/zt6XmD3 a5tLvOAtsn121fhoczaQ4ir5S7UiJEdwmVmOqKYe9E9YYw58RuR55LP9LhJbvIejEa8A XMog== X-Gm-Message-State: AO0yUKWUhHJHFh445tC7/B0UAr5SHgMa0oHw9Owgv+Gy+mzsC6SvKFV0 5MIfC9JwnPTcLUnUEjHALSGENCk= 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-Rspamd-Queue-Id: EAB8A120012 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 6r96b1q1hwf5ra4ohx8ikpqpip9ui1xn X-HE-Tag: 1677630956-898970 X-HE-Meta: U2FsdGVkX1+GQ6l+2xYyaifFxyh5z/BhTCxn0P9yx8elEca/Kz3Kxw1b848KRf0Y2MYIyo3Fe9wKQkuAGf41JRZMZucts1NJ33D8RIlAqQeA/UT36qNtWHi6S00sQO/saw4Gmoh7mqPsAhrm0Vt0J1v2z0n7RAZjcnrHz96pkr20yVm7HFy74CSd5gqwSV+5lY//mQqq+r5rdcz/xwcwPO4UqOdZxwjgHmNmvs7zFwWzv6qhGvnYdX7b2tB5RxrajPJmLvNsKwIiDbQxp7jxVQzdRerWI4ID1auwYRUIhn1+tBIytThb7IzpImEXrpNoJo4Ql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fucjV1zqf9u2oFUzAB0mYBgTTw2XsZwAd18bvkm0leflvPk9Y01DrSs+Y6ln0Sv5g60t8sJAFt2hit4z+K/FSimqlAeIYFmtQoy1TDaSoqu9L1kNwPrM971I5e4AsLlxgkLYpi7xE2TtpfZPwvo02i2tuHdARlQ6Ki1e128HMP6r2AswUBzCPppdTCgWDOQmBDv+5/DPlM3I8sQB3d3KaXLpViKvShrtS4c/ZnwCH83t0pqO+1ggCPfAlE0eEWhxpjZjGkxGoug1ZdwyK4HFL7oKpwUTUCPSv70dNsPLO8eZ5Buw3KxfUc/Vy+q48STPra+Ta+pjZKDQ8S+lsnGC0C3ZDOlxWfwhVSnUQeJm/7lCcONdSdFGyVR4P9+Kfpaw2tbxN+ZKSHa/K37QwtOUGVq9BYWJD6zB3tqkgFFXcOCf1mq7FI3PQqNx17mTmmGsAX/5HTw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. */