Re: 14.1 NFS / mountd : -alldirs not working as expected

From: Michael Proto <mike_at_jellydonut.org>
Date: Wed, 27 Nov 2024 03:09:56 UTC
On Tue, Nov 26, 2024 at 11:01 AM Rick Macklem <rick.macklem@gmail.com> wrote:
> I dug into the git repository and, believe it or not, it looks like this was
> broken between releng1.0 and releng2.0 (there doesn't seem to be an
> exact commit).
>
> Basically, for releng1.0 the path provided by the exports line was passed
> into mount(2), which would fail if the path was not a mount point.
> This was how "not at a mount point" was detected for -alldirs.
>
> For releng2.0, it passes f_mntonname to mount(2), which is the
> mount point. This broke the check for "is a mount point".
> To be honest, the while() loop calling nmount(2) is mostly
> (if not entirely useless), because its purpose was to climb the path
> to the mount point and this should never now happen.
>
> I do have a patch that detects "not a mount point" using a strcmp()
> between f_mntoname and the path in the exports line.
> That should be sufficient, since symbolic links should not be in
> the path in exports(5).
>
> Michael, once you create a bugzilla bug report (bugs.freebsd.org),
> I will attach the patch and work on getting it committed.
>
> rick
>
> >
> > rick
> >
> > > >
> > > >   /etc/rc.conf :
> > > > nfs_server_enable="YES"
> > > > rpcbind_enable="YES"
> > > > rpc_statd_enable="YES"
> > > > rpc_lockd_enable="YES"
> > > > mountd_enable="YES"
> > > >
> > > >   /etc/exports :
> > > > /cdrom -alldirs,quiet,ro -network=10.0.0.0/24
> > > >
> > > > (at this time /cdrom exists as a directory but is not currently a
> > > > filesystem mount point)
> > > > on the server:
> > > > root@zfstest1:~ # killall -HUP mountd
> > > >
> > > >   /var/log/messages:
> > > > Nov 20 22:34:56 zfstest1 mountd[27724]: Warning: exporting /cdrom
> > > > exports entire / file system
> > > I took a closer look and this is a bug. It appears that -alldirs is supposed
> > > to fail when a non-mountpoint is exported.
> > >
> > > It appears to have been introduced to the system long ago, although I
> > > haven't yet tracked down the commit.
> > >
> > > mountd.c assumes that nmount(8) will fail when the directory path
> > > is not a mount point, however for MNT_UPDATE (which is what is
> > > used to export file systems) this is not the case.
> > >
> > > Please create a bugzilla bug report for this and I will work on a patch.
> > >
> > > Btw, quiet is also broken in the sense that it will cause any nmount(8)
> > > failure to fail. However, since nmount(8) does not fail for this case,
> > > it hardly matters. I will come up with a patch for this too, since it is
> > > easy to fix.
> > >
> > > Thanks for reporting this, rick



https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=282995

Thank you for digging deeper into this! Had no idea it was that much
of a legacy situation, beats my introduction to FreeBSD by 2 releases.


-Michael Proto