(I'm so sorry!) Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

NFS: add a key type that reveals the namespace .nfs keyring serial number

The per-namespace .nfs keyring is linked into no keyring that userspace possesses, so a tool that provisions x509 credentials, or a mount helper that searches for them, cannot reach it. Every keyring operation from userspace takes a serial number, and nothing hands this one out. Register an "nfs_keyring" key type whose request_key handler runs in the caller's context, without an upcall, and instantiates the key with the serial number of the caller's namespace .nfs keyring. Userspace reads the serial number with one request_key() and one keyctl_read(). A keyring search runs before the handler does, and a task keeps its session keyring across setns(). The type carries KEY_TYPE_NET_DOMAIN so a key instantiated in one namespace does not answer a request from another. Its preparse accepts no payload but the caller's own serial number, so a key planted by add_key() cannot misdirect a later request. Register the type after register_pernet_subsys() has installed nfs_net_id, and unregister it before the per-namespace state goes away. unregister_key_type() waits for in-flight request_key() calls to drain, so the handler never runs against a freed struct nfs_net. Signed-off-by: Chuck Lever <cel@kernel.org> Signed-off-by: Anna Schumaker <anna.schumaker@hammerspace.com>


Author Chuck Lever Committer Anna Schumaker Date Commit Parent e27b84e0
+163 -1
3 changed files
+163 -1
3 changed files