Page MenuHomeFreeBSD

nfs: Default to nfs_reserved_port_only="YES"
ClosedPublic

Authored by markj on Mon, Apr 22, 8:26 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 29, 3:17 PM
Unknown Object (File)
Sat, Apr 27, 9:04 AM
Unknown Object (File)
Fri, Apr 26, 4:06 PM
Unknown Object (File)
Fri, Apr 26, 2:21 PM
Unknown Object (File)
Thu, Apr 25, 10:53 PM
Unknown Object (File)
Thu, Apr 25, 5:38 PM
Unknown Object (File)
Thu, Apr 25, 1:42 PM
Unknown Object (File)
Thu, Apr 25, 1:42 PM
Subscribers

Details

Summary

This setting causes the NFS server to check that all RPCs are sent from
a privileged (<= 1023) port, rejecting those that are not. This
slightly raises the bar for a user with network access to an
unauthenticated NFS server to access exported NFS filesystems.

Users that use traditional NFS clients (e.g., those provided by FreeBSD
or Linux) should not see any difference, assuming that unprivileged
filesystem mounting is disallowed.

Note that the setting is per-VNET, so may be overridden in VNET jails
without affecting the rest of the system.

Discussed with: freebsd-arch@
Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Mon, Apr 22, 8:26 PM

lgtm. I cannot recall if there is any man page change
needed for this?

This revision is now accepted and ready to land.Mon, Apr 22, 9:52 PM
bz added a subscriber: bz.

lgtm. I cannot recall if there is any man page change
needed for this?

man 5 rc.conf doesn't seem to specify a default; so at least that is fine.

Should we change the in-kernel default as well? It will normally be overridden by the rc.conf setting so it doesn't have a practical impact but probably good for consistency.

Should we change the in-kernel default as well? It will normally be overridden by the rc.conf setting so it doesn't have a practical impact but probably good for consistency.

Would NFS Root be affected by that? Hmm it's a tunable so less of a problem in case people do have trouble. That should probably be documented somewhere then though..

In D44906#1023888, @bz wrote:

Should we change the in-kernel default as well? It will normally be overridden by the rc.conf setting so it doesn't have a practical impact but probably good for consistency.

Would NFS Root be affected by that? Hmm it's a tunable so less of a problem in case people do have trouble.

This is a server setting, so I wouldn't expect so.

There's also NFS_REQRSVPORT, but it is unrelated I guess?

Should we change the in-kernel default as well? It will normally be overridden by the rc.conf setting so it doesn't have a practical impact but probably good for consistency.

+1

In D44906#1023888, @bz wrote:

Should we change the in-kernel default as well? It will normally be overridden by the rc.conf setting so it doesn't have a practical impact but probably good for consistency.

Would NFS Root be affected by that? Hmm it's a tunable so less of a problem in case people do have trouble.

This is a server setting, so I wouldn't expect so.

Sorry for the noise. 3:20AM and just had a NFS Root client "hang" for the 5min timeout. Time to stop for yestoday.

There's also NFS_REQRSVPORT, but it is unrelated I guess?

Oh hmm, not unrelated, but at a glance I think it is superseded by the privport check. That is, all code paths which lead there first have to go through the privport check. But I could be wrong about this.

Oh hmm, not unrelated, but at a glance I think it is superseded by the privport check. That is, all code paths which lead there first have to go through the privport check. But I could be wrong about this.

It feels like NFS_REQRSVPORT is older but apparently it was introduced by the same (initial) commit as the if (nfs_privport ... check (9ec7b004d0edb). Maybe replacing NFS_REQRSVPORT by a runtime check for nfs_privport would make sense, but I don't really know this code. It may be instead that the code under NFS_REQRSVPORT is redundant, I'm not sure either. In any case, this would be a separate change.

Oh hmm, not unrelated, but at a glance I think it is superseded by the privport check. That is, all code paths which lead there first have to go through the privport check. But I could be wrong about this.

It feels like NFS_REQRSVPORT is older but apparently it was introduced by the same (initial) commit as the if (nfs_privport ... check (9ec7b004d0edb). Maybe replacing NFS_REQRSVPORT by a runtime check for nfs_privport would make sense, but I don't really know this code. It may be instead that the code under NFS_REQRSVPORT is redundant, I'm not sure either. In any case, this would be a separate change.

Wow, this one is embarrassing... 25+ years ago I was using OpenBSD for various things and
put this code in (OpenBSD didn't have a port# check). Then, 25 years ago, I did the first
rendition of NFSv4 starting from that OpenBSD code. The comment comes from the fact
that the NFSv4 working group was anti-reserved port# in those days.

It's cruft that has never been built for FreeBSD. I can get rid of it (or Mark can).

Oh hmm, not unrelated, but at a glance I think it is superseded by the privport check. That is, all code paths which lead there first have to go through the privport check. But I could be wrong about this.

It feels like NFS_REQRSVPORT is older but apparently it was introduced by the same (initial) commit as the if (nfs_privport ... check (9ec7b004d0edb). Maybe replacing NFS_REQRSVPORT by a runtime check for nfs_privport would make sense, but I don't really know this code. It may be instead that the code under NFS_REQRSVPORT is redundant, I'm not sure either. In any case, this would be a separate change.

Wow, this one is embarrassing... 25+ years ago I was using OpenBSD for various things and
put this code in (OpenBSD didn't have a port# check). Then, 25 years ago, I did the first
rendition of NFSv4 starting from that OpenBSD code. The comment comes from the fact
that the NFSv4 working group was anti-reserved port# in those days.

It's cruft that has never been built for FreeBSD. I can get rid of it (or Mark can).

I'll leave it to you. :)

Initialize the sysctl to 1 as well.

This revision now requires review to proceed.Tue, Apr 23, 4:06 PM
This revision is now accepted and ready to land.Tue, Apr 23, 4:08 PM