Bug 292283 - (JAVA) NFSv4.1 client trying to set FATTR4_SYSTEM or FATTR4_HIDDEN gets EPERM for file and dir creation attemps
Summary: (JAVA) NFSv4.1 client trying to set FATTR4_SYSTEM or FATTR4_HIDDEN gets EPERM...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 15.0-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Rick Macklem
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2026-01-08 19:49 UTC by Aurélien Couderc
Modified: 2026-10-01 08:42 UTC (History)
4 users (show)

See Also:
rmacklem: mfc-stable15+


Attachments
Fix for NFSv4.n client specifying hidden/system during file creation (2.72 KB, patch)
2026-01-08 21: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 Aurélien Couderc 2026-01-08 19:49:19 UTC
Our CI uses this script to quickly setup a FreeBSD NFSv4.1 server for
testing. The script worked with FreeBSD 14.2, but with FreeBSD 15.0
all files are suddenly read-only (write access gets EPERM):

sysrc rpcbind_enable="YES"
sysrc mountd_enable="YES"
sysrc nfs_server_enable=YES
sysrc nfsv4_server_enable=YES
sysrc nfsuserd_flags="-domain GLOBAL.LOC"
sysrc nfsuserd_enable=YES
sysrc nfscbd_enable=YES
printf 'vfs.nfs.enable_uidtostring=0\n' >>'/etc/sysctl.conf'
printf 'vfs.nfsd.enable_stringtouid=0\n' >>'/etc/sysctl.conf'
printf 'vfs.nfsd.issue_delegations=1\n' >>'/etc/sysctl.conf'
mkdir /nfsdata
chmod a+rwxt /nfsdata
printf 'V4: /\n' >'/etc/exports'
printf '/nfsdata -network=80.247.17.0 -mask=255.255.255.0  -sec=sys\n'
>>'/etc/exports'
service nfsd start


The failed NFS4.2 op looks like this in wireshark:

Network File System, Ops(8): SEQUENCE, PUTFH, SAVEFH, OPEN, GETFH,
GETATTR, RESTOREFH, GETATTR
    [Program Version: 4]
    [V4 Procedure: COMPOUND (1)]
    Tag: open
    minorversion: 2
    Operations (count: 8): SEQUENCE, PUTFH, SAVEFH, OPEN, GETFH,
GETATTR, RESTOREFH, GETATTR
        Opcode: SEQUENCE (53)
        Opcode: PUTFH (22)
        Opcode: SAVEFH (32)
        Opcode: OPEN (18)
            seqid: 0x00000000
            share_access: OPEN4_SHARE_ACCESS_WRITE (2)
            share_deny: OPEN4_SHARE_DENY_NONE (0)
            clientid: 0x0000000000000000
            owner: <DATA>
            Open Type: OPEN4_CREATE (1)
                Create Mode: UNCHECKED4 (0)
                Attr mask[0]: 0x02000010 (Size, Hidden)
                    reqd_attr: Size (4)
                        size: 0
                    reco_attr: Hidden (25)
                        fattr4_hidden: No
                Attr mask[1]: 0x00004002 (Mode, System)
                    reco_attr: Mode (33)
                        mode: 0644, Name: Unknown, Read permission for
owner, Write permission for owner, Read permission for group, Read
permission for others
                    reco_attr: System (46)
                        fattr4_system: No
            Claim Type: CLAIM_NULL (0)
                Name: u
                    length: 1
                    contents: u
                    fill bytes: opaque data
        Opcode: GETFH (10)
        Opcode: GETATTR (9)
        Opcode: RESTOREFH (31)
        Opcode: GETATTR (9)
    [Main Opcode: OPEN (18)]

Based on comments in freebsd-hackers@ this is an issue with ZFS, see https://lists.freebsd.org/archives/freebsd-hackers/2026-January/005476.html
Comment 1 Rick Macklem freebsd_committer freebsd_triage 2026-01-08 21:28:14 UTC
Created attachment 266952 [details]
Fix for NFSv4.n client specifying hidden/system during file creation

The problem seems to be caused by ZFS calling
secpolicy_xvattr() when any va_flags bit
(which includes UF_HIDDEN and UF_SYSTEM)
is specified for VOP_CREATE().

specpolicy_xvattr() returns EPERM for non-root,
which is good, because if the code is patched
to allow it, ZFS panics.

This patch avoids the problem by disabling the
va_flags field for VOP_CREATE() and then setting
the va_flags bits via VOP_SETATTR() after the
VOP_CREATE(), for the NFSv4.n server.
Comment 2 Aurélien Couderc 2026-01-08 21:29:13 UTC
Comment on attachment 266952 [details]
Fix for NFSv4.n client specifying hidden/system during file creation

The patch seems to work with our JAVA NFSv4.2 client.
Comment 3 commit-hook freebsd_committer freebsd_triage 2026-01-09 00:34:22 UTC
A commit in branch main references this bug:

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

commit a6d57f312f18bbeeda8a34e99d0a662b0db9a190
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2026-01-08 16:27:32 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2026-01-08 16:27:32 +0000

    nfsd: Fix handling of hidden/system during Open/Create

    When an NFSv4.n client specifies settings for the archive,
    hidden and/or system attributes during a Open/Create, the
    Open/Create fails for ZFS.  This is caused by ZFS doing
    a secpolicy_xvattr() call, which fails for non-root.
    If this check is bypassed, ZFS panics.

    This patch resolves the problem by disabling va_flags
    for the VOP_CREATE() call in the NFSv4.n server and
    then setting the flags with a subsequent VOP_SETATTR().

    This problem only affects FreeBSD-15 and main, since the
    archive, system and hidden attributes are not enabled
    for FreeBSD-14.

    I think a similar problem exists for the NFSv4.n
    Open/Create/Exclusive_41, but that will be resolved
    in a future commit.

    Note that the Linux, Solaris and FreeBSD clients
    do not set archive, hidden or system for Open/Create,
    so the bug does not affect mounts from those clients.

    PR:     292283
    Reported by:    Aurelien Couderc <aurelien.couderc2002@gmail.com>
    Tested by:      Aurelien Couderc <aurelien.couderc2002@gmail.com>
    MFC after:      2 weeks

 sys/fs/nfsserver/nfs_nfsdport.c | 11 +++++++++++
 sys/fs/nfsserver/nfs_nfsdsubs.c | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)
Comment 4 Rick Macklem freebsd_committer freebsd_triage 2026-01-09 00:35:55 UTC
The patch has been committed to main and
will be MFC'd.
Comment 5 Aurélien Couderc 2026-01-09 10:42:13 UTC
(In reply to Rick Macklem from comment #4)
Is there a FreeBSD 15 "testing" repro which can be used to update a stock FreeBSD 15.0 installation to include this fix?
Comment 6 Aurélien Couderc 2026-01-09 10:42:38 UTC
(In reply to commit-hook from comment #3)
Thank you!
Comment 7 Aurélien Couderc 2026-01-09 10:48:23 UTC
(In reply to Rick Macklem from comment #1)
Could you please file a bug report against ZFS, and post the bug report URL here for reference?
Comment 8 Rick Macklem freebsd_committer freebsd_triage 2026-01-09 12:39:01 UTC
(In reply to Aurélien Couderc from comment #5)
In 2 weeks, the patch will be merged from current (MFC)
to stable/15, which is what 15.n is branched from.

I think you could call stable/15 a testing branch
for 15.n.
Comment 9 commit-hook freebsd_committer freebsd_triage 2026-01-24 00:48:33 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=6fd7e55c94134b01c6e0f14f53d3172f18ab786f

commit 6fd7e55c94134b01c6e0f14f53d3172f18ab786f
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2026-01-08 16:27:32 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2026-01-24 00:43:05 +0000

    nfsd: Fix handling of hidden/system during Open/Create

    When an NFSv4.n client specifies settings for the archive,
    hidden and/or system attributes during a Open/Create, the
    Open/Create fails for ZFS.  This is caused by ZFS doing
    a secpolicy_xvattr() call, which fails for non-root.
    If this check is bypassed, ZFS panics.

    This patch resolves the problem by disabling va_flags
    for the VOP_CREATE() call in the NFSv4.n server and
    then setting the flags with a subsequent VOP_SETATTR().

    This problem only affects FreeBSD-15 and main, since the
    archive, system and hidden attributes are not enabled
    for FreeBSD-14.

    I think a similar problem exists for the NFSv4.n
    Open/Create/Exclusive_41, but that will be resolved
    in a future commit.

    Note that the Linux, Solaris and FreeBSD clients
    do not set archive, hidden or system for Open/Create,
    so the bug does not affect mounts from those clients.

    PR:     292283

    (cherry picked from commit a6d57f312f18bbeeda8a34e99d0a662b0db9a190)

 sys/fs/nfsserver/nfs_nfsdport.c | 11 +++++++++++
 sys/fs/nfsserver/nfs_nfsdsubs.c | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)
Comment 10 Rick Macklem freebsd_committer freebsd_triage 2026-01-24 00:50:38 UTC
The patch has been MFC'd.
Comment 11 Aurélien Couderc 2026-10-01 08:42:46 UTC
(In reply to commit-hook from comment #9)
In which FreeBSD 15.x release is this fixed ?