Bug 274574 - The NFSv4.1/4.2 server misparses the Open Claim_Deleg_Cur_FH option
Summary: The NFSv4.1/4.2 server misparses the Open Claim_Deleg_Cur_FH option
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Some People
Assignee: Rick Macklem
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-19 02:28 UTC by Rick Macklem
Modified: 2024-01-10 21:37 UTC (History)
0 users

See Also:
rmacklem: mfc-stable14+
rmacklem: mfc-stable13+
rmacklem: mfc-stable12+


Attachments
Fix handling of the Open Claim_Deleg_Cur_FH option (3.08 KB, patch)
2023-10-19 02:28 UTC, Rick Macklem
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rick Macklem freebsd_committer freebsd_triage 2023-10-19 02:28:38 UTC
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.
Comment 1 commit-hook freebsd_committer freebsd_triage 2023-10-19 19:37:52 UTC
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(-)
Comment 2 Rick Macklem freebsd_committer freebsd_triage 2023-10-20 03:02:37 UTC
The patch has been committed to main and will be MFC'd.
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-11-02 22:02:38 UTC
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(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2023-11-02 23:35:56 UTC
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(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2023-11-02 23:45:59 UTC
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(-)
Comment 6 Rick Macklem freebsd_committer freebsd_triage 2023-11-02 23:50:25 UTC
The patch has been MFC'd.
I am leaving the PR open until a possible
FreeBSD-14 errata is done.
Comment 7 Rick Macklem freebsd_committer freebsd_triage 2024-01-10 21:37:03 UTC
The patch was committed to main and MFC'd to
stable/12, stable/13 and stable/14.