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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 AA435C433DB for ; Wed, 27 Jan 2021 19:31:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3642564DC4 for ; Wed, 27 Jan 2021 19:31:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3642564DC4 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 A2A286B0005; Wed, 27 Jan 2021 14:31:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9DA926B0006; Wed, 27 Jan 2021 14:31:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C97D6B006E; Wed, 27 Jan 2021 14:31:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0244.hostedemail.com [216.40.44.244]) by kanga.kvack.org (Postfix) with ESMTP id 72FBA6B0005 for ; Wed, 27 Jan 2021 14:31:44 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3BA4F181AEF10 for ; Wed, 27 Jan 2021 19:31:44 +0000 (UTC) X-FDA: 77752549728.30.pain60_1516a2927599 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id 6711D180B3C94 for ; Wed, 27 Jan 2021 19:31:43 +0000 (UTC) X-HE-Tag: pain60_1516a2927599 X-Filterd-Recvd-Size: 5470 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Wed, 27 Jan 2021 19:31:42 +0000 (UTC) Received: by mail-lf1-f54.google.com with SMTP id m22so4298355lfg.5 for ; Wed, 27 Jan 2021 11:31:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZJB6pzhcxR6RIOhk+W4vBLAOQOY6A+IbRkTJX3GrSIA=; b=Nex7m0nPT6ikFYD0UDxgXryCJyYTx+pRUl8n/I+/+QgVAzM5sX/Iufo8IZe70BES4A PxumGwRUK+eKwrok3peAydYv34EWMMQMd6k8vlFvyDIPohc+dGl9OdT0wXxeuKjCUlu3 DoAjRpEayelexJA+o2u5g1eysr8elGHigTn34= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZJB6pzhcxR6RIOhk+W4vBLAOQOY6A+IbRkTJX3GrSIA=; b=qYnNGJyMJOlUn1LsrQZuQEgbd10F30Cel6FPj5YyFqVRl6ApcTdtXhntRPdl1Tb0bQ Rn3a/4uYlh9gAH1hstwhtzW5aflY9r4KbpbRj0tS3jGDlO8PTQMyXXa7nN0XoWf27Kv9 vUpU1hH1E60ubZUwOLIHI/OrfW9xcWi3oXYZZJ/bRoXgYFCd3KpMYx8htZfBHkBx9anG w+X2rFem/3tXHNtf53+Y1FUsWsKNHsPKqIsTKmGhCg4cvwHBvO+45TsaZ+DuzFwr8Z+P XBJEjq6xyESBVCtxvcgbmnlPBi+I0Ufb3aqP7cgdJTKKCHRgq72fisHHq08AaVP9vOvM KITQ== X-Gm-Message-State: AOAM530ojGO6liFRGFU/62cJ69C+cfe6n3vfLugAEM4VoZU+PX7G5i4d 0njGGcPicJPj//99Izef4yRRdb7EQ6PBMw== X-Google-Smtp-Source: ABdhPJzS3vqoXKyew4mS9He9z/CratS8O/48XdH/FpNqCoXqAIuDUzBjD3WwlIl1T7zHc77ABYi3eQ== X-Received: by 2002:a19:87d4:: with SMTP id j203mr5630242lfd.379.1611775900060; Wed, 27 Jan 2021 11:31:40 -0800 (PST) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com. [209.85.167.47]) by smtp.gmail.com with ESMTPSA id r22sm875724ljc.90.2021.01.27.11.31.38 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Jan 2021 11:31:38 -0800 (PST) Received: by mail-lf1-f47.google.com with SMTP id p21so4274926lfu.11 for ; Wed, 27 Jan 2021 11:31:38 -0800 (PST) X-Received: by 2002:ac2:420a:: with SMTP id y10mr5554909lfh.377.1611775897778; Wed, 27 Jan 2021 11:31:37 -0800 (PST) MIME-Version: 1.0 References: <000000000000672eda05b9e291ff@google.com> In-Reply-To: <000000000000672eda05b9e291ff@google.com> From: Linus Torvalds Date: Wed, 27 Jan 2021 11:31:21 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: KASAN: invalid-free in p9_client_create (2) To: syzbot , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton Cc: Dominique Martinet , David Miller , ericvh@gmail.com, Jakub Kicinski , Linux Kernel Mailing List , lucho@ionkov.net, Netdev , syzkaller-bugs , v9fs-developer@lists.sourceforge.net, wanghai38@huawei.com, Linux-MM Content-Type: text/plain; charset="UTF-8" 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: [ 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