git: 3e8081ac8869 - stable/13 - nfscl: Sanity check the Sequence slotid in reply

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Sat, 11 Dec 2021 02:31:50 UTC
The branch stable/13 has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=3e8081ac8869e2b5b92d4a84c217a05cdd10487a

commit 3e8081ac8869e2b5b92d4a84c217a05cdd10487a
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2021-11-27 23:02:04 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2021-12-11 02:28:14 +0000

    nfscl: Sanity check the Sequence slotid in reply
    
    The slotid in the Sequence reply must be the same as
    in the request.  Check that it is the same and log
    a console message if it is not, plus set it to the
    correct value.
    
    PR:     260071
    
    (cherry picked from commit 1c15c8c0e935f3f7def7b03e9546f7d6790f465e)
---
 sys/fs/nfs/nfs_commonkrpc.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c
index c1a5fab2a358..4d8db64f419f 100644
--- a/sys/fs/nfs/nfs_commonkrpc.c
+++ b/sys/fs/nfs/nfs_commonkrpc.c
@@ -1038,6 +1038,18 @@ tryagain:
 					tl += NFSX_V4SESSIONID / NFSX_UNSIGNED;
 					retseq = fxdr_unsigned(uint32_t, *tl++);
 					slot = fxdr_unsigned(int, *tl++);
+					if ((nd->nd_flag & ND_HASSLOTID) != 0) {
+						if (slot != nd->nd_slotid) {
+							printf("newnfs_request:"
+							    " Wrong session "
+							    "slot=%d\n", slot);
+							slot = nd->nd_slotid;
+						}
+					} else if (slot != 0) {
+						printf("newnfs_request: Bad "
+						    "session slot=%d\n", slot);
+						slot = 0;
+					}
 					freeslot = slot;
 					if (retseq != sep->nfsess_slotseq[slot])
 						printf("retseq diff 0x%x\n",