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.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,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 44D00C433DB for ; Fri, 8 Jan 2021 01:41:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B136A23601 for ; Fri, 8 Jan 2021 01:41:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B136A23601 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DD1FA8D0161; Thu, 7 Jan 2021 20:41:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D5B5A8D0156; Thu, 7 Jan 2021 20:41:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C71738D0161; Thu, 7 Jan 2021 20:41:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0059.hostedemail.com [216.40.44.59]) by kanga.kvack.org (Postfix) with ESMTP id ADA5D8D0156 for ; Thu, 7 Jan 2021 20:41:09 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 71AA91DF4 for ; Fri, 8 Jan 2021 01:41:09 +0000 (UTC) X-FDA: 77680904658.01.north44_3c0932d274ef Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 528C110050799 for ; Fri, 8 Jan 2021 01:41:09 +0000 (UTC) X-HE-Tag: north44_3c0932d274ef X-Filterd-Recvd-Size: 2854 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Fri, 8 Jan 2021 01:41:08 +0000 (UTC) Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DBm4S6m0Lzl11j; Fri, 8 Jan 2021 09:39:52 +0800 (CST) Received: from [10.174.179.174] (10.174.179.174) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.498.0; Fri, 8 Jan 2021 09:41:01 +0800 Subject: Re: [PATCH] mm/hugetlb: Fix potential double free in hugetlb_register_node() error path To: Andrew Morton , Mike Kravetz CC: , References: <20210107123249.36964-1-linmiaohe@huawei.com> <20210107151502.7c581d98078ba90e63553dd4@linux-foundation.org> From: Miaohe Lin Message-ID: <0c53d7a7-df61-9187-676b-6ba5d0829394@huawei.com> Date: Fri, 8 Jan 2021 09:41:01 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210107151502.7c581d98078ba90e63553dd4@linux-foundation.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.174] X-CFilter-Loop: Reflected 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 2021/1/8 7:15, Andrew Morton wrote: > On Thu, 7 Jan 2021 11:59:38 -0800 Mike Kravetz wrote: > >> On 1/7/21 4:32 AM, Miaohe Lin wrote: >>> In hugetlb_sysfs_add_hstate(), we would do kobject_put() on hstate_kobjs >>> when failed to create sysfs group but forget to set hstate_kobjs to NULL. >>> Then in hugetlb_register_node() error path, we may free it again via >>> hugetlb_unregister_node(). >>> >>> Fixes: a3437870160c ("hugetlb: new sysfs interface") >>> Signed-off-by: Miaohe Lin >>> Cc: >>> --- >>> mm/hugetlb.c | 4 +++- >>> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> Thanks, this is a potential issue that should be fixed. >> >> Reviewed-by: Mike Kravetz >> >> This has been around for a long time (more than 12 years). I suspect >> nobody actually experienced this issue. You just discovered via code >> inspection. Correct? Yes, I found this by code inspection. >> At one time cc stable would not be accepted for this type of issue, >> not sure about today. > > sysfs_create_group() will only fail if something is terribly messed up > - probably it has never happened to anyone. I don't think the > cc:stable is justified here. > > . > I would take care of more when cc stable. Many thanks for both of you!