From: Richard Weinberger <richard@nod.at>
To: linux-nfs <linux-nfs@vger.kernel.org>
Cc: trond.myklebust@hammerspace.com,
chris chilvers <chris.chilvers@appsbroker.com>
Subject: mountd: Possible bug in next_mnt()
Date: Wed, 8 Mar 2023 16:05:59 +0100 (CET) [thread overview]
Message-ID: <1497292229.221220.1678287959937.JavaMail.zimbra@nod.at> (raw)
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.
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? :-)
Thanks,
//richard
next reply other threads:[~2023-03-08 15:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-08 15:05 Richard Weinberger [this message]
2023-03-11 16:19 ` mountd: Possible bug in next_mnt() Steve Dickson
2023-03-11 16:52 ` Richard Weinberger
2023-03-12 13:31 ` Steve Dickson
2023-03-12 13:36 ` Richard Weinberger
2023-03-12 14:20 ` Steve Dickson
2023-03-12 16:51 ` Richard Weinberger
2023-03-15 22:04 ` Richard Weinberger
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=1497292229.221220.1678287959937.JavaMail.zimbra@nod.at \
--to=richard@nod.at \
--cc=chris.chilvers@appsbroker.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@hammerspace.com \
/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