opnsense-src/sys/fs/nfsserver
Olivier Certner cfbe7a62dc
nfs, rpc: Ensure kernel credentials have at least one group
This fixes several bugs where some 'struct ucred' in the kernel,
constructed from user input (via nmount(2)) or obtained from other
servers (e.g., gssd(8)), could have an unfilled 'cr_groups' field and
whose 'cr_groups[0]' (or 'cr_gid', which is an alias) was later
accessed, causing an uninitialized access giving random access rights.

Use crsetgroups_fallback() to enforce a fallback group when possible.
For NFS, the chosen fallback group is that of the NFS server in the
current VNET (NFSD_VNET(nfsrv_defaultgid)).

There does not seem to be any sensible fallback available in rpc code
(sys/rpc/svc_auth.c, svc_getcred()) on AUTH_UNIX (TLS or not), so just
fail credential retrieval there.  Stock NSS sources, rpc.tlsservd(8) or
rpc.tlsclntd(8) provide non-empty group lists, so will not be impacted.

Discussed with: rmacklem (by mail)
Approved by:    markj (mentor)
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D46918
2024-11-02 21:37:42 +01:00
..
nfs_fha_new.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
nfs_fha_new.h sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
nfs_nfsdcache.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
nfs_nfsdkrpc.c nfsserver: Default to nfs_reserved_port_only="YES" 2024-04-23 12:54:46 -04:00
nfs_nfsdport.c nfs, rpc: Ensure kernel credentials have at least one group 2024-11-02 21:37:42 +01:00
nfs_nfsdserv.c nfsd: Fix handling of NFSv4 setable attributes 2024-08-27 14:19:33 -07:00
nfs_nfsdsocket.c nfs, rpc: Ensure kernel credentials have at least one group 2024-11-02 21:37:42 +01:00
nfs_nfsdstate.c nfsd: Fix close handling when vfs.nfsd.enable_locallocks=1 2024-09-30 15:49:57 -07:00
nfs_nfsdsubs.c nfsd: Fix handling of credentials with cr_ngroups == 0 2024-10-21 15:48:39 -07:00