[PATCH] KNFSD rmdir bugs

G. Allen Morris III (gam3@dharma.sehda.com)
Sat, 16 Jan 1999 15:40:38 -0800


While I was looking into the problem reported by Christian,
I found a bug in the nfsd_unlink code. Below is a script
that will cause an Oops. There was also a mistake in the
error code being retuned in fh_verify if a file/directory
is deleted out from under kernel nfsd.

---------------------- test.sh --------------------------
HOST=`hostname`
sudo mount -o intr $HOST:/tmp /mnt/tmp
sudo su -c '(echo 34 > /proc/sys/sunrpc/nfsd_debug)'
mkdir /mnt/tmp/bob
ls -lad /mnt/tmp/bob /tmp/bob
rmdir /tmp/bob
ls -lad /mnt/tmp/bob /homes/gam3/bob
rmdir /mnt/tmp/bob
# Oops
ls -lad /mnt/tmp/bob
sudo umount /mnt/tmp
---------------------- nfsd.patch --------------------------
diff -x .* -x *.o -x *.a -x *.s -ru linux-2.2.0-pre7/fs/nfsd/nfsfh.c linux/fs/nfsd/nfsfh.c
--- linux-2.2.0-pre7/fs/nfsd/nfsfh.c Fri Jan 1 23:03:09 1999
+++ linux/fs/nfsd/nfsfh.c Sat Jan 16 15:24:53 1999
@@ -1055,7 +1055,7 @@
/*
* Look up the dentry using the NFS file handle.
*/
- error = nfserr_stale;
+ error = nfserr_noent;
dentry = find_fh_dentry(fh);
if (!dentry)
goto out;
diff -x .* -x *.o -x *.a -x *.s -ru linux-2.2.0-pre7/fs/nfsd/nfssvc.c linux/fs/nfsd/nfssvc.c
diff -x .* -x *.o -x *.a -x *.s -ru linux-2.2.0-pre7/fs/nfsd/vfs.c linux/fs/nfsd/vfs.c
--- linux-2.2.0-pre7/fs/nfsd/vfs.c Mon Jan 11 21:59:50 1999
+++ linux/fs/nfsd/vfs.c Sat Jan 16 15:16:42 1999
@@ -282,7 +282,7 @@

/* Change the attributes. */
if (iap->ia_valid) {
- kernel_cap_t saved_cap;
+ kernel_cap_t saved_cap = 0;

iap->ia_valid |= ATTR_CTIME;
iap->ia_ctime = CURRENT_TIME;
@@ -1109,6 +1109,12 @@
err = PTR_ERR(rdentry);
if (IS_ERR(rdentry))
goto out_nfserr;
+
+ if (!rdentry->d_inode) {
+ dput(rdentry);
+ err = nfserr_noent;
+ goto out;
+ }

if (type != S_IFDIR) {
/* It's UNLINK */

>>>H.J. Lu said:
> Forwarded message:
> >From redhat.com!alan Fri Jan 15 18:15:22 1999

---------------------------------
G. Allen Morris III

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/