Secure user authentication using RPCSEC_GSS [5/7]
Subsystems (4)
PATCH 1/1 Secure user authentication using RPCSEC_GSS [5/7]
Provide basic framework for RPCSEC_GSS authentication for the RPC client.
- Updates the mount_data struct for NFSv2 and v3 to pass down the security
- Will provide secure authentication, and later data encryption on a per-user basis. Later patches will provide actual implementations of Kerberos 5 security. SPKM and LIPKEY are still being planned.
- Security context negotiation and initialization are all assumed to be done in userland. Later patches will provide the actual upcall mechanisms to allow for this.
Cheers,
Trond
fs/Kconfig +4 -0
@@ -1262,6 +1262,10 @@ default m if NFS_FS!=y && NFSD!=y && (NFS_FS=m || NFSD=m) default y if NFS_FS=y || NFSD=y +config SUNRPC_GSS + tristate "Provide RPCSEC_GSS authentication (EXPERIMENTAL)" + depends on SUNRPC && EXPERIMENTAL + config LOCKD tristate default m if NFS_FS!=y && NFSD!=y && (NFS_FS=m || NFSD=m)
fs/nfs/inode.c +8 -1
@@ -367,6 +367,7 @@struct rpc_clnt *clnt =NULL ;struct rpc_timeout timeparms;int tcp, err = -EIO ; +u32 authflavor; server =NFS_SB (sb); sb->s_blocksize_bits =0 ;
@@ -429,8 +430,14 @@printk (KERN_WARNING "NFS: cannot create RPC transport.\n" ); goto out_fail; } + +if (data->flags &NFS_MOUNT_SECFLAVOUR ) + authflavor = data->pseudoflavor; +else + authflavor =RPC_AUTH_UNIX ; + clnt =rpc_create_client (xprt, server->hostname, &nfs_program, - server->rpc_ops->version,RPC_AUTH_UNIX ); + server->rpc_ops->version, authflavor);if (clnt ==NULL ) {printk (KERN_WARNING "NFS: cannot create RPC client.\n" );xprt_destroy (xprt);
include/linux/nfs_mount.h +1 -2
@@ -40,6 +40,7 @@int namlen;/* 2 */ unsigned int bsize;/* 3 */ struct nfs3_fh root;/* 4 */ +int pseudoflavor;/* 4 */ };/* bits in the flags field */
@@ -55,10 +56,8 @@#define NFS_MOUNT_KERBEROS 0x0100/* 3 */ #define NFS_MOUNT_NONLM 0x0200/* 3 */ #define NFS_MOUNT_BROKEN_SUID 0x0400/* 4 */ -#if 0 #define NFS_MOUNT_STRICTLOCK 0x1000/* reserved for NFSv4 */ #define NFS_MOUNT_SECFLAVOUR 0x2000/* reserved */ -#endif #define NFS_MOUNT_FLAGMASK 0xFFFF#endif
include/linux/sunrpc/auth.h +13 -2
@@ -13,12 +13,17 @@#include <linux/config.h> #include <linux/sunrpc/sched.h> +#include <linux/sunrpc/msg_prot.h> +#include <linux/sunrpc/xdr.h> #include <asm/atomic.h> /* size of the nodename buffer */ #define UNX_MAXNODENAME 32 +/* Maximum size (in bytes) of an rpc credential or verifier */ +#define RPC_MAX_AUTH_SIZE (400) +/* Work around the lack of a VFS credential */ struct auth_cred {uid_t uid;
@@ -64,6 +69,10 @@unsigned int au_rslack;/* reply verf size guess */ unsigned int au_flags;/* various flags */ struct rpc_authops * au_ops;/* operations */ +rpc_authflavor_t au_flavor;/* pseudoflavor (note may +* differ from the flavor in +* au_ops->au_flavor in gss +* case) */ /* per-flavor data */ };
@@ -79,10 +88,10 @@#ifdef RPC_DEBUG char * au_name;#endif -struct rpc_auth * (*create)(struct rpc_clnt *); +struct rpc_auth * (*create)(struct rpc_clnt *,rpc_authflavor_t );void (*destroy)(struct rpc_auth *); -struct rpc_cred * (*crcreate)(struct auth_cred *,int ); +struct rpc_cred * (*crcreate)(struct rpc_auth *,struct auth_cred *,int ); };struct rpc_credops {
@@ -100,6 +109,8 @@extern struct rpc_authops authdes_ops;#endif +u32 pseudoflavor_to_flavor (rpc_authflavor_t ); +int rpcauth_register (struct rpc_authops *);int rpcauth_unregister (struct rpc_authops *);struct rpc_auth *rpcauth_create (rpc_authflavor_t ,struct rpc_clnt *);
include/linux/sunrpc/auth_gss.h +97 -0
97 lines not on this page · raw message
include/linux/sunrpc/gss_api.h +157 -0
157 lines not on this page · raw message
include/linux/sunrpc/gss_asn1.h +85 -0
85 lines not on this page · raw message
include/linux/sunrpc/gss_err.h +177 -0
177 lines not on this page · raw message
include/linux/sunrpc/msg_prot.h +15 -1
@@ -20,7 +20,18 @@RPC_AUTH_SHORT =2 ,RPC_AUTH_DES =3 ,RPC_AUTH_KRB =4 , +RPC_AUTH_GSS =6 ,RPC_AUTH_MAXFLAVOR =8 , +/* pseudoflavors: */ +RPC_AUTH_GSS_KRB5 =390003 , +RPC_AUTH_GSS_KRB5I =390004 , +RPC_AUTH_GSS_KRB5P =390005 , +RPC_AUTH_GSS_LKEY =390006 , +RPC_AUTH_GSS_LKEYI =390007 , +RPC_AUTH_GSS_LKEYP =390008 , +RPC_AUTH_GSS_SPKM =390009 , +RPC_AUTH_GSS_SPKMI =390010 , + RPC_AUTH_GSS_SPKMP = 390011, }; enum rpc_msg_type {
@@ -53,7 +64,10 @@RPC_AUTH_REJECTEDCRED =2 ,RPC_AUTH_BADVERF =3 ,RPC_AUTH_REJECTEDVERF =4 , - RPC_AUTH_TOOWEAK = 5 +RPC_AUTH_TOOWEAK =5 , +/* RPCSEC_GSS errors */ +RPCSEC_GSS_CREDPROBLEM =13 , + RPCSEC_GSS_CTXPROBLEM = 14 };#define RPC_PMAP_PROGRAM 100000
include/linux/sunrpc/sched.h +3 -0
@@ -12,6 +12,7 @@#include <linux/timer.h> #include <linux/sunrpc/types.h> #include <linux/wait.h> +#include <linux/sunrpc/xdr.h> /* * Define this if you want to test the fast scheduler for async calls.
@@ -53,6 +54,8 @@__u8 tk_garb_retry, tk_cred_retry, tk_suid_retry; +u32 tk_gss_seqno;/* rpcsec_gss sequence number +used on this request */ /* * timeout_fn to be executed by timer bottom half
include/linux/sunrpc/xdr.h +3 -1
@@ -80,7 +80,9 @@#define rpc_autherr_badverf __constant_htonl(RPC_AUTH_BADVERF)#define rpc_autherr_rejectedverf __constant_htonl(RPC_AUTH_REJECTEDVERF)#define rpc_autherr_tooweak __constant_htonl(RPC_AUTH_TOOWEAK) - +#define rpcsec_gsserr_credproblem __constant_htonl(RPCSEC_GSS_CREDPROBLEM) +#define rpcsec_gsserr_ctxproblem __constant_htonl(RPCSEC_GSS_CTXPROBLEM) +#define rpc_autherr_oldseqnum __constant_htonl(101)/* * Miscellaneous XDR helper functions
net/sunrpc/Makefile +6 -1
@@ -4,7 +4,7 @@ obj-$(CONFIG_SUNRPC) += sunrpc.o -export-objs := sunrpc_syms.o +export-objs := sunrpc_syms.o sunrpcgss_syms.o sunrpc-y := clnt.o xprt.o sched.o \ auth.o auth_null.o auth_unix.o \
@@ -14,4 +14,9 @@ sunrpc-$(CONFIG_PROC_FS) += stats.o sunrpc-$(CONFIG_SYSCTL) += sysctl.o +obj-$(CONFIG_SUNRPC_GSS) += auth_rpcgss.o + +auth_rpcgss-objs := auth_gss.o gss_pseudoflavors.o gss_generic_token.o \ + sunrpcgss_syms.o gss_mech_switch.o gss_delete_sec_context.o + include $(TOPDIR)/Rules.make
net/sunrpc/auth.c +11 -3
@@ -24,6 +24,13 @@ NULL, /* others can be loadable modules */ }; +u32 +pseudoflavor_to_flavor (u32 flavor) { +if (flavor >=RPC_AUTH_MAXFLAVOR ) +return RPC_AUTH_GSS ; +return flavor; +} +int rpcauth_register (struct rpc_authops *ops) {
@@ -51,13 +58,14 @@ }struct rpc_auth * -rpcauth_create (rpc_authflavor_t flavor,struct rpc_clnt *clnt) +rpcauth_create (rpc_authflavor_t pseudoflavor,struct rpc_clnt *clnt) {struct rpc_authops *ops; +u32 flavor =pseudoflavor_to_flavor (pseudoflavor);if (flavor >=RPC_AUTH_MAXFLAVOR || !(ops = auth_flavors[flavor]))return NULL ; - clnt->cl_auth = ops->create (clnt); + clnt->cl_auth = ops->create (clnt, pseudoflavor);return clnt->cl_auth; }
@@ -218,7 +226,7 @@rpcauth_destroy_credlist (&free);if (!cred) { - new = auth->au_ops->crcreate (acred, taskflags); + new = auth->au_ops->crcreate (auth, acred, taskflags);if (new) {#ifdef RPC_DEBUG new->cr_magic =RPCAUTH_CRED_MAGIC ;
net/sunrpc/auth_gss.c +373 -0
373 lines not on this page · raw message
net/sunrpc/auth_null.c +2 -2
@@ -20,7 +20,7 @@static struct rpc_credops null_credops;static struct rpc_auth * -nul_create (struct rpc_clnt *clnt) +nul_create (struct rpc_clnt *clnt,rpc_authflavor_t flavor) {struct rpc_auth *auth;
@@ -48,7 +48,7 @@* Create NULL creds for current process */ static struct rpc_cred * -nul_create_cred (struct auth_cred *acred,int flags) +nul_create_cred (struct rpc_auth *auth,struct auth_cred *acred,int flags) {struct rpc_cred *cred;
net/sunrpc/auth_unix.c +3 -3
@@ -38,7 +38,7 @@static struct rpc_credops unix_credops;static struct rpc_auth * -unx_create (struct rpc_clnt *clnt) +unx_create (struct rpc_clnt *clnt,rpc_authflavor_t flavor) {struct rpc_auth *auth;
@@ -64,7 +64,7 @@ }static struct rpc_cred * -unx_create_cred (struct auth_cred *acred,int flags) +unx_create_cred (struct rpc_auth *auth,struct auth_cred *acred,int flags) {struct unx_cred *cred;int i;
@@ -208,7 +208,7 @@ } size =ntohl (*p++); -if (size >400 ) { +if (size >RPC_MAX_AUTH_SIZE ) {printk ("RPC: giant verf size: %u\n" , size);return NULL ; }
net/sunrpc/clnt.c +3 -2
@@ -34,7 +34,7 @@#include <linux/nfs.h> -#define RPC_SLACK_SPACE 512/* total overkill */ +#define RPC_SLACK_SPACE (1024)/* total overkill */ #ifdef RPC_DEBUG # define RPCDBG_FACILITY RPCDBG_CALL
@@ -548,7 +548,8 @@if (!(p =call_header (task))) {printk (KERN_INFO "RPC: call_header failed, exit EIO\n" );rpc_exit (task, -EIO ); - }else +return ; + }if (encode && (status =encode (req, p, task->tk_msg.rpc_argp)) <0 ) {printk (KERN_WARNING "%s: can't encode arguments: %d\n" , clnt->cl_protname, -status);
net/sunrpc/gss_delete_sec_context.c +66 -0
66 lines not on this page · raw message
net/sunrpc/gss_generic_token.c +269 -0
269 lines not on this page · raw message
net/sunrpc/gss_mech_switch.c +279 -0
279 lines not on this page · raw message
net/sunrpc/gss_pseudoflavors.c +235 -0
235 lines not on this page · raw message
net/sunrpc/sunrpcgss_syms.c +35 -0
@@ -0,0 +1,35 @@ +#define __NO_VERSION__ +#include <linux/config.h> +#include <linux/module.h> + +#include <linux/types.h> +#include <linux/socket.h> +#include <linux/sched.h> +#include <linux/uio.h> +#include <linux/unistd.h> + +#include <linux/sunrpc/auth_gss.h> +#include <linux/sunrpc/gss_asn1.h> + +/* sec_triples: */ +EXPORT_SYMBOL (gss_register_triple); +EXPORT_SYMBOL (gss_unregister_triple); +EXPORT_SYMBOL (gss_cmp_triples); +EXPORT_SYMBOL (gss_pseudoflavor_to_mechOID); +EXPORT_SYMBOL (gss_pseudoflavor_supported); +EXPORT_SYMBOL (gss_pseudoflavor_to_service); + +/* registering gss mechanisms to the mech switching code: */ +EXPORT_SYMBOL (gss_mech_register); +EXPORT_SYMBOL (gss_mech_get); +EXPORT_SYMBOL (gss_mech_get_by_OID); +EXPORT_SYMBOL (gss_mech_put); + +/* generic functionality in gss code: */ +EXPORT_SYMBOL (gss_delete_sec_context_generic); +EXPORT_SYMBOL (g_make_token_header); +EXPORT_SYMBOL (g_verify_token_header); +EXPORT_SYMBOL (g_token_size); + +/* debug */ +EXPORT_SYMBOL (print_hexl);
-------------------------------------------------------
This sf.net email is sponsored by: Influence the future of Java(TM) technology. Join the Java Community Process(SM) (JCP(SM)) program now.
http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0004en
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs