Skip to content

kNFSD Encrypted Filehandles

Benjamin Coddington linux-crypto linux-nfs oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 32 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7nfsd: Convert export flags to use BIT() macrofs/nfsd/nfsctl.c include/uapi/linux/nfsd/export.h+19 -190 replies
2/7nfsd: Add a symmetric-key cipher for encrypted filehandlesDocumentation/netlink/specs/nfsd.yaml fs/nfsd/netlink.c fs/nfsd/netlink.h +4 more+88 -00 replies
3/7nfsd/sunrpc: add per-thread crypto context pointerinclude/linux/sunrpc/svc.h net/sunrpc/svc.c+6 -40 replies
4/7NFSD: Add a per-knfsd reusable encfh_buffs/nfsd/export.c fs/nfsd/localio.c fs/nfsd/lockd.c +7 more+34 -210 replies
5/7NFSD/export: Add encrypt_fh export optionfs/nfsd/export.c include/uapi/linux/nfsd/export.h+4 -30 replies
6/7NFSD: Add filehandle crypto functions and helpersfs/nfsd/nfsfh.c fs/nfsd/nfsfh.h+178 -04 replies
7/7NFSD: Enable filehandle encryptionfs/nfsd/nfs3xdr.c fs/nfsd/nfs4xdr.c fs/nfsd/nfsfh.c +1 more+28 -90 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH v1 0/7] kNFSD Encrypted Filehandles

In order to harden kNFSD against various filehandle manipulation techniques the following patches implement a method of reversibly encrypting filehandle contents.

Using the kernel's skcipher AES-CBC, filehandles are encrypted by firstly hashing the fileid using the fsid as a salt, then using the hashed fileid as the first block to finally hash the fsid.

The first attempts at this used stack-allocated buffers, but I ran into many memory alignment problems on my arm64 machine that sent me back to using GFP_KERNEL allocations (here's to you /include/linux/scatterlist.h:210). In order to avoid constant allocation/freeing, the buffers are allocated once for every knfsd thread. If anyone has suggestions for reducing the number of buffers required and their memcpy() operations, I am all ears.

Currently the code overloads filehandle's auth_type byte. This seems appropriate for this purpose, but this implementation does not actually reject unencrypted filehandles on an export that is giving out encrypted ones. I expect we'll want to tighten this up in a future version.

Comments and critique welcome.

Benjamin Coddington (7):
nfsd: Convert export flags to use BIT() macro
nfsd: Add a symmetric-key cipher for encrypted filehandles nfsd/sunrpc: add per-thread crypto context pointer
NFSD: Add a per-knfsd reusable encfh_buf NFSD/export: Add encrypt_fh export option
NFSD: Add filehandle crypto functions and helpers
NFSD: Enable filehandle encryption

 Documentation/netlink/specs/nfsd.yaml |  12 ++
 fs/nfsd/export.c                      |   7 +-
 fs/nfsd/localio.c                     |   2 +-
 fs/nfsd/lockd.c                       |   2 +-
 fs/nfsd/netlink.c                     |  15 +++
 fs/nfsd/netlink.h                     |   1 +
 fs/nfsd/netns.h                       |   1 +
 fs/nfsd/nfs3proc.c                    |  10 +-
 fs/nfsd/nfs3xdr.c                     |  14 +-
 fs/nfsd/nfs4proc.c                    |  10 +-
 fs/nfsd/nfs4xdr.c                     |  14 +-
 fs/nfsd/nfsctl.c                      |  40 +++++-
 fs/nfsd/nfsfh.c                       | 179 +++++++++++++++++++++++++-
 fs/nfsd/nfsfh.h                       |  26 +++-
 fs/nfsd/nfsproc.c                     |   8 +-
 fs/nfsd/trace.h                       |  19 +++
 include/linux/sunrpc/svc.h            |  12 +-
 include/uapi/linux/nfsd/export.h      |  36 +++---
 include/uapi/linux/nfsd_netlink.h     |   2 +
 net/sunrpc/svc.c                      |   1 +
 20 files changed, 356 insertions(+), 55 deletions(-)
Signature · 1 line
2.50.1