git: 815a7affac83 - stable/13 - nfscl: Sanity check irdcnt in nfsrpc_createsession

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Fri, 10 Dec 2021 00:57:39 UTC
The branch stable/13 has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=815a7affac8314de7546c2083cc9a6acf414ee54

commit 815a7affac8314de7546c2083cc9a6acf414ee54
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2021-11-26 23:28:40 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2021-12-10 00:54:18 +0000

    nfscl: Sanity check irdcnt in nfsrpc_createsession
    
    PR:     259996
    
    (cherry picked from commit 22f7bcb523e7138248832fb304559c8f23276e08)
---
 sys/fs/nfsclient/nfs_clrpcops.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c
index b616cd729ab1..a87495da8568 100644
--- a/sys/fs/nfsclient/nfs_clrpcops.c
+++ b/sys/fs/nfsclient/nfs_clrpcops.c
@@ -4987,6 +4987,10 @@ nfsrpc_createsession(struct nfsmount *nmp, struct nfsclsession *sep,
 		sep->nfsess_foreslots = fxdr_unsigned(uint16_t, *tl++);
 		NFSCL_DEBUG(4, "fore slots=%d\n", (int)sep->nfsess_foreslots);
 		irdcnt = fxdr_unsigned(int, *tl);
+		if (irdcnt < 0 || irdcnt > 1) {
+			error = NFSERR_BADXDR;
+			goto nfsmout;
+		}
 		if (irdcnt > 0)
 			NFSM_DISSECT(tl, uint32_t *, irdcnt * NFSX_UNSIGNED);