All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Ryusuke Konishi <konishi.ryusuke@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Pavel Skripkin <paskripkin@gmail.com>,
	Vyacheslav Dubeyko <Vyacheslav.Dubeyko@hgst.com>,
	linux-nilfs <linux-nilfs@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] nilfs2: fix memory leak in nilfs_sysfs_delete_device_group
Date: Fri, 25 Jun 2021 04:29:22 +0900	[thread overview]
Message-ID: <CAKFNMokV7WC_6LVBKJ2mN26w91ZT=rfLvzD5v4cYahHH2ZUWpQ@mail.gmail.com> (raw)
In-Reply-To: <20210612140559.20022-1-paskripkin@gmail.com>

Hi Andrew,

On Sat, Jun 12, 2021 at 11:06 PM Pavel Skripkin <paskripkin@gmail.com> 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:
>     [<ffffffff81a2c656>] kstrdup+0x36/0x70 mm/util.c:60
>     [<ffffffff81a2c6e3>] kstrdup_const+0x53/0x80 mm/util.c:83
>     [<ffffffff83ccc698>] kvasprintf_const+0x108/0x190 lib/kasprintf.c:48
>     [<ffffffff83e99926>] kobject_set_name_vargs+0x56/0x150 lib/kobject.c:289
>     [<ffffffff83e99fd9>] kobject_add_varg lib/kobject.c:384 [inline]
>     [<ffffffff83e99fd9>] kobject_init_and_add+0xc9/0x160 lib/kobject.c:473
>     [<ffffffff8304e840>] nilfs_sysfs_create_device_group+0x150/0x800 fs/nilfs2/sysfs.c:999
>     [<ffffffff830159f6>] init_nilfs+0xe26/0x12b0 fs/nilfs2/the_nilfs.c:637
>
> Fixes: da7141fb78db ("nilfs2: add /sys/fs/nilfs2/<device> group")
> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>

This fix looks correct to me.

Acked-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>

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
>

WARNING: multiple messages have this Message-ID (diff)
From: Ryusuke Konishi <konishi.ryusuke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Cc: Pavel Skripkin
	<paskripkin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Vyacheslav Dubeyko
	<Vyacheslav.Dubeyko-XckBA8eALwE@public.gmane.org>,
	linux-nilfs <linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] nilfs2: fix memory leak in nilfs_sysfs_delete_device_group
Date: Fri, 25 Jun 2021 04:29:22 +0900	[thread overview]
Message-ID: <CAKFNMokV7WC_6LVBKJ2mN26w91ZT=rfLvzD5v4cYahHH2ZUWpQ@mail.gmail.com> (raw)
In-Reply-To: <20210612140559.20022-1-paskripkin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Hi Andrew,

On Sat, Jun 12, 2021 at 11:06 PM Pavel Skripkin <paskripkin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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:
>     [<ffffffff81a2c656>] kstrdup+0x36/0x70 mm/util.c:60
>     [<ffffffff81a2c6e3>] kstrdup_const+0x53/0x80 mm/util.c:83
>     [<ffffffff83ccc698>] kvasprintf_const+0x108/0x190 lib/kasprintf.c:48
>     [<ffffffff83e99926>] kobject_set_name_vargs+0x56/0x150 lib/kobject.c:289
>     [<ffffffff83e99fd9>] kobject_add_varg lib/kobject.c:384 [inline]
>     [<ffffffff83e99fd9>] kobject_init_and_add+0xc9/0x160 lib/kobject.c:473
>     [<ffffffff8304e840>] nilfs_sysfs_create_device_group+0x150/0x800 fs/nilfs2/sysfs.c:999
>     [<ffffffff830159f6>] init_nilfs+0xe26/0x12b0 fs/nilfs2/the_nilfs.c:637
>
> Fixes: da7141fb78db ("nilfs2: add /sys/fs/nilfs2/<device> group")
> Signed-off-by: Pavel Skripkin <paskripkin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

This fix looks correct to me.

Acked-by: Ryusuke Konishi <konishi.ryusuke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

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
>

  reply	other threads:[~2021-06-24 19:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-12 14:05 [PATCH] nilfs2: fix memory leak in nilfs_sysfs_delete_device_group Pavel Skripkin
2021-06-12 14:05 ` Pavel Skripkin
2021-06-24 19:29 ` Ryusuke Konishi [this message]
2021-06-24 19:29   ` Ryusuke Konishi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKFNMokV7WC_6LVBKJ2mN26w91ZT=rfLvzD5v4cYahHH2ZUWpQ@mail.gmail.com' \
    --to=konishi.ryusuke@gmail.com \
    --cc=Vyacheslav.Dubeyko@hgst.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nilfs@vger.kernel.org \
    --cc=paskripkin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.