Re: [PATCH] mm/hugetlb: Fix potential double free in hugetlb_register_node() error path

From: Miaohe Lin
Date: Thu Jan 07 2021 - 20:42:03 EST


On 2021/1/8 7:15, Andrew Morton wrote:
> On Thu, 7 Jan 2021 11:59:38 -0800 Mike Kravetz <mike.kravetz@xxxxxxxxxx> 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 <linmiaohe@xxxxxxxxxx>
>>> Cc: <stable@xxxxxxxxxxxxxxx>
>>> ---
>>> 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 <mike.kravetz@xxxxxxxxxx>
>>
>> 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!