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: 13150948 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 AE488C61DA3 for ; Fri, 24 Feb 2023 06:16:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CACED6B0072; Fri, 24 Feb 2023 01:16:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C5D9A6B0073; Fri, 24 Feb 2023 01:16:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B254A6B0074; Fri, 24 Feb 2023 01:16:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9FAE66B0072 for ; Fri, 24 Feb 2023 01:16:03 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6F5A812152F for ; Fri, 24 Feb 2023 06:16:03 +0000 (UTC) X-FDA: 80501175006.06.A7C8D9A Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf13.hostedemail.com (Postfix) with ESMTP id B966C2000E for ; Fri, 24 Feb 2023 06:16:00 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="JlyeV/p0"; spf=pass (imf13.hostedemail.com: domain of 3H1b4YwMKCNID004CC492.0CA96BIL-AA8Jy08.CF4@flex--pcc.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3H1b4YwMKCNID004CC492.0CA96BIL-AA8Jy08.CF4@flex--pcc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677219360; a=rsa-sha256; cv=none; b=odmqtLcqvN2aVnffeBmRucO2AfxbVXxi5jgUHT6G+A1/n451w0HoUWCL0K1SPHkJNsxJH1 gpBxxNv/wjRu6vb3LUNGp/P+d7PpoPXyGz9UmOduoeJpvhP8hLDf+OF6O6O2lZeLNkpwDJ iAM+CuanuDcA7wAqzBPh5TE0Cq5+DCU= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="JlyeV/p0"; spf=pass (imf13.hostedemail.com: domain of 3H1b4YwMKCNID004CC492.0CA96BIL-AA8Jy08.CF4@flex--pcc.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3H1b4YwMKCNID004CC492.0CA96BIL-AA8Jy08.CF4@flex--pcc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677219360; 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: references:dkim-signature; bh=DwUBlkJdKPYrehLUGi744iL0IslrZEMB0ydUaeQ3WSw=; b=1D9cBfQcE9bQBISSQEsIXKvE6TJstCSOqDMlcJn+A7vJQWn/MRoRAHnJzmYme4o3GDi79f PoxmGO2/oLy38e0xShctHCQuJ97ewsHbxi+mp38PhAQ03uIPDnd+ox5Vnum3QhgpjWOHQM 80hJxJb1lXyatRAaVa6MX4lV/625mHk= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-536a4eba107so188893807b3.19 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=VzTTn6fSRjJQNrbl+k1nv7+RrsVfWbGfvSiBB/6PBeENRefYxYCUkhxec20Q9duqRl iNsEtbqz5VTGoNLd8le85N0KW/aaE5uHdHiFRDKLWn4fQbz+cYcang+FaprPCE7nUnyq aWIraipeX7x3K+cmTTnRIEH8G17nppIbZ/LONa2gfYa0SZle8DD70NcLpt2vZSG+n8Nr lSqjozMr3fP/sgcNKLXlHycMWHS8D5zA1khAJ2B92l+4y/3POJe9CHj8myZy8XqCDfBX 4SRjF1ynTqP1cE1cx5yZUUE8wrmOULQF7zPZJyJWIaB81V0mlyrDz43JfKnWq6xonQD8 uuvQ== X-Gm-Message-State: AO0yUKUp3RZ1zLkFC0CFACanmeY3qMBwFAuRqxwBQaRYq7VkWciQhVCX BnmdJG94MOKWcY6qBhW43Zw0SH0= 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-Rspam-User: X-Rspamd-Queue-Id: B966C2000E X-Rspamd-Server: rspam01 X-Stat-Signature: p3o9y9o1tzs7dymx5en43jiyoerbmg17 X-HE-Tag: 1677219360-244967 X-HE-Meta: U2FsdGVkX1/tZXHvoWFqQAkbZCk+iCJHR3NwvlDpb+Loz0WdXTyxKtg9ABZvoezr4226YLBtj6Kfd5HEDjqUGD1xMXKhEIZkbH1BZJxAh/blD7AK+5+FiiKMTv4P7ipF2LPJJ3iok6or+vu9DbiuEP18IYCsSlcS3/VSq20joy8oae1/ze9quITWqXS3mvQQx8KeC1025FeTpGBcE8GKDHoa2LnIzGcHmh7rYvrYafi2f7bLbWGbsivIyfEoMC0ogeTjhYSIzILluHfto9nlbL0OUFX3axecTkJX7cHI8C8yrgFzqp5mjHyI0cRC0UNrTSIu9Ra+wwqUz/gBCEN7ufupNPoXRFvxUneTz3/48gnMfIVWZETtGBKlmEZJU/iXbSG9ShvwNHAwdDX5gQN5ogIegCaN1w2DHuynZlvPeAfphJMqwVrU8ydeSA1ZlLxWfIsKqGnsudVXbFQeVL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ZQjQMYLENN0ambz2wILDgHP8Skrxjr8mzFKOK4qYi9f3+vQvP+r7BjhzpWRyM02DsgtGcjUU2ecT5A7SdSuxTBXZFqB/RaqVBBG7BwTDBq8TDI9PjTAeAUatk+7jRiilaG0povPtnuKzW0BBejdZm5a29fnZj+7T8O57ioWD0rrPKcePtJRDFESx0dhTgMEoz0GsGHNqwjb96hIat1UEpAZMd87CqRYgDaVE5RG1dJb0UmXLD0NB6rMjeqi+BWwo7Hcm8JznOKLZ2S57ojqPjAA/eVJvU7tLljwgK9g== 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. */