public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joel Becker <jlbec@evilplan.org>
To: Jiri Slaby <jslaby@suse.cz>
Cc: npiggin@kernel.dk, Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	Jiri Slaby <jirislaby@gmail.com>
Subject: Re: OOPS in configfs when doing d_delete
Date: Tue, 22 Feb 2011 01:14:16 -0800	[thread overview]
Message-ID: <20110222091415.GD30966@noexit> (raw)
In-Reply-To: <4D6242AD.2090600@suse.cz>

On Mon, Feb 21, 2011 at 11:47:09AM +0100, Jiri Slaby wrote:
> > 	I think you're right about the superfluous test, but I need more
> > investigation to see what's going on.  Thanks for the report.
> > 	What was causing attach_group() to fail?  Do you know?
> 
> Dunno, I just modprobe'd the configfs example from Doc dir
> (configfs_example_macros).

	I'm going to revisit the failed example (which shouldn't fail, I
would think).  Can you try the following patch to safely handle the
failure rather than crashing the kernel?

Joel

>From 68bbb327c48fdcdc48b71435d19b9e899745adf0 Mon Sep 17 00:00:00 2001
From: Joel Becker <jlbec@evilplan.org>
Date: Tue, 22 Feb 2011 01:09:49 -0800
Subject: [PATCH] configfs: Don't try to d_delete() negative dentries.

When configfs is faking mkdir() on its subsystem or default group
objects, it starts by adding a negative dentry.  It then tries to
instantiate the group.  If that should fail, it must clean up after
itself.

I was using d_delete() here, but configfs_attach_group() promises to
return an empty dentry on error.  d_delete() explodes with the entry
dentry.  Let's try d_drop() instead.  The unhashing is what we want for
our dentry.

Signed-off-by: Joel Becker <jlbec@evilplan.org>
---
 fs/configfs/dir.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 90ff3cb..2af26b8 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -689,7 +689,8 @@ static int create_default_group(struct config_group *parent_group,
 			sd = child->d_fsdata;
 			sd->s_type |= CONFIGFS_USET_DEFAULT;
 		} else {
-			d_delete(child);
+			BUG_ON(child->d_inode);
+			d_drop(child);
 			dput(child);
 		}
 	}
@@ -1683,7 +1684,8 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys)
 		err = configfs_attach_group(sd->s_element, &group->cg_item,
 					    dentry);
 		if (err) {
-			d_delete(dentry);
+			BUG_ON(dentry->d_inode);
+			d_drop(dentry);
 			dput(dentry);
 		} else {
 			spin_lock(&configfs_dirent_lock);
-- 
1.7.3.1


-- 

"But then she looks me in the eye
 And says, 'We're going to last forever,'
 And man you know I can't begin to doubt it.
 Cause it just feels so good and so free and so right,
 I know we ain't never going to change our minds about it, Hey!
 Here comes my girl."

			http://www.jlbec.org/
			jlbec@evilplan.org

  reply	other threads:[~2011-02-22  9:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-21 10:20 OOPS in configfs when doing d_delete Jiri Slaby
2011-02-21 10:44 ` Joel Becker
2011-02-21 10:47   ` Jiri Slaby
2011-02-22  9:14     ` Joel Becker [this message]
2011-03-01 22:42       ` Jiri Slaby
2011-05-12  9:34       ` Jiri Slaby
2011-05-18 19:58         ` Joel Becker
2011-05-27 21:12           ` Jiri Slaby
2011-05-27 21:13             ` Joel Becker

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=20110222091415.GD30966@noexit \
    --to=jlbec@evilplan.org \
    --cc=jirislaby@gmail.com \
    --cc=jslaby@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npiggin@kernel.dk \
    --cc=viro@zeniv.linux.org.uk \
    /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