From mboxrd@z Thu Jan 1 00:00:00 1970 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 68406C433F5 for ; Wed, 1 Dec 2021 14:11:35 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gR5UaMiuPYVf+y2ZBQyAKyM22imXPkLnSp9V3jb4IGQ=; b=M7/Z+V9FV0djhC +Mq56kHUYx1Rlr7isNGsSPZh+zaJG5qrFgDt8/YaKi8uOUBZmhzC1Zs5kuW6qazhYQR+vUIlKIpw/ r/nxZyGbyRk0kQW3ccIUVat80HlqxnMY/JS4m+eoOevHin+LA1CtB9knKblU/YY7fGKQogxGh9eaS WJeNPa0e3+T6qRU5vLsSEJxhZcxRRWUZHesni/SNPJIa1oAMYHsclbsKbFJ6IJGhD7pPZ/Rbz7Tmw YVqwLyrxd2+YjzXl1dhfz6DHgNl0+8mT+4h1Pqs6EelEYiYmmYcM4l8tRKHZtcjzbgdvIj7Nwjsa2 bIbi6WElIX6sIFVyEulQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1msQJE-008yp5-Ro; Wed, 01 Dec 2021 14:10:09 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1msQJB-008yoV-LV for linux-arm-kernel@lists.infradead.org; Wed, 01 Dec 2021 14:10:07 +0000 Received: by mail-wr1-x42d.google.com with SMTP id a18so52645652wrn.6 for ; Wed, 01 Dec 2021 06:10:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=aUvgIVEScJ2chwYi4PLdpPCh/e6Qof2JA3Rw4wY6NeM=; b=KUnaUN2PNTK/x7spFYPPquL7JGhJnuKP77ipiJILvdOG/Y2DJ/DEUIXzal57vgLUIV Cabps9cVEDaB6qHXt2jEf7Fvu2kN0GKIe+g1sFJ/wKpJ0GG3S57tSeTIDx0ct/wgi8pG hrjYoB3WTMbTY1vWR6ZQNNk9nvDa3BHhFfCoAtSL1zjRYbF1f2kWg4vTMDI8/07DEniy j7ErHCLAuYHiu3XxZe5hazjh0Vpvffrv6EoxpnvfIauAWhLwPkRcmytVTHglJOjT9eUe 8zJZxNh3fHGPwqoz0ZouznAZPw7wVipWixCOvYXpcY62NNKxYMyEjdeC1VB0fEbcTLCc E6kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=aUvgIVEScJ2chwYi4PLdpPCh/e6Qof2JA3Rw4wY6NeM=; b=Dd9b+6rsKumefzcqjwQB6TGXehYaLG0TjoaJPEOeMuzRfOeP4Enj0VRhQXT1vRpe05 /JtzrXMzO/RTuShumTaeC1VuvsCGmiB5fem8DxNGpx3H4oFijwnBXi/fQI+erej6NYpS XunRPMxi6QkeWaaBaSU/YCP+opTP9NWFnxVFfk+gX7D958cGFWJ2jgv2LE+TEB5uX1/6 oI3ZTgdCOq4Ya0hkBZtBjUJdHtZ5uSznWBRb4fzTNqdAFabWDPjkj5jWovK9wdIUktOc SO/134t84uDh24CwdwQQsJWlvJ3SDwMVmRx0+IaV+5cJq3zEsqJrAHrnYUEKdh2dI+2E EncQ== X-Gm-Message-State: AOAM532zz/SuMFckROOyx7Xp5CkEo4Zr3USeVnjPicbHzasN5DiR7N6/ 46v5CFVHeuoNs5bE/wGMOPowew== X-Google-Smtp-Source: ABdhPJzykwV4hr6ZfUUQXvfgwBoaE3LE+ImTY7GtLFjEdbZ/Yd8kTcyj9WFwDYjClESvftHYnoDIFQ== X-Received: by 2002:a5d:59ab:: with SMTP id p11mr7011310wrr.340.1638367803580; Wed, 01 Dec 2021 06:10:03 -0800 (PST) Received: from elver.google.com ([2a00:79e0:15:13:95ad:1401:cf07:6d1a]) by smtp.gmail.com with ESMTPSA id k8sm19121353wrn.91.2021.12.01.06.10.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Dec 2021 06:10:02 -0800 (PST) Date: Wed, 1 Dec 2021 15:09:56 +0100 From: Marco Elver To: andrey.konovalov@linux.dev Cc: Alexander Potapenko , Vincenzo Frascino , Catalin Marinas , Peter Collingbourne , Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Andrew Morton , linux-mm@kvack.org, Will Deacon , linux-arm-kernel@lists.infradead.org, Evgenii Stepanov , linux-kernel@vger.kernel.org, Andrey Konovalov Subject: Re: [PATCH 04/31] kasan, page_alloc: simplify kasan_poison_pages call site Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.0.5 (2021-01-21) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211201_061005_748491_38D6A393 X-CRM114-Status: GOOD ( 20.25 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Nov 30, 2021 at 10:39PM +0100, andrey.konovalov@linux.dev wrote: > From: Andrey Konovalov > > Simplify the code around calling kasan_poison_pages() in > free_pages_prepare(). > > Reording kasan_poison_pages() and kernel_init_free_pages() is OK, > since kernel_init_free_pages() can handle poisoned memory. Why did they have to be reordered? > This patch does no functional changes besides reordering the calls. > > Signed-off-by: Andrey Konovalov > --- > mm/page_alloc.c | 18 +++++------------- > 1 file changed, 5 insertions(+), 13 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 3f3ea41f8c64..0673db27dd12 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -1289,6 +1289,7 @@ static __always_inline bool free_pages_prepare(struct page *page, > { > int bad = 0; > bool skip_kasan_poison = should_skip_kasan_poison(page, fpi_flags); skip_kasan_poison is only used once now, so you could remove the variable -- unless later code will use it in more than once place again. > + bool init = want_init_on_free(); > > VM_BUG_ON_PAGE(PageTail(page), page); > > @@ -1359,19 +1360,10 @@ 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 (kasan_has_integrated_init()) { > - bool init = want_init_on_free(); > - > - if (!skip_kasan_poison) > - kasan_poison_pages(page, order, init); > - } else { > - bool init = want_init_on_free(); > - > - if (init) > - kernel_init_free_pages(page, 1 << order); > - if (!skip_kasan_poison) > - kasan_poison_pages(page, order, init); > - } > + if (!skip_kasan_poison) > + kasan_poison_pages(page, order, init); > + if (init && !kasan_has_integrated_init()) > + kernel_init_free_pages(page, 1 << order); > > /* > * arch_free_page() can make the page's contents inaccessible. s390 > -- > 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 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 E933CC433EF for ; Wed, 1 Dec 2021 14:12:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5BBBB6B0073; Wed, 1 Dec 2021 09:11:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 56B876B0074; Wed, 1 Dec 2021 09:11:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3E6B86B0075; Wed, 1 Dec 2021 09:11:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0080.hostedemail.com [216.40.44.80]) by kanga.kvack.org (Postfix) with ESMTP id 2E74A6B0073 for ; Wed, 1 Dec 2021 09:11:53 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E6A907E587 for ; Wed, 1 Dec 2021 14:11:42 +0000 (UTC) X-FDA: 78869413644.27.56F6C84 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by imf20.hostedemail.com (Postfix) with ESMTP id 3A1A9D000667 for ; Wed, 1 Dec 2021 14:10:04 +0000 (UTC) Received: by mail-wr1-f54.google.com with SMTP id v11so52581996wrw.10 for ; Wed, 01 Dec 2021 06:10:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=aUvgIVEScJ2chwYi4PLdpPCh/e6Qof2JA3Rw4wY6NeM=; b=KUnaUN2PNTK/x7spFYPPquL7JGhJnuKP77ipiJILvdOG/Y2DJ/DEUIXzal57vgLUIV Cabps9cVEDaB6qHXt2jEf7Fvu2kN0GKIe+g1sFJ/wKpJ0GG3S57tSeTIDx0ct/wgi8pG hrjYoB3WTMbTY1vWR6ZQNNk9nvDa3BHhFfCoAtSL1zjRYbF1f2kWg4vTMDI8/07DEniy j7ErHCLAuYHiu3XxZe5hazjh0Vpvffrv6EoxpnvfIauAWhLwPkRcmytVTHglJOjT9eUe 8zJZxNh3fHGPwqoz0ZouznAZPw7wVipWixCOvYXpcY62NNKxYMyEjdeC1VB0fEbcTLCc E6kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=aUvgIVEScJ2chwYi4PLdpPCh/e6Qof2JA3Rw4wY6NeM=; b=zryffxSMdgAbaSGQiyxCVBNYivEY2FayxTuvDtQ0LrRbI18rYldOMewJOJN6rXdAVM erVlF1WVVBUAoFBr5V8QybhYbbS0Uu4ISpH+eaozk3V4UNnS3LOQOHBkyfPMAkF8yIXr kr/rGjSG+bknl9uF1S6c0NKbZcHAWuGaQ1bv4n1EEmiQNp52Fuj+0ctsNH+OuVCnMgaj a0M2nzYhrzJw+hyglHpvmby+U41BBcLoOk576LJh4WIbjqqBkyYKamurUu+KCQwBqGDa eJYrP73c2Kn7ow79CcCBZADf61AsYCT9B5ys13tPKgsDToJTcm1rBs2O1ZSmRDO+yyT0 Sa3g== X-Gm-Message-State: AOAM533TLbcaHqGDpJklgU/p1C0snuuL51NReRFXMFFh6LqHGxlcT/3c LG4Gik9x/yD/VT/C6bHxhZJTiw== X-Google-Smtp-Source: ABdhPJzykwV4hr6ZfUUQXvfgwBoaE3LE+ImTY7GtLFjEdbZ/Yd8kTcyj9WFwDYjClESvftHYnoDIFQ== X-Received: by 2002:a5d:59ab:: with SMTP id p11mr7011310wrr.340.1638367803580; Wed, 01 Dec 2021 06:10:03 -0800 (PST) Received: from elver.google.com ([2a00:79e0:15:13:95ad:1401:cf07:6d1a]) by smtp.gmail.com with ESMTPSA id k8sm19121353wrn.91.2021.12.01.06.10.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Dec 2021 06:10:02 -0800 (PST) Date: Wed, 1 Dec 2021 15:09:56 +0100 From: Marco Elver To: andrey.konovalov@linux.dev Cc: Alexander Potapenko , Vincenzo Frascino , Catalin Marinas , Peter Collingbourne , Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Andrew Morton , linux-mm@kvack.org, Will Deacon , linux-arm-kernel@lists.infradead.org, Evgenii Stepanov , linux-kernel@vger.kernel.org, Andrey Konovalov Subject: Re: [PATCH 04/31] kasan, page_alloc: simplify kasan_poison_pages call site Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.0.5 (2021-01-21) X-Stat-Signature: jjm6krgc7aug7adrhfqp9n5c3e8bsgag Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=KUnaUN2P; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of elver@google.com designates 209.85.221.54 as permitted sender) smtp.mailfrom=elver@google.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 3A1A9D000667 X-HE-Tag: 1638367804-126059 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: On Tue, Nov 30, 2021 at 10:39PM +0100, andrey.konovalov@linux.dev wrote: > From: Andrey Konovalov > > Simplify the code around calling kasan_poison_pages() in > free_pages_prepare(). > > Reording kasan_poison_pages() and kernel_init_free_pages() is OK, > since kernel_init_free_pages() can handle poisoned memory. Why did they have to be reordered? > This patch does no functional changes besides reordering the calls. > > Signed-off-by: Andrey Konovalov > --- > mm/page_alloc.c | 18 +++++------------- > 1 file changed, 5 insertions(+), 13 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 3f3ea41f8c64..0673db27dd12 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -1289,6 +1289,7 @@ static __always_inline bool free_pages_prepare(struct page *page, > { > int bad = 0; > bool skip_kasan_poison = should_skip_kasan_poison(page, fpi_flags); skip_kasan_poison is only used once now, so you could remove the variable -- unless later code will use it in more than once place again. > + bool init = want_init_on_free(); > > VM_BUG_ON_PAGE(PageTail(page), page); > > @@ -1359,19 +1360,10 @@ 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 (kasan_has_integrated_init()) { > - bool init = want_init_on_free(); > - > - if (!skip_kasan_poison) > - kasan_poison_pages(page, order, init); > - } else { > - bool init = want_init_on_free(); > - > - if (init) > - kernel_init_free_pages(page, 1 << order); > - if (!skip_kasan_poison) > - kasan_poison_pages(page, order, init); > - } > + if (!skip_kasan_poison) > + kasan_poison_pages(page, order, init); > + if (init && !kasan_has_integrated_init()) > + kernel_init_free_pages(page, 1 << order); > > /* > * arch_free_page() can make the page's contents inaccessible. s390 > -- > 2.25.1