Created attachment 245723 [details] Fix handling of the Open Claim_Deleg_Cur_FH option If delegations are enabled (vfs.nfsd.issue_delegations==1, not by default), a non-FreeBSD NFSv4.1/4.2 client mount might perform an Open with the Claim_Deleg_Cur_FH option. This will not work unless the attached patch is applied to the FreeBSD NFSv4.1/4.2 server. Note that this does not affect a FreeBSD NFSv4.1/4.2 mount, but may affect mounts from non-FreeBSD clients.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=f300335d9aebf2e99862bf783978bd44ede23550 commit f300335d9aebf2e99862bf783978bd44ede23550 Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2023-10-19 19:35:35 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2023-10-19 19:35:35 +0000 nfsd: Fix NFSv4.1/4.2 Claim_Deleg_Cur_FH When I implemented a test patch using Open Claim_Deleg_Cur_FH I discovered that the NFSv4.1/4.2 server was broken for this Open option. Fortunately it is never used by the FreeBSD client and never used by other clients unless delegations are enabled. (The FreeBSD NFSv4 server does not have delegations enabled by default.) Claim_Deleg_Cur_FH was broken because the code mistakenly assumed a stateID argument, which is not the case. This patch fixes the bug by changing the XDR parser to not expect a stateID and to fill most of the stateID in from the clientID. The clientID is the first two elements of the "other" array for the stateID and is sufficient to identify which client the delegation is issued to. Since there is only one delegation issued to a client per file, this is sufficient to locate the correct delegation. If you are running non-FreeBSD NFSv4.1/4.2 mounts against the FreeBSD server, you need this patch if you have delegations enabled. PR: 274574 MFC after: 2 weeks sys/fs/nfsserver/nfs_nfsdserv.c | 10 ++++++++-- sys/fs/nfsserver/nfs_nfsdstate.c | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-)
The patch has been committed to main and will be MFC'd.
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=d9e28d5d40c9888f996e895d4bde51b49e7b0946 commit d9e28d5d40c9888f996e895d4bde51b49e7b0946 Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2023-10-19 19:35:35 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2023-11-02 22:00:48 +0000 nfsd: Fix NFSv4.1/4.2 Claim_Deleg_Cur_FH When I implemented a test patch using Open Claim_Deleg_Cur_FH I discovered that the NFSv4.1/4.2 server was broken for this Open option. Fortunately it is never used by the FreeBSD client and never used by other clients unless delegations are enabled. (The FreeBSD NFSv4 server does not have delegations enabled by default.) Claim_Deleg_Cur_FH was broken because the code mistakenly assumed a stateID argument, which is not the case. This patch fixes the bug by changing the XDR parser to not expect a stateID and to fill most of the stateID in from the clientID. The clientID is the first two elements of the "other" array for the stateID and is sufficient to identify which client the delegation is issued to. Since there is only one delegation issued to a client per file, this is sufficient to locate the correct delegation. If you are running non-FreeBSD NFSv4.1/4.2 mounts against the FreeBSD server, you need this patch if you have delegations enabled. PR: 274574 (cherry picked from commit f300335d9aebf2e99862bf783978bd44ede23550) sys/fs/nfsserver/nfs_nfsdserv.c | 10 ++++++++-- sys/fs/nfsserver/nfs_nfsdstate.c | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=f33609bc7799bd1ebefa2f7cad02be646bcf21e9 commit f33609bc7799bd1ebefa2f7cad02be646bcf21e9 Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2023-10-19 19:35:35 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2023-11-02 23:33:48 +0000 nfsd: Fix NFSv4.1/4.2 Claim_Deleg_Cur_FH When I implemented a test patch using Open Claim_Deleg_Cur_FH I discovered that the NFSv4.1/4.2 server was broken for this Open option. Fortunately it is never used by the FreeBSD client and never used by other clients unless delegations are enabled. (The FreeBSD NFSv4 server does not have delegations enabled by default.) Claim_Deleg_Cur_FH was broken because the code mistakenly assumed a stateID argument, which is not the case. This patch fixes the bug by changing the XDR parser to not expect a stateID and to fill most of the stateID in from the clientID. The clientID is the first two elements of the "other" array for the stateID and is sufficient to identify which client the delegation is issued to. Since there is only one delegation issued to a client per file, this is sufficient to locate the correct delegation. If you are running non-FreeBSD NFSv4.1/4.2 mounts against the FreeBSD server, you need this patch if you have delegations enabled. PR: 274574 (cherry picked from commit f300335d9aebf2e99862bf783978bd44ede23550) sys/fs/nfsserver/nfs_nfsdserv.c | 10 ++++++++-- sys/fs/nfsserver/nfs_nfsdstate.c | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-)
A commit in branch stable/12 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=f383f4ad30a61fd0cd5104bb5c730aff139b993d commit f383f4ad30a61fd0cd5104bb5c730aff139b993d Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2023-10-19 19:35:35 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2023-11-02 23:44:27 +0000 nfsd: Fix NFSv4.1/4.2 Claim_Deleg_Cur_FH When I implemented a test patch using Open Claim_Deleg_Cur_FH I discovered that the NFSv4.1/4.2 server was broken for this Open option. Fortunately it is never used by the FreeBSD client and never used by other clients unless delegations are enabled. (The FreeBSD NFSv4 server does not have delegations enabled by default.) Claim_Deleg_Cur_FH was broken because the code mistakenly assumed a stateID argument, which is not the case. This patch fixes the bug by changing the XDR parser to not expect a stateID and to fill most of the stateID in from the clientID. The clientID is the first two elements of the "other" array for the stateID and is sufficient to identify which client the delegation is issued to. Since there is only one delegation issued to a client per file, this is sufficient to locate the correct delegation. If you are running non-FreeBSD NFSv4.1/4.2 mounts against the FreeBSD server, you need this patch if you have delegations enabled. PR: 274574 (cherry picked from commit f300335d9aebf2e99862bf783978bd44ede23550) sys/fs/nfsserver/nfs_nfsdserv.c | 10 ++++++++-- sys/fs/nfsserver/nfs_nfsdstate.c | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-)
The patch has been MFC'd. I am leaving the PR open until a possible FreeBSD-14 errata is done.
The patch was committed to main and MFC'd to stable/12, stable/13 and stable/14.