Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4486130pxf; Tue, 30 Mar 2021 08:58:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIPJAht4yXNRit+EPLkOhAW9bMcyxQUwkKjXQv/+x+l4o7VzNGJtBVf3AKXLjLFCP7nz2B X-Received: by 2002:a17:906:ecf3:: with SMTP id qt19mr33513823ejb.467.1617119908110; Tue, 30 Mar 2021 08:58:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617119908; cv=none; d=google.com; s=arc-20160816; b=s3GtNvH5YkqkOhD5V7CMapzHVG1xKBh2vd0bP2j54JCFDasAwZ7OFmEA93UaxN1tGS kSViaxaMEijtvPD8jWwjizien9P6hq0Lp7CCou2yh3jzgWs8uWZMg+N/dvQV/PssbBI+ 5wwdlmUqMn8z3lD3VSEN+TtQPpogm7BrtcbgqR+JOa+EvLKwIBwcoF8hTxU9iSbkUoS2 Lmx6ivF1VFslXLGApaNr+VC3apumHHKQGCb9mwBlWrRRxfSoAo5989ISDjOtoVLpVAx4 aJWSU7IcydvmVVT1qzcR3Gqs6Ndj3ld+3ERXj7i+5/zQdgMASfb2RWkQNCMgjYvvOIs2 BwSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=64b3fdMPlVJUNEUsxnzXgqJK3VMxYzeiBjitNt1Dkog=; b=N/bp+bMgRfq3ogZd2dM1EXa6aZq5rd8VHegv0NXgTLnFzEQlh8lbOze7EnLsVKEqZE Ld62nsvrSnF4p+MPXSCqLv+C6eIGktozNGqiZGqvMZQ/EWm9B8tQ6HSdyF3KHsMCjxnY xgNxlR8igfC3wOHiOdtzxbs4AQJIr0F05eRi9IAs8q6CClvLkwoBVxzmZ/NzC/U+v/Bt K9v1Z88qTDMJgYSlfHSRhLwx33TQ35uy0CdUskzuQwRD5FWeFY+EFEL3otHRnL7Glike RqBNzniQre0aXCK3xMEmP5pbN85emjq3IiDR8/XDhc369A0jb+BnrUVH20v/boOkNZ+t rDZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bq23si14904042ejb.498.2021.03.30.08.58.04; Tue, 30 Mar 2021 08:58:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232224AbhC3PzD (ORCPT + 99 others); Tue, 30 Mar 2021 11:55:03 -0400 Received: from mx2.suse.de ([195.135.220.15]:45704 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232201AbhC3Pyf (ORCPT ); Tue, 30 Mar 2021 11:54:35 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 44DADAF10; Tue, 30 Mar 2021 15:54:34 +0000 (UTC) Subject: Re: [PATCH mm] mm, kasan: fix for "integrate page_alloc init with HW_TAGS" To: Andrey Konovalov , Andrew Morton Cc: Sergei Trofimovich , Alexander Potapenko , Marco Elver , Dmitry Vyukov , Andrey Ryabinin , Andrey Konovalov , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <2e5e80481533e73876d5d187d1f278f9656df73a.1617118134.git.andreyknvl@google.com> From: Vlastimil Babka Message-ID: <115c3cd4-a5ec-ea4c-fdc8-a17a0990bd30@suse.cz> Date: Tue, 30 Mar 2021 17:54:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <2e5e80481533e73876d5d187d1f278f9656df73a.1617118134.git.andreyknvl@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/30/21 5:31 PM, Andrey Konovalov wrote: > My commit "integrate page_alloc init with HW_TAGS" changed the order of > kernel_unpoison_pages() and kernel_init_free_pages() calls. This leads > to __GFP_ZERO allocations being incorrectly poisoned when page poisoning > is enabled. Correction: This leads to check_poison_mem() complain about memory corruption because the poison pattern has already been overwritten by zeroes. > Fix by restoring the initial order. Also add a warning comment. > > Reported-by: Vlastimil Babka > Reported-by: Sergei Trofimovich > Signed-off-by: Andrey Konovalov I expect this will be folded to your patch in mmotm anyway, so the changelog is not as important... > --- > mm/page_alloc.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 033bd92e8398..1fc5061f8ca1 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -2328,6 +2328,12 @@ inline void post_alloc_hook(struct page *page, unsigned int order, > arch_alloc_page(page, order); > debug_pagealloc_map_pages(page, 1 << order); > > + /* > + * Page unpoisoning must happen before memory initialization. > + * Otherwise, a __GFP_ZERO allocation will not be initialized. ... but the comment should be corrected too: "Otherwise, a __GFP_ZERO allocation will trigger a memory corruption report during unpoisoning." Thanks. > + */ > + kernel_unpoison_pages(page, 1 << order); > + > /* > * As memory initialization might be integrated into KASAN, > * kasan_alloc_pages and kernel_init_free_pages must be > @@ -2338,7 +2344,6 @@ inline void post_alloc_hook(struct page *page, unsigned int order, > if (init && !kasan_has_integrated_init()) > kernel_init_free_pages(page, 1 << order); > > - kernel_unpoison_pages(page, 1 << order); > set_page_owner(page, order, gfp_flags); > } > >