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: 13154441 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 68669C64ED6 for ; Tue, 28 Feb 2023 06:32:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EFA156B0072; Tue, 28 Feb 2023 01:32:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E86936B0073; Tue, 28 Feb 2023 01:32:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D4B106B0075; Tue, 28 Feb 2023 01:32:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C5D586B0072 for ; Tue, 28 Feb 2023 01:32:54 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9B23F1610E3 for ; Tue, 28 Feb 2023 06:32:54 +0000 (UTC) X-FDA: 80515732668.04.F50D876 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf14.hostedemail.com (Postfix) with ESMTP id DA055100012 for ; Tue, 28 Feb 2023 06:32:51 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=exeEIY5f; spf=pass (imf14.hostedemail.com: domain of 3EqD9YwMKCG8cPPTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--pcc.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3EqD9YwMKCG8cPPTbbTYR.PbZYVahk-ZZXiNPX.beT@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=1677565971; 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=wvjkzVZNjD23+PYC4lPbHb8EWcHxd0qwqj3Ki5t+HUO0/qsTnurG0LnEV6tdwUaPjkDqHR hO43eijybJHgL/WOP0HCtwfs6+Bo5KmRULvZ0nGSEuFN/K/13p7X/oLFTVlF0sr2lWp71B PCM56hAEm3AwYIQK05Tj11yNEILFug4= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=exeEIY5f; spf=pass (imf14.hostedemail.com: domain of 3EqD9YwMKCG8cPPTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--pcc.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3EqD9YwMKCG8cPPTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--pcc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677565971; a=rsa-sha256; cv=none; b=Dk1xt4Z9LTqy8t/Jq+Xm29EXVJlcaipKn7Uv3q9EjALMuKVTAjkkExIu18kFRtWLbCMcbm 05lHfx85BgO/xF61tljnSqU9d/eFXDfaKLs1TfyYc9OSy5JsFslF6TKEmtAWMyv3giTFkF 00Jj5yGhkYUzBzuwTmbsJ218m1jqRSs= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-536c02ed619so192192477b3.8 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=cKKQMlxZBOGvXBJSYyGDTJnhNmLLzYOaVOAtdtPsQNECOtch3cCc6HpDKwyNn2vfnH EVE3u0HFErPT5MRU8WHIaih138G0n8vdPp9/t+1gFUA0tjrTVTrHVnXtYiZmzBopdoSh e2h/E0ScbCZrj5II7hwMckuU8CbJ22cohBtKw9Cu7f6wRrcvQVtUs3dZLj/fjCdpsQzj XaMk5aSEj3hQkIDl1uo5GXylrRDkHobb+thuFhdkWaoi7X0w4tzvgOEW7XJ6EQ4zLShV HP3vqR4+qmqPFMPsFsMkJN1n3gbCOW6j1ULnV7qc9I/AIkZwSq9aBvayhOqMR58Zs7MC egmg== X-Gm-Message-State: AO0yUKV+E5KbkzrQ3plbZC8yficO8NF5b9ixlvrREg4WVs6w7Euv2UIP bnZZzUcUDR5wq2p8Wkz+Dx6RwyU= 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-Stat-Signature: o9k8qh8mbba1nz7t31hzt3i3d5jds4x6 X-Rspam-User: X-Rspamd-Queue-Id: DA055100012 X-Rspamd-Server: rspam06 X-HE-Tag: 1677565971-227328 X-HE-Meta: U2FsdGVkX185Fdxo7uygUqpmEv7HUip1H51CKfnKBV9hjzrFb8bQeH7dEHhf5+TOq/Vnj7cR7wDP3hdEYbDNwQDJPVA+Ui3EX1l5AF6STNVQu/INYhQDbGWbQI+7tEQhmUDV1hEoTlQnHWYG5SiClEcNj2qG9IF8gtqV/m8KqHgQB/nm3LT7cJFANTXeaZ3S1puqEh99+l5U6HX54Ox0YsLbqCYGHGSWg1STItIMX2AcqFRS4sha11Ho2QGsmR6xgB5ul+cHRCr4tYIvzE1zWwjlTF1aKj+0VIuz76qtLVqoF2/JUwJBzY+HNlYiZF4+ZqC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2+r69/d+2+wowvB3suKnSyPPfacE9GdFmYii8svPa40bRSvfuWM6lpTDQfT+JAp6C47pe34jTGS+MA5sDYVB8Zm/PZ1kj+MuVZ3o2uhvJGlfjRYkQi1QhfWzac+fm/gq8TqB4CMgEXwQtk+hClIbFd+TZSfMSWvWSpO5K+iT2+KfoCqDr8hciY/lUz65PudE5N5oFHqSZDd1jA8UTkN+kBnZlsrFO2w001w04MIC9oeNCwYnwUpWTi+FjLzmKf/2ifrFe2nGsZSwdoQvZi03FX88WUJGSRSzt1oeBm6cK1AxE/aHRTtqauGFEuXI+fsI+nXQCEC6Z0+vafMefIqspAeRpJu2HjJ/a6EhDWZ4KqJe0p5HyLdjo4OeUFT8qEaSwZLYtQMCLda4cRwatXg75JSZGGvB8/REaU8nLSUfiVnCoxeq2XG8ZP/uqb41yz9L1IWic= 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. */