git: 6c9170e0afc4 - main - svc.c: Check for a non-NULL xp_socket

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Tue, 28 May 2024 02:23:37 UTC
The branch main has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=6c9170e0afc4ebec81ba88a6370ebf6cb55520ba

commit 6c9170e0afc4ebec81ba88a6370ebf6cb55520ba
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2024-05-28 02:22:04 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2024-05-28 02:22:04 +0000

    svc.c: Check for a non-NULL xp_socket
    
    Commit a16ff32f04b5 added support to the kernel RPC to set
    TCP_USE_DDP.
    However, for the unusual case of a NFSv4.1/4.2 non-NULL callback,
    the xp_socket field of SVCXPRT is NULL, since it uses the same
    socket as the client->server connection.
    
    This patch adds the check for this to avoid crashes.
    
    This only affects NFSv4.1/4.2 mounts where either pNFS or
    delegations are in use.
    
    MFC after:      3 days
---
 sys/rpc/svc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/rpc/svc.c b/sys/rpc/svc.c
index 99678f693a3e..f94e744d40f4 100644
--- a/sys/rpc/svc.c
+++ b/sys/rpc/svc.c
@@ -996,6 +996,7 @@ svc_getreq(SVCXPRT *xprt, struct svc_req **rqstp_ret)
 		 * enable TLS offload first.
 		 */
 		if (xprt->xp_doneddp == 0 && r->rq_proc != NULLPROC &&
+		    xprt->xp_socket != NULL &&
 		    atomic_cmpset_int(&xprt->xp_doneddp, 0, 1)) {
 			if (xprt->xp_socket->so_proto->pr_protocol ==
 			    IPPROTO_TCP) {