public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: David Howells <dhowells@redhat.com>
Cc: Ian Kent <raven@themaw.net>, Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org,
	Trond Myklebust <trond.myklebust@fys.uio.no>
Subject: Re: 2.6.18-rc4-mm1
Date: Wed, 16 Aug 2006 13:23:47 +0100	[thread overview]
Message-ID: <6237.1155731027@warthog.cambridge.redhat.com> (raw)
In-Reply-To: <30157.1155722439@warthog.cambridge.redhat.com>

David Howells <dhowells@redhat.com> wrote:

> ...
>  (8) An unconstructed dentry is left, which causes the "?---------" lines to
>      appear in the ls -l listing.
> ...
> However, (8) might well represent a bug in NFS.

I've done some investigation into this:

The automount point before mounting has one security label and another after
mounting:

	[root@andromeda ~]# ls -Zd /net/trash
	dr-xr-xr-x  root root system_u:object_r:autofs_t       /net/trash/
	[root@andromeda ~]# ls -l /net/trash
	total 87
	drwxr-xr-x   2 root root       3072 Aug 10 04:10 bin/
	drwxr-xr-x   2 root root       1024 Aug  1 16:13 boot/
	drwxr-xr-x   2 root root       1024 Aug  1 16:13 dev/
	drwxr-xr-x 133 root root      10240 Aug 16 12:36 etc/
	drwxr-xr-x   2 root root       1024 Jul 12 09:48 home/
	drwxr-xr-x  12 root root       7168 Aug 10 04:10 lib/
	drwxrwsr-x   2 root cambridge  1024 Aug  1 20:41 local/
	drwx------   2 root root      12288 Aug  1 16:12 lost+found/
	drwxr-xr-x   2 root root       1024 Jul 12 09:48 media/
	drwxr-xr-x   2 root root       1024 Jul 24 14:17 misc/
	dr-xr-xr-x   2 root root       1024 Aug  3 09:35 net/
	dr-xr-xr-x   2 root root       1024 Aug  9 16:27 netopt/
	?---------   ? ?    ?             ?            ? /net/trash/mnt
	?---------   ? ?    ?             ?            ? /net/trash/usr
	drwxr-xr-x   2 root root       1024 Jul 12 09:48 opt/
	drwxr-xr-x   2 root root       1024 Aug  1 16:13 proc/
	dr-xr-xr-x   2 root root       1024 Aug  3 09:26 project/
	drwxr-x---   7 root root       1024 Aug 16 11:49 root/
	drwxr-xr-x   2 root root      11264 Aug 10 04:10 sbin/
	drwxr-xr-x   2 root root       1024 Aug  1 16:13 selinux/
	drwxr-xr-x   2 root root       1024 Jul 12 09:48 srv/
	drwxr-xr-x   2 root root       1024 Aug  1 16:13 sys/
	drwxr-xr-x   3 root root       1024 Aug  1 20:27 tftpboot/
	drwxrwxrwt   4 root root       3072 Aug 16 11:49 tmp/
	drwxr-xr-x  29 root root       1024 Aug  1 19:56 var/
	drwxr-xr-x   2 root root       1024 Aug  9 11:35 warthog/
	[root@andromeda ~]# ls -Zd /net/trash
	drwxr-xr-x  root root system_u:object_r:nfs_t          /net/trash/

Automount daemons all have the automount_t label:

	[root@andromeda ~]# ps -Zaux | grep automount
	Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.6/FAQ
	root:system_r:automount_t       root      ... /usr/sbin/automount --timeout=60
	root:system_r:automount_t       root      ... /usr/sbin/automount --timeout=60
	root:system_r:automount_t       root      ... /usr/sbin/automount --timeout=60
	root:system_r:automount_t       root      ... /usr/sbin/automount --timeout=60


I added this patch to instrument nfs_lookup():

	--- fs/nfs/dir.c.orig	2006-08-14 09:08:28.000000000 +0100
	+++ fs/nfs/dir.c	2006-08-16 12:49:20.000000000 +0100
	@@ -890,6 +890,10 @@ static struct dentry *nfs_lookup(struct 
		struct nfs_fh fhandle;
		struct nfs_fattr fattr;

	+	printk("-->nfs_lookup(%s,%s,{%x,%x,%x})\n",
	+	       dentry->d_parent->d_name.name, dentry->d_name.name,
	+	       nd->flags, nd->intent.open.flags, nd->intent.open.create_mode);
	+
		dfprintk(VFS, "NFS: lookup(%s/%s)\n",
			dentry->d_parent->d_name.name, dentry->d_name.name);
		nfs_inc_stats(dir, NFSIOS_VFSLOOKUP);
	@@ -904,8 +908,10 @@ static struct dentry *nfs_lookup(struct 
		lock_kernel();

		/* If we're doing an exclusive create, optimize away the lookup */
	-	if (nfs_is_exclusive_create(dir, nd))
	+	if (nfs_is_exclusive_create(dir, nd)) {
	+		printk("exlusive_create\n");
			goto no_entry;
	+	}

		error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, &fhandle, &fattr);
		if (error == -ENOENT)
	@@ -933,6 +939,7 @@ no_entry:
	 out_unlock:
		unlock_kernel();
	 out:
	+	printk("<--nfs_lookup() = %p\n", res);
		return res;
	 }

And saw the following appear in the kernel log around the problem bit for
trash:/usr:

| ...
| SELinux: initialized (dev 0:18, type nfs), uses genfs_contexts
| audit(1155729189.533:468): avc:  denied  { read } for  pid=6472 comm="automount" name="cambridge-temp.redhat.com.2" dev=hda2 ino=688243 scontext=root:system_r:automount_t:s0 tcontext=system_u:object_r:var_yp_t:s0 tclass=file
| audit(1155729189.557:469): avc:  denied  { name_bind } for  pid=6472 comm="automount" src=716 scontext=root:system_r:automount_t:s0 tcontext=system_u:object_r:reserved_port_t:s0 tclass=udp_socket

Not sure what's going on here.  The automounter tried to do bind a socket to a
reserved port perhaps and was denied.

| NFS: nfs_update_inode(0:18/2 ct=1 info=0x6)
| NFS: permission(0:18/2), mask=0x1, res=0

sys_mkdirat() calls do_path_lookup(), which checks MAY_EXEC on the dir.

| NFS: permission(0:18/2), mask=0x1, res=0

lookup_create() is called.  This calls __lookup_hash(), which checks MAY_EXEC
on the dir.

| -->nfs_lookup(,usr,{200,80,44e3069a})

__lookup_hash() then looks up the new dentry with intent to create:

	VARIABLE			VALUE
	===============================	===============================
	nd->flags			LOOKUP_CREATE
	nd->intent.open.flags		O_EXCL
	nd->intent.open.create_mode	weird value, even in octal

This means that nfs_lookup() considers this to be "an exclusive create" of
this node, and dispenses with the LOOKUP RPC call to the server.

| NFS: lookup(/usr)
| exlusive_create

Just to confirm that the lookup is skipped.

| <--nfs_lookup() = 00000000

We return the dentry we were given, but don't return an error.  The dentry we
were given is left negative (on the assumption it's about to be created), but
does get attached to the directory.

| NFS: permission(0:18/2), mask=0x3, res=0

vfs_mkdir() calls may_create() which checks that the directory has MAY_WRITE
and MAY_EXEC permissions.  This firstly calls nfs_permission, which grants
permission.

| audit(1155729189.605:470): avc:  denied  { write } for  pid=6472 comm="automount" name="" dev=0:18 ino=2 scontext=root:system_r:automount_t:s0 tcontext=system_u:object_r:nfs_t:s0 tclass=dir

And secondly calls security_inode_permission() though which SELinux which
_denies_ permission.

| NFS: dentry_delete(/usr, 0)

vfs_mkdir() returns -ENOACCES to sys_mkdirat() which releases its hold on the
dentry, but leaves the negative dentry attached to the directory.


The negative dentry wouldn't normally be a problem, even though it's attached
to its parent directory... except for the small matter that it's subsequently
listed in a directory read operation.

However, the dcache still retains the negative dentry.  I'm not sure how to
deal with this.  I think nfs_lookup() _must_ contact the server and prefill
the dentry if it can.  Trond?

David

  reply	other threads:[~2006-08-16 12:24 UTC|newest]

Thread overview: 192+ 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                       ` David Howells [this message]
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
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
     [not found] <fa.nURugTWtyfQKAbvUB0DbTkmyPAY@ifi.uio.no>
2006-08-16  2:57 ` 2.6.18-rc4-mm1 Robert Hancock
2006-08-16  4:26   ` 2.6.18-rc4-mm1 Andrew Morton
2006-08-16  4:29     ` 2.6.18-rc4-mm1 Dave Jones
2006-08-24 19:46       ` 2.6.18-rc4-mm1 Pavel Machek
2006-08-16 23:18     ` 2.6.18-rc4-mm1 Robert Hancock
2006-08-16 19:41   ` 2.6.18-rc4-mm1 Len Brown

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=6237.1155731027@warthog.cambridge.redhat.com \
    --to=dhowells@redhat.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=raven@themaw.net \
    --cc=trond.myklebust@fys.uio.no \
    /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