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 X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 270D1C10F14 for ; Tue, 15 Oct 2019 12:12:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D722C205F4 for ; Tue, 15 Oct 2019 12:12:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D722C205F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8810C8E0005; Tue, 15 Oct 2019 08:12:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 82FCF8E0001; Tue, 15 Oct 2019 08:12:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7452E8E0005; Tue, 15 Oct 2019 08:12:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0235.hostedemail.com [216.40.44.235]) by kanga.kvack.org (Postfix) with ESMTP id 53A678E0001 for ; Tue, 15 Oct 2019 08:12:55 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id E9E8D75B2 for ; Tue, 15 Oct 2019 12:12:54 +0000 (UTC) X-FDA: 76045907868.17.drink20_53a0818927c54 X-HE-Tag: drink20_53a0818927c54 X-Filterd-Recvd-Size: 3132 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Tue, 15 Oct 2019 12:12:54 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6F8E2B392; Tue, 15 Oct 2019 12:12:53 +0000 (UTC) Date: Tue, 15 Oct 2019 14:12:53 +0200 From: Michal Hocko To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org, Anshuman Khandual , Mike Kravetz , Andrew Morton Subject: Re: [PATCH v1] hugetlbfs: don't access uninitialized memmaps in pfn_range_valid_gigantic() Message-ID: <20191015121253.GH317@dhcp22.suse.cz> References: <20191015120717.4858-1-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191015120717.4858-1-david@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) 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 15-10-19 14:07:17, David Hildenbrand wrote: > Uninitialized memmaps contain garbage and in the worst case trigger > kernel BUGs, especially with CONFIG_PAGE_POISONING. They should not get > touched. > > Let's make sure that we only consider online memory (managed by the > buddy) that has initialized memmaps. ZONE_DEVICE is not applicable. > > page_zone() will call page_to_nid(), which will trigger > VM_BUG_ON_PGFLAGS(PagePoisoned(page), page) with CONFIG_PAGE_POISONING > and CONFIG_DEBUG_VM_PGFLAGS when called on uninitialized memmaps. This > can be the case when an offline memory block (e.g., never onlined) is > spanned by a zone. > > Note: As explained by Michal in [1], alloc_contig_range() will verify > the range. So it boils down to the wrong access in this function. > > [1] http://lkml.kernel.org/r/20180423000943.GO17484@dhcp22.suse.cz > > Reported-by: Michal Hocko > Fixes: f1dd2cd13c4b ("mm, memory_hotplug: do not associate hotadded memory to zones until online") # visible after d0dc12e86b319 > Cc: stable@vger.kernel.org # v4.13+ > Cc: Anshuman Khandual > Cc: Mike Kravetz > Cc: Andrew Morton > Cc: Michal Hocko > Signed-off-by: David Hildenbrand Acked-by: Michal Hocko Thanks! > --- > mm/hugetlb.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index ef37c85423a5..b45a95363a84 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1084,11 +1084,10 @@ static bool pfn_range_valid_gigantic(struct zone *z, > struct page *page; > > for (i = start_pfn; i < end_pfn; i++) { > - if (!pfn_valid(i)) > + page = pfn_to_online_page(i); > + if (!page) > return false; > > - page = pfn_to_page(i); > - > if (page_zone(page) != z) > return false; > > -- > 2.21.0 -- Michal Hocko SUSE Labs