Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp490394pxv; Thu, 24 Jun 2021 12:31:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXgDfmJz4fCY0hvC2LyUrG4KsBEYtQckGT9JLTzWZVxyfKE7K/dve+WuttHRBPxOrAD1mE X-Received: by 2002:a50:b2c5:: with SMTP id p63mr9357932edd.5.1624563069394; Thu, 24 Jun 2021 12:31:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624563069; cv=none; d=google.com; s=arc-20160816; b=woxchtjuP8V0/XNFrwrBeezxvp6bky+O42iG4uyYCXET/2gFlMn+zCyWHRv6lD79KR hPFw/97h+uBMmZ/NxKH4+LgKmh3EDZ41r4Z5mLEh80ZAxgYsVsxGDkrqEybj8DQIfaMp TfsrIZsCtEfY5cRPJmlILwv+OwE/V0dckbDt1A726JqXq1RpN6MkCCiYNfJQ/s94h7Sl UKOdzJw8ZRRZrEn6WXyn+GMyKNXkE4xN9H8Bk8tTgw9iTOIuqIL1lgVxNQzNTuPqTLEe fsqkzU6wRoUzbgV35Aom8jeQS61D3SH/vpP1CvkyNZpWNYydA3ceJ+UfSAqoX2qcnC+i uO1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=l0vCZVJmlxeZsHP1JHZxI0c+0Gn87IYlynAirE52ORE=; b=fKg0uXM5efu6ZG96EY+qq+MngJHBAfHvxq8vGStOcTfV3vtgl0m+zCUsW2dew1HMGK Cw5vyR525rii3bY+bF/yQp8z+Gs/5e33YL+hEkVITDOlM6C9f8VpMVL5LKYMjURTWvaA gYe+hyWVvYJxoYWuQg+69MSHnb06pOTzkPBWlF6anA2YXcgSS8prpBB2DBtU2YJJSYje MxYPkVXMtrmOjpd6Sx13PivCPsN7guM2bx446TTTZLuZmxv2gAg7My5fsPvz1CwlW4qk /PXKUIt5GszO7tjCz0VZHPVH8pkp43dFNyfa5ew+bigxMTdAVXk2Q+LtR78f9joj6x96 OOBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HWs70M2r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 23si3975260ejg.6.2021.06.24.12.30.45; Thu, 24 Jun 2021 12:31:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HWs70M2r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232554AbhFXTb4 (ORCPT + 99 others); Thu, 24 Jun 2021 15:31:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232029AbhFXTb4 (ORCPT ); Thu, 24 Jun 2021 15:31:56 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84682C061574; Thu, 24 Jun 2021 12:29:36 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id hz1so11260391ejc.1; Thu, 24 Jun 2021 12:29:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=l0vCZVJmlxeZsHP1JHZxI0c+0Gn87IYlynAirE52ORE=; b=HWs70M2rMsBn+n0I+yCR6V0lcXTcc5lOy9y+1P1OuFVoXbPbE+pa7mAROQTLu8I6i0 +5Ch4iiHXSMBd6U/AlKh/M82F+UAIJIHUl8DFDb2qpfERlWuKqrVtQg2bSEcGX0ZQQQs ZEweBw6cGsdvqbKKMibmup65JwEyyfhopU6G8Yq6RW2Dgbc6T/ZB0GfXxzGbfJs73eUU PNvYUMQ/wEgujB3FCkM9qby/sfU1b2nGqnb4z3qemiXfZuxmLfKCx7kyQrMBOLFQg1bk Z3UR8+nFp1/tPw6XrZ0cqCYnprT/LqnYL7ZerZU9qH4J/dnwMLrbh1zg5MxHEglYro38 gRVQ== 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=l0vCZVJmlxeZsHP1JHZxI0c+0Gn87IYlynAirE52ORE=; b=Sm3NJ4aDapMW/L2hEJ98pNuNTTuRrq7s4/HtTasyJyp3wdHtpAqFFBQW70BRsgvO18 IEMi2A445ftnwLJ1OsIDmSz6WFhUmut79jpsclcJOBsKK/eKCAoSv5HBdaPdJHk+p4Dz IKLeTvbFpZRw2QHtiXgA7QoToFEkL/m3zaJ4eZPhrA2giyleTdIDzIF0oo4U3VgygPUH aCeKz4zVC/m7Xzu+YUDVNMufkBKLaeRc1yGRH3C7lNwhVVsUuqrOCi3FW6HIHsWsXvIq Lt/JCyCIFgkYmuohgdXFMs9zJ8qvJjW+Oiyj1Es3tmKPe+ppHkst05gV5p5/jx9THynr dbuA== X-Gm-Message-State: AOAM530OoxzYbfVrM8EpY+7uwBp4guYdols4JrsHf4heMias0rLWRXaG ULbQQACpIPyElgGWxZrn+W9krCmWNU7VsgzjrW0= X-Received: by 2002:a17:906:2844:: with SMTP id s4mr6760586ejc.263.1624562974956; Thu, 24 Jun 2021 12:29:34 -0700 (PDT) MIME-Version: 1.0 References: <20210612140559.20022-1-paskripkin@gmail.com> In-Reply-To: <20210612140559.20022-1-paskripkin@gmail.com> From: Ryusuke Konishi Date: Fri, 25 Jun 2021 04:29:22 +0900 Message-ID: Subject: Re: [PATCH] nilfs2: fix memory leak in nilfs_sysfs_delete_device_group To: Andrew Morton Cc: Pavel Skripkin , Vyacheslav Dubeyko , linux-nilfs , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andrew, On Sat, Jun 12, 2021 at 11:06 PM Pavel Skripkin wrote: > > My local syzbot instance hit memory leak in nilfs2. > The problem was in missing kobject_put() in > nilfs_sysfs_delete_device_group(). > > kobject_del() does not call kobject_cleanup() for > passed kobject and it leads to leaking duped > kobject name if kobject_put() was not called. > > Fail log: > > BUG: memory leak > unreferenced object 0xffff8880596171e0 (size 8): > comm "syz-executor379", pid 8381, jiffies 4294980258 (age 21.100s) > hex dump (first 8 bytes): > 6c 6f 6f 70 30 00 00 00 loop0... > backtrace: > [] kstrdup+0x36/0x70 mm/util.c:60 > [] kstrdup_const+0x53/0x80 mm/util.c:83 > [] kvasprintf_const+0x108/0x190 lib/kasprintf.c:48 > [] kobject_set_name_vargs+0x56/0x150 lib/kobject.c:289 > [] kobject_add_varg lib/kobject.c:384 [inline] > [] kobject_init_and_add+0xc9/0x160 lib/kobject.c:473 > [] nilfs_sysfs_create_device_group+0x150/0x800 fs/nilfs2/sysfs.c:999 > [] init_nilfs+0xe26/0x12b0 fs/nilfs2/the_nilfs.c:637 > > Fixes: da7141fb78db ("nilfs2: add /sys/fs/nilfs2/ group") > Signed-off-by: Pavel Skripkin This fix looks correct to me. Acked-by: Ryusuke Konishi Thanks, Ryusuke Konishi > --- > fs/nilfs2/sysfs.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c > index 303d71430bdd..9c6c0e2e5880 100644 > --- a/fs/nilfs2/sysfs.c > +++ b/fs/nilfs2/sysfs.c > @@ -1053,6 +1053,7 @@ void nilfs_sysfs_delete_device_group(struct the_nilfs *nilfs) > nilfs_sysfs_delete_superblock_group(nilfs); > nilfs_sysfs_delete_segctor_group(nilfs); > kobject_del(&nilfs->ns_dev_kobj); > + kobject_put(&nilfs->ns_dev_kobj); > kfree(nilfs->ns_dev_subgroups); > } > > -- > 2.32.0 >