Skip to contentSkip to conversation

Bug in NFS

PATCH In review Abramo Bagnara 1 participant 2 messages Jul 13, 2001 NFS server

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bug in NFS

I have found a bug in NFSv2.

[root@igor /tmp]# mount igor:/u u
[root@igor /tmp]# cd u
[root@igor u]# umask 000
[root@igor u]# ls -l q
ls: q: File o directory inesistente
[root@igor u]# touch q
[root@igor u]# ls -l q
-rw-r--r-- 1 root root 0 lug 13 07:56 q

This seems to be caused by use of unitialized current->fs->umask via vfs_create called by nfsd_create.

Patch for 2.4.6 follows.

Signature · 8 lines
Abramo Bagnara                       mailto:[email protected]

Opera Unica                          Phone: +39.546.656023
Via Emilia Interna, 140
48014 Castel Bolognese (RA) - Italy

ALSA project               http://www.alsa-project.org
It sounds good!
fs/nfsd/auth.c renamed from fs/nfsd/auth.c.~1~ +1 -0
@@ -34,6 +34,7 @@
 				cred->cr_groups[i] = exp->ex_anon_gid;
 	}
 
+	current->fs->umask = 0;
 	if (cred->cr_uid != (uid_t) -1)
 		current->fsuid = cred->cr_uid;
 	else
#1 lore raw
Quoted 33 lines · Neil Brown
Quoted 12 lines · On Friday July 13, [email protected] wrote:

I have found a bug in NFSv2.

[root@igor /tmp]# mount igor:/u u
[root@igor /tmp]# cd u
[root@igor u]# umask 000
[root@igor u]# ls -l q
ls: q: File o directory inesistente
[root@igor u]# touch q
[root@igor u]# ls -l q
-rw-r--r-- 1 root root 0 lug 13 07:56 q

Quoted 3 lines

This seems to be caused by use of unitialized current->fs->umask via vfs_create called by nfsd_create.

Hmmm.. I think there is more here than immediately meets the eye.

current->fs->umask is initialised, to 0, in include/linux/fs_struct.h The "INIT_FS" define is used to set the initial value of the fs_struct (see arch/i386/kernel/init_task.c - other archs are the same). The third field here is the umask field.

This is the fs_struct for init, and for every kernel thread that call daemonise, as the nfsd threads do ever since 2.4.3pre5 or there abouts.

If the umask for nfsd is getting set to 022, as it would appear from your experiment, then either:
- your init process is setting it, or
- you are using some odd architecture that doesn't use INIT_FS

Quoted 4 lines

So: what init program are you running, what architecture, any other patches, anything else that might explain why your machine is different from mine. Because on mine, the touched file gets the right permissions.

I've seen that on several systems with the following characteristics:

- Torvalds linux-2.4.6, Torvalds linux-2.4.4, linux-2.4.4+xfs from sgi
- nfsd compiled as a module (I suppose this make the difference we see)
- stock redhat-7.1 with updates applied

$ rpm -qf /sbin/init
SysVinit-2.78-17
Signature · 8 lines
Abramo Bagnara                       mailto:[email protected]

Opera Unica                          Phone: +39.546.656023
Via Emilia Interna, 140
48014 Castel Bolognese (RA) - Italy

ALSA project               http://www.alsa-project.org
It sounds good!