Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4523109pxf; Tue, 30 Mar 2021 09:46:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7OswDRbZCdIvYTRyKr4ZDEdUCx6n2h362Zu4gy/YbaLU23YNAllsyiZwBYk00Ms7fnLOo X-Received: by 2002:a05:6402:1d19:: with SMTP id dg25mr34913909edb.218.1617122761100; Tue, 30 Mar 2021 09:46:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617122761; cv=none; d=google.com; s=arc-20160816; b=p2HZIdQzKHQ39GbsjvHdHHLvkyfAiRxWOgd6VYKtKYPcuhjECz4p3D783aOvx50pLh 7IrNHkBihmwHYXb3Oau+olTanYZczAycR5nD6TjwnTpMjSycrUHdI/udYS8sr3UvJkrI na2vAZPcqnHm6csC3niQNbATSlsxyC72WSAfWdW3jqFn2uFOu6yYDMsbedjxjkv+LQT2 13NLAve7aNXVBGcSefuHHkDl7jiQt85hr+q5AnGfMRIKm0jsgQz3OA5izDADWzsHWU86 Qpt2KZj8ABXWYbCCUc58FL6Di2h+PoIQ1hyIb0aGqtwOLLElIbHAC59db49chtVXvRor eHCQ== 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=BblGTPjukWoa8VnRbNefv63l5EwB6ojoSWVnFIKy4ac=; b=d31DnmYtnvmRZXAZKBxQY5ojbvGs5xr3+PiKOHnjGREGJPkU51uwFhAfxonT6L/fRj f88+K4wbQcx0mcqkH6JgormyG8YND6UOH/qNwyXXlpSZ2da9lI5vQpgZY8e82nP2NiCD 7O+JGsi9ZQ2iRZwn5W5ttGXY+sClkAVKyIh1pQY5YebctQBBc7YfMrcFlcedCcJoAhoY cd109TksUiZTLZtVKDKlOke7XuARtRNyJn5vg5mmTNXZaGwBTBbNNd7a/adEve7iUcHL uLkY5wC8ci+DEoDBkdusIniZ1qCU2tBw2ixKdNQXthuoyaJdhkm6G8NRXoTF01UusSUk tzyg== 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 f11si15097589ejr.284.2021.03.30.09.45.38; Tue, 30 Mar 2021 09:46:01 -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 S232057AbhC3Qol (ORCPT + 99 others); Tue, 30 Mar 2021 12:44:41 -0400 Received: from mx2.suse.de ([195.135.220.15]:46308 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231532AbhC3Qo2 (ORCPT ); Tue, 30 Mar 2021 12:44:28 -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 207D0B02D; Tue, 30 Mar 2021 16:44:10 +0000 (UTC) Subject: Re: [PATCH mm v2] 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: <65b6028dea2e9a6e8e2cb779b5115c09457363fc.1617122211.git.andreyknvl@google.com> From: Vlastimil Babka Message-ID: <404ad944-ab46-cffb-5fbb-3dd7ae25caaa@suse.cz> Date: Tue, 30 Mar 2021 18:44:09 +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: <65b6028dea2e9a6e8e2cb779b5115c09457363fc.1617122211.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 6:37 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 complaints from the page unpoisoning code, as the poison pattern gets > overwritten for __GFP_ZERO allocations. > > Fix by restoring the initial order. Also add a warning comment. > > Reported-by: Vlastimil Babka > Reported-by: Sergei Trofimovich > Signed-off-by: Andrey Konovalov Tested that the bug indeed occurs in -next and is fixed by this. Thanks. > --- > mm/page_alloc.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 033bd92e8398..d2c020563c0b 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -2328,6 +2328,13 @@ 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, the poison pattern will be overwritten for __GFP_ZERO > + * allocations and the page unpoisoning code will complain. > + */ > + 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 +2345,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); > } > >