Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1132661ybt; Tue, 7 Jul 2020 08:28:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyG5xu9JBHH3P5gamrwwTzATbkk6KMdioqfAl3fjzF1IwgdNqfu/BMnMgQqCxqAclNS40f+ X-Received: by 2002:a50:e1c5:: with SMTP id m5mr62130481edl.47.1594135736392; Tue, 07 Jul 2020 08:28:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594135736; cv=none; d=google.com; s=arc-20160816; b=bgF2BmyqdjYEtLKIsrKl5j3m0iIv0gYNwew7XLoSNusa6mH/MitENYQGq7DZpsb3BL UMzbfXOhq3FlNyhoOuzGol93VR06ep88/mYvIyWf+anJ1ynQ+a+MF3yGruz1sYmjQDMv Qlmw4SnD9Eb7AeOyp+6FxnEEpZtLnkBtoKrrcSHc7Z6QxFZOFISdZQlf13K7A3UVl/Zx 3osAmjO6MtivcIrbSyagPm4wxR7zmvx4sE9qMwsM9XE9zY/wpw5dsmgNIO9ljwdi02Fk 0ABbmAy6bslUiP3GzHtx6BcxfrnHbHqo5357vTwtXxNjAEwZCAx3BO1KSfkjlZzwhG1G StJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=b2HuRUwRzKdxPLQ/d7Q1YQluB3n1UvhRbfpS7dCBZfQ=; b=tSjBwB0DubX5fx7dTuW6ef9qLAspOiz13ibLpACdpIi1v8o5Bb619r4eeJbR6uWuhi sN1LK7cafnBIPyLTzYsanVd1Bvg6+ufyPiaetwJ2OIb0aDyAs545nKYN+sxe5sLK9FQG kL/7RjbWMSiZE5iMV7ptfIwj7adwCKOsZz4Kp9TMuWm7PemJp978K9pDnagDfyGjCnea xDR5l9LUj5nNWPcW4lkud4wAbHyzwO/SVXrxJPbHC5M27YbS5Efon43/eeIJyky8kepI ASI8cvD9bcwQhCKEItyASkGr/xIn9opL2OJxlinOzfA98wdBup6Hj4QSHv+GW4G5JWzd UM1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XDMOxePU; 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 o5si18123894edj.37.2020.07.07.08.28.33; Tue, 07 Jul 2020 08:28:56 -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; dkim=pass header.i=@kernel.org header.s=default header.b=XDMOxePU; 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 S1729348AbgGGP1x (ORCPT + 99 others); Tue, 7 Jul 2020 11:27:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:41228 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729613AbgGGP0x (ORCPT ); Tue, 7 Jul 2020 11:26:53 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 76A6D2078D; Tue, 7 Jul 2020 15:26:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594135612; bh=0y18ZHgiz26Tm4pcX6CTElfyBW51TPaISFDBGKZ4z9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XDMOxePUAogxwVfTc51jg3b5Ry6zFbo3H0t2NjJqRemCFvDRDJLY3npRCWtntp1Cm GVByeUGAE6xZYMxpGR4Yt80ahdtvLB9pDF8uq98XXEc+/K9+4yx0QR5yZybFTIgLcH 2dHKUGFiBzrqzsAFLo6LjhSmc2WlVhSW4NgeQVVQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Matthew Wilcox (Oracle)" , Mike Kravetz , Andrew Morton , Michal Hocko , "Kirill A . Shutemov" , Linus Torvalds Subject: [PATCH 5.7 109/112] mm/hugetlb.c: fix pages per hugetlb calculation Date: Tue, 7 Jul 2020 17:17:54 +0200 Message-Id: <20200707145806.156348388@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200707145800.925304888@linuxfoundation.org> References: <20200707145800.925304888@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Kravetz commit 1139d336fff425f9a20374945cdd28eb44d09fa8 upstream. The routine hpage_nr_pages() was incorrectly used to calculate the number of base pages in a hugetlb page. hpage_nr_pages is designed to be called for THP pages and will return HPAGE_PMD_NR for hugetlb pages of any size. Due to the context in which hpage_nr_pages was called, it is unlikely to produce a user visible error. The routine with the incorrect call is only exercised in the case of hugetlb memory error or migration. In addition, this would need to be on an architecture which supports huge page sizes less than PMD_SIZE. And, the vma containing the huge page would also need to smaller than PMD_SIZE. Fixes: c0d0381ade79 ("hugetlbfs: use i_mmap_rwsem for more pmd sharing synchronization") Reported-by: Matthew Wilcox (Oracle) Signed-off-by: Mike Kravetz Signed-off-by: Andrew Morton Reviewed-by: Matthew Wilcox (Oracle) Cc: Michal Hocko Cc: "Kirill A . Shutemov" Cc: Link: http://lkml.kernel.org/r/20200629185003.97202-1-mike.kravetz@oracle.com Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/hugetlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1594,7 +1594,7 @@ static struct address_space *_get_hugetl /* Use first found vma */ pgoff_start = page_to_pgoff(hpage); - pgoff_end = pgoff_start + hpage_nr_pages(hpage) - 1; + pgoff_end = pgoff_start + pages_per_huge_page(page_hstate(hpage)) - 1; anon_vma_interval_tree_foreach(avc, &anon_vma->rb_root, pgoff_start, pgoff_end) { struct vm_area_struct *vma = avc->vma;