162306a36Sopenharmony_ci=========================================
262306a36Sopenharmony_cirpcsec_gss support for kernel RPC servers
362306a36Sopenharmony_ci=========================================
462306a36Sopenharmony_ci
562306a36Sopenharmony_ciThis document gives references to the standards and protocols used to
662306a36Sopenharmony_ciimplement RPCGSS authentication in kernel RPC servers such as the NFS
762306a36Sopenharmony_ciserver and the NFS client's NFSv4.0 callback server.  (But note that
862306a36Sopenharmony_ciNFSv4.1 and higher don't require the client to act as a server for the
962306a36Sopenharmony_cipurposes of authentication.)
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ciRPCGSS is specified in a few IETF documents:
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci - RFC2203 v1: https://tools.ietf.org/rfc/rfc2203.txt
1462306a36Sopenharmony_ci - RFC5403 v2: https://tools.ietf.org/rfc/rfc5403.txt
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ciThere is a third version that we don't currently implement:
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci - RFC7861 v3: https://tools.ietf.org/rfc/rfc7861.txt
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ciBackground
2162306a36Sopenharmony_ci==========
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ciThe RPCGSS Authentication method describes a way to perform GSSAPI
2462306a36Sopenharmony_ciAuthentication for NFS.  Although GSSAPI is itself completely mechanism
2562306a36Sopenharmony_ciagnostic, in many cases only the KRB5 mechanism is supported by NFS
2662306a36Sopenharmony_ciimplementations.
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ciThe Linux kernel, at the moment, supports only the KRB5 mechanism, and
2962306a36Sopenharmony_cidepends on GSSAPI extensions that are KRB5 specific.
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ciGSSAPI is a complex library, and implementing it completely in kernel is
3262306a36Sopenharmony_ciunwarranted. However GSSAPI operations are fundamentally separable in 2
3362306a36Sopenharmony_ciparts:
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci- initial context establishment
3662306a36Sopenharmony_ci- integrity/privacy protection (signing and encrypting of individual
3762306a36Sopenharmony_ci  packets)
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ciThe former is more complex and policy-independent, but less
4062306a36Sopenharmony_ciperformance-sensitive.  The latter is simpler and needs to be very fast.
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ciTherefore, we perform per-packet integrity and privacy protection in the
4362306a36Sopenharmony_cikernel, but leave the initial context establishment to userspace.  We
4462306a36Sopenharmony_cineed upcalls to request userspace to perform context establishment.
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ciNFS Server Legacy Upcall Mechanism
4762306a36Sopenharmony_ci==================================
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ciThe classic upcall mechanism uses a custom text based upcall mechanism
5062306a36Sopenharmony_cito talk to a custom daemon called rpc.svcgssd that is provide by the
5162306a36Sopenharmony_cinfs-utils package.
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ciThis upcall mechanism has 2 limitations:
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ciA) It can handle tokens that are no bigger than 2KiB
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ciIn some Kerberos deployment GSSAPI tokens can be quite big, up and
5862306a36Sopenharmony_cibeyond 64KiB in size due to various authorization extensions attacked to
5962306a36Sopenharmony_cithe Kerberos tickets, that needs to be sent through the GSS layer in
6062306a36Sopenharmony_ciorder to perform context establishment.
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ciB) It does not properly handle creds where the user is member of more
6362306a36Sopenharmony_cithan a few thousand groups (the current hard limit in the kernel is 65K
6462306a36Sopenharmony_cigroups) due to limitation on the size of the buffer that can be send
6562306a36Sopenharmony_ciback to the kernel (4KiB).
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ciNFS Server New RPC Upcall Mechanism
6862306a36Sopenharmony_ci===================================
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ciThe newer upcall mechanism uses RPC over a unix socket to a daemon
7162306a36Sopenharmony_cicalled gss-proxy, implemented by a userspace program called Gssproxy.
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ciThe gss_proxy RPC protocol is currently documented `here
7462306a36Sopenharmony_ci<https://fedorahosted.org/gss-proxy/wiki/ProtocolDocumentation>`_.
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ciThis upcall mechanism uses the kernel rpc client and connects to the gssproxy
7762306a36Sopenharmony_ciuserspace program over a regular unix socket. The gssproxy protocol does not
7862306a36Sopenharmony_cisuffer from the size limitations of the legacy protocol.
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ciNegotiating Upcall Mechanisms
8162306a36Sopenharmony_ci=============================
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ciTo provide backward compatibility, the kernel defaults to using the
8462306a36Sopenharmony_cilegacy mechanism.  To switch to the new mechanism, gss-proxy must bind
8562306a36Sopenharmony_cito /var/run/gssproxy.sock and then write "1" to
8662306a36Sopenharmony_ci/proc/net/rpc/use-gss-proxy.  If gss-proxy dies, it must repeat both
8762306a36Sopenharmony_cisteps.
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ciOnce the upcall mechanism is chosen, it cannot be changed.  To prevent
9062306a36Sopenharmony_cilocking into the legacy mechanisms, the above steps must be performed
9162306a36Sopenharmony_cibefore starting nfsd.  Whoever starts nfsd can guarantee this by reading
9262306a36Sopenharmony_cifrom /proc/net/rpc/use-gss-proxy and checking that it contains a
9362306a36Sopenharmony_ci"1"--the read will block until gss-proxy has done its write to the file.
94