git: 878084c774c6 - main - nfsserver: Do not increment seqid on BADSEQID
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 05 Nov 2026 21:12:07 UTC
The branch main has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=878084c774c6d68fcdb65e00ba8f74726dda0999
commit 878084c774c6d68fcdb65e00ba8f74726dda0999
Author: Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-11-05 21:11:30 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-11-05 21:11:30 +0000
nfsserver: Do not increment seqid on BADSEQID
When returning NFSERR_BADSEQID, the server should not have incremented
the sequence ID, yet the call to nfsrv_checkseqid() a few lines above
does precisely that. Instead, check for a legitimate retransmission
of the original successful request, and reject otherwise, before the
ticket is used and sequence ID incremented.
MFC after: 1 week
Fixes: ff45b9fc1a8c ("Bjorn reported a problem...")
Sponsored by: Klara, Inc.
Reviewed by: rmacklem
Differential Revision: https://reviews.freebsd.org/D61156
---
sys/fs/nfsserver/nfs_nfsdstate.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c
index 2fdce567c1ce..5b36dc9c9721 100644
--- a/sys/fs/nfsserver/nfs_nfsdstate.c
+++ b/sys/fs/nfsserver/nfs_nfsdstate.c
@@ -2008,19 +2008,31 @@ tryagain:
if (error == 0) {
if (new_stp->ls_flags & NFSLCK_OPENTOLOCK) {
+ if (stp->ls_flags & NFSLCK_OPEN)
+ nfsrv_getowner(&stp->ls_open, new_stp, &lckstp);
/*
* If haslock set, we've already checked the seqid.
*/
if (!haslock) {
- if (stp->ls_flags & NFSLCK_OPEN)
- error = nfsrv_checkseqid(nd, new_stp->ls_seq,
- stp->ls_openowner, new_stp->ls_op);
- else
+ if (stp->ls_flags & NFSLCK_OPEN) {
+ /*
+ * A new NFSv4.0 request cannot reuse a lock
+ * owner. Reject it before checkseqid consumes
+ * the open seqid and replaces the cached reply.
+ * The current seqid may be a retransmission of
+ * the original LOCK; let checkseqid validate it.
+ */
+ if (lckstp != NULL &&
+ (nd->nd_flag & ND_NFSV41) == 0 &&
+ new_stp->ls_seq != stp->ls_openowner->ls_seq)
+ error = NFSERR_BADSEQID;
+ else
+ error = nfsrv_checkseqid(nd, new_stp->ls_seq,
+ stp->ls_openowner, new_stp->ls_op);
+ } else
error = NFSERR_BADSTATEID;
}
- if (!error)
- nfsrv_getowner(&stp->ls_open, new_stp, &lckstp);
- if (lckstp) {
+ if (!error && lckstp) {
/*
* For NFSv4.1 and NFSv4.2 allow an
* open_to_lock_owner when the lock_owner already
@@ -2033,7 +2045,7 @@ tryagain:
new_stp->ls_flags &= ~NFSLCK_OPENTOLOCK;
else
error = NFSERR_BADSEQID;
- } else
+ } else if (lckstp == NULL)
lckstp = new_stp;
} else if (new_stp->ls_flags&(NFSLCK_LOCK|NFSLCK_UNLOCK)) {
/*