git: 7d9dc91a9901 - main - nfscl: Fix the NFSv4.0 mount so that it does not crash
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 15 Oct 2022 15:39:58 UTC
The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=7d9dc91a9901689bbf263935ef1b04617a70efb0 commit 7d9dc91a9901689bbf263935ef1b04617a70efb0 Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2022-10-15 15:38:07 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2022-10-15 15:38:07 +0000 nfscl: Fix the NFSv4.0 mount so that it does not crash Commit efe58855f3ea modifies IN_LOOPBACK() so that it uses a VNET variable. Without this patch, nfscl_getmyip() uses IN_LOOPBACK() when the VNET is not set and crashes the system. nfscl_getmyip() is only called when a NFSv4.0 (not NFSv4.1/4.2) mount is done. This patch re-organizes nfscl_getmyip() so that IN_LOOPBACK() is before the CURVENT_RESTORE() macro, to avoid the crashes. Reviewed by: karels, zlei.huang_gmail.com Differential Revision: https://reviews.freebsd.org/D37008 --- sys/fs/nfsclient/nfs_clport.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clport.c b/sys/fs/nfsclient/nfs_clport.c index e77aaccbc720..f5d7c3caea0f 100644 --- a/sys/fs/nfsclient/nfs_clport.c +++ b/sys/fs/nfsclient/nfs_clport.c @@ -1014,18 +1014,18 @@ nfscl_getmyip(struct nfsmount *nmp, struct in6_addr *paddr, int *isinet6p) NET_EPOCH_ENTER(et); CURVNET_SET(CRED_TO_VNET(nmp->nm_sockreq.nr_cred)); nh = fib4_lookup(fibnum, sin->sin_addr, 0, NHR_NONE, 0); - CURVNET_RESTORE(); - if (nh != NULL) + if (nh != NULL) { addr = IA_SIN(ifatoia(nh->nh_ifa))->sin_addr; + if (IN_LOOPBACK(ntohl(addr.s_addr))) { + /* Ignore loopback addresses */ + nh = NULL; + } + } + CURVNET_RESTORE(); NET_EPOCH_EXIT(et); - if (nh == NULL) - return (NULL); - if (IN_LOOPBACK(ntohl(addr.s_addr))) { - /* Ignore loopback addresses */ + if (nh == NULL) return (NULL); - } - *isinet6p = 0; *((struct in_addr *)paddr) = addr;