From nobody Sun May 17 02:13:57 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gJ4Hb4bhyz6cXLv for ; Sun, 17 May 2026 02:14:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gJ4Hb0gl8z3F0M for ; Sun, 17 May 2026 02:14:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1778984043; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+H2kUvGRf+6jSbv4oVwBsJSchXynh9M2/jEdvKUveUo=; b=ul6llwpOmepyGO+RLQbwVK4xi2IwDlnkuvXujXNYGP6sJxbBnynBHKrP9rK0PupM/Euy5z /u4HJbenGtJrsoy9AsSAZyl1CVW7gvAPMVkWwEYRqlWePlAyMBt3YAXaod1/XLpZb3T9wI otyWE82DOU2ddmCrYjnnvvSSleLdkzmvOGQI5TuFUYz/uRTwUKV9QUgJls54yPsYkE41uQ hUuf7dEryAZtzzJR6DCbXQqPMHK40jlCviEumTSy/jkF33ZMXzoHOCtbtAqPUpTlkaFd8X aHP6h9tv1TaCzQgr91SiJ+oj6Mjc4be5qXpaGb8LKrHR8eTRyRBUPuxjeQA/fA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1778984043; a=rsa-sha256; cv=none; b=wc0DPRqEEeOPBobABThHPxgydrt/oLmQgHljAMZ0kFmHOkpqGQgoDU7LUUhb5sR4vrO3VH QkbFUC/Kcyj1JLRRVzREr9SAwUOTHhNpfLUWpag941cawBoFtjZisVxawHCvhYsAtdKJvm 6X59EYGqNgaegeqQlI8jsg5qlQK0ISh6ODSWOCKwdcU7ho/CJ6iKrxENyjlXEfW6/M2BB+ pTqSB13p3rWTvE7bv/fGd6a4SMthgaF3BHM9V7RTZV4m5v2h609GgQUntHRTa5MjL3wMBR 8VyQqYiK91T/PEdfo0S8DN5ZtDePTTV/dwZ5Nscr2jv1ZRP+moaDjhQC7ucKSw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1778984043; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+H2kUvGRf+6jSbv4oVwBsJSchXynh9M2/jEdvKUveUo=; b=sdIPG1EYNVRMD38GGY7jhzjkKn23kHIGiAGkuT8pjyfmdXInUUOYzblNpRNAlb9xxZmBkh IsNSmN6GUivBPnNkPPIsxOZGk2FZE+/6TJncM7QVr9f1xuWQimRyOAA4mDWK+qrDTm3MvH x+auaGaRBPHP8UNGsDdlTcoIS+CoaGhUiQXIEoKCG5pSwlOtItHS+zVV4k5V5eHYQ4NDae lxQEQ+fxkuHYVWH7TFCry0gYWwNKXMFI4axJ4XJ4jt0EfFxELU/MktCGQuABgMPAz1VwqH Wjxs368/kN/g0HyNI0rIwHnRiWHP1EOleU8OGQ3OZnXr5lqhI4NN6Z/ImhaGRA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gJ4Hb03sfz5rT for ; Sun, 17 May 2026 02:14:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 37682 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 17 May 2026 02:13:57 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 763de195d7bd - stable/15 - nfsd: Disable use of callbacks for NFSv4.0 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 763de195d7bd6ea34fb45ac53b298ce750af2806 Auto-Submitted: auto-generated Date: Sun, 17 May 2026 02:13:57 +0000 Message-Id: <6a092465.37682.1fd327ea@gitrepo.freebsd.org> The branch stable/15 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=763de195d7bd6ea34fb45ac53b298ce750af2806 commit 763de195d7bd6ea34fb45ac53b298ce750af2806 Author: Rick Macklem AuthorDate: 2026-05-03 23:25:45 +0000 Commit: Rick Macklem CommitDate: 2026-05-17 02:11:52 +0000 nfsd: Disable use of callbacks for NFSv4.0 Commit 71ac1ec5c9d9 disabled callbacks for the NFS client for NFSv4.0. This patch does the same for the NFSv4.0 server. The only use for callbacks for NFSv4.0 is delegations and delegations rarely work well for NFSv4.0 anyhow. Therefore, this patch disables callbacks for the NFSv4.0 server. This is the same behavior as occurs when vfs.nfsd.issue_delegations is 0. This change allowed the functions called nfsrv_getclientipaddr() and nfsrv_getipnumber() to be removed from the kernel. (cherry picked from commit 457c621add0a531273ee27798c924c6aaeacc4c1) --- sys/fs/nfsserver/nfs_nfsdstate.c | 261 +++++---------------------------------- 1 file changed, 32 insertions(+), 229 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c index 845949b8f630..e36a5c7810da 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -165,7 +165,6 @@ static void nfsrv_insertlock(struct nfslock *new_lop, struct nfslock *insert_lop, struct nfsstate *stp, struct nfslockfile *lfp); static void nfsrv_updatelock(struct nfsstate *stp, struct nfslock **new_lopp, struct nfslock **other_lopp, struct nfslockfile *lfp); -static int nfsrv_getipnumber(u_char *cp); static int nfsrv_checkrestart(nfsquad_t clientid, u_int32_t flags, nfsv4stateid_t *stateidp, int specialid); static int nfsrv_checkgrace(struct nfsrv_descript *nd, struct nfsclient *clp, @@ -4078,269 +4077,73 @@ out: } /* - * Get the client ip address for callbacks. If the strings can't be parsed, - * just set lc_program to 0 to indicate no callbacks are possible. - * (For cases where the address can't be parsed or is 0.0.0.0.0.0, set - * the address to the client's transport address. This won't be used - * for callbacks, but can be printed out by nfsstats for info.) + * Just set lc_program to 0 to indicate no callbacks are possible. + * Set the address to the client's transport address. This won't be used + * for callbacks, but can be printed out by nfsstats for info. * Return error if the xdr can't be parsed, 0 otherwise. */ int nfsrv_getclientipaddr(struct nfsrv_descript *nd, struct nfsclient *clp) { - u_int32_t *tl; - u_char *cp, *cp2; - int i, j, maxalen = 0, minalen = 0; - sa_family_t af; + uint32_t *tl; + int error = 0, i; #ifdef INET - struct sockaddr_in *rin = NULL, *sin; + struct sockaddr_in *rin, *sin; #endif #ifdef INET6 - struct sockaddr_in6 *rin6 = NULL, *sin6; + struct sockaddr_in6 *rin6, *sin6; #endif - u_char *addr; - int error = 0, cantparse = 0; - union { - in_addr_t ival; - u_char cval[4]; - } ip; - union { - in_port_t sval; - u_char cval[2]; - } port; - - /* 8 is the maximum length of the port# string. */ - addr = malloc(INET6_ADDRSTRLEN + 8, M_TEMP, M_WAITOK); + clp->lc_req.nr_client = NULL; clp->lc_req.nr_lock = 0; - af = AF_UNSPEC; - NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); + NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED); i = fxdr_unsigned(int, *tl); - if (i >= 3 && i <= 4) { - error = nfsrv_mtostr(nd, addr, i); + if (i < 0) { + error = NFSERR_BADXDR; + goto nfsmout; + } else if (i > 0) { + error = nfsm_advance(nd, NFSM_RNDUP(i), -1); if (error) goto nfsmout; -#ifdef INET - if (!strcmp(addr, "tcp")) { - clp->lc_flags |= LCL_TCPCALLBACK; - clp->lc_req.nr_sotype = SOCK_STREAM; - clp->lc_req.nr_soproto = IPPROTO_TCP; - af = AF_INET; - } else if (!strcmp(addr, "udp")) { - clp->lc_req.nr_sotype = SOCK_DGRAM; - clp->lc_req.nr_soproto = IPPROTO_UDP; - af = AF_INET; - } -#endif -#ifdef INET6 - if (af == AF_UNSPEC) { - if (!strcmp(addr, "tcp6")) { - clp->lc_flags |= LCL_TCPCALLBACK; - clp->lc_req.nr_sotype = SOCK_STREAM; - clp->lc_req.nr_soproto = IPPROTO_TCP; - af = AF_INET6; - } else if (!strcmp(addr, "udp6")) { - clp->lc_req.nr_sotype = SOCK_DGRAM; - clp->lc_req.nr_soproto = IPPROTO_UDP; - af = AF_INET6; - } - } -#endif - if (af == AF_UNSPEC) { - cantparse = 1; - } - } else { - cantparse = 1; - if (i > 0) { - error = nfsm_advance(nd, NFSM_RNDUP(i), -1); - if (error) - goto nfsmout; - } } - /* - * The caller has allocated clp->lc_req.nr_nam to be large enough - * for either AF_INET or AF_INET6 and zeroed out the contents. - * maxalen is set to the maximum length of the host IP address string - * plus 8 for the maximum length of the port#. - * minalen is set to the minimum length of the host IP address string - * plus 4 for the minimum length of the port#. - * These lengths do not include NULL termination, - * so INET[6]_ADDRSTRLEN - 1 is used in the calculations. - */ - switch (af) { + NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED); + i = fxdr_unsigned(int, *tl); + if (i < 0) { + error = NFSERR_BADXDR; + goto nfsmout; + } else if (i > 0) { + error = nfsm_advance(nd, NFSM_RNDUP(i), -1); + if (error) + goto nfsmout; + } + switch (nd->nd_nam->sa_family) { #ifdef INET case AF_INET: + sin = (struct sockaddr_in *)nd->nd_nam; rin = (struct sockaddr_in *)clp->lc_req.nr_nam; rin->sin_family = AF_INET; rin->sin_len = sizeof(struct sockaddr_in); - maxalen = INET_ADDRSTRLEN - 1 + 8; - minalen = 7 + 4; + rin->sin_addr.s_addr = sin->sin_addr.s_addr; + rin->sin_port = 0x0; break; #endif #ifdef INET6 case AF_INET6: + sin6 = (struct sockaddr_in6 *)nd->nd_nam; rin6 = (struct sockaddr_in6 *)clp->lc_req.nr_nam; rin6->sin6_family = AF_INET6; rin6->sin6_len = sizeof(struct sockaddr_in6); - maxalen = INET6_ADDRSTRLEN - 1 + 8; - minalen = 3 + 4; + rin6->sin6_addr = sin6->sin6_addr; + rin6->sin6_port = 0x0; break; #endif } - NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); - i = fxdr_unsigned(int, *tl); - if (i < 0) { - error = NFSERR_BADXDR; - goto nfsmout; - } else if (i == 0) { - cantparse = 1; - } else if (!cantparse && i <= maxalen && i >= minalen) { - error = nfsrv_mtostr(nd, addr, i); - if (error) - goto nfsmout; - - /* - * Parse out the address fields. We expect 6 decimal numbers - * separated by '.'s for AF_INET and two decimal numbers - * preceded by '.'s for AF_INET6. - */ - cp = NULL; - switch (af) { -#ifdef INET6 - /* - * For AF_INET6, first parse the host address. - */ - case AF_INET6: - cp = strchr(addr, '.'); - if (cp != NULL) { - *cp++ = '\0'; - if (inet_pton(af, addr, &rin6->sin6_addr) == 1) - i = 4; - else { - cp = NULL; - cantparse = 1; - } - } - break; -#endif -#ifdef INET - case AF_INET: - cp = addr; - i = 0; - break; -#endif - } - while (cp != NULL && *cp && i < 6) { - cp2 = cp; - while (*cp2 && *cp2 != '.') - cp2++; - if (*cp2) - *cp2++ = '\0'; - else if (i != 5) { - cantparse = 1; - break; - } - j = nfsrv_getipnumber(cp); - if (j >= 0) { - if (i < 4) - ip.cval[3 - i] = j; - else - port.cval[5 - i] = j; - } else { - cantparse = 1; - break; - } - cp = cp2; - i++; - } - if (!cantparse) { - /* - * The host address INADDR_ANY is (mis)used to indicate - * "there is no valid callback address". - */ - switch (af) { -#ifdef INET6 - case AF_INET6: - if (!IN6_ARE_ADDR_EQUAL(&rin6->sin6_addr, - &in6addr_any)) - rin6->sin6_port = htons(port.sval); - else - cantparse = 1; - break; -#endif -#ifdef INET - case AF_INET: - if (ip.ival != INADDR_ANY) { - rin->sin_addr.s_addr = htonl(ip.ival); - rin->sin_port = htons(port.sval); - } else { - cantparse = 1; - } - break; -#endif - } - } - } else { - cantparse = 1; - if (i > 0) { - error = nfsm_advance(nd, NFSM_RNDUP(i), -1); - if (error) - goto nfsmout; - } - } - if (cantparse) { - switch (nd->nd_nam->sa_family) { -#ifdef INET - case AF_INET: - sin = (struct sockaddr_in *)nd->nd_nam; - rin = (struct sockaddr_in *)clp->lc_req.nr_nam; - rin->sin_family = AF_INET; - rin->sin_len = sizeof(struct sockaddr_in); - rin->sin_addr.s_addr = sin->sin_addr.s_addr; - rin->sin_port = 0x0; - break; -#endif -#ifdef INET6 - case AF_INET6: - sin6 = (struct sockaddr_in6 *)nd->nd_nam; - rin6 = (struct sockaddr_in6 *)clp->lc_req.nr_nam; - rin6->sin6_family = AF_INET6; - rin6->sin6_len = sizeof(struct sockaddr_in6); - rin6->sin6_addr = sin6->sin6_addr; - rin6->sin6_port = 0x0; - break; -#endif - } - clp->lc_program = 0; - } + clp->lc_program = 0; nfsmout: - free(addr, M_TEMP); NFSEXITCODE2(error, nd); return (error); } -/* - * Turn a string of up to three decimal digits into a number. Return -1 upon - * error. - */ -static int -nfsrv_getipnumber(u_char *cp) -{ - int i = 0, j = 0; - - while (*cp) { - if (j > 2 || *cp < '0' || *cp > '9') - return (-1); - i *= 10; - i += (*cp - '0'); - cp++; - j++; - } - if (i < 256) - return (i); - return (-1); -} - /* * This function checks for restart conditions. */