cregit-Linux how code gets into the kernel

Release 4.11 net/sunrpc/svcauth.c

Directory: net/sunrpc
/*
 * linux/net/sunrpc/svcauth.c
 *
 * The generic interface for RPC authentication on the server side.
 *
 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
 *
 * CHANGES
 * 19-Apr-2000 Chris Evans      - Security fix
 */

#include <linux/types.h>
#include <linux/module.h>
#include <linux/sunrpc/types.h>
#include <linux/sunrpc/xdr.h>
#include <linux/sunrpc/svcsock.h>
#include <linux/sunrpc/svcauth.h>
#include <linux/err.h>
#include <linux/hash.h>


#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); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)6247.33%110.00%
Neil Brown5138.93%440.00%
J. Bruce Fields1410.69%220.00%
Alexey Dobriyan21.53%220.00%
Chuck Lever21.53%110.00%
Total131100.00%10100.00%

EXPORT_SYMBOL_GPL(svc_authenticate);
int svc_set_client(struct svc_rqst *rqstp) { rqstp->rq_client = NULL; return rqstp->rq_authop->set_client(rqstp); }

Contributors

PersonTokensPropCommitsCommitProp
Neil Brown2076.92%150.00%
J. Bruce Fields623.08%150.00%
Total26100.00%2100.00%

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; }

Contributors

PersonTokensPropCommitsCommitProp
Neil Brown5498.18%266.67%
Linus Torvalds (pre-git)11.82%133.33%
Total55100.00%3100.00%


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; }

Contributors

PersonTokensPropCommitsCommitProp
Neil Brown3456.67%250.00%
Linus Torvalds (pre-git)2440.00%125.00%
Chuck Lever23.33%125.00%
Total60100.00%4100.00%

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); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)1957.58%133.33%
Neil Brown1236.36%133.33%
Chuck Lever26.06%133.33%
Total33100.00%3100.00%

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<<DN_HASHBITS) static struct hlist_head auth_domain_table[DN_HASHMAX]; static DEFINE_SPINLOCK(auth_domain_lock);
static void auth_domain_release(struct kref *kref) { struct auth_domain *dom = container_of(kref, struct auth_domain, ref); hlist_del(&dom->hash); dom->flavour->domain_release(dom); spin_unlock(&auth_domain_lock); }

Contributors

PersonTokensPropCommitsCommitProp
Neil Brown2244.90%240.00%
Peter Zijlstra1632.65%120.00%
Akinobu Mita612.24%120.00%
Linus Torvalds (pre-git)510.20%120.00%
Total49100.00%5100.00%


void auth_domain_put(struct auth_domain *dom) { kref_put_lock(&dom->ref, auth_domain_release, &auth_domain_lock); }

Contributors

PersonTokensPropCommitsCommitProp
Peter Zijlstra2295.65%150.00%
Linus Torvalds (pre-git)14.35%150.00%
Total23100.00%2100.00%

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; }

Contributors

PersonTokensPropCommitsCommitProp
Neil Brown10898.18%583.33%
Linus Torvalds (pre-git)21.82%116.67%
Total110100.00%6100.00%

EXPORT_SYMBOL_GPL(auth_domain_lookup);
struct auth_domain *auth_domain_find(char *name) { return auth_domain_lookup(name, NULL); }

Contributors

PersonTokensPropCommitsCommitProp
Neil Brown1894.74%375.00%
Linus Torvalds (pre-git)15.26%125.00%
Total19100.00%4100.00%

EXPORT_SYMBOL_GPL(auth_domain_find);

Overall Contributors

PersonTokensPropCommitsCommitProp
Neil Brown37558.96%1140.74%
Linus Torvalds (pre-git)14322.48%13.70%
Peter Zijlstra416.45%27.41%
Trond Myklebust314.87%27.41%
J. Bruce Fields203.14%27.41%
Chuck Lever71.10%13.70%
Akinobu Mita60.94%13.70%
Thomas Gleixner40.63%13.70%
Dave Jones30.47%13.70%
Fabian Frederick20.31%13.70%
Alexey Dobriyan20.31%27.41%
Hideaki Yoshifuji / 吉藤英明10.16%13.70%
Michael Opdenacker10.16%13.70%
Total636100.00%27100.00%
Directory: net/sunrpc
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.