Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

SUNRPC: remove generic cred code.

This is no longer used.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

authored by

NeilBrown and committed by
Anna Schumaker
89a4f758 a52458b4

+2 -225
-6
include/linux/sunrpc/auth.h
··· 104 104 105 105 /* Flags for rpcauth_lookupcred() */ 106 106 #define RPCAUTH_LOOKUP_NEW 0x01 /* Accept an uninitialised cred */ 107 - #define RPCAUTH_LOOKUP_RCU 0x02 /* lock-less lookup */ 108 107 109 108 /* 110 109 * Client authentication ops ··· 150 151 extern const struct rpc_authops authnull_ops; 151 152 152 153 int __init rpc_init_authunix(void); 153 - int __init rpc_init_generic_auth(void); 154 154 int __init rpcauth_init_module(void); 155 155 void rpcauth_remove_module(void); 156 - void rpc_destroy_generic_auth(void); 157 156 void rpc_destroy_authunix(void); 158 157 159 - struct rpc_cred * rpc_lookup_cred(void); 160 - struct rpc_cred * rpc_lookup_cred_nonblock(void); 161 - struct rpc_cred * rpc_lookup_generic_cred(struct auth_cred *, int, gfp_t); 162 158 int rpcauth_register(const struct rpc_authops *); 163 159 int rpcauth_unregister(const struct rpc_authops *); 164 160 struct rpc_auth * rpcauth_create(const struct rpc_auth_create_args *,
+1 -1
net/sunrpc/Makefile
··· 9 9 obj-$(CONFIG_SUNRPC_XPRT_RDMA) += xprtrdma/ 10 10 11 11 sunrpc-y := clnt.o xprt.o socklib.o xprtsock.o sched.o \ 12 - auth.o auth_null.o auth_unix.o auth_generic.o \ 12 + auth.o auth_null.o auth_unix.o \ 13 13 svc.o svcsock.o svcauth.o svcauth_unix.o \ 14 14 addr.o rpcb_clnt.o timer.o xdr.o \ 15 15 sunrpc_syms.o cache.o rpc_pipe.o \
+1 -17
net/sunrpc/auth.c
··· 578 578 hlist_for_each_entry_rcu(entry, &cache->hashtable[nr], cr_hash) { 579 579 if (!entry->cr_ops->crmatch(acred, entry, flags)) 580 580 continue; 581 - if (flags & RPCAUTH_LOOKUP_RCU) { 582 - if (test_bit(RPCAUTH_CRED_NEW, &entry->cr_flags) || 583 - refcount_read(&entry->cr_count) == 0) 584 - continue; 585 - cred = entry; 586 - break; 587 - } 588 581 cred = get_rpccred(entry); 589 582 if (cred) 590 583 break; ··· 586 593 587 594 if (cred != NULL) 588 595 goto found; 589 - 590 - if (flags & RPCAUTH_LOOKUP_RCU) 591 - return ERR_PTR(-ECHILD); 592 596 593 597 new = auth->au_ops->crcreate(auth, acred, flags, gfp); 594 598 if (IS_ERR(new)) { ··· 915 925 err = rpc_init_authunix(); 916 926 if (err < 0) 917 927 goto out1; 918 - err = rpc_init_generic_auth(); 919 - if (err < 0) 920 - goto out2; 921 928 err = register_shrinker(&rpc_cred_shrinker); 922 929 if (err < 0) 923 - goto out3; 930 + goto out2; 924 931 return 0; 925 - out3: 926 - rpc_destroy_generic_auth(); 927 932 out2: 928 933 rpc_destroy_authunix(); 929 934 out1: ··· 928 943 void rpcauth_remove_module(void) 929 944 { 930 945 rpc_destroy_authunix(); 931 - rpc_destroy_generic_auth(); 932 946 unregister_shrinker(&rpc_cred_shrinker); 933 947 }
-199
net/sunrpc/auth_generic.c
··· 1 - /* 2 - * Generic RPC credential 3 - * 4 - * Copyright (C) 2008, Trond Myklebust <Trond.Myklebust@netapp.com> 5 - */ 6 - 7 - #include <linux/err.h> 8 - #include <linux/slab.h> 9 - #include <linux/types.h> 10 - #include <linux/module.h> 11 - #include <linux/sched.h> 12 - #include <linux/sunrpc/auth.h> 13 - #include <linux/sunrpc/clnt.h> 14 - #include <linux/sunrpc/debug.h> 15 - #include <linux/sunrpc/sched.h> 16 - 17 - #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 18 - # define RPCDBG_FACILITY RPCDBG_AUTH 19 - #endif 20 - 21 - struct generic_cred { 22 - struct rpc_cred gc_base; 23 - struct auth_cred acred; 24 - }; 25 - 26 - static struct rpc_auth generic_auth; 27 - static const struct rpc_credops generic_credops; 28 - 29 - /* 30 - * Public call interface 31 - */ 32 - struct rpc_cred *rpc_lookup_cred(void) 33 - { 34 - return rpcauth_lookupcred(&generic_auth, 0); 35 - } 36 - EXPORT_SYMBOL_GPL(rpc_lookup_cred); 37 - 38 - struct rpc_cred * 39 - rpc_lookup_generic_cred(struct auth_cred *acred, int flags, gfp_t gfp) 40 - { 41 - return rpcauth_lookup_credcache(&generic_auth, acred, flags, gfp); 42 - } 43 - EXPORT_SYMBOL_GPL(rpc_lookup_generic_cred); 44 - 45 - struct rpc_cred *rpc_lookup_cred_nonblock(void) 46 - { 47 - return rpcauth_lookupcred(&generic_auth, RPCAUTH_LOOKUP_RCU); 48 - } 49 - EXPORT_SYMBOL_GPL(rpc_lookup_cred_nonblock); 50 - 51 - static struct rpc_cred *generic_bind_cred(struct rpc_task *task, 52 - struct rpc_cred *cred, int lookupflags) 53 - { 54 - struct rpc_auth *auth = task->tk_client->cl_auth; 55 - struct auth_cred *acred = &container_of(cred, struct generic_cred, gc_base)->acred; 56 - 57 - return auth->au_ops->lookup_cred(auth, acred, lookupflags); 58 - } 59 - 60 - static int 61 - generic_hash_cred(struct auth_cred *acred, unsigned int hashbits) 62 - { 63 - return hash_64(from_kgid(&init_user_ns, acred->cred->fsgid) | 64 - ((u64)from_kuid(&init_user_ns, acred->cred->fsuid) << 65 - (sizeof(gid_t) * 8)), hashbits); 66 - } 67 - 68 - /* 69 - * Lookup generic creds for current process 70 - */ 71 - static struct rpc_cred * 72 - generic_lookup_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) 73 - { 74 - return rpcauth_lookup_credcache(&generic_auth, acred, flags, GFP_KERNEL); 75 - } 76 - 77 - static struct rpc_cred * 78 - generic_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags, gfp_t gfp) 79 - { 80 - struct generic_cred *gcred; 81 - 82 - gcred = kmalloc(sizeof(*gcred), gfp); 83 - if (gcred == NULL) 84 - return ERR_PTR(-ENOMEM); 85 - 86 - rpcauth_init_cred(&gcred->gc_base, acred, &generic_auth, &generic_credops); 87 - gcred->gc_base.cr_flags = 1UL << RPCAUTH_CRED_UPTODATE; 88 - 89 - gcred->acred.cred = gcred->gc_base.cr_cred; 90 - gcred->acred.principal = acred->principal; 91 - 92 - dprintk("RPC: allocated %s cred %p for uid %d gid %d\n", 93 - gcred->acred.principal ? "machine" : "generic", 94 - gcred, 95 - from_kuid(&init_user_ns, acred->cred->fsuid), 96 - from_kgid(&init_user_ns, acred->cred->fsgid)); 97 - return &gcred->gc_base; 98 - } 99 - 100 - static void 101 - generic_free_cred(struct rpc_cred *cred) 102 - { 103 - struct generic_cred *gcred = container_of(cred, struct generic_cred, gc_base); 104 - 105 - dprintk("RPC: generic_free_cred %p\n", gcred); 106 - put_cred(cred->cr_cred); 107 - kfree(gcred); 108 - } 109 - 110 - static void 111 - generic_free_cred_callback(struct rcu_head *head) 112 - { 113 - struct rpc_cred *cred = container_of(head, struct rpc_cred, cr_rcu); 114 - generic_free_cred(cred); 115 - } 116 - 117 - static void 118 - generic_destroy_cred(struct rpc_cred *cred) 119 - { 120 - call_rcu(&cred->cr_rcu, generic_free_cred_callback); 121 - } 122 - 123 - static int 124 - machine_cred_match(struct auth_cred *acred, struct generic_cred *gcred, int flags) 125 - { 126 - if (!gcred->acred.principal || 127 - gcred->acred.principal != acred->principal || 128 - !uid_eq(gcred->acred.cred->fsuid, acred->cred->fsuid) || 129 - !gid_eq(gcred->acred.cred->fsgid, acred->cred->fsgid)) 130 - return 0; 131 - return 1; 132 - } 133 - 134 - /* 135 - * Match credentials against current process creds. 136 - */ 137 - static int 138 - generic_match(struct auth_cred *acred, struct rpc_cred *cred, int flags) 139 - { 140 - struct generic_cred *gcred = container_of(cred, struct generic_cred, gc_base); 141 - int i; 142 - struct group_info *a, *g; 143 - 144 - if (acred->principal) 145 - return machine_cred_match(acred, gcred, flags); 146 - 147 - if (!uid_eq(gcred->acred.cred->fsuid, acred->cred->fsuid) || 148 - !gid_eq(gcred->acred.cred->fsgid, acred->cred->fsgid) || 149 - gcred->acred.principal != NULL) 150 - goto out_nomatch; 151 - 152 - a = acred->cred->group_info; 153 - g = gcred->acred.cred->group_info; 154 - /* Optimisation in the case where pointers are identical... */ 155 - if (a == g) 156 - goto out_match; 157 - 158 - /* Slow path... */ 159 - if (g->ngroups != a->ngroups) 160 - goto out_nomatch; 161 - for (i = 0; i < g->ngroups; i++) { 162 - if (!gid_eq(g->gid[i], a->gid[i])) 163 - goto out_nomatch; 164 - } 165 - out_match: 166 - return 1; 167 - out_nomatch: 168 - return 0; 169 - } 170 - 171 - int __init rpc_init_generic_auth(void) 172 - { 173 - return rpcauth_init_credcache(&generic_auth); 174 - } 175 - 176 - void rpc_destroy_generic_auth(void) 177 - { 178 - rpcauth_destroy_credcache(&generic_auth); 179 - } 180 - 181 - static const struct rpc_authops generic_auth_ops = { 182 - .owner = THIS_MODULE, 183 - .au_name = "Generic", 184 - .hash_cred = generic_hash_cred, 185 - .lookup_cred = generic_lookup_cred, 186 - .crcreate = generic_create_cred, 187 - }; 188 - 189 - static struct rpc_auth generic_auth = { 190 - .au_ops = &generic_auth_ops, 191 - .au_count = REFCOUNT_INIT(1), 192 - }; 193 - 194 - static const struct rpc_credops generic_credops = { 195 - .cr_name = "Generic cred", 196 - .crdestroy = generic_destroy_cred, 197 - .crbind = generic_bind_cred, 198 - .crmatch = generic_match, 199 - };
-2
net/sunrpc/auth_null.c
··· 36 36 static struct rpc_cred * 37 37 nul_lookup_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) 38 38 { 39 - if (flags & RPCAUTH_LOOKUP_RCU) 40 - return &null_cred; 41 39 return get_rpccred(&null_cred); 42 40 } 43 41