* [PATCH 1/5] sunrpc: add hash_cred() function to rpc_authops struct
2016-09-29 15:44 [PATCH 0/5] Add auth-specific auth_cred hash functions Frank Sorenson
@ 2016-09-29 15:44 ` Frank Sorenson
2016-09-29 15:44 ` [PATCH 2/5] sunrpc: add generic_auth hash_cred() function Frank Sorenson
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Frank Sorenson @ 2016-09-29 15:44 UTC (permalink / raw)
To: linux-nfs
Currently, a single hash algorithm is used to hash the auth_cred for
the credcache for all rpc_auth types. Add a hash_cred() function to
the rpc_authops struct to allow a hash function specific to each
auth flavor.
Signed-off-by: Frank Sorenson <sorenson@redhat.com>
---
include/linux/sunrpc/auth.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h
index 4ccf184..b1bc62b 100644
--- a/include/linux/sunrpc/auth.h
+++ b/include/linux/sunrpc/auth.h
@@ -131,6 +131,7 @@ struct rpc_authops {
struct rpc_auth * (*create)(struct rpc_auth_create_args *, struct rpc_clnt *);
void (*destroy)(struct rpc_auth *);
+ int (*hash_cred)(struct auth_cred *, unsigned int);
struct rpc_cred * (*lookup_cred)(struct rpc_auth *, struct auth_cred *, int);
struct rpc_cred * (*crcreate)(struct rpc_auth*, struct auth_cred *, int, gfp_t);
int (*list_pseudoflavors)(rpc_authflavor_t *, int);
--
2.5.5
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/5] sunrpc: add generic_auth hash_cred() function
2016-09-29 15:44 [PATCH 0/5] Add auth-specific auth_cred hash functions Frank Sorenson
2016-09-29 15:44 ` [PATCH 1/5] sunrpc: add hash_cred() function to rpc_authops struct Frank Sorenson
@ 2016-09-29 15:44 ` Frank Sorenson
2016-09-29 15:44 ` [PATCH 3/5] sunrpc: add auth_unix " Frank Sorenson
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Frank Sorenson @ 2016-09-29 15:44 UTC (permalink / raw)
To: linux-nfs
Add a hash_cred() function for generic_auth, using both the
uid and gid from the auth_cred.
Signed-off-by: Frank Sorenson <sorenson@redhat.com>
---
net/sunrpc/auth_generic.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/net/sunrpc/auth_generic.c b/net/sunrpc/auth_generic.c
index 1682195..0494513 100644
--- a/net/sunrpc/auth_generic.c
+++ b/net/sunrpc/auth_generic.c
@@ -78,6 +78,14 @@ static struct rpc_cred *generic_bind_cred(struct rpc_task *task,
return auth->au_ops->lookup_cred(auth, acred, lookupflags);
}
+static int
+generic_hash_cred(struct auth_cred *acred, unsigned int hashbits)
+{
+ return hash_64(from_kgid(&init_user_ns, acred->gid) |
+ ((u64)from_kuid(&init_user_ns, acred->uid) <<
+ (sizeof(gid_t) * 8)), hashbits);
+}
+
/*
* Lookup generic creds for current process
*/
@@ -258,6 +266,7 @@ generic_key_timeout(struct rpc_auth *auth, struct rpc_cred *cred)
static const struct rpc_authops generic_auth_ops = {
.owner = THIS_MODULE,
.au_name = "Generic",
+ .hash_cred = generic_hash_cred,
.lookup_cred = generic_lookup_cred,
.crcreate = generic_create_cred,
.key_timeout = generic_key_timeout,
--
2.5.5
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/5] sunrpc: add auth_unix hash_cred() function
2016-09-29 15:44 [PATCH 0/5] Add auth-specific auth_cred hash functions Frank Sorenson
2016-09-29 15:44 ` [PATCH 1/5] sunrpc: add hash_cred() function to rpc_authops struct Frank Sorenson
2016-09-29 15:44 ` [PATCH 2/5] sunrpc: add generic_auth hash_cred() function Frank Sorenson
@ 2016-09-29 15:44 ` Frank Sorenson
2016-09-29 15:44 ` [PATCH 4/5] sunrpc: add RPCSEC_GSS " Frank Sorenson
2016-09-29 15:44 ` [PATCH 5/5] sunrpc: replace generic auth_cred hash with auth-specific function Frank Sorenson
4 siblings, 0 replies; 6+ messages in thread
From: Frank Sorenson @ 2016-09-29 15:44 UTC (permalink / raw)
To: linux-nfs
Add a hash_cred() function for auth_unix, using both the
uid and gid from the auth_cred.
Signed-off-by: Frank Sorenson <sorenson@redhat.com>
---
net/sunrpc/auth_unix.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c
index a99278c..4c0c572 100644
--- a/net/sunrpc/auth_unix.c
+++ b/net/sunrpc/auth_unix.c
@@ -46,6 +46,14 @@ unx_destroy(struct rpc_auth *auth)
rpcauth_clear_credcache(auth->au_credcache);
}
+static int
+unx_hash_cred(struct auth_cred *acred, unsigned int hashbits)
+{
+ return hash_64(from_kgid(&init_user_ns, acred->gid) |
+ ((u64)from_kuid(&init_user_ns, acred->uid) <<
+ (sizeof(gid_t) * 8)), hashbits);
+}
+
/*
* Lookup AUTH_UNIX creds for current process
*/
@@ -220,6 +228,7 @@ const struct rpc_authops authunix_ops = {
.au_name = "UNIX",
.create = unx_create,
.destroy = unx_destroy,
+ .hash_cred = unx_hash_cred,
.lookup_cred = unx_lookup_cred,
.crcreate = unx_create_cred,
};
--
2.5.5
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 4/5] sunrpc: add RPCSEC_GSS hash_cred() function
2016-09-29 15:44 [PATCH 0/5] Add auth-specific auth_cred hash functions Frank Sorenson
` (2 preceding siblings ...)
2016-09-29 15:44 ` [PATCH 3/5] sunrpc: add auth_unix " Frank Sorenson
@ 2016-09-29 15:44 ` Frank Sorenson
2016-09-29 15:44 ` [PATCH 5/5] sunrpc: replace generic auth_cred hash with auth-specific function Frank Sorenson
4 siblings, 0 replies; 6+ messages in thread
From: Frank Sorenson @ 2016-09-29 15:44 UTC (permalink / raw)
To: linux-nfs
Add a hash_cred() function for RPCSEC_GSS, using only the
uid from the auth_cred.
Signed-off-by: Frank Sorenson <sorenson@redhat.com>
---
net/sunrpc/auth_gss/auth_gss.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 976c781..d8bd97a 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -1298,6 +1298,12 @@ gss_destroy_cred(struct rpc_cred *cred)
gss_destroy_nullcred(cred);
}
+static int
+gss_hash_cred(struct auth_cred *acred, unsigned int hashbits)
+{
+ return hash_64(from_kuid(&init_user_ns, acred->uid), hashbits);
+}
+
/*
* Lookup RPCSEC_GSS cred for the current process
*/
@@ -1982,6 +1988,7 @@ static const struct rpc_authops authgss_ops = {
.au_name = "RPCSEC_GSS",
.create = gss_create,
.destroy = gss_destroy,
+ .hash_cred = gss_hash_cred,
.lookup_cred = gss_lookup_cred,
.crcreate = gss_create_cred,
.list_pseudoflavors = gss_mech_list_pseudoflavors,
--
2.5.5
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 5/5] sunrpc: replace generic auth_cred hash with auth-specific function
2016-09-29 15:44 [PATCH 0/5] Add auth-specific auth_cred hash functions Frank Sorenson
` (3 preceding siblings ...)
2016-09-29 15:44 ` [PATCH 4/5] sunrpc: add RPCSEC_GSS " Frank Sorenson
@ 2016-09-29 15:44 ` Frank Sorenson
4 siblings, 0 replies; 6+ messages in thread
From: Frank Sorenson @ 2016-09-29 15:44 UTC (permalink / raw)
To: linux-nfs
Replace the generic code to hash the auth_cred with the call to
the auth-specific hash function in the rpc_authops struct.
Signed-off-by: Frank Sorenson <sorenson@redhat.com>
---
net/sunrpc/auth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index a7e42f9..2bff63a 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -551,7 +551,7 @@ rpcauth_lookup_credcache(struct rpc_auth *auth, struct auth_cred * acred,
*entry, *new;
unsigned int nr;
- nr = hash_long(from_kuid(&init_user_ns, acred->uid), cache->hashbits);
+ nr = auth->au_ops->hash_cred(acred, cache->hashbits);
rcu_read_lock();
hlist_for_each_entry_rcu(entry, &cache->hashtable[nr], cr_hash) {
--
2.5.5
^ permalink raw reply related [flat|nested] 6+ messages in thread