linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Hillf Danton <hdanton@sina.com>
Cc: syzbot <syzbot+38f5d5cf7ae88c46b11a@syzkaller.appspotmail.com>,
	gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	syzkaller-bugs@googlegroups.com
Subject: Re: WARNING in kernfs_create_dir_ns
Date: Mon, 8 Jul 2019 07:46:32 -0700	[thread overview]
Message-ID: <20190708144632.GB657710@devbig004.ftw2.facebook.com> (raw)
In-Reply-To: <0000000000003bbf1b058c83f55a@google.com>

Hello,

On Mon, Jul 01, 2019 at 01:52:35PM +0800, Hillf Danton wrote:
> >WARNING: CPU: 0 PID: 8613 at fs/kernfs/dir.c:493 kernfs_get  fs/kernfs/dir.c:493 [inline]
> >WARNING: CPU: 0 PID: 8613 at fs/kernfs/dir.c:493 kernfs_new_node  fs/kernfs/dir.c:700 [inline]
> >WARNING: CPU: 0 PID: 8613 at fs/kernfs/dir.c:493 kernfs_create_dir_ns+0x205/0x230 fs/kernfs/dir.c:1022
...
> --- a/fs/sysfs/dir.c
> +++ b/fs/sysfs/dir.c
> @@ -53,6 +53,10 @@ int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
> 	if (!parent)
> 		return -ENOENT;
> 
> +	/* create dir if parent is not dying */
> +	if (!atomic_inc_not_zero(&parent->count))
> +		return -ENOENT;
> +
> 	kobject_get_ownership(kobj, &uid, &gid);
> 
> 	kn = kernfs_create_dir_ns(parent, kobject_name(kobj),
> @@ -61,10 +65,12 @@ int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
> 	if (IS_ERR(kn)) {
> 		if (PTR_ERR(kn) == -EEXIST)
> 			sysfs_warn_dup(parent, kobject_name(kobj));
> +		kernfs_put(parent);
> 		return PTR_ERR(kn);
> 	}
> 
> 	kobj->sd = kn;
> +	kernfs_put(parent);

I don't think this is the correct fix.  It's being called with kobj
whose parent's sysfs node is dangling.  It gotta be fixed from the
caller side.

Thanks.

-- 
tejun

  reply	other threads:[~2019-07-08 14:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-29 13:12 WARNING in kernfs_create_dir_ns syzbot
2019-06-30  5:41 ` syzbot
2019-07-08 14:46   ` Tejun Heo [this message]
2019-06-30 10:40 ` syzbot
2020-04-16  0:11 ` syzbot
2020-04-16  0:30   ` Waiman Long
     [not found] <20190709022335.12928-1-hdanton@sina.com>
2019-07-09 14:22 ` Tejun Heo

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=20190708144632.GB657710@devbig004.ftw2.facebook.com \
    --to=tj@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdanton@sina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+38f5d5cf7ae88c46b11a@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).