From: Trond Myklebust <trond.myklebust@fys.uio.no>
To: David Howells <dhowells@redhat.com>
Cc: Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org, aviro@redhat.com,
Ian Kent <raven@themaw.net>
Subject: Re: [PATCH] NFS: Revalidate on readdir referring to null dentry
Date: Wed, 16 Aug 2006 11:49:59 -0400 [thread overview]
Message-ID: <1155743399.5683.13.camel@localhost> (raw)
In-Reply-To: <5910.1155741329@warthog.cambridge.redhat.com>
On Wed, 2006-08-16 at 16:15 +0100, David Howells wrote:
> Andrew Morton <akpm@osdl.org> wrote:
>
> > This kernel breaks autofs /net handling. Bisection shows that the bug is
> > introduced by git-nfs.patch.
>
> Does this patch fix your problem?
>
> David
> ---
> NFS: Revalidate on readdir referring to null dentry
>
> From: David Howells <dhowells@redhat.com>
>
> Have nfs_readdir_lookup() force dentry revalidation when it comes across a
> name specified by a READDIR RPC call that corresponds to a negative dentry in
> the dcache.
>
> This can be caused by an optimisation in nfs_lookup() that causes a dentry to
> be incorrectly left as negative when mkdir() or similar is aborted by SELinux
> mid-procedure.
>
> This can be triggered by mounting through autofs4 a server:/ NFS share for
> which there are other exports available on that server. SELinux also has to
> be turned on in enforcing mode to abort mid-flow the mkdir operation performed
> by autofs4.
>
> The problematic sequence of events is this:
>
> (1) nfs_lookup() is called by sys_mkdirat() -> lookup_create() ->
> __lookup_hash() with intent to create exclusively set in the nameidata:
>
> nd->flags == LOOKUP_CREATE
> nd->intent.open.flags == O_EXCL
>
> (2) nfs_lookup() has an optimisation to avoid going to the server in this
> case, presumably since the nfs_mkdir() op or whatever will deal with the
> conflict.
>
> (3) nfs_lookup() returns successfully, leaving the dentry in a negative state,
> but attached to the parent directory.
>
> (4) sys_mkdirat() calls vfs_mkdir() which calls may_create(). may_create()
> checks that the directory has MAY_WRITE and MAY_EXEC permissions.
>
> (5) may_create() calls nfs_permission(), which grants permission.
>
> (6) may_create() calls security_inode_permission(), which calls SELinux, which
> then _DENIES_ permission.
>
> (7) may_create() fails, and vfs_mkdir() then fails and sys_mkdirat() then
> fails (as does sys_mkdir).
>
> _However_, the new dentry is left in the negative state, with no
> consultation of the server.
>
> (8) The parent directory is listed, and the name of the new dentry is
> returned.
>
> (9) stat on the new dentry fails (because it's negative), and "ls -l" returns
> "?---------" as the file type and mode.
>
> This fix makes step (8) cause a revalidation to occur on the dentry at the
> start of step (9).
>
> Signed-Off-By: David Howells <dhowells@redhat.com>
> ---
>
> fs/nfs/dir.c | 16 +++++++++++++++-
> include/linux/dcache.h | 5 +++++
> 2 files changed, 20 insertions(+), 1 deletions(-)
>
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index e746ed1..901b382 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -745,6 +745,13 @@ static int nfs_lookup_revalidate(struct
> nfs_inc_stats(dir, NFSIOS_DENTRYREVALIDATE);
> inode = dentry->d_inode;
>
> + if (dentry->d_flags & DCACHE_NEED_REVALIDATE) {
This flag is redundant. There already exist methods for determining if a
dentry needs revalidation by means of the nfs_*_verifier() functions. If
you want to force a dentry lookup upon next revalidation, then add
something like
void nfs_dentry_force_revalidate(struct inode *dir, struct dentry *dentry)
{
nfs_set_verifier(dentry, nfs_save_change_attribute(dir) - 1);
}
Better still, in the case of a negative dentry: just call d_drop().
Cheers,
Trond
> + spin_lock(&dentry->d_lock);
> + dentry->d_flags &= ~DCACHE_NEED_REVALIDATE;
> + spin_unlock(&dentry->d_lock);
> + goto out_bad;
> + }
> +
> if (!inode) {
> if (nfs_neg_need_reval(dir, dentry, nd))
> goto out_bad;
> @@ -1105,8 +1112,15 @@ static struct dentry *nfs_readdir_lookup
> }
> name.hash = full_name_hash(name.name, name.len);
> dentry = d_lookup(parent, &name);
> - if (dentry != NULL)
> + if (dentry != NULL) {
> + /* negative dentries must be reconsidered */
> + if (!IS_ERR(dentry) && !dentry->d_inode) {
> + spin_lock(&dentry->d_lock);
> + dentry->d_flags |= DCACHE_NEED_REVALIDATE;
> + spin_unlock(&dentry->d_lock);
> + }
> return dentry;
> + }
> if (!desc->plus || !(entry->fattr->valid & NFS_ATTR_FATTR))
> return NULL;
> /* Note: caller is already holding the dir->i_mutex! */
> diff --git a/include/linux/dcache.h b/include/linux/dcache.h
> index 63f64a9..c401a7d 100644
> --- a/include/linux/dcache.h
> +++ b/include/linux/dcache.h
> @@ -176,6 +176,11 @@ #define DCACHE_UNHASHED 0x0010
>
> #define DCACHE_INOTIFY_PARENT_WATCHED 0x0020 /* Parent inode is watched */
>
> +#define DCACHE_NEED_REVALIDATE 0x0040
> + /* Dentry needs revalidation by filesystem. Set by NFS, for example,
> + * when we see in a directory listing a file for which we have a
> + * negative dentry */
> +
> extern spinlock_t dcache_lock;
>
> /**
next prev parent reply other threads:[~2006-08-16 15:50 UTC|newest]
Thread overview: 186+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-13 8:24 2.6.18-rc4-mm1 Andrew Morton
2006-08-13 11:45 ` 2.6.18-rc4-mm1 Maciej Rutecki
2006-08-13 19:11 ` 2.6.18-rc4-mm1 Andrew Morton
2006-08-13 22:44 ` 2.6.18-rc4-mm1 Ben Buxton
2006-08-13 22:58 ` 2.6.18-rc4-mm1 Michal Piotrowski
2006-08-13 23:25 ` 2.6.18-rc4-mm1 Dave Jones
2006-08-14 11:55 ` 2.6.18-rc4-mm1 Ben Buxton
2006-08-14 20:20 ` 2.6.18-rc4-mm1 Dave Jones
2006-08-14 21:13 ` 2.6.18-rc4-mm1 Ben B
2006-08-14 21:22 ` 2.6.18-rc4-mm1 Dave Jones
2006-08-14 21:46 ` 2.6.18-rc4-mm1 Andrew Morton
2006-08-14 0:00 ` 2.6.18-rc4-mm1 Dmitry Torokhov
2006-08-14 12:03 ` 2.6.18-rc4-mm1 Ben B
2006-08-14 13:45 ` 2.6.18-rc4-mm1 Dmitry Torokhov
2006-08-14 21:44 ` 2.6.18-rc4-mm1 Ben B
2006-08-15 2:23 ` 2.6.18-rc4-mm1 Dmitry Torokhov
2022-08-14 8:42 ` 2.6.18-rc4-mm1 Maciej Rutecki
2006-08-14 9:12 ` 2.6.18-rc4-mm1 Rafael J. Wysocki
2006-08-14 11:35 ` 2.6.18-rc4-mm1 Maciej Rutecki
2006-08-15 0:27 ` Linux Kernel Developer opening Eric Radman
2006-08-17 12:22 ` 2.6.18-rc4-mm1 Andreas Mohr
2006-08-18 10:30 ` 2.6.18-rc4-mm1 Andy Whitcroft
2006-08-13 23:58 ` 2.6.18-rc4-mm1 Dmitry Torokhov
[not found] ` <d120d5000608140643tddd9ce4o986560740ef5dbd7@mail.gmail.com>
2006-08-14 18:24 ` 2.6.18-rc4-mm1 Maciej Rutecki
2006-08-13 12:24 ` 2.6.18-rc4-mm1 Michal Piotrowski
2006-08-14 6:36 ` 2.6.18-rc4-mm1 Reuben Farrelly
2006-08-14 9:06 ` 2.6.18-rc4-mm1 Rafael J. Wysocki
2006-08-13 12:43 ` 2.6.18-rc4-mm1 Rafael J. Wysocki
2006-08-13 14:32 ` [patch] fix posix timer errors Frederik Deweerdt
2006-08-13 17:23 ` Andrew Morton
2006-08-13 15:30 ` [-mm patch] arch/i386/mm/ioremap.c must #include <asm/cacheflush.h> Adrian Bunk
2006-08-13 15:30 ` 2.6.18-rc4-mm1: drivers/video/sis/ compile error Adrian Bunk
2006-08-13 16:29 ` Michal Piotrowski
2006-08-13 16:40 ` Adrian Bunk
2006-08-13 17:20 ` Michal Piotrowski
2006-08-13 17:38 ` 2.6.18-rc4-mm1 Laurent Riffard
2006-08-13 20:39 ` 2.6.18-rc4-mm1 Andrew Morton
2006-08-14 7:58 ` 2.6.18-rc4-mm1 David Howells
2006-08-14 8:06 ` 2.6.18-rc4-mm1 Ian Kent
2006-08-14 9:32 ` 2.6.18-rc4-mm1 David Howells
2006-08-14 17:16 ` 2.6.18-rc4-mm1 Andrew Morton
2006-08-14 18:12 ` 2.6.18-rc4-mm1 David Howells
2006-08-14 18:17 ` 2.6.18-rc4-mm1 David Howells
2006-08-14 18:24 ` 2.6.18-rc4-mm1 Andrew Morton
2006-08-14 18:32 ` 2.6.18-rc4-mm1 David Howells
2006-08-14 21:31 ` 2.6.18-rc4-mm1 Andrew Morton
2006-08-15 9:51 ` 2.6.18-rc4-mm1 David Howells
2006-08-15 13:50 ` 2.6.18-rc4-mm1 Andrew Morton
2006-08-15 14:47 ` 2.6.18-rc4-mm1 David Howells
2006-08-15 16:15 ` 2.6.18-rc4-mm1 Andrew Morton
2006-08-15 17:29 ` 2.6.18-rc4-mm1 David Howells
2006-08-15 17:48 ` 2.6.18-rc4-mm1 Andrew Morton
2006-08-15 18:35 ` 2.6.18-rc4-mm1 David Howells
2006-08-15 18:49 ` 2.6.18-rc4-mm1 Andrew Morton
2006-08-15 19:20 ` 2.6.18-rc4-mm1 David Howells
2006-08-16 9:34 ` 2.6.18-rc4-mm1 David Howells
2006-08-16 10:00 ` 2.6.18-rc4-mm1 David Howells
2006-08-16 12:23 ` 2.6.18-rc4-mm1 David Howells
2006-08-16 12:58 ` 2.6.18-rc4-mm1 Ian Kent
2006-08-16 13:20 ` 2.6.18-rc4-mm1 David Howells
2006-08-16 12:36 ` 2.6.18-rc4-mm1 Ian Kent
2006-08-14 22:49 ` 2.6.18-rc4-mm1 Trond Myklebust
2006-08-14 23:51 ` 2.6.18-rc4-mm1 Andrew Morton
2006-08-15 16:39 ` 2.6.18-rc4-mm1 David Howells
2006-08-15 16:55 ` 2.6.18-rc4-mm1 David Howells
2006-08-15 17:13 ` 2.6.18-rc4-mm1 Trond Myklebust
2006-08-15 17:22 ` 2.6.18-rc4-mm1 David Howells
2006-08-16 15:15 ` [PATCH] NFS: Revalidate on readdir referring to null dentry David Howells
2006-08-16 15:49 ` Trond Myklebust [this message]
2006-08-16 16:15 ` [PATCH] NFS: Replace null dentries that appear in readdir's list David Howells
2006-08-16 16:35 ` Trond Myklebust
2006-08-17 5:12 ` Ian Kent
2006-08-17 7:42 ` Andrew Morton
2006-08-17 12:13 ` David Howells
2006-08-17 12:33 ` David Howells
2006-08-18 9:09 ` David Howells
2006-08-17 13:24 ` David Howells
2006-08-17 13:45 ` David Howells
2006-08-18 0:47 ` Ian Kent
2006-08-18 9:21 ` David Howells
2006-08-18 0:58 ` Ian Kent
2006-08-18 1:05 ` Ian Kent
2006-08-18 9:38 ` [PATCH] NFS: Replace null dentries that appear in readdir's list [try #2] David Howells
2006-08-19 16:48 ` Andrew Morton
2006-08-20 13:15 ` David Howells
2006-08-20 14:25 ` Ian Kent
2006-08-21 9:42 ` David Howells
2006-08-21 11:35 ` Ian Kent
2006-08-21 12:16 ` David Howells
2006-08-21 13:33 ` Ian Kent
2006-08-21 15:17 ` David Howells
2006-08-22 2:04 ` Ian Kent
2006-08-22 3:29 ` Ian Kent
2006-08-22 4:10 ` Trond Myklebust
2006-08-13 21:00 ` [-mm patch] make drivers/cpufreq/cpufreq_ondemand.c:powersave_bias_target() static Adrian Bunk
2006-08-13 21:00 ` [-mm patch] make drivers/hwmon/hdaps.c:transform_axes() static Adrian Bunk
2006-08-13 22:56 ` Shem Multinymous
2006-08-13 21:00 ` [-mm patch] drivers/media/dvb/frontends/: make 4 functions static Adrian Bunk
2006-08-13 21:00 ` [-mm patch] drivers/char/drm/: cleanups Adrian Bunk
2006-08-13 21:00 ` [-mm patch] kernel/time/ntp.c: possible cleanups Adrian Bunk
2006-08-13 21:01 ` [-mm patch] cleanup drivers/ata/Kconfig Adrian Bunk
2006-08-13 22:46 ` Alan Cox
2006-08-14 22:12 ` Adrian Bunk
2006-08-14 18:28 ` Jeff Garzik
2006-08-14 22:33 ` [libata " Adrian Bunk
2006-08-15 7:51 ` [-mm " Greg KH
2006-08-15 9:39 ` Adrian Bunk
2006-08-13 21:01 ` [-mm patch] net/decnet/: cleanups Adrian Bunk
2006-08-13 21:01 ` [-mm patch] net/ipv6/ip6_fib.c: make code static Adrian Bunk
2006-08-13 21:01 ` [-mm patch] Kconfig: move CRYPTO to the "Cryptographic options" menu Adrian Bunk
2006-08-13 22:40 ` Herbert Xu
2006-08-13 23:01 ` 2.6.18-rc4-mm1: ATI SB600 SATA drivers: modpost errors Adrian Bunk
2006-08-14 7:00 ` [patch -mm] s390: remove HIGHMEM dependencies Heiko Carstens
2006-08-14 14:13 ` Christoph Lameter
2006-08-14 14:02 ` 2.6.18-rc4-mm1 Michal Piotrowski
2006-08-14 18:19 ` 2.6.18-rc4-mm1 Andrew Morton
2006-08-14 19:01 ` 2.6.18-rc4-mm1 Michal Piotrowski
2006-08-14 19:20 ` 2.6.18-rc4-mm1 john stultz
2006-08-14 19:27 ` 2.6.18-rc4-mm1 Michal Piotrowski
2006-08-14 19:44 ` 2.6.18-rc4-mm1 john stultz
2006-08-14 20:48 ` 2.6.18-rc4-mm1 Michal Piotrowski
2006-08-14 20:56 ` 2.6.18-rc4-mm1 Dave Jones
2006-08-14 21:13 ` 2.6.18-rc4-mm1 Michal Piotrowski
2006-08-14 21:20 ` 2.6.18-rc4-mm1 Dave Jones
2006-08-14 22:08 ` 2.6.18-rc4-mm1 Michal Piotrowski
2006-08-14 14:38 ` 2.6.18-rc4-mm1: eth0: trigger_send() called with the transmitter busy Laurent Riffard
2006-08-14 16:50 ` Andrew Morton
2006-08-14 17:47 ` Laurent Riffard
2006-08-14 20:06 ` Laurent Riffard
2006-08-14 21:25 ` Rafael J. Wysocki
2006-08-14 23:01 ` Laurent Riffard
2006-08-15 10:10 ` Rafael J. Wysocki
2006-08-15 15:38 ` Laurent Riffard
2006-08-15 16:39 ` Rafael J. Wysocki
2006-08-14 15:11 ` [-mm PATCH] ioremap: fixed MIPS build error Yoichi Yuasa
2006-08-14 17:54 ` 2.6.18-rc4-mm1 Rafael J. Wysocki
2006-08-14 18:15 ` 2.6.18-rc4-mm1 Andrew Morton
2006-08-15 14:07 ` 2.6.18-rc4-mm1 Atsushi Nemoto
2006-08-15 17:14 ` 2.6.18-rc4-mm1 Rafael J. Wysocki
2006-08-15 13:25 ` 2.6.18-rc4-mm1 BUG, drm related Frederik Deweerdt
2006-08-15 14:16 ` Andrew Morton
2006-08-15 17:37 ` Frederik Deweerdt
2006-08-15 16:21 ` Andrew Morton
2006-08-18 11:11 ` oops while loading snd-seq-oss (was: Re: 2.6.18-rc4-mm1 BUG, drm related) Frederik Deweerdt
2006-08-18 15:52 ` Andrew Morton
2006-08-18 15:58 ` Takashi Iwai
2006-08-18 18:44 ` Frederik Deweerdt
2006-08-18 19:43 ` Frederik Deweerdt
2006-08-18 18:45 ` Frederik Deweerdt
2006-08-19 23:08 ` 2.6.18-rc4-mm1 BUG, drm relatedy Frederik Deweerdt
2006-08-21 11:24 ` Dave Airlie
2006-08-21 14:08 ` Frederik Deweerdt
2006-08-21 23:48 ` Dave Airlie
2006-08-16 9:41 ` 2.6.18-rc4-mm1 -- new depancy on curses development Andy Whitcroft
2006-08-16 10:35 ` Andy Whitcroft
2006-08-16 18:33 ` Sam Ravnborg
2006-08-16 19:26 ` Andy Whitcroft
2006-08-16 11:44 ` 2.6.18-rc4-mm1 BUG null pointer deref while saving a file Helge Hafting
2006-08-16 14:28 ` Dave Kleikamp
2006-08-18 8:24 ` Helge Hafting
2006-08-18 12:20 ` Dave Kleikamp
2006-08-17 22:10 ` 2.6.18-rc4-mm1 Spurious ACK/NAK on isa0060/serio0, 2.6.18-rc2 is fine Helge Hafting
2006-08-17 22:34 ` Helge Hafting
2006-08-18 21:56 ` Greg KH
2006-08-19 11:00 ` Helge Hafting
2006-08-17 22:44 ` 2.6.18-rc4-mm1 - time moving at 3x speed! Helge Hafting
2006-08-17 23:15 ` john stultz
2006-08-18 8:18 ` Helge Hafting
2006-08-18 9:34 ` Andi Kleen
2006-08-18 9:30 ` Helge Hafting
2006-08-18 10:55 ` Andi Kleen
2006-08-18 10:01 ` Helge Hafting
2006-08-18 10:24 ` Rafael J. Wysocki
2006-08-18 11:21 ` Andi Kleen
2006-08-18 22:23 ` Randy.Dunlap
2006-08-19 10:50 ` 2.6.18-rc4-mm1 - time moving at 3x speed, bisect finished Helge Hafting
2006-08-20 17:06 ` Roman Zippel
2006-08-20 17:51 ` thunder7
2006-08-20 19:24 ` Roman Zippel
2006-08-20 19:42 ` thunder7
2006-08-20 21:47 ` 2.6.18-rc4-mm1 - time moving at 3x speed, fix confirmed Helge Hafting
2006-08-19 23:16 ` [mm patch] drm, minor fixes Frederik Deweerdt
2006-08-20 9:37 ` Arjan van de Ven
2006-08-20 12:17 ` Frederik Deweerdt
2006-08-21 11:22 ` Dave Airlie
2006-08-20 14:48 ` [PATCH -mm] agp.h: constify struct agp_bridge_data::version Alexey Dobriyan
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=1155743399.5683.13.camel@localhost \
--to=trond.myklebust@fys.uio.no \
--cc=akpm@osdl.org \
--cc=aviro@redhat.com \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=raven@themaw.net \
/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