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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 9381EC47082 for ; Mon, 31 May 2021 06:49:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2061F61186 for ; Mon, 31 May 2021 06:49:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2061F61186 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 40B286B0036; Mon, 31 May 2021 02:49:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BAEF8D0001; Mon, 31 May 2021 02:49:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25BA66B0070; Mon, 31 May 2021 02:49:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0076.hostedemail.com [216.40.44.76]) by kanga.kvack.org (Postfix) with ESMTP id E953D6B0036 for ; Mon, 31 May 2021 02:49:01 -0400 (EDT) Received: from smtpin32.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 498F18249980 for ; Mon, 31 May 2021 06:49:01 +0000 (UTC) X-FDA: 78200598882.32.E18A07B Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf30.hostedemail.com (Postfix) with ESMTP id 7576DE000240 for ; Mon, 31 May 2021 06:48:52 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622443739; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+lr7oE5hWOvbLfQreFLJO+2NuHgm+ZeXzWkRJMgDAnI=; b=G7KTuedXlFr6twlSfk3OFs2Qvzo9RsPBZ9+rmSZBK1XMvAzfI6zZsxjQXwYMhOqBu92CsE wrL+wG3jxyWWAxtJyUHyGuduIRth8Ql6amjcfcZSvJhj1+nQxQV1uVZV9JTuyjWZqPByfl QozDHaVHxp6tIc8xAPHGFHnZGvoRBjw= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7BFD3B24F; Mon, 31 May 2021 06:48:59 +0000 (UTC) Date: Mon, 31 May 2021 08:48:58 +0200 From: Michal Hocko To: Mike Kravetz Cc: Linux-MM , lkml , Muchun Song , Oscar Salvador , David Hildenbrand , Naoya Horiguchi , Andrew Morton Subject: Re: [PATCH] mm: hugetlb: fix dissolve_free_huge_page use of tail/head page Message-ID: References: <20210527231225.226987-1-mike.kravetz@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210527231225.226987-1-mike.kravetz@oracle.com> Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=G7KTuedX; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf30.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.15 as permitted sender) smtp.mailfrom=mhocko@suse.com X-Stat-Signature: kepucy4ozdbaon8bqzmfjxz4hotgrhfj X-Rspamd-Queue-Id: 7576DE000240 X-Rspamd-Server: rspam02 X-HE-Tag: 1622443732-905205 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 Thu 27-05-21 16:12:25, Mike Kravetz wrote: > The routine dissolve_free_huge_page can be passed the tail page of a > hugetlb page. The tail page is incorrectly passed on to the routines > alloc_huge_page_vmemmap and add_hugetlb_page which expect a hugetlb > head page. > > Operating on a tail page instead of head page could result in addressing > exceptions or vmemmap corruption. > > Signed-off-by: Mike Kravetz Acked-by: Michal Hocko > --- > The code with this issue is only in mmotm (and next). Specifically > mm: hugetlb: alloc the vmemmap pages associated with each HugeTLB page > Andrew, I assume you will fix in your tree. Yes, folding this in sounds like the best way forward. > > mm/hugetlb.c | 4 ++-- > scripts/rust-version.sh | 0 > 2 files changed, 2 insertions(+), 2 deletions(-) > mode change 100644 => 100755 scripts/rust-version.sh > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 69a4b551c157..d2461c1f32dd 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1954,7 +1954,7 @@ int dissolve_free_huge_page(struct page *page) > * Attempt to allocate vmemmmap here so that we can take > * appropriate action on failure. > */ > - rc = alloc_huge_page_vmemmap(h, page); > + rc = alloc_huge_page_vmemmap(h, head); > if (!rc) { > /* > * Move PageHWPoison flag from head page to the raw > @@ -1968,7 +1968,7 @@ int dissolve_free_huge_page(struct page *page) > update_and_free_page(h, head, false); > } else { > spin_lock_irq(&hugetlb_lock); > - add_hugetlb_page(h, page, false); > + add_hugetlb_page(h, head, false); > h->max_huge_pages++; > spin_unlock_irq(&hugetlb_lock); > } > diff --git a/scripts/rust-version.sh b/scripts/rust-version.sh > old mode 100644 > new mode 100755 > -- > 2.31.1 > -- Michal Hocko SUSE Labs