public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Coddington <bcodding@hammerspace.com>
To: Chuck Lever <chuck.lever@oracle.com>,
	Jeff Layton <jlayton@kernel.org>, NeilBrown <neil@brown.name>,
	Trond Myklebust <trondmy@kernel.org>,
	Anna Schumaker <anna@kernel.org>,
	Benjamin Coddington <bcodding@hammerspace.com>,
	Eric Biggers <ebiggers@kernel.org>,
	Rick Macklem <rick.macklem@gmail.com>
Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-crypto@vger.kernel.org
Subject: [PATCH v1 0/4] kNFSD Signed Filehandles
Date: Fri, 16 Jan 2026 09:32:10 -0500	[thread overview]
Message-ID: <cover.1768573690.git.bcodding@hammerspace.com> (raw)

The following series enables the linux NFS server to add a Message
Authentication Code (MAC) to the filehandles it gives to clients.  This
provides additional protection to the exported filesystem against filehandle
guessing attacks.

Filesystems generate their own filehandles through the export_operation
"encode_fh" and a filehandle provides sufficient access to open a file
without needing to perform a lookup.  An NFS client holding a valid
filehandle can remotely open and read the contents of the file referred to
by the filehandle.

In order to acquire a filehandle, you must perform lookup operations on the
parent directory(ies), and the permissions on those directories may
prohibit you from walking into them to find the files within.  This would
normally be considered sufficient protection on a local filesystem to
prohibit users from accessing those files, however when the filesystem is
exported via NFS those files can still be accessed by guessing the correct,
valid filehandles.

Filehandles are easy to guess because they are well-formed.  The
open_by_handle_at(2) man page contains an example C program
(t_name_to_handle_at.c) that can display a filehandle given a path.  Here's
an example filehandle from a fairly modern XFS:

# ./t_name_to_handle_at /exports/foo 
57
12 129    99 00 00 00 00 00 00 00 b4 10 0b 8c

          ^---------  filehandle  ----------^
          ^------- inode -------^ ^-- gen --^

This filehandle consists of a 64-bit inode number and 32-bit generation
number.  Because the handle is well-formed, its easy to fabricate
filehandles that match other files within the same filesystem.  You can
simply insert inode numbers and iterate on the generation number.
Eventually you'll be able to access the file using open_by_handle_at(2).
For a local system, open_by_handle_at(2) requires CAP_DAC_READ_SEARCH, which
protects against guessing attacks by unprivileged users.

In contrast to a local user using open_by_handle(2), the NFS server must
permissively allow remote clients to open by filehandle without being able
to check or trust the remote caller's access. Therefore additional
protection against this attack is needed for NFS case.  We propose to sign
filehandles by appending an 8-byte MAC which is the siphash of the
filehandle from a key set from the nfs-utilities.  NFS server can then
ensure that guessing a valid filehandle+MAC is practically impossible
without knowledge of the MAC's key.  The NFS server performs optional
signing by possessing a key set from userspace and having the "sign_fh"
export option.

Because filehandles are long-lived, and there's no method for expiring them,
the server's key should be set once and not changed.  It also should be
persisted across restarts.  The methods to set the key allow only setting it
once, afterward it cannot be changed.  A separate patchset for nfs-utils
contains the userspace changes required to set the server's key.

I had a previous attempt to solve this problem by encrypting filehandles,
which turned out to be a problematic, poor solution.  The discussion on
that previous attempt is here:
https://lore.kernel.org/linux-nfs/510E10A4-11BE-412D-93AF-C4CC969954E7@hammerspace.com/T/#t

There are some changes from that version:
	- sign filehandles instead of encrypt them (Eric Biggers)
	- fix the NFSEXP_ macros, specifically NFSEXP_ALLFLAGS (NeilBrown)
	- rebase onto cel/nfsd-next (Chuck Lever)
	- condensed/clarified problem explantion (thanks Chuck Lever)
	- add nfsctl file "fh_key" for rpc.nfsd to also set the key

I plan on adding additional work to enable the server to check whether the
8-byte MAC will overflow maximum filehandle length for the protocol at
export time.  There could be some filesystems with 40-byte fileid and
24-byte fsid which would break NFSv3's 64-byte filehandle maximum with an
8-byte MAC appended.  The server should refuse to export those filesystems
when "sign_fh" is requested.

Thanks for any comments and critique.

Benjamin Coddington (4):
  nfsd: Convert export flags to use BIT() macro
  nfsd: Add a key for signing filehandles
  NFSD/export: Add sign_fh export option
  NFSD: Sign filehandles

 Documentation/netlink/specs/nfsd.yaml | 12 ++++
 fs/nfsd/export.c                      |  5 +-
 fs/nfsd/netlink.c                     | 15 +++++
 fs/nfsd/netlink.h                     |  1 +
 fs/nfsd/netns.h                       |  2 +
 fs/nfsd/nfs3xdr.c                     | 20 +++---
 fs/nfsd/nfs4xdr.c                     | 12 ++--
 fs/nfsd/nfsctl.c                      | 87 ++++++++++++++++++++++++++-
 fs/nfsd/nfsfh.c                       | 72 +++++++++++++++++++++-
 fs/nfsd/nfsfh.h                       | 22 +++++++
 fs/nfsd/trace.h                       | 19 ++++++
 include/linux/sunrpc/svc.h            |  1 +
 include/uapi/linux/nfsd/export.h      | 38 ++++++------
 include/uapi/linux/nfsd_netlink.h     |  2 +
 14 files changed, 272 insertions(+), 36 deletions(-)


base-commit: bfd453acb5637b5df881cef4b21803344aa9e7ac
-- 
2.50.1


             reply	other threads:[~2026-01-16 14:32 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-16 14:32 Benjamin Coddington [this message]
2026-01-16 14:32 ` [PATCH v1 1/4] nfsd: Convert export flags to use BIT() macro Benjamin Coddington
2026-01-16 15:31   ` Chuck Lever
2026-01-16 15:35     ` Benjamin Coddington
2026-01-16 15:38       ` Chuck Lever
2026-01-16 15:39         ` Benjamin Coddington
2026-01-16 14:32 ` [PATCH v1 2/4] nfsd: Add a key for signing filehandles Benjamin Coddington
2026-01-16 14:59   ` Jeff Layton
2026-01-16 15:09     ` Chuck Lever
2026-01-16 15:18       ` Benjamin Coddington
2026-01-16 15:25       ` Jeff Layton
2026-01-16 15:45         ` Chuck Lever
2026-01-16 15:52           ` Jeff Layton
2026-01-16 16:17             ` Chuck Lever
2026-01-19 16:15     ` Benjamin Coddington
2026-01-16 16:11   ` Chuck Lever
2026-01-16 16:42     ` Benjamin Coddington
2026-01-16 19:55       ` Chuck Lever
2026-01-16 21:37   ` kernel test robot
2026-01-16 14:32 ` [PATCH v1 3/4] NFSD/export: Add sign_fh export option Benjamin Coddington
2026-01-16 16:26   ` Chuck Lever
2026-01-16 14:32 ` [PATCH v1 4/4] NFSD: Sign filehandles Benjamin Coddington
2026-01-16 17:12   ` Chuck Lever
2026-01-16 18:29     ` Benjamin Coddington
2026-01-16 22:47   ` kernel test robot
2026-01-16 16:56 ` [PATCH v1 0/4] kNFSD Signed Filehandles Chuck Lever
2026-01-16 17:17   ` Benjamin Coddington
2026-01-16 19:43     ` Chuck Lever
2026-01-16 20:03       ` Trond Myklebust
2026-01-16 20:11       ` Benjamin Coddington
2026-01-17  0:54 ` [PATCH v1 4/4] NFSD: Sign filehandles NeilBrown
2026-01-17 12:30   ` Benjamin Coddington
2026-01-17  1:24 ` [PATCH v1 0/4] kNFSD Signed Filehandles NeilBrown
2026-01-17 12:30   ` Benjamin Coddington
2026-01-19  4:24     ` NeilBrown
2026-01-19  9:14 ` Christian Brauner
2026-01-19 21:06   ` NeilBrown
2026-01-19 21:29     ` Jeff Layton
2026-01-19 22:58       ` NeilBrown
2026-01-20  9:23     ` Christian Brauner
2026-01-20  9:46       ` NeilBrown
2026-01-20 10:20         ` Christian Brauner
2026-01-20 10:28           ` NeilBrown
2026-01-20 10:37             ` Christian Brauner
2026-01-20 10:13 ` NeilBrown
2026-01-20 12:56   ` Benjamin Coddington
2026-01-20 10:55 ` Miklos Szeredi
2026-01-20 13:03   ` Benjamin Coddington
2026-01-20 14:44     ` Miklos Szeredi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1768573690.git.bcodding@hammerspace.com \
    --to=bcodding@hammerspace.com \
    --cc=anna@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=ebiggers@kernel.org \
    --cc=jlayton@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=rick.macklem@gmail.com \
    --cc=trondmy@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox