/* * linux/net/sunrpc/svcauth.c * * The generic interface for RPC authentication on the server side. * * Copyright (C) 1995, 1996 Olaf Kirch * * CHANGES * 19-Apr-2000 Chris Evans - Security fix */ #include #include #include #include #include #include #include #include #define RPCDBG_FACILITY RPCDBG_AUTH /* * Table of authenticators */ extern struct auth_ops svcauth_null; extern struct auth_ops svcauth_unix; static DEFINE_SPINLOCK(authtab_lock); static struct auth_ops *authtab[RPC_AUTH_MAXFLAVOR] = { [0] = &svcauth_null, [1] = &svcauth_unix, }; int svc_authenticate(struct svc_rqst *rqstp, __be32 *authp) { rpc_authflavor_t flavor; struct auth_ops *aops; *authp = rpc_auth_ok; flavor = svc_getnl(&rqstp->rq_arg.head[0]); dprintk("svc: svc_authenticate (%d)\n", flavor); spin_lock(&authtab_lock); if (flavor >= RPC_AUTH_MAXFLAVOR || !(aops = authtab[flavor]) || !try_module_get(aops->owner)) { spin_unlock(&authtab_lock); *authp = rpc_autherr_badcred; return SVC_DENIED; } spin_unlock(&authtab_lock); rqstp->rq_auth_slack = 0; init_svc_cred(&rqstp->rq_cred); rqstp->rq_authop = aops; return aops->accept(rqstp, authp); } EXPORT_SYMBOL_GPL(svc_authenticate); int svc_set_client(struct svc_rqst *rqstp) { rqstp->rq_client = NULL; return rqstp->rq_authop->set_client(rqstp); } EXPORT_SYMBOL_GPL(svc_set_client); /* A request, which was authenticated, has now executed. * Time to finalise the credentials and verifier * and release and resources */ int svc_authorise(struct svc_rqst *rqstp) { struct auth_ops *aops = rqstp->rq_authop; int rv = 0; rqstp->rq_authop = NULL; if (aops) { rv = aops->release(rqstp); module_put(aops->owner); } return rv; } int svc_auth_register(rpc_authflavor_t flavor, struct auth_ops *aops) { int rv = -EINVAL; spin_lock(&authtab_lock); if (flavor < RPC_AUTH_MAXFLAVOR && authtab[flavor] == NULL) { authtab[flavor] = aops; rv = 0; } spin_unlock(&authtab_lock); return rv; } EXPORT_SYMBOL_GPL(svc_auth_register); void svc_auth_unregister(rpc_authflavor_t flavor) { spin_lock(&authtab_lock); if (flavor < RPC_AUTH_MAXFLAVOR) authtab[flavor] = NULL; spin_unlock(&authtab_lock); } EXPORT_SYMBOL_GPL(svc_auth_unregister); /************************************************** * 'auth_domains' are stored in a hash table indexed by name. * When the last reference to an 'auth_domain' is dropped, * the object is unhashed and freed. * If auth_domain_lookup fails to find an entry, it will return * it's second argument 'new'. If this is non-null, it will * have been atomically linked into the table. */ #define DN_HASHBITS 6 #define DN_HASHMAX (1<ref.refcount, &auth_domain_lock)) { hlist_del(&dom->hash); dom->flavour->domain_release(dom); spin_unlock(&auth_domain_lock); } } EXPORT_SYMBOL_GPL(auth_domain_put); struct auth_domain * auth_domain_lookup(char *name, struct auth_domain *new) { struct auth_domain *hp; struct hlist_head *head; head = &auth_domain_table[hash_str(name, DN_HASHBITS)]; spin_lock(&auth_domain_lock); hlist_for_each_entry(hp, head, hash) { if (strcmp(hp->name, name)==0) { kref_get(&hp->ref); spin_unlock(&auth_domain_lock); return hp; } } if (new) hlist_add_head(&new->hash, head); spin_unlock(&auth_domain_lock); return new; } EXPORT_SYMBOL_GPL(auth_domain_lookup); struct auth_domain *auth_domain_find(char *name) { return auth_domain_lookup(name, NULL); } EXPORT_SYMBOL_GPL(auth_domain_find); ='4'>4space:mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2016-12-18 14:35:45 +0100
committerDaniel Vetter <daniel.vetter@ffwll.ch>2017-01-30 10:17:17 +0100
commit4e5b54f127426c82dc2816340c26d951a5bb3429 (patch)
treecc3a8f7e335cf12880bc8d1a1e2066f6cfe0a68e /net/dccp/ccids
parent566cf877a1fcb6d6dc0126b076aad062054c2637 (diff)
drm: prevent double-(un)registration for connectors
If we're unlucky then the registration from a hotplugged connector might race with the final registration step on driver load. And since MST topology discover is asynchronous that's even somewhat likely. v2: Also update the kerneldoc for @registered! v3: Review from Chris: - Improve kerneldoc for late_register/early_unregister callbacks. - Use mutex_destroy. Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Sean Paul <seanpaul@chromium.org> Reported-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/20161218133545.2106-1-daniel.vetter@ffwll.ch (cherry picked from commit e73ab00e9a0f1731f34d0620a9c55f5c30c4ad4e)
Diffstat (limited to 'net/dccp/ccids')