All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Linux 2.6.38-rc5
Date: Wed, 16 Feb 2011 16:19:29 +0000	[thread overview]
Message-ID: <20110216161929.GF22723@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20110216160643.GE22723@ZenIV.linux.org.uk>

On Wed, Feb 16, 2011 at 04:06:43PM +0000, Al Viro wrote:

> Sigh...  I see what's going on.  We'd got inode from dentry that is getting
> crapped under us.  We will *not* survive dropping RCU - it's bad enough for
> full restart in normal mode.  So right after we'd seen that (already wrong)
> inode has ->follow_link(), we decide to drop RCU.  Originally this BUG_ON
> hadn't been reached in that case - we had already failed with -ECHILD before
> we got to it.  Now we don't...
> 
> _However_, I don't like passing inode to do_follow_link().  I'd rather set
> nd->inode to inode first and use it there.  Let me think a bit and see if
> it's feasible...

No, that won't do.  The damn thing uses previous value of nd->inode if
it walks into relative symlink...

	Let's shift that call of nameidata_dentry_drop_rcu_maybe() into both
callers of do_follow_link() instead.  Marginally less obvious that we won't
reach the guts of do_follow_link() in RCU mode, just as obvious that overall
structure is ugly as hell and avoids making it even uglier by passing inode
down there.  How about this:

diff --git a/fs/namei.c b/fs/namei.c
index 9e701e2..d7003cf 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -800,10 +800,6 @@ static inline int do_follow_link(struct path *path, struct nameidata *nd)
 	void *cookie;
 	int err = -ELOOP;
 
-	/* We drop rcu-walk here */
-	if (nameidata_dentry_drop_rcu_maybe(nd, path->dentry))
-		return -ECHILD;
-
 	if (current->link_count >= MAX_NESTED_LINKS)
 		goto loop;
 	if (current->total_link_count >= 40)
@@ -1413,6 +1409,9 @@ exec_again:
 			goto out_dput;
 
 		if (inode->i_op->follow_link) {
+			/* We drop rcu-walk here */
+			if (nameidata_dentry_drop_rcu_maybe(nd, next.dentry))
+				return -ECHILD;
 			BUG_ON(inode != next.dentry->d_inode);
 			err = do_follow_link(&next, nd);
 			if (err)
@@ -1458,6 +1457,8 @@ last_component:
 			break;
 		if (inode && unlikely(inode->i_op->follow_link) &&
 		    (lookup_flags & LOOKUP_FOLLOW)) {
+			if (nameidata_dentry_drop_rcu_maybe(nd, next.dentry))
+				return -ECHILD;
 			BUG_ON(inode != next.dentry->d_inode);
 			err = do_follow_link(&next, nd);
 			if (err)

  reply	other threads:[~2011-02-16 16:19 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-16  4:16 Linux 2.6.38-rc5 Linus Torvalds
2011-02-16 11:14 ` Eric Dumazet
2011-02-16 13:55   ` Eric Dumazet
2011-02-16 15:46   ` Linus Torvalds
2011-02-16 16:06     ` Al Viro
2011-02-16 16:19       ` Al Viro [this message]
2011-02-16 16:33         ` Linus Torvalds
2011-02-16 16:39           ` Al Viro
2011-02-16 16:47             ` Eric Dumazet
2011-02-16 16:22     ` Eric Dumazet
2011-02-16 19:26 ` [PATCH] fix backlight brightness on intel LVDS panel after reopening lid Alex Riesen
2011-02-16 19:46   ` Alex Riesen
2011-02-16 19:54     ` Jesse Barnes
2011-02-16 19:59       ` Alex Riesen
2011-02-16 20:05         ` Jesse Barnes
2011-02-16 20:28           ` Alex Riesen
2011-02-17  1:41     ` [PATCH] drm/i915: Do not handle backlight combination mode specially Indan Zupancic
2011-02-17  1:41       ` Indan Zupancic
2011-02-17 22:13   ` [PATCH] fix backlight brightness on intel LVDS panel after reopening lid Tino Keitel
2011-02-18  4:57     ` Indan Zupancic
2011-02-19 12:11       ` Alex Riesen
2011-02-19 12:26         ` Alex Riesen
2011-02-19 23:07           ` Linus Torvalds
2011-02-19 23:07             ` Linus Torvalds
2011-02-22 21:04             ` Jesse Barnes
2011-02-22 21:04               ` Jesse Barnes
2011-02-22 22:31               ` Tino Keitel
2011-02-23  1:09                 ` Linus Torvalds
2011-02-23  1:09                   ` Linus Torvalds
2011-03-04  6:53                   ` Indan Zupancic
2011-03-04  6:53                     ` Indan Zupancic
2011-03-04 18:47                     ` Linus Torvalds
2011-03-04 23:32                       ` Indan Zupancic
2011-03-04 23:32                         ` Indan Zupancic
2011-03-06 17:40                       ` Alex Riesen
2011-03-10  5:50                       ` Indan Zupancic
2011-03-10  5:50                         ` Indan Zupancic
2011-03-10  6:00                         ` Indan Zupancic
2011-03-10  6:00                           ` Indan Zupancic
2011-03-10  7:49                         ` Takashi Iwai
2011-03-10  7:49                           ` Takashi Iwai
2011-03-10  8:25                           ` Takashi Iwai
2011-03-10 10:06                             ` Indan Zupancic
2011-03-10 10:06                               ` Indan Zupancic
2011-03-10 12:59                               ` Takashi Iwai
2011-03-10 13:02                               ` [PATCH] drm/i915: Revive combination mode for backlight control Takashi Iwai
2011-03-10 19:36                                 ` Keith Packard
2011-03-10 19:36                                   ` Keith Packard
2011-03-11  1:30                                   ` Indan Zupancic
2011-03-11  1:23                                 ` Indan Zupancic
2011-03-11  1:28                                   ` Linus Torvalds
2011-03-11  1:28                                     ` Linus Torvalds
2011-03-11  7:26                                   ` Takashi Iwai
2011-03-11  9:08                                     ` Indan Zupancic
2011-03-11  9:08                                       ` Indan Zupancic
2011-03-11  7:34                                   ` Keith Packard
2011-03-11  7:34                                     ` Keith Packard
2011-03-10  8:45                           ` [PATCH] fix backlight brightness on intel LVDS panel after reopening lid Indan Zupancic
2011-03-10 12:51                             ` Takashi Iwai
2011-03-05  0:26                     ` Peter Stuge
2011-03-05  0:26                       ` Peter Stuge
2011-02-23  1:32               ` Indan Zupancic
2011-02-23  1:32                 ` Indan Zupancic
2011-02-18  5:45   ` Tino Keitel
2011-02-20 14:03 ` Linux 2.6.38-rc5 Paul Rolland

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=20110216161929.GF22723@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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.