Skip to contentSkip to conversation

Dynamically load GSS pseudoflavors by OID

PATCH Superseded Chuck Lever 2 participants 13 messages Jan 30, 2013 – Jan 31, 2013

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Dynamically load GSS pseudoflavors by OID

Hi-

Currently the RPC client is able to dynamically load GSS security flavor support by name or pseudoflavor number, but not by [OID, qop, service] tuple. Such a tuple can be provided by an NFSv4 server in a SECINFO reply, for example.

This means that if an NFSv4 server lists a tuple for, say, krb5p, in a SECINFO reply, our client will pretend it doesn't support krb5p if the rpc-auth-gss-krb5 module is available on the system but does not happen to be loaded at that moment.

This series implements support for loading the correct GSS pseudoflavor module before searching by GSS tuple. This version needs testing, which I'll get to first thing tomorrow, but I've already tested earlier versions of these patches with success.

Thanks to reviewers of v1. Changes since v1:

  1.  Simplify function and method names
  2.  Add an equivalent server-side interface
  3.  Improve automatic loading of the auth_rpcgss module
  4.  nfs_find_best_sec() also verifies non-GSS flavors against
      RPC client's list of registered flavors
  5.  Search for (qop, svc) pair without adding a new function
  6.  Clean up GSS mech switch
  7.  Remove dprintk() calls
  8.  Improve patch descriptions
  9.  Numerous small improvements and fixes

---

Chuck Lever (9):
SUNRPC: Remove EXPORT_SYMBOL_GPL() from GSS mech switch
SUNRPC: Make gss_mech_get() static
SUNRPC: Refactor nfsd4_do_encode_secinfo()
SUNRPC: Consider qop when looking up pseudoflavors
SUNRPC: Load GSS kernel module by OID
SUNRPC: Introduce rpcauth_get_pseudoflavor()
SUNRPC: Define rpcsec_gss_info structure
NFS: Remove unneeded forward declaration
SUNRPC: Missing module alias for auth_rpcgss.ko

 fs/nfs/nfs4namespace.c                |   43 +++++++-----
 fs/nfs/nfs4xdr.c                      |   20 +++---
 fs/nfsd/nfs4xdr.c                     |   43 ++++++------
 include/linux/nfs_xdr.h               |   24 +------
 include/linux/sunrpc/auth.h           |    6 ++
 include/linux/sunrpc/gss_api.h        |   29 ++++++--
 net/sunrpc/Kconfig                    |    1 
 net/sunrpc/auth.c                     |   68 +++++++++++++++++++
 net/sunrpc/auth_gss/auth_gss.c        |    3 +
 net/sunrpc/auth_gss/gss_krb5_mech.c   |    6 +-
 net/sunrpc/auth_gss/gss_mech_switch.c |  117 +++++++++++++++++++++++++--------
 net/sunrpc/auth_gss/svcauth_gss.c     |    4 +
 12 files changed, 257 insertions(+), 107 deletions(-)
Signature · 1 line
Chuck Lever
#1 lore raw

PATCH v2 1/9 SUNRPC: Missing module alias for auth_rpcgss.ko

Commit f344f6df "SUNRPC: Auto-load RPC authentication kernel modules", Mon Mar 20 13:44:08 2006, adds a request_module() call in rpcauth_create() to auto-load RPC security modules when a ULP tries to create a credential of that flavor.

In rpcauth_create(), the name of the module to load is built like this:

	request_module("rpc-auth-%u", flavor);

This means that for, say, RPC_AUTH_GSS, request_module() is looking for a module or alias called "rpc-auth-6". I don't see such an alias -- the GSS module is named "auth_rpcgss".

---

 net/sunrpc/auth_gss/auth_gss.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
net/sunrpc/auth_gss/auth_gss.c +1 -0
index 6e5c824..4db065d 100644
@@ -1721,6 +1721,7 @@ static void __exit exit_rpcsec_gss(void)
 	rcu_barrier(); /* Wait for completion of call_rcu()'s */
 }
 
+MODULE_ALIAS("rpc-auth-6");
 MODULE_LICENSE("GPL");
 module_param_named(expired_cred_retry_delay,
 		   gss_expired_cred_retry_delay,
#2 lore raw

PATCH v2 2/9 NFS: Remove unneeded forward declaration

In reply to Chuck Lever

I've built with NFSv4 enabled and disabled. This forward declaration does not seem to be required.

---

 include/linux/nfs_xdr.h |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
include/linux/nfs_xdr.h +0 -3
index 29adb12..467167402 100644
@@ -14,9 +14,6 @@
 #define NFS_DEF_FILE_IO_SIZE	(4096U)
 #define NFS_MIN_FILE_IO_SIZE	(1024U)
 
-/* Forward declaration for NFS v3 */
-struct nfs4_secinfo_flavors;
-
 struct nfs4_string {
 	unsigned int len;
 	char *data;
#3 lore raw

PATCH v2 3/9 SUNRPC: Define rpcsec_gss_info structure

In reply to Chuck Lever

The NFSv4 SECINFO procedure returns a list of security flavors. Any GSS flavor also has a GSS tuple containing an OID, a quality-of- protection value, and a service value, which specifies a particular GSS pseudoflavor.

For simplicity and efficiency, I'd like to return each GSS tuple from the NFSv4 SECINFO XDR decoder and pass it straight into the RPC client.

Define a data structure that is visible to both the NFS client and the RPC client.

---

 fs/nfs/nfs4namespace.c              |   12 ++++++------
 fs/nfs/nfs4xdr.c                    |   20 +++++++++++---------
 include/linux/nfs_xdr.h             |   21 +++++----------------
 include/linux/sunrpc/gss_api.h      |   14 ++++++++++++--
 net/sunrpc/auth_gss/gss_krb5_mech.c |    2 +-
 5 files changed, 35 insertions(+), 34 deletions(-)
fs/nfs/nfs4namespace.c +6 -6
index 1e09eb7..f97b0a8 100644
@@ -137,23 +137,23 @@ rpc_authflavor_t nfs_find_best_sec(struct nfs4_secinfo_flavors *flavors)
 {
 	struct gss_api_mech *mech;
 	struct xdr_netobj oid;
-	int i;
+	unsigned int i;
 	rpc_authflavor_t pseudoflavor = RPC_AUTH_UNIX;
 
 	for (i = 0; i < flavors->num_flavors; i++) {
-		struct nfs4_secinfo_flavor *flavor;
-		flavor = &flavors->flavors[i];
+		struct nfs4_secinfo4 *flavor = &flavors->flavors[i];
 
 		if (flavor->flavor == RPC_AUTH_NULL || flavor->flavor == RPC_AUTH_UNIX) {
 			pseudoflavor = flavor->flavor;
 			break;
 		} else if (flavor->flavor == RPC_AUTH_GSS) {
-			oid.len  = flavor->gss.sec_oid4.len;
-			oid.data = flavor->gss.sec_oid4.data;
+			oid.len  = flavor->flavor_info.oid.len;
+			oid.data = flavor->flavor_info.oid.data;
 			mech = gss_mech_get_by_OID(&oid);
 			if (!mech)
 				continue;
-			pseudoflavor = gss_svc_to_pseudoflavor(mech, flavor->gss.service);
+			pseudoflavor = gss_svc_to_pseudoflavor(mech,
+						flavor->flavor_info.service);
 			gss_mech_put(mech);
 			break;
 		}
fs/nfs/nfs4xdr.c +11 -9
index 26b1439..c445b8c 100644
@@ -5209,27 +5209,29 @@ static int decode_delegreturn(struct xdr_stream *xdr)
 	return decode_op_hdr(xdr, OP_DELEGRETURN);
 }
 
-static int decode_secinfo_gss(struct xdr_stream *xdr, struct nfs4_secinfo_flavor *flavor)
+static int decode_secinfo_gss(struct xdr_stream *xdr, struct nfs4_secinfo4 *flavor)
 {
+	u32 oid_len;
 	__be32 *p;
 
 	p = xdr_inline_decode(xdr, 4);
 	if (unlikely(!p))
 		goto out_overflow;
-	flavor->gss.sec_oid4.len = be32_to_cpup(p);
-	if (flavor->gss.sec_oid4.len > GSS_OID_MAX_LEN)
+	oid_len = be32_to_cpup(p);
+	if (oid_len > GSS_OID_MAX_LEN)
 		goto out_err;
 
-	p = xdr_inline_decode(xdr, flavor->gss.sec_oid4.len);
+	p = xdr_inline_decode(xdr, oid_len);
 	if (unlikely(!p))
 		goto out_overflow;
-	memcpy(flavor->gss.sec_oid4.data, p, flavor->gss.sec_oid4.len);
+	memcpy(flavor->flavor_info.oid.data, p, oid_len);
+	flavor->flavor_info.oid.len = oid_len;
 
 	p = xdr_inline_decode(xdr, 8);
 	if (unlikely(!p))
 		goto out_overflow;
-	flavor->gss.qop4 = be32_to_cpup(p++);
-	flavor->gss.service = be32_to_cpup(p);
+	flavor->flavor_info.qop = be32_to_cpup(p++);
+	flavor->flavor_info.service = be32_to_cpup(p);
 
 	return 0;
 
@@ -5242,10 +5244,10 @@ out_err:
 
 static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
 {
-	struct nfs4_secinfo_flavor *sec_flavor;
+	struct nfs4_secinfo4 *sec_flavor;
+	unsigned int i, num_flavors;
 	int status;
 	__be32 *p;
-	int i, num_flavors;
 
 	p = xdr_inline_decode(xdr, 4);
 	if (unlikely(!p))
include/linux/nfs_xdr.h +5 -16
index 467167402..92a6e7c 100644
@@ -1046,25 +1046,14 @@ struct nfs4_fs_locations_res {
 	struct nfs4_fs_locations       *fs_locations;
 };
 
-struct nfs4_secinfo_oid {
-	unsigned int len;
-	char data[GSS_OID_MAX_LEN];
-};
-
-struct nfs4_secinfo_gss {
-	struct nfs4_secinfo_oid sec_oid4;
-	unsigned int qop4;
-	unsigned int service;
-};
-
-struct nfs4_secinfo_flavor {
-	unsigned int 		flavor;
-	struct nfs4_secinfo_gss	gss;
+struct nfs4_secinfo4 {
+	u32			flavor;
+	struct rpcsec_gss_info	flavor_info;
 };
 
 struct nfs4_secinfo_flavors {
-	unsigned int num_flavors;
-	struct nfs4_secinfo_flavor flavors[0];
+	unsigned int		num_flavors;
+	struct nfs4_secinfo4	flavors[0];
 };
 
 struct nfs4_secinfo_arg {
include/linux/sunrpc/gss_api.h +12 -2
index a19e254..98950e5 100644
@@ -25,10 +25,20 @@ struct gss_ctx {
 
 #define GSS_C_NO_BUFFER		((struct xdr_netobj) 0)
 #define GSS_C_NO_CONTEXT	((struct gss_ctx *) 0)
-#define GSS_C_NULL_OID		((struct xdr_netobj) 0)
 
 /*XXX  arbitrary length - is this set somewhere? */
 #define GSS_OID_MAX_LEN 32
+struct rpcsec_gss_oid {
+	unsigned int	len;
+	u8		data[GSS_OID_MAX_LEN];
+};
+
+/* From RFC 3530 */
+struct rpcsec_gss_info {
+	struct rpcsec_gss_oid	oid;
+	u32			qop;
+	u32			service;
+};
 
 /* gss-api prototypes; note that these are somewhat simplified versions of
  * the prototypes specified in RFC 2744. */
@@ -76,7 +86,7 @@ struct pf_desc {
 struct gss_api_mech {
 	struct list_head	gm_list;
 	struct module		*gm_owner;
-	struct xdr_netobj	gm_oid;
+	struct rpcsec_gss_oid	gm_oid;
 	char			*gm_name;
 	const struct gss_api_ops *gm_ops;
 	/* pseudoflavors supported by this mechanism: */
net/sunrpc/auth_gss/gss_krb5_mech.c +1 -1
index d3611f1..61d36ce 100644
@@ -754,7 +754,7 @@ MODULE_ALIAS("rpc-auth-gss-390005");
 static struct gss_api_mech gss_kerberos_mech = {
 	.gm_name	= "krb5",
 	.gm_owner	= THIS_MODULE,
-	.gm_oid		= {9, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02"},
+	.gm_oid		= { 9, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02" },
 	.gm_ops		= &gss_kerberos_ops,
 	.gm_pf_num	= ARRAY_SIZE(gss_kerberos_pfs),
 	.gm_pfs		= gss_kerberos_pfs,
#4 lore raw

PATCH v2 4/9 SUNRPC: Introduce rpcauth_get_pseudoflavor()

In reply to Chuck Lever

nfs_find_best_sec() now verifies all flavors requested in a SECINFO reply against those that have been explicitly registered via rpcauth_register(). For GSS pseudoflavors, these are verified against the list of GSS pseudoflavors registered via gss_mech_register().

Note that the current version of nfs_find_best_sec() can return RPC_AUTH_MAXFLAVOR if the server returns a recognized OID but an unsupported "service" value. The new code returns RPC_AUTH_UNIX in this case.

---

 fs/nfs/nfs4namespace.c                |   41 +++++++++++++++++++--------------
 include/linux/sunrpc/auth.h           |    4 +++
 include/linux/sunrpc/gss_api.h        |    5 ++--
 net/sunrpc/auth.c                     |   34 +++++++++++++++++++++++++++
 net/sunrpc/auth_gss/auth_gss.c        |    1 +
 net/sunrpc/auth_gss/gss_mech_switch.c |   28 +++++++++++++++++++----
 6 files changed, 87 insertions(+), 26 deletions(-)
fs/nfs/nfs4namespace.c +23 -18
index f97b0a8..2187ae7 100644
@@ -133,33 +133,38 @@ static size_t nfs_parse_server_name(char *string, size_t len,
 	return ret;
 }
 
+/**
+ * nfs_find_best_sec - Find a security mechanism supported locally
+ * @flavors: List of security tuples returned by SECINFO procedure
+ *
+ * Return the pseudoflavor of the first security mechanism in
+ * "flavors" that is locally supported.  Return RPC_AUTH_UNIX if
+ * no matching flavor is found in the array.  The "flavors" array
+ * is searched in the order returned from the server, per RFC 3530
+ * recommendation.
+ */
 rpc_authflavor_t nfs_find_best_sec(struct nfs4_secinfo_flavors *flavors)
 {
-	struct gss_api_mech *mech;
-	struct xdr_netobj oid;
+	rpc_authflavor_t pseudoflavor;
+	struct nfs4_secinfo4 *secinfo;
 	unsigned int i;
-	rpc_authflavor_t pseudoflavor = RPC_AUTH_UNIX;
 
 	for (i = 0; i < flavors->num_flavors; i++) {
-		struct nfs4_secinfo4 *flavor = &flavors->flavors[i];
-
-		if (flavor->flavor == RPC_AUTH_NULL || flavor->flavor == RPC_AUTH_UNIX) {
-			pseudoflavor = flavor->flavor;
-			break;
-		} else if (flavor->flavor == RPC_AUTH_GSS) {
-			oid.len  = flavor->flavor_info.oid.len;
-			oid.data = flavor->flavor_info.oid.data;
-			mech = gss_mech_get_by_OID(&oid);
-			if (!mech)
-				continue;
-			pseudoflavor = gss_svc_to_pseudoflavor(mech,
-						flavor->flavor_info.service);
-			gss_mech_put(mech);
+		secinfo = &flavors->flavors[i];
+
+		switch (secinfo->flavor) {
+		case RPC_AUTH_NULL:
+		case RPC_AUTH_UNIX:
+		case RPC_AUTH_GSS:
+			pseudoflavor = rpcauth_get_pseudoflavor(secinfo->flavor,
+							&secinfo->flavor_info);
+			if (pseudoflavor != RPC_AUTH_MAXFLAVOR)
+				return pseudoflavor;
 			break;
 		}
 	}
 
-	return pseudoflavor;
+	return RPC_AUTH_UNIX;
 }
 
 static rpc_authflavor_t nfs4_negotiate_security(struct inode *inode, struct qstr *name)
include/linux/sunrpc/auth.h +4 -0
index f25ba92..476e97c 100644
@@ -21,6 +21,8 @@
 /* size of the nodename buffer */
 #define UNX_MAXNODENAME	32
 
+struct rpcsec_gss_info;
+
 /* Work around the lack of a VFS credential */
 struct auth_cred {
 	uid_t	uid;
@@ -102,6 +104,7 @@ struct rpc_authops {
 	int			(*pipes_create)(struct rpc_auth *);
 	void			(*pipes_destroy)(struct rpc_auth *);
 	int			(*list_pseudoflavors)(rpc_authflavor_t *, int);
+	rpc_authflavor_t	(*info2flavor)(struct rpcsec_gss_info *);
 };
 
 struct rpc_credops {
@@ -136,6 +139,7 @@ int			rpcauth_register(const struct rpc_authops *);
 int			rpcauth_unregister(const struct rpc_authops *);
 struct rpc_auth *	rpcauth_create(rpc_authflavor_t, struct rpc_clnt *);
 void			rpcauth_release(struct rpc_auth *);
+rpc_authflavor_t	rpcauth_get_pseudoflavor(rpc_authflavor_t, struct rpcsec_gss_info *);
 int			rpcauth_list_flavors(rpc_authflavor_t *, int);
 struct rpc_cred *	rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int);
 void			rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *);
include/linux/sunrpc/gss_api.h +2 -3
index 98950e5..aba7687 100644
@@ -127,9 +127,8 @@ struct gss_api_ops {
 int gss_mech_register(struct gss_api_mech *);
 void gss_mech_unregister(struct gss_api_mech *);
 
-/* returns a mechanism descriptor given an OID, and increments the mechanism's
- * reference count. */
-struct gss_api_mech * gss_mech_get_by_OID(struct xdr_netobj *);
+/* Given a GSS security tuple, look up a pseudoflavor */
+rpc_authflavor_t gss_mech_info2flavor(struct rpcsec_gss_info *);
 
 /* Returns a reference to a mechanism, given a name like "krb5" etc. */
 struct gss_api_mech *gss_mech_get_by_name(const char *);
net/sunrpc/auth.c +34 -0
index b5c067b..ec18827 100644
@@ -124,6 +124,40 @@ rpcauth_unregister(const struct rpc_authops *ops)
 EXPORT_SYMBOL_GPL(rpcauth_unregister);
 
 /**
+ * rpcauth_get_pseudoflavor - check if security flavor is supported
+ * @flavor: a security flavor
+ * @info: a GSS mech OID, quality of protection, and service value
+ *
+ * Verifies that an appropriate kernel module is available or already loaded.
+ * Returns an equivalent pseudoflavor, or RPC_AUTH_MAXFLAVOR if "flavor" is
+ * not supported locally.
+ */
+rpc_authflavor_t
+rpcauth_get_pseudoflavor(rpc_authflavor_t flavor, struct rpcsec_gss_info *info)
+{
+	const struct rpc_authops *ops;
+	rpc_authflavor_t pseudoflavor;
+
+	if ((ops = auth_flavors[flavor]) == NULL)
+		request_module("rpc-auth-%u", flavor);
+	spin_lock(&rpc_authflavor_lock);
+	ops = auth_flavors[flavor];
+	if (ops == NULL || !try_module_get(ops->owner)) {
+		spin_unlock(&rpc_authflavor_lock);
+		return RPC_AUTH_MAXFLAVOR;
+	}
+	spin_unlock(&rpc_authflavor_lock);
+
+	pseudoflavor = flavor;
+	if (ops->info2flavor != NULL)
+		pseudoflavor = ops->info2flavor(info);
+
+	module_put(ops->owner);
+	return pseudoflavor;
+}
+EXPORT_SYMBOL_GPL(rpcauth_get_pseudoflavor);
+
+/**
  * rpcauth_list_flavors - discover registered flavors and pseudoflavors
  * @array: array to fill in
  * @size: size of "array"
net/sunrpc/auth_gss/auth_gss.c +1 -0
index 4db065d..4522297 100644
@@ -1629,6 +1629,7 @@ static const struct rpc_authops authgss_ops = {
 	.pipes_create	= gss_pipes_dentries_create,
 	.pipes_destroy	= gss_pipes_dentries_destroy,
 	.list_pseudoflavors = gss_mech_list_pseudoflavors,
+	.info2flavor	= gss_mech_info2flavor,
 };
 
 static const struct rpc_credops gss_credops = {
net/sunrpc/auth_gss/gss_mech_switch.c +23 -5
index b174fcd..b09f25b 100644
@@ -171,8 +171,7 @@ struct gss_api_mech * gss_mech_get_by_name(const char *name)
 }
 EXPORT_SYMBOL_GPL(gss_mech_get_by_name);
 
-struct gss_api_mech *
-gss_mech_get_by_OID(struct xdr_netobj *obj)
+static struct gss_api_mech *gss_mech_get_by_OID(struct rpcsec_gss_oid *obj)
 {
 	struct gss_api_mech	*pos, *gm = NULL;
 
@@ -188,11 +187,8 @@ gss_mech_get_by_OID(struct xdr_netobj *obj)
 	}
 	spin_unlock(&registered_mechs_lock);
 	return gm;
-
 }
 
-EXPORT_SYMBOL_GPL(gss_mech_get_by_OID);
-
 static inline int
 mech_supports_pseudoflavor(struct gss_api_mech *gm, u32 pseudoflavor)
 {
@@ -282,6 +278,28 @@ gss_svc_to_pseudoflavor(struct gss_api_mech *gm, u32 service)
 }
 EXPORT_SYMBOL_GPL(gss_svc_to_pseudoflavor);
 
+/**
+ * gss_mech_info2flavor - look up a pseudoflavor given a GSS tuple
+ * @info: a GSS mech OID, quality of protection, and service value
+ *
+ * Returns a matching pseudoflavor, or RPC_AUTH_MAXFLAVOR if the tuple is
+ * not supported.
+ */
+rpc_authflavor_t gss_mech_info2flavor(struct rpcsec_gss_info *info)
+{
+	rpc_authflavor_t pseudoflavor;
+	struct gss_api_mech *gm;
+
+	gm = gss_mech_get_by_OID(&info->oid);
+	if (gm == NULL)
+		return RPC_AUTH_MAXFLAVOR;
+
+	pseudoflavor = gss_svc_to_pseudoflavor(gm, info->service);
+
+	gss_mech_put(gm);
+	return pseudoflavor;
+}
+
 u32
 gss_pseudoflavor_to_service(struct gss_api_mech *gm, u32 pseudoflavor)
 {
#5 lore raw

PATCH v2 5/9 SUNRPC: Load GSS kernel module by OID

In reply to Chuck Lever

The current GSS mech switch can find and load GSS pseudoflavor modules by name ("krb5") or pseudoflavor number ("390003"), but cannot find GSS modules by GSS tuple:

[ "1.2.840.113554.1.2.2", GSS_C_QOP_DEFAULT, RPC_GSS_SVC_NONE ]

This is important when dealing with a SECINFO request. A SECINFO reply contains a list of flavors the server supports for the requested export, but GSS flavors also have a GSS tuple that maps to a pseudoflavor (like 390003 for krb5).

If the GSS module that supports the OID in the tuple is not loaded, our client is not able to load that module dynamically to support that pseudoflavor.

Add a way for the GSS mech switch to load GSS pseudoflavor support by OID before searching for the pseudoflavor that matches the OID and service.

---

 net/sunrpc/Kconfig                    |    1 +
 net/sunrpc/auth_gss/gss_krb5_mech.c   |    1 +
 net/sunrpc/auth_gss/gss_mech_switch.c |    7 +++++++
 3 files changed, 9 insertions(+), 0 deletions(-)
net/sunrpc/Kconfig +1 -0
index 03d03e3..f97f555 100644
@@ -3,6 +3,7 @@ config SUNRPC
 
 config SUNRPC_GSS
 	tristate
+	select OID_REGISTRY
 
 config SUNRPC_BACKCHANNEL
 	bool
net/sunrpc/auth_gss/gss_krb5_mech.c +1 -0
index 61d36ce..b822ec5 100644
@@ -750,6 +750,7 @@ MODULE_ALIAS("rpc-auth-gss-krb5p");
 MODULE_ALIAS("rpc-auth-gss-390003");
 MODULE_ALIAS("rpc-auth-gss-390004");
 MODULE_ALIAS("rpc-auth-gss-390005");
+MODULE_ALIAS("rpc-auth-gss-1.2.840.113554.1.2.2");
 
 static struct gss_api_mech gss_kerberos_mech = {
 	.gm_name	= "krb5",
net/sunrpc/auth_gss/gss_mech_switch.c +7 -0
index b09f25b..8d03d32 100644
@@ -36,6 +36,7 @@
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/oid_registry.h>
 #include <linux/sunrpc/msg_prot.h>
 #include <linux/sunrpc/gss_asn1.h>
 #include <linux/sunrpc/auth_gss.h>
@@ -174,6 +175,12 @@ EXPORT_SYMBOL_GPL(gss_mech_get_by_name);
 static struct gss_api_mech *gss_mech_get_by_OID(struct rpcsec_gss_oid *obj)
 {
 	struct gss_api_mech	*pos, *gm = NULL;
+	char buf[32];
+
+	if (sprint_oid(obj->data, obj->len, buf, sizeof(buf)) < 0)
+		return NULL;
+	dprintk("RPC:       %s(%s)\n", __func__, buf);
+	request_module("rpc-auth-gss-%s", buf);
 
 	spin_lock(&registered_mechs_lock);
 	list_for_each_entry(pos, &registered_mechs, gm_list) {
#6 lore raw

PATCH v2 6/9 SUNRPC: Consider qop when looking up pseudoflavors

In reply to Chuck Lever

The NFSv4 SECINFO operation returns a list of security flavors that the server supports for a particular share. An NFSv4 client is supposed to pick a pseudoflavor it supports that corresponds to one of the flavors returned by the server.

GSS flavors in this list have a GSS tuple that identify a specific GSS pseudoflavor.

Currently our client ignores the GSS tuple's "qop" value. A matching pseudoflavor is chosen based only on the OID and service value.

So far this omission has not had much effect on Linux. The NFSv4 protocol currently supports only one qop value: zero, or GSS_C_QOP_DEFAULT.

However, if an NFSv4 server happens to return something other than zero in the qop field, our client won't notice. This could cause the client to behave in incorrect ways that could have security implications.

---

 include/linux/sunrpc/gss_api.h        |    4 +++-
 net/sunrpc/auth_gss/gss_krb5_mech.c   |    3 +++
 net/sunrpc/auth_gss/gss_mech_switch.c |   19 +++++++++++++------
 net/sunrpc/auth_gss/svcauth_gss.c     |    4 +++-
 4 files changed, 22 insertions(+), 8 deletions(-)
include/linux/sunrpc/gss_api.h +3 -1
index aba7687..e8299b2 100644
@@ -25,6 +25,7 @@ struct gss_ctx {
 
 #define GSS_C_NO_BUFFER		((struct xdr_netobj) 0)
 #define GSS_C_NO_CONTEXT	((struct gss_ctx *) 0)
+#define GSS_C_QOP_DEFAULT	(0)
 
 /*XXX  arbitrary length - is this set somewhere? */
 #define GSS_OID_MAX_LEN 32
@@ -68,12 +69,13 @@ u32 gss_unwrap(
 u32 gss_delete_sec_context(
 		struct gss_ctx		**ctx_id);
 
-u32 gss_svc_to_pseudoflavor(struct gss_api_mech *, u32 service);
+rpc_authflavor_t gss_svc_to_pseudoflavor(struct gss_api_mech *, u32 qop, u32 service);
 u32 gss_pseudoflavor_to_service(struct gss_api_mech *, u32 pseudoflavor);
 char *gss_service_to_auth_domain_name(struct gss_api_mech *, u32 service);
 
 struct pf_desc {
 	u32	pseudoflavor;
+	u32	qop;
 	u32	service;
 	char	*name;
 	char	*auth_domain_name;
net/sunrpc/auth_gss/gss_krb5_mech.c +3 -0
index b822ec5..33255ff 100644
@@ -729,16 +729,19 @@ static const struct gss_api_ops gss_kerberos_ops = {
 static struct pf_desc gss_kerberos_pfs[] = {
 	[0] = {
 		.pseudoflavor = RPC_AUTH_GSS_KRB5,
+		.qop = GSS_C_QOP_DEFAULT,
 		.service = RPC_GSS_SVC_NONE,
 		.name = "krb5",
 	},
 	[1] = {
 		.pseudoflavor = RPC_AUTH_GSS_KRB5I,
+		.qop = GSS_C_QOP_DEFAULT,
 		.service = RPC_GSS_SVC_INTEGRITY,
 		.name = "krb5i",
 	},
 	[2] = {
 		.pseudoflavor = RPC_AUTH_GSS_KRB5P,
+		.qop = GSS_C_QOP_DEFAULT,
 		.service = RPC_GSS_SVC_PRIVACY,
 		.name = "krb5p",
 	},
net/sunrpc/auth_gss/gss_mech_switch.c +13 -6
index 8d03d32..c8da89e 100644
@@ -271,19 +271,26 @@ int gss_mech_list_pseudoflavors(rpc_authflavor_t *array_ptr, int size)
 	return i;
 }
 
-u32
-gss_svc_to_pseudoflavor(struct gss_api_mech *gm, u32 service)
+/**
+ * gss_svc_to_pseudoflavor - map a GSS service number to a pseudoflavor
+ * @gm: GSS mechanism handle
+ * @qop: GSS quality-of-protection value
+ * @service: GSS service value
+ *
+ * Returns a matching security flavor, or RPC_AUTH_MAXFLAVOR if none is found.
+ */
+rpc_authflavor_t gss_svc_to_pseudoflavor(struct gss_api_mech *gm, u32 qop, u32 service)
 {
 	int i;
 
 	for (i = 0; i < gm->gm_pf_num; i++) {
-		if (gm->gm_pfs[i].service == service) {
+		if (gm->gm_pfs[i].qop == qop &&
+		    gm->gm_pfs[i].service == service) {
 			return gm->gm_pfs[i].pseudoflavor;
 		}
 	}
-	return RPC_AUTH_MAXFLAVOR; /* illegal value */
+	return RPC_AUTH_MAXFLAVOR;
 }
-EXPORT_SYMBOL_GPL(gss_svc_to_pseudoflavor);
 
 /**
  * gss_mech_info2flavor - look up a pseudoflavor given a GSS tuple
@@ -301,7 +308,7 @@ rpc_authflavor_t gss_mech_info2flavor(struct rpcsec_gss_info *info)
 	if (gm == NULL)
 		return RPC_AUTH_MAXFLAVOR;
 
-	pseudoflavor = gss_svc_to_pseudoflavor(gm, info->service);
+	pseudoflavor = gss_svc_to_pseudoflavor(gm, info->qop, info->service);
 
 	gss_mech_put(gm);
 	return pseudoflavor;
net/sunrpc/auth_gss/svcauth_gss.c +3 -1
index 73e9573..2c0481d 100644
@@ -1208,7 +1208,9 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)
 		svcdata->rsci = rsci;
 		cache_get(&rsci->h);
 		rqstp->rq_cred.cr_flavor = gss_svc_to_pseudoflavor(
-					rsci->mechctx->mech_type, gc->gc_svc);
+					rsci->mechctx->mech_type,
+					GSS_C_QOP_DEFAULT,
+					gc->gc_svc);
 		ret = SVC_OK;
 		goto out;
 	}
#7 lore raw

PATCH v2 8/9 SUNRPC: Make gss_mech_get() static

In reply to Chuck Lever

gss_mech_get() is no longer used outside of gss_mech_switch.c.

---

 include/linux/sunrpc/gss_api.h        |    3 ---
 net/sunrpc/auth_gss/gss_mech_switch.c |    5 +----
 2 files changed, 1 insertions(+), 7 deletions(-)
include/linux/sunrpc/gss_api.h +0 -3
index dc1e51b..59cfcff 100644
@@ -144,9 +144,6 @@ struct gss_api_mech *gss_mech_get_by_pseudoflavor(u32);
 /* Fill in an array with a list of supported pseudoflavors */
 int gss_mech_list_pseudoflavors(rpc_authflavor_t *, int);
 
-/* Just increments the mechanism's reference count and returns its input: */
-struct gss_api_mech * gss_mech_get(struct gss_api_mech *);
-
 /* For every successful gss_mech_get or gss_mech_get_by_* call there must be a
  * corresponding call to gss_mech_put. */
 void gss_mech_put(struct gss_api_mech *);
net/sunrpc/auth_gss/gss_mech_switch.c +1 -4
index a8d6ee5..b9f4f7b 100644
@@ -132,15 +132,12 @@ gss_mech_unregister(struct gss_api_mech *gm)
 
 EXPORT_SYMBOL_GPL(gss_mech_unregister);
 
-struct gss_api_mech *
-gss_mech_get(struct gss_api_mech *gm)
+static struct gss_api_mech *gss_mech_get(struct gss_api_mech *gm)
 {
 	__module_get(gm->gm_owner);
 	return gm;
 }
 
-EXPORT_SYMBOL_GPL(gss_mech_get);
-
 struct gss_api_mech *
 _gss_mech_get_by_name(const char *name)
 {
#8 lore raw

PATCH v2 9/9 SUNRPC: Remove EXPORT_SYMBOL_GPL() from GSS mech switch

In reply to Chuck Lever

Clean up: Reduce the symbol table footprint for auth_rpcgss.ko by removing exported symbols for functions that are not used outside of auth_rpcgss.

The remaining two EXPORTs in gss_mech_switch.c get documenting comments.

---

 net/sunrpc/auth_gss/gss_mech_switch.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)
net/sunrpc/auth_gss/gss_mech_switch.c +13 -13
index b9f4f7b..719ee68 100644
@@ -103,8 +103,13 @@ out:
 	return status;
 }
 
-int
-gss_mech_register(struct gss_api_mech *gm)
+/**
+ * gss_mech_register - register a GSS mechanism
+ * @gm: GSS mechanism handle
+ *
+ * Returns zero if successful, or a negative errno.
+ */
+int gss_mech_register(struct gss_api_mech *gm)
 {
 	int status;
 
@@ -117,11 +122,14 @@ gss_mech_register(struct gss_api_mech *gm)
 	dprintk("RPC:       registered gss mechanism %s\n", gm->gm_name);
 	return 0;
 }
-
 EXPORT_SYMBOL_GPL(gss_mech_register);
 
-void
-gss_mech_unregister(struct gss_api_mech *gm)
+/**
+ * gss_mech_unregister - release a GSS mechanism
+ * @gm: GSS mechanism handle
+ *
+ */
+void gss_mech_unregister(struct gss_api_mech *gm)
 {
 	spin_lock(&registered_mechs_lock);
 	list_del(&gm->gm_list);
@@ -129,7 +137,6 @@ gss_mech_unregister(struct gss_api_mech *gm)
 	dprintk("RPC:       unregistered gss mechanism %s\n", gm->gm_name);
 	gss_mech_free(gm);
 }
-
 EXPORT_SYMBOL_GPL(gss_mech_unregister);
 
 static struct gss_api_mech *gss_mech_get(struct gss_api_mech *gm)
@@ -167,7 +174,6 @@ struct gss_api_mech * gss_mech_get_by_name(const char *name)
 	}
 	return gm;
 }
-EXPORT_SYMBOL_GPL(gss_mech_get_by_name);
 
 static struct gss_api_mech *gss_mech_get_by_OID(struct rpcsec_gss_oid *obj)
 {
@@ -353,8 +359,6 @@ gss_pseudoflavor_to_service(struct gss_api_mech *gm, u32 pseudoflavor)
 	return 0;
 }
 
-EXPORT_SYMBOL_GPL(gss_pseudoflavor_to_service);
-
 char *
 gss_service_to_auth_domain_name(struct gss_api_mech *gm, u32 service)
 {
@@ -367,8 +371,6 @@ gss_service_to_auth_domain_name(struct gss_api_mech *gm, u32 service)
 	return NULL;
 }
 
-EXPORT_SYMBOL_GPL(gss_service_to_auth_domain_name);
-
 void
 gss_mech_put(struct gss_api_mech * gm)
 {
@@ -376,8 +378,6 @@ gss_mech_put(struct gss_api_mech * gm)
 		module_put(gm->gm_owner);
 }
 
-EXPORT_SYMBOL_GPL(gss_mech_put);
-
 /* The mech could probably be determined from the token instead, but it's just
  * as easy for now to pass it in. */
 int
#9 lore raw
In reply to Chuck Lever

PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBsaW51eC1uZnMtb3duZXJAdmdl ci5rZXJuZWwub3JnIFttYWlsdG86bGludXgtbmZzLQ0KPiBvd25lckB2Z2VyLmtlcm5lbC5vcmdd IE9uIEJlaGFsZiBPZiBDaHVjayBMZXZlcg0KPiBTZW50OiBXZWRuZXNkYXksIEphbnVhcnkgMzAs IDIwMTMgNjo0MiBQTQ0KPiBUbzogbGludXgtbmZzQHZnZXIua2VybmVsLm9yZw0KPiBTdWJqZWN0 OiBbUEFUQ0ggdjIgMC85XSBEeW5hbWljYWxseSBsb2FkIEdTUyBwc2V1ZG9mbGF2b3JzIGJ5IE9J RA0KPiANCj4gSGktDQo+IA0KPiBDdXJyZW50bHkgdGhlIFJQQyBjbGllbnQgaXMgYWJsZSB0byBk eW5hbWljYWxseSBsb2FkIEdTUyBzZWN1cml0eSBmbGF2b3INCj4gc3VwcG9ydCBieSBuYW1lIG9y IHBzZXVkb2ZsYXZvciBudW1iZXIsIGJ1dCBub3QgYnkgW09JRCwgcW9wLCBzZXJ2aWNlXQ0KPiB0 dXBsZS4gIFN1Y2ggYSB0dXBsZSBjYW4gYmUgcHJvdmlkZWQgYnkgYW4gTkZTdjQgc2VydmVyIGlu IGEgU0VDSU5GTyByZXBseSwNCj4gZm9yIGV4YW1wbGUuDQo+IA0KPiBUaGlzIG1lYW5zIHRoYXQg aWYgYW4gTkZTdjQgc2VydmVyIGxpc3RzIGEgdHVwbGUgZm9yLCBzYXksIGtyYjVwLCBpbiBhIFNF Q0lORk8NCj4gcmVwbHksIG91ciBjbGllbnQgd2lsbCBwcmV0ZW5kIGl0IGRvZXNuJ3Qgc3VwcG9y dCBrcmI1cCBpZiB0aGUgcnBjLWF1dGgtZ3NzLWtyYjUNCj4gbW9kdWxlIGlzIGF2YWlsYWJsZSBv biB0aGUgc3lzdGVtIGJ1dCBkb2VzIG5vdCBoYXBwZW4gdG8gYmUgbG9hZGVkIGF0IHRoYXQNCj4g bW9tZW50Lg0KPiANCj4gVGhpcyBzZXJpZXMgaW1wbGVtZW50cyBzdXBwb3J0IGZvciBsb2FkaW5n IHRoZSBjb3JyZWN0IEdTUyBwc2V1ZG9mbGF2b3INCj4gbW9kdWxlIGJlZm9yZSBzZWFyY2hpbmcg YnkgR1NTIHR1cGxlLiAgVGhpcyB2ZXJzaW9uIG5lZWRzIHRlc3RpbmcsIHdoaWNoIEknbGwNCj4g Z2V0IHRvIGZpcnN0IHRoaW5nIHRvbW9ycm93LCBidXQgSSd2ZSBhbHJlYWR5IHRlc3RlZCBlYXJs aWVyIHZlcnNpb25zIG9mIHRoZXNlDQo+IHBhdGNoZXMgd2l0aCBzdWNjZXNzLg0KPiANCj4gVGhh bmtzIHRvIHJldmlld2VycyBvZiB2MS4gIENoYW5nZXMgc2luY2UgdjE6DQo+IA0KPiAgIDEuICBT aW1wbGlmeSBmdW5jdGlvbiBhbmQgbWV0aG9kIG5hbWVzDQo+ICAgMi4gIEFkZCBhbiBlcXVpdmFs ZW50IHNlcnZlci1zaWRlIGludGVyZmFjZQ0KPiAgIDMuICBJbXByb3ZlIGF1dG9tYXRpYyBsb2Fk aW5nIG9mIHRoZSBhdXRoX3JwY2dzcyBtb2R1bGUNCj4gICA0LiAgbmZzX2ZpbmRfYmVzdF9zZWMo KSBhbHNvIHZlcmlmaWVzIG5vbi1HU1MgZmxhdm9ycyBhZ2FpbnN0DQo+ICAgICAgIFJQQyBjbGll bnQncyBsaXN0IG9mIHJlZ2lzdGVyZWQgZmxhdm9ycw0KPiAgIDUuICBTZWFyY2ggZm9yIChxb3As IHN2YykgcGFpciB3aXRob3V0IGFkZGluZyBhIG5ldyBmdW5jdGlvbg0KPiAgIDYuICBDbGVhbiB1 cCBHU1MgbWVjaCBzd2l0Y2gNCj4gICA3LiAgUmVtb3ZlIGRwcmludGsoKSBjYWxscw0KPiAgIDgu ICBJbXByb3ZlIHBhdGNoIGRlc2NyaXB0aW9ucw0KPiAgIDkuICBOdW1lcm91cyBzbWFsbCBpbXBy b3ZlbWVudHMgYW5kIGZpeGVzDQo+IA0KPiAtLS0NCj4gDQo+IENodWNrIExldmVyICg5KToNCj4g ICAgICAgU1VOUlBDOiBSZW1vdmUgRVhQT1JUX1NZTUJPTF9HUEwoKSBmcm9tIEdTUyBtZWNoIHN3 aXRjaA0KPiAgICAgICBTVU5SUEM6IE1ha2UgZ3NzX21lY2hfZ2V0KCkgc3RhdGljDQo+ICAgICAg IFNVTlJQQzogUmVmYWN0b3IgbmZzZDRfZG9fZW5jb2RlX3NlY2luZm8oKQ0KPiAgICAgICBTVU5S UEM6IENvbnNpZGVyIHFvcCB3aGVuIGxvb2tpbmcgdXAgcHNldWRvZmxhdm9ycw0KPiAgICAgICBT VU5SUEM6IExvYWQgR1NTIGtlcm5lbCBtb2R1bGUgYnkgT0lEDQo+ICAgICAgIFNVTlJQQzogSW50 cm9kdWNlIHJwY2F1dGhfZ2V0X3BzZXVkb2ZsYXZvcigpDQo+ICAgICAgIFNVTlJQQzogRGVmaW5l IHJwY3NlY19nc3NfaW5mbyBzdHJ1Y3R1cmUNCj4gICAgICAgTkZTOiBSZW1vdmUgdW5uZWVkZWQg Zm9yd2FyZCBkZWNsYXJhdGlvbg0KPiAgICAgICBTVU5SUEM6IE1pc3NpbmcgbW9kdWxlIGFsaWFz IGZvciBhdXRoX3JwY2dzcy5rbw0KPiANCj4gDQo+ICBmcy9uZnMvbmZzNG5hbWVzcGFjZS5jICAg ICAgICAgICAgICAgIHwgICA0MyArKysrKysrLS0tLS0NCj4gIGZzL25mcy9uZnM0eGRyLmMgICAg ICAgICAgICAgICAgICAgICAgfCAgIDIwICsrKy0tLQ0KPiAgZnMvbmZzZC9uZnM0eGRyLmMgICAg ICAgICAgICAgICAgICAgICB8ICAgNDMgKysrKysrLS0tLS0tDQo+ICBpbmNsdWRlL2xpbnV4L25m c194ZHIuaCAgICAgICAgICAgICAgIHwgICAyNCArLS0tLS0tDQo+ICBpbmNsdWRlL2xpbnV4L3N1 bnJwYy9hdXRoLmggICAgICAgICAgIHwgICAgNiArKw0KPiAgaW5jbHVkZS9saW51eC9zdW5ycGMv Z3NzX2FwaS5oICAgICAgICB8ICAgMjkgKysrKysrLS0NCj4gIG5ldC9zdW5ycGMvS2NvbmZpZyAg ICAgICAgICAgICAgICAgICAgfCAgICAxDQo+ICBuZXQvc3VucnBjL2F1dGguYyAgICAgICAgICAg ICAgICAgICAgIHwgICA2OCArKysrKysrKysrKysrKysrKysrDQo+ICBuZXQvc3VucnBjL2F1dGhf Z3NzL2F1dGhfZ3NzLmMgICAgICAgIHwgICAgMyArDQo+ICBuZXQvc3VucnBjL2F1dGhfZ3NzL2dz c19rcmI1X21lY2guYyAgIHwgICAgNiArLQ0KPiAgbmV0L3N1bnJwYy9hdXRoX2dzcy9nc3NfbWVj aF9zd2l0Y2guYyB8ICAxMTcNCj4gKysrKysrKysrKysrKysrKysrKysrKysrKy0tLS0tLS0tDQo+ ICBuZXQvc3VucnBjL2F1dGhfZ3NzL3N2Y2F1dGhfZ3NzLmMgICAgIHwgICAgNCArDQo+ICAxMiBm aWxlcyBjaGFuZ2VkLCAyNTcgaW5zZXJ0aW9ucygrKSwgMTA3IGRlbGV0aW9ucygtKQ0KPiANCg0K TG9va3MgZ29vZCEgSG93IGhhdmUgeW91IHRlc3RlZCBpdD8NCg0KQ2hlZXJzDQogIFRyb25kDQo=

#10 lore raw
Quoted 67 lines · Trond
Quoted 51 lines

-----Original Message-----
From: [email protected] [mailto:linux-nfs- [email protected]] On Behalf Of Chuck Lever
Sent: Wednesday, January 30, 2013 6:42 PM
To: [email protected]
Subject: [PATCH v2 0/9] Dynamically load GSS pseudoflavors by OID

Hi-

Currently the RPC client is able to dynamically load GSS security flavor support by name or pseudoflavor number, but not by [OID, qop, service] tuple. Such a tuple can be provided by an NFSv4 server in a SECINFO reply, for example.

This means that if an NFSv4 server lists a tuple for, say, krb5p, in a SECINFO reply, our client will pretend it doesn't support krb5p if the rpc-auth-gss-krb5 module is available on the system but does not happen to be loaded at that moment.

This series implements support for loading the correct GSS pseudoflavor module before searching by GSS tuple. This version needs testing, which I'll get to first thing tomorrow, but I've already tested earlier versions of these patches with success.

Thanks to reviewers of v1. Changes since v1:

 1.  Simplify function and method names
 2.  Add an equivalent server-side interface
 3.  Improve automatic loading of the auth_rpcgss module
 4.  nfs_find_best_sec() also verifies non-GSS flavors against
     RPC client's list of registered flavors
 5.  Search for (qop, svc) pair without adding a new function
 6.  Clean up GSS mech switch
 7.  Remove dprintk() calls
 8.  Improve patch descriptions
 9.  Numerous small improvements and fixes

---

Chuck Lever (9):
SUNRPC: Remove EXPORT_SYMBOL_GPL() from GSS mech switch
SUNRPC: Make gss_mech_get() static
SUNRPC: Refactor nfsd4_do_encode_secinfo()
SUNRPC: Consider qop when looking up pseudoflavors
SUNRPC: Load GSS kernel module by OID
SUNRPC: Introduce rpcauth_get_pseudoflavor()
SUNRPC: Define rpcsec_gss_info structure
NFS: Remove unneeded forward declaration
SUNRPC: Missing module alias for auth_rpcgss.ko

Quoted 15 lines
fs/nfs/nfs4namespace.c                |   43 +++++++-----
fs/nfs/nfs4xdr.c                      |   20 +++---
fs/nfsd/nfs4xdr.c                     |   43 ++++++------
include/linux/nfs_xdr.h               |   24 +------
include/linux/sunrpc/auth.h           |    6 ++
include/linux/sunrpc/gss_api.h        |   29 ++++++--
net/sunrpc/Kconfig                    |    1
net/sunrpc/auth.c                     |   68 +++++++++++++++++++
net/sunrpc/auth_gss/auth_gss.c        |    3 +
net/sunrpc/auth_gss/gss_krb5_mech.c   |    6 +-
net/sunrpc/auth_gss/gss_mech_switch.c |  117
+++++++++++++++++++++++++--------
net/sunrpc/auth_gss/svcauth_gss.c     |    4 +
12 files changed, 257 insertions(+), 107 deletions(-)
Quoted 1 line

Looks good! How have you tested it?

Start with a Solaris 11 NFS server and my client. The server has a Kerberos-only share called /test/krb5-only.

1. "sudo rmmod auth_rpcgss" on the client (no NFS mounts at this point)

2. "sudo mount server:/ /mnt"

3. The client accesses the pseudo-fs with AUTH_UNIX (observed with wireshark)

4. After I kinit on the client, I cd into /test/krb5-only

5. The client encounters the WRONG_SEC and performs a SECINFO request (observed with wireshark)

6. The correct kernel modules are loaded, and the cd completes successfully.

7. I "cd ~" and unmount /mnt. The module refcounts go to zero.

I've run this with debugging enabled and extra dprintk's, and it looks like the client is doing all the right things.

I'd like to extend the testing a bit with a Linux NFS server, now that there's a server-side change in this series. And naturally I'll need broad compile-testing with various combinations of CONFIG options. I'm open to suggestions of other use cases / corner cases.

Signature · 2 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
#11 lore raw

Sent from my iPhone

Quoted 77 lines · Chuck Lever
Quoted 66 lines · Trond
Quoted 51 lines

-----Original Message-----
From: [email protected] [mailto:linux-nfs- [email protected]] On Behalf Of Chuck Lever
Sent: Wednesday, January 30, 2013 6:42 PM
To: [email protected]
Subject: [PATCH v2 0/9] Dynamically load GSS pseudoflavors by OID

Hi-

Currently the RPC client is able to dynamically load GSS security flavor support by name or pseudoflavor number, but not by [OID, qop, service] tuple. Such a tuple can be provided by an NFSv4 server in a SECINFO reply, for example.

This means that if an NFSv4 server lists a tuple for, say, krb5p, in a SECINFO reply, our client will pretend it doesn't support krb5p if the rpc-auth-gss-krb5 module is available on the system but does not happen to be loaded at that moment.

This series implements support for loading the correct GSS pseudoflavor module before searching by GSS tuple. This version needs testing, which I'll get to first thing tomorrow, but I've already tested earlier versions of these patches with success.

Thanks to reviewers of v1. Changes since v1:

1.  Simplify function and method names
2.  Add an equivalent server-side interface
3.  Improve automatic loading of the auth_rpcgss module
4.  nfs_find_best_sec() also verifies non-GSS flavors against
    RPC client's list of registered flavors
5.  Search for (qop, svc) pair without adding a new function
6.  Clean up GSS mech switch
7.  Remove dprintk() calls
8.  Improve patch descriptions
9.  Numerous small improvements and fixes

---

Chuck Lever (9):
SUNRPC: Remove EXPORT_SYMBOL_GPL() from GSS mech switch
SUNRPC: Make gss_mech_get() static
SUNRPC: Refactor nfsd4_do_encode_secinfo()
SUNRPC: Consider qop when looking up pseudoflavors
SUNRPC: Load GSS kernel module by OID
SUNRPC: Introduce rpcauth_get_pseudoflavor()
SUNRPC: Define rpcsec_gss_info structure
NFS: Remove unneeded forward declaration
SUNRPC: Missing module alias for auth_rpcgss.ko

Quoted 14 lines
fs/nfs/nfs4namespace.c                |   43 +++++++-----
fs/nfs/nfs4xdr.c                      |   20 +++---
fs/nfsd/nfs4xdr.c                     |   43 ++++++------
include/linux/nfs_xdr.h               |   24 +------
include/linux/sunrpc/auth.h           |    6 ++
include/linux/sunrpc/gss_api.h        |   29 ++++++--
net/sunrpc/Kconfig                    |    1
net/sunrpc/auth.c                     |   68 +++++++++++++++++++
net/sunrpc/auth_gss/auth_gss.c        |    3 +
net/sunrpc/auth_gss/gss_krb5_mech.c   |    6 +-
net/sunrpc/auth_gss/gss_mech_switch.c |  117
+++++++++++++++++++++++++--------
net/sunrpc/auth_gss/svcauth_gss.c |    4 +
12 files changed, 257 insertions(+), 107 deletions(-)
Quoted 1 line

Looks good! How have you tested it?

Start with a Solaris 11 NFS server and my client. The server has a Kerberos-only share called /test/krb5-only.

1. "sudo rmmod auth_rpcgss" on the client (no NFS mounts at this point)

2. "sudo mount server:/ /mnt"

Quoted 7 lines

3. The client accesses the pseudo-fs with AUTH_UNIX (observed with wireshark)

4. After I kinit on the client, I cd into /test/krb5-only

5. The client encounters the WRONG_SEC and performs a SECINFO request (observed with wireshark)

6. The correct kernel modules are loaded, and the cd completes successfully.

Note if I blacklist the Kerberos module or neglect to kinit, the krb5-only directory is unreadable, as expected.

Quoted 18 lines

7. I "cd ~" and unmount /mnt. The module refcounts go to zero.

I've run this with debugging enabled and extra dprintk's, and it looks like the client is doing all the right things.

I'd like to extend the testing a bit with a Linux NFS server, now that there's a server-side change in this series. And naturally I'll need broad compile-testing with various combinations of CONFIG options. I'm open to suggestions of other use cases / corner cases.

Signature · 10 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com




--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#12 lore raw
In reply to Chuck Lever
Quoted 7 lines · Chuck Lever
Quoted 1 line · Trond

Looks good! How have you tested it?

Start with a Solaris 11 NFS server and my client. The server has a Kerberos-only share called /test/krb5-only.

1. "sudo rmmod auth_rpcgss" on the client (no NFS mounts at this point)

Bash history says I misremembered this. I actually used:

"sudo rmmod rpcsec_gss_krb5"

So, part of my next round of testing will try to remove both rpcsec_gss_krb5 and auth_rpcgss, if I can, and see if all the right things happen when I cross into a krb5-only file system.

Quoted 15 lines

2. "sudo mount server:/ /mnt"

3. The client accesses the pseudo-fs with AUTH_UNIX (observed with wireshark)

4. After I kinit on the client, I cd into /test/krb5-only

5. The client encounters the WRONG_SEC and performs a SECINFO request (observed with wireshark)

6. The correct kernel modules are loaded, and the cd completes successfully.

7. I "cd ~" and unmount /mnt. The module refcounts go to zero.

I've run this with debugging enabled and extra dprintk's, and it looks like the client is doing all the right things.

I'd like to extend the testing a bit with a Linux NFS server, now that there's a server-side change in this series. And naturally I'll need broad compile-testing with various combinations of CONFIG options. I'm open to suggestions of other use cases / corner cases.

Signature · 2 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com