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 3EB92C433DB for ; Thu, 28 Jan 2021 00:19:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EEFC064DD7 for ; Thu, 28 Jan 2021 00:19:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231616AbhA1ASy (ORCPT ); Wed, 27 Jan 2021 19:18:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:53556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231147AbhA1ASh (ORCPT ); Wed, 27 Jan 2021 19:18:37 -0500 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.