mountd: Possible bug in next_mnt()
Subsystems (2)
Hi!
next_mnt() finds submounts below a given path p.
While investigating into an issue in my crossmount patches for nfs-utils I noticed that it does not work when fsid=root, rootdir=/some/path/ and then "/" is being exported. In this case next_mnt() is asked to find submounts of "/" but returns none.
In my opinion this wrong because every mount is a submount of "/".
The following change fixes the problem on my side but I'm not sure whether "/" is a special case in mountd where next_mnt() has to bail out.
support/export/cache.c +2 -2
@@ -410,13 +410,13 @@ static char *next_mnt(void **v, char *p) *v = f; }else f = *v; -while ((me =getmntent (f)) !=NULL && l >1 ) { +while ((me =getmntent (f)) !=NULL && l >=1 ) {char *mnt_dir =nfsd_path_strip_root (me->mnt_dir);if (!mnt_dir)continue ; -if (strncmp (mnt_dir, p, l) ==0 && mnt_dir[l] =='/' ) +if (strncmp (mnt_dir, p, l) ==0 && (l ==1 || mnt_dir[l] =='/' ))return mnt_dir; }endmntent (f);
Comments? :-)
Thanks,
//richard
Hello,
My apologies... Eating some PTO...
Quoted 6 lines · Richard Weinberger
Hi!
next_mnt()finds submounts below a given path p.
While investigating into an issue in my crossmount patches for nfs-utils I noticed that it does not work when fsid=root, rootdir=/some/path/ and then "/" is being exported. In this casenext_mnt()is asked to find submounts of "/" but returns none.
I'm not clear as what you are saying... "rootdir=/some/path/" is not an export option.
Quoted 27 lines
In my opinion this wrong because every mount is a submount of "/".
The following change fixes the problem on my side but I'm not sure whether "/" is a special case in mountd where
next_mnt()has to bail out.support/export/cache.c +2
-2@@ -410,13 +410,13 @@ static char *next_mnt(void **v, char *p) *v = f; }else f = *v; -while ((me =getmntent (f)) !=NULL && l >1 ) { +while ((me =getmntent (f)) !=NULL && l >=1 ) {char *mnt_dir =nfsd_path_strip_root (me->mnt_dir);if (!mnt_dir)continue ; -if (strncmp (mnt_dir, p, l) ==0 && mnt_dir[l] =='/' ) +if (strncmp (mnt_dir, p, l) ==0 && (l ==1 || mnt_dir[l] =='/' ))return mnt_dir; }endmntent (f);
Quoted 1 line
Comments? :-)
Putting this is the correct patch format including a Signed-off-by signature... would help.
steved.
Quoted 4 lines
Thanks,
//richard
----- Ursprüngliche Mail -----
Quoted 8 lines
Quoted 6 lines
next_mnt()finds submounts below a given path p.
While investigating into an issue in my crossmount patches for nfs-utils I noticed
that it does not work when fsid=root, rootdir=/some/path/ and then "/" is being exported.
In this casenext_mnt()is asked to find submounts of "/" but returns none.I'm not clear as what you are saying... "rootdir=/some/path/" is not an export option.
Sorry for being imprecise.
rootdir= is an nfs.conf exports option.
Thanks,
//richard
Quoted 7 lines · Richard Weinberger
----- Ursprüngliche Mail -----
Quoted 6 lines
Quoted 6 lines
next_mnt()finds submounts below a given path p.
While investigating into an issue in my crossmount patches for nfs-utils I noticed
that it does not work when fsid=root, rootdir=/some/path/ and then "/" is being exported.
In this casenext_mnt()is asked to find submounts of "/" but returns none.
Quoted 5 lines
Quoted 2 lines
I'm not clear as what you are saying... "rootdir=/some/path/" is not an export option.
Sorry for being imprecise.
rootdir= is an nfs.conf exports option.Point. But I still need the patch in the correct
format with the Signed-off-by...
steved.
Quoted 4 lines
Thanks,
//richard
----- Ursprüngliche Mail -----
Quoted 8 lines · Richard Weinberger
Quoted 7 lines
----- Ursprüngliche Mail -----
Quoted 6 lines
Quoted 6 lines
next_mnt()finds submounts below a given path p.
While investigating into an issue in my crossmount patches for nfs-utils I noticed
that it does not work when fsid=root, rootdir=/some/path/ and then "/" is being exported.
In this casenext_mnt()is asked to find submounts of "/" but returns none.
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
I'm not clear as what you are saying... "rootdir=/some/path/" is not an export option.
Sorry for being imprecise.
rootdir= is an nfs.conf exports option.Point. But I still need the patch in the correctformat with the Signed-off-by...
Well, the goal of my mail was not sending a ready-to-apply patch. It was a question. To me next_mnt() looks wrong but I'm not sure whether the current handling of "/" is desired for some special case I'm not aware of.
I'll happily send a patch after we agree that next_mnt() is wrong.
Thanks,
//richard
Quoted 15 lines · Richard Weinberger
----- Ursprüngliche Mail -----
Quoted 14 lines · Richard Weinberger
Quoted 13 lines
----- Ursprüngliche Mail -----
Quoted 8 lines
Quoted 6 lines
next_mnt()finds submounts below a given path p.
While investigating into an issue in my crossmount patches for nfs-utils I noticed
that it does not work when fsid=root, rootdir=/some/path/ and then "/" is being exported.
In this casenext_mnt()is asked to find submounts of "/" but returns none.I'm not clear as what you are saying... "rootdir=/some/path/" is not an export option.
Sorry for being imprecise.
rootdir= is an nfs.conf exports option.Point. But I still need the patch in the correct
Quoted 7 lines
Quoted 1 line
format with the Signed-off-by...
Well, the goal of my mail was not sending a ready-to-apply patch. It was a question. To me
next_mnt()looks wrong but I'm not sure whether the current handling of "/" is desired for some special case I'm not aware of.I'll happily send a patch after we agree that
next_mnt()is wrong.
I'm still trying to reproduce problem... I have
/etc/nfs.conf: rootdir=/export
/etc/exports:
/home *(rw,sec=sys:krb5:krb5i:krb5p)
/tmp *(rw,fsid=666,all_squash)
/ *(rw,fsid=root,all_squash)
I'm not seeing the problem... Where does the crossmount come in?
steved.
----- Ursprüngliche Mail -----
Quoted 7 lines
Quoted 5 lines
Well, the goal of my mail was not sending a ready-to-apply patch. It was a question. To me
next_mnt()looks wrong but I'm not sure whether the current handling of "/" is desired for some special case I'm not aware of.I'll happily send a patch after we agree that
next_mnt()is wrong.I'm still trying to reproduce problem... I have
Quoted 8 lines
/etc/nfs.conf: rootdir=/export
/etc/exports:
/home *(rw,sec=sys:krb5:krb5i:krb5p)
/tmp *(rw,fsid=666,all_squash)
/ *(rw,fsid=root,all_squash)I'm not seeing the problem... Where does the crossmount come in?
Chris reported the problem to me while he was testing my re-export/crossmount patches. I can try reproducing without re-exporting later.
In theory you should see the problem as follows:
1. Have rootdir=/export in your nfs.conf
2. /export is some filesystem that contains more mounts
3. /export/fs1 is a different filesytem
4. /export/fs2 is a different filesytem too
5. /etc/exports contains: / *(rw,fsid=root,all_squash,crossmount)
Client mounts / to /nfs and then tries to access /nfs/fs1.
Then nfsd_fh() iterates over all exports, finds one with NFSEXP_CROSSMOUNT set. Using next_mnt() it finds possible sub-mounts. But for the "/" case next_mnt() returns none -> nfsd_fh() fails -> client cannot enter /nfs/fs1.
Thanks,
//richard
----- Ursprüngliche Mail -----
Quoted 9 lines
Quoted 9 lines
I'm still trying to reproduce problem... I have
/etc/nfs.conf: rootdir=/export
/etc/exports:
/home *(rw,sec=sys:krb5:krb5i:krb5p)
/tmp *(rw,fsid=666,all_squash)
/ *(rw,fsid=root,all_squash)
Quoted 5 lines
Quoted 1 line
I'm not seeing the problem... Where does the crossmount come in?
Chris reported the problem to me while he was testing my re-export/crossmount patches.
I can try reproducing without re-exporting later.
Finally I found some cycles to reproduce without my re-exporting setup.
1. /etc/exports contains:
/ *(rw,crossmnt,no_subtree_check,fsid=root)
2. /etc/nfs.conf contains:
[exports]
rootdir=/nfs_srv
3. Mounts:
/root/fs1.ext4 on /nfs_srv type ext4 (rw,relatime) /root/fs2.ext4 on /nfs_srv/fs2 type ext4 (rw,relatime)
4. On the client:
# ls /nfs_client/fs2 ls: cannot open directory '/nfs_client/fs2': Stale file handle
I'll send a proper patch ASAP.next_mnt() has to deal with "/" too.
Thanks,
//richard