git: 1155c9a35835 - main - clnt_rdma.c: Fix handling of a client reply retried reply

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Thu, 26 Nov 2026 14:36:44 UTC
The branch main has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=1155c9a35835dd7a590fcf6915f4d7b5631f6d1c

commit 1155c9a35835dd7a590fcf6915f4d7b5631f6d1c
Author:     Vinicius Ferrao <ferrao@versatushpc.com.br>
AuthorDate: 2026-11-26 14:34:31 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2026-11-26 14:34:31 +0000

    clnt_rdma.c: Fix handling of a client reply retried reply
    
    When the client does a retry (due to an expired RPCSEC_GSS credential),
    the handling of the reply chunk was not done correctly.
    
    This patch fixes this.
    
    Reviewed by:    rmacklem
    Sponsored by:   VersatusHPC
    MFC after:      1 month
---
 sys/ofed/drivers/infiniband/ulp/nfsclrdma/clnt_rdma.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/sys/ofed/drivers/infiniband/ulp/nfsclrdma/clnt_rdma.c b/sys/ofed/drivers/infiniband/ulp/nfsclrdma/clnt_rdma.c
index 841c4756c722..a7b87640aefb 100644
--- a/sys/ofed/drivers/infiniband/ulp/nfsclrdma/clnt_rdma.c
+++ b/sys/ofed/drivers/infiniband/ulp/nfsclrdma/clnt_rdma.c
@@ -413,6 +413,7 @@ clnt_rdma_call(
 	struct timeval timeout;
 	uint32_t xid, rdma_xid, rdma_vers, rdma_credit, rdma_body, rpos;
 	uint32_t tlen, tlen2, length, handle, reduce_pos, rpchdr_len;
+	uint32_t reply_max;
 	uint64_t offset;
 	struct mbuf *m1, *m2, *mreq, *results, *mr, *mreduce, *mreduce_prev;
 	struct ct_request *cr;
@@ -935,6 +936,8 @@ got_reply:
 		goto cannotdecode;
 	}
 	crdma->crdma_xp.credits = rdma_credit;
+	reply_max = reply_chp != NULL ?
+	    m_length(reply_chp->mextpg, NULL) : 0;
 	reply_chunks[READLIST] = chunks[READLIST];
 	reply_chunks[WRITELIST] = chunks[WRITELIST];
 	reply_chunks[WRITECHUNK] = chunks[WRITECHUNK];
@@ -990,6 +993,10 @@ got_reply:
 						    "bogus\n");
 						goto cannotdecode;
 					}
+					if (i == WRITECHUNK &&
+					    rdma_body == RDMA_NOMSG &&
+					    length > reply_max - tlen)
+						goto cannotdecode;
 					tlen += length;
 					RPCRDMA_DEBUG(4, "clnt_rdma_call: Got "
 					    "segment handle=0x%x length=%d "
@@ -1103,6 +1110,7 @@ got_reply:
 					xprt_rdma_unmap_chunk(&crdma->crdma_xp,
 					    request_chp);
 					request_chp = NULL;
+					chunks[READLIST] = 0;
 					rpc_free_rdma_reduction(mr);
 					mr = NULL;
 				}