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.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 28331C433E0 for ; Thu, 28 Jan 2021 11:40:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE3E764DDB for ; Thu, 28 Jan 2021 11:40:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231281AbhA1LkA (ORCPT ); Thu, 28 Jan 2021 06:40:00 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:11212 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbhA1Lj6 (ORCPT ); Thu, 28 Jan 2021 06:39:58 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DRJP26h74zl9l6; Thu, 28 Jan 2021 19:37:42 +0800 (CST) Received: from [10.174.179.81] (10.174.179.81) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.498.0; Thu, 28 Jan 2021 19:39:12 +0800 Subject: Re: KASAN: invalid-free in p9_client_create (2) To: Linus Torvalds , syzbot , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton CC: Dominique Martinet , David Miller , , Jakub Kicinski , Linux Kernel Mailing List , , Netdev , syzkaller-bugs , , Linux-MM References: <000000000000672eda05b9e291ff@google.com> From: "wanghai (M)" Message-ID: Date: Thu, 28 Jan 2021 19:39:12 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.81] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2021/1/28 3:31, Linus Torvalds 写道: > [ Participants list changed - syzbot thought this was networking and > p9, but it really looks entirely like a slub internal bug. I left the > innocent people on the list just to let them know they are innocent ] > > On Wed, Jan 27, 2021 at 6:27 AM syzbot > wrote: >> The issue was bisected to: >> >> commit dde3c6b72a16c2db826f54b2d49bdea26c3534a2 >> Author: Wang Hai >> Date: Wed Jun 3 22:56:21 2020 +0000 >> >> mm/slub: fix a memory leak in sysfs_slab_add() >> >> BUG: KASAN: double-free or invalid-free in slab_free mm/slub.c:3142 [inline] >> BUG: KASAN: double-free or invalid-free in kmem_cache_free+0x82/0x350 mm/slub.c:3158 > The p9 part of this bug report seems to be a red herring. > > The problem looks like it's simply the kmem_cache failure case, ie: > > - mm/slab_common.c: create_cache(): if the __kmem_cache_create() > fails, it does: > > out_free_cache: > kmem_cache_free(kmem_cache, s); > > - but __kmem_cache_create() - at least for slub() - will have done > > sysfs_slab_add(s) .. fails .. > -> kobject_del(&s->kobj); .. which frees s ... > > so the networking and p9 are fine, and the only reason p9 shows up in > the trace is that apparently it causes that failure in > kobject_init_and_add() for whatever reason, and that then exposes the > problem. > > So the added kobject_put() really looks buggy in this situation, and > the memory leak that that commit dde3c6b72a16 ("mm/slub: fix a memory > leak in sysfs_slab_add()") fixes is now a double free. > > And no, I don't think you can just remove the kmem_cache_free() in > create_cache(), because _other_ error cases of __kmem_cache_create() > do not free this. > > Wang Hai - comments? I'm inclined to revert that commit for now unless > somebody can come up with a proper fix.. > > Linus > . Hi, Linus. I'm sorry for introducing this bug, and I agree to revert it. I've just sent the revert patch. https://lore.kernel.org/patchwork/patch/1372475/ Thanks, Wang Hai