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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 B79EFC433E0 for ; Thu, 28 Jan 2021 00:17:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 68B7664DD3 for ; Thu, 28 Jan 2021 00:17:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68B7664DD3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B54736B0005; Wed, 27 Jan 2021 19:17:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B05DF6B006C; Wed, 27 Jan 2021 19:17:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A41EA6B006E; Wed, 27 Jan 2021 19:17:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9096C6B0005 for ; Wed, 27 Jan 2021 19:17:58 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5082B1EE6 for ; Thu, 28 Jan 2021 00:17:58 +0000 (UTC) X-FDA: 77753271036.11.work70_5c0c4da2759b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 2B7E9180F8B81 for ; Thu, 28 Jan 2021 00:17:58 +0000 (UTC) X-HE-Tag: work70_5c0c4da2759b X-Filterd-Recvd-Size: 2819 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Thu, 28 Jan 2021 00:17:57 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 8167A64DD1; Thu, 28 Jan 2021 00:17:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1611793076; bh=gket93QkDzc1u3zC/b47KPkU1uZdkl7O52e5jROE9r8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hy5Bu3gEdXNa8Sjf4GfI+2liI+Jb7rCNj47E+l1D29lvXaUanjw3Yl12jUxUGj2cq hbKbZI8ApA5V3pFDw9asiLtBVEy7gdy/EAu0RPAMjZ7UN8VvJ8WjbHp0QzRAgzw65O QnK8o2/bkNP0Aa2YVCV1VNFyHbQ+7zHQL9xTGjCw= Date: Wed, 27 Jan 2021 16:17:55 -0800 From: Andrew Morton To: Miaohe Lin Cc: Mike Kravetz , , Subject: Re: [PATCH] mm/hugetlb: Fix use after free when subpool max_hpages accounting is not enabled Message-Id: <20210127161755.68bf43047007a8a2889e302a@linux-foundation.org> In-Reply-To: References: <20210126115510.53374-1-linmiaohe@huawei.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 Wed, 27 Jan 2021 10:08:22 +0800 Miaohe Lin wrote: > On 2021/1/27 8:06, Mike Kravetz wrote: > > On 1/26/21 3:55 AM, Miaohe Lin wrote: > >> When subpool max_hpages accounting is not enabled, used_hpages is always 0 > >> and might lead to release subpool prematurely because it indicates no pages > >> are used now while there might be. > > > > It might be good to say that you need min_hpages accounting (min_size mount > > option) enabled for this issue to occur. Or, perhaps say this is possible > > if a hugetlbfs filesystem is created with the min_size option and without > > the size option. > > > > That might better explain the conditions in which a user could see the issue. > > So commit log might looks like this ? > """ > If a hugetlbfs filesystem is created with the min_size option and without > the size option, used_hpages is always 0 and might lead to release subpool > prematurely because it indicates no pages are used now while there might > be. > > In order to fix this issue, we should check used_hpages == 0 iff max_hpages > accounting is enabled. As max_hpages accounting should be enabled in most > common case, this is not worth a Cc stable. > """ > > If so, should I send a V2 or Andrew would kindly do this? > Many thanks. I made that change, thanks.