Skip to content

Commit 36d179f

Browse files
committed
Merge tag 'nfsd-7.1' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux
Pull nfsd updates from Chuck Lever: - filehandle signing to defend against filehandle-guessing attacks (Benjamin Coddington) The server now appends a SipHash-2-4 MAC to each filehandle when the new "sign_fh" export option is enabled. NFSD then verifies filehandles received from clients against the expected MAC; mismatches return NFS error STALE - convert the entire NLMv4 server-side XDR layer from hand-written C to xdrgen-generated code, spanning roughly thirty patches (Chuck Lever) XDR functions are generally boilerplate code and are easy to get wrong. The goals of this conversion are improved memory safety, lower maintenance burden, and groundwork for eventual Rust code generation for these functions. - improve pNFS block/SCSI layout robustness with two related changes (Dai Ngo) SCSI persistent reservation fencing is now tracked per client and per device via an xarray, to avoid both redundant preempt operations on devices already fenced and a potential NFSD deadlock when all nfsd threads are waiting for a layout return. - scalability and infrastructure improvements Sincere thanks to all contributors, reviewers, testers, and bug reporters who participated in the v7.1 NFSD development cycle. * tag 'nfsd-7.1' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux: (83 commits) NFSD: Docs: clean up pnfs server timeout docs nfsd: fix comment typo in nfsxdr nfsd: fix comment typo in nfs3xdr NFSD: convert callback RPC program to per-net namespace NFSD: use per-operation statidx for callback procedures svcrdma: Use contiguous pages for RDMA Read sink buffers SUNRPC: Add svc_rqst_page_release() helper SUNRPC: xdr.h: fix all kernel-doc warnings svcrdma: Factor out WR chain linking into helper svcrdma: Add Write chunk WRs to the RPC's Send WR chain svcrdma: Clean up use of rdma->sc_pd->device svcrdma: Clean up use of rdma->sc_pd->device in Receive paths svcrdma: Add fair queuing for Send Queue access SUNRPC: Optimize rq_respages allocation in svc_alloc_arg SUNRPC: Track consumed rq_pages entries svcrdma: preserve rq_next_page in svc_rdma_save_io_pages SUNRPC: Handle NULL entries in svc_rqst_release_pages SUNRPC: Allocate a separate Reply page array SUNRPC: Tighten bounds checking in svc_rqst_replace_page NFSD: Sign filehandles ...
2 parents c1f49de + d644a69 commit 36d179f

78 files changed

Lines changed: 4421 additions & 1724 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Documentation/admin-guide/nfs/pnfs-block-server.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,33 @@ how to translate the device into a serial number from SCSI EVPD 0x80::
4040
4141
echo "fencing client ${CLIENT} serial ${EVPD}" >> /var/log/pnfsd-fence.log
4242
EOF
43+
44+
If the nfsd server needs to fence a non-responding client and the
45+
fencing operation fails, the server logs a warning message in the
46+
system log with the following format:
47+
48+
FENCE failed client[IP_address] clid[#n] device[dev_name]
49+
50+
where:
51+
52+
- IP_address: refers to the IP address of the affected client.
53+
- #n: indicates the unique client identifier.
54+
- dev_name: specifies the name of the block device related
55+
to the fencing attempt.
56+
57+
The server will repeatedly retry the operation indefinitely. During
58+
this time, access to the affected file is restricted for all other
59+
clients. This is to prevent potential data corruption if multiple
60+
clients access the same file simultaneously.
61+
62+
To restore access to the affected file for other clients, the admin
63+
needs to take the following actions:
64+
65+
- shutdown or power off the client being fenced.
66+
- manually expire the client to release all its state on the server::
67+
68+
echo 'expire' > /proc/fs/nfsd/clients/clid/ctl
69+
70+
where:
71+
72+
- clid: is the unique client identifier displayed in the system log.

Documentation/admin-guide/nfs/pnfs-scsi-server.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,34 @@ option and the underlying SCSI device support persistent reservations.
2222
On the client make sure the kernel has the CONFIG_PNFS_BLOCK option
2323
enabled, and the file system is mounted using the NFSv4.1 protocol
2424
version (mount -o vers=4.1).
25+
26+
If the nfsd server needs to fence a non-responding client and the
27+
fencing operation fails, the server logs a warning message in the
28+
system log with the following format:
29+
30+
FENCE failed client[IP_address] clid[#n] device[dev_name]
31+
32+
where:
33+
34+
- IP_address: refers to the IP address of the affected client.
35+
- #n: indicates the unique client identifier.
36+
- dev_name: specifies the name of the block device related
37+
to the fencing attempt.
38+
39+
The server will repeatedly retry the operation indefinitely. During
40+
this time, access to the affected file is restricted for all other
41+
clients. This is to prevent potential data corruption if multiple
42+
clients access the same file simultaneously.
43+
44+
To restore access to the affected file for other clients, the admin
45+
needs to take the following actions:
46+
47+
- shutdown or power off the client being fenced.
48+
- manually expire the client to release all its state on the server::
49+
50+
echo 'expire' > /proc/fs/nfsd/clients/clid/ctl
51+
52+
where:
53+
54+
- clid: is the unique client identifier displayed in the system log.
55+

Documentation/filesystems/locking.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ prototypes::
398398
bool (*lm_breaker_owns_lease)(struct file_lock *);
399399
bool (*lm_lock_expirable)(struct file_lock *);
400400
void (*lm_expire_lock)(void);
401+
bool (*lm_breaker_timedout)(struct file_lease *);
401402

402403
locking rules:
403404

@@ -412,6 +413,7 @@ lm_breaker_owns_lease: yes no no
412413
lm_lock_expirable yes no no
413414
lm_expire_lock no no yes
414415
lm_open_conflict yes no no
416+
lm_breaker_timedout yes no no
415417
====================== ============= ================= =========
416418

417419
buffer_head

Documentation/filesystems/nfs/exporting.rst

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,88 @@ following flags are defined:
206206
all of an inode's dirty data on last close. Exports that behave this
207207
way should set EXPORT_OP_FLUSH_ON_CLOSE so that NFSD knows to skip
208208
waiting for writeback when closing such files.
209+
210+
Signed Filehandles
211+
------------------
212+
213+
To protect against filehandle guessing attacks, the Linux NFS server can be
214+
configured to sign filehandles with a Message Authentication Code (MAC).
215+
216+
Standard NFS filehandles are often predictable. If an attacker can guess
217+
a valid filehandle for a file they do not have permission to access via
218+
directory traversal, they may be able to bypass path-based permissions
219+
(though they still remain subject to inode-level permissions).
220+
221+
Signed filehandles prevent this by appending a MAC to the filehandle
222+
before it is sent to the client. Upon receiving a filehandle back from a
223+
client, the server re-calculates the MAC using its internal key and
224+
verifies it against the one provided. If the signatures do not match,
225+
the server treats the filehandle as invalid (returning NFS[34]ERR_STALE).
226+
227+
Note that signing filehandles provides integrity and authenticity but
228+
not confidentiality. The contents of the filehandle remain visible to
229+
the client; they simply cannot be forged or modified.
230+
231+
Configuration
232+
~~~~~~~~~~~~~
233+
234+
To enable signed filehandles, the administrator must provide a signing
235+
key to the kernel and enable the "sign_fh" export option.
236+
237+
1. Providing a Key
238+
The signing key is managed via the nfsd netlink interface. This key
239+
is per-network-namespace and must be set before any exports using
240+
"sign_fh" become active.
241+
242+
2. Export Options
243+
The feature is controlled on a per-export basis in /etc/exports:
244+
245+
sign_fh
246+
Enables signing for all filehandles generated under this export.
247+
248+
no_sign_fh
249+
(Default) Disables signing.
250+
251+
Key Management and Rotation
252+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
253+
254+
The security of this mechanism relies entirely on the secrecy of the
255+
signing key.
256+
257+
Initial Setup:
258+
The key should be generated using a high-quality random source and
259+
loaded early in the boot process or during the nfs-server startup
260+
sequence.
261+
262+
Changing Keys:
263+
If a key is changed while clients have active mounts, existing
264+
filehandles held by those clients will become invalid, resulting in
265+
"Stale file handle" errors on the client side.
266+
267+
Safe Rotation:
268+
Currently, there is no mechanism for "graceful" key rotation
269+
(maintaining multiple valid keys). Changing the key is an atomic
270+
operation that immediately invalidates all previous signatures.
271+
272+
Transitioning Exports
273+
~~~~~~~~~~~~~~~~~~~~~
274+
275+
When adding or removing the "sign_fh" flag from an active export, the
276+
following behaviors should be expected:
277+
278+
+-------------------+---------------------------------------------------+
279+
| Change | Result for Existing Clients |
280+
+===================+===================================================+
281+
| Adding sign_fh | Clients holding unsigned filehandles will find |
282+
| | them rejected, as the server now expects a |
283+
| | signature. |
284+
+-------------------+---------------------------------------------------+
285+
| Removing sign_fh | Clients holding signed filehandles will find them |
286+
| | rejected, as the server now expects the |
287+
| | filehandle to end at its traditional boundary |
288+
| | without a MAC. |
289+
+-------------------+---------------------------------------------------+
290+
291+
Because filehandles are often cached persistently by clients, adding or
292+
removing this option should generally be done during a scheduled maintenance
293+
window involving a NFS client unmount/remount.

Documentation/netlink/specs/nfsd.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ attribute-sets:
8181
-
8282
name: min-threads
8383
type: u32
84+
-
85+
name: fh-key
86+
type: binary
87+
checks:
88+
exact-len: 16
8489
-
8590
name: version
8691
attributes:
@@ -163,6 +168,7 @@ operations:
163168
- leasetime
164169
- scope
165170
- min-threads
171+
- fh-key
166172
-
167173
name: threads-get
168174
doc: get the maximum number of running threads

0 commit comments

Comments
 (0)