Thread (8 messages) 8 messages, 2 authors, 2023-03-15

Re: mountd: Possible bug in next_mnt()

From: Steve Dickson <hidden>
Date: 2023-03-11 16:20:15

Hello,

My apologies... Eating some PTO...

On 3/8/23 10:05 AM, Richard Weinberger wrote:
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.
I'm not clear as what you are saying... "rootdir=/some/path/" is not an
export option.
quoted hunk ↗ jump to hunk
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.
diff --git a/support/export/cache.c b/support/export/cache.c
index 2497d4f48df3..be20cb34adcb 100644
--- a/support/export/cache.c
+++ b/support/export/cache.c
@@ -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? :-)
Putting this is the correct patch format including a Signed-off-by
signature... would help.

steved.
Thanks,
//richard
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help