git: 761033d3aace - stable/13 - nfscl: Fix handling of a bad session slot (NFSv4.1/4.2)

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Fri, 02 Sep 2022 02:09:57 UTC
The branch stable/13 has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=761033d3aace36eea1d82bbce86e06206b4cb17c

commit 761033d3aace36eea1d82bbce86e06206b4cb17c
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2022-08-26 03:33:31 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2022-09-02 02:07:05 +0000

    nfscl: Fix handling of a bad session slot (NFSv4.1/4.2)
    
    When a session has been marked defunct by the server
    sending a NFSERR_BADSESSION reply to the NFSv4.1/4.2
    client, nfsv4_sequencelookup() returns NFSERR_BADSESSION
    without actually assigning a session slot.
    Without this patch, newnfs_request() would erroneously
    free slot 0.
    
    This could result in the slot being reused prematurely,
    but most likely just generated a "freeing free slot!!"
    console message.
    
    This patch fixes the code to not do the erroneous
    freeing of the slot for this case.
    
    PR:     260011
    (cherry picked from commit 2b612c9d3bb528551de9eaabbdbadae89a36ba8b)
---
 sys/fs/nfs/nfs_commonkrpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c
index 81df586879c5..91ebd84fabd0 100644
--- a/sys/fs/nfs/nfs_commonkrpc.c
+++ b/sys/fs/nfs/nfs_commonkrpc.c
@@ -1080,12 +1080,12 @@ tryagain:
 						    }
 						    slot = nd->nd_slotid;
 						}
+						freeslot = slot;
 					} 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",
 						    retseq);