diff options
author | rmacklem <rmacklem@FreeBSD.org> | 2012-12-18 00:25:48 +0000 |
---|---|---|
committer | rmacklem <rmacklem@FreeBSD.org> | 2012-12-18 00:25:48 +0000 |
commit | a41d1bc642641e36d620138f93f484921d361bce (patch) | |
tree | 1a528b7e5e6224c7d6841c880e1617f1b61ec29e /sys/kgssapi/gss_acquire_cred.c | |
parent | 17649eee7d94c9b2e7885ee9119c83cef611a8e4 (diff) | |
download | FreeBSD-src-a41d1bc642641e36d620138f93f484921d361bce.zip FreeBSD-src-a41d1bc642641e36d620138f93f484921d361bce.tar.gz |
Piete.Brooks at cl.cam.ac.uk reported via email a crash which was
caused by use of an invalid kgss_gssd_handle during an upcall to
the gssd daemon when it has exited. This patch seems to avoid the
crashes by holding a reference count on the kgss_gssd_handle until
the upcall is done. It also adds a new mutex kgss_gssd_lock used to
make manipulation of kgss_gssd_handle SMP safe.
Tested by: Illias A. Marinos, Herbert Poeckl
Reviewed by: jhb
MFC after: 2 weeks
Diffstat (limited to 'sys/kgssapi/gss_acquire_cred.c')
-rw-r--r-- | sys/kgssapi/gss_acquire_cred.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/kgssapi/gss_acquire_cred.c b/sys/kgssapi/gss_acquire_cred.c index e5fe821..4a5f115 100644 --- a/sys/kgssapi/gss_acquire_cred.c +++ b/sys/kgssapi/gss_acquire_cred.c @@ -31,7 +31,9 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/kernel.h> #include <sys/kobj.h> +#include <sys/lock.h> #include <sys/malloc.h> +#include <sys/mutex.h> #include <sys/proc.h> #include <kgssapi/gssapi.h> @@ -55,8 +57,11 @@ gss_acquire_cred(OM_uint32 *minor_status, enum clnt_stat stat; gss_cred_id_t cred; int i; + CLIENT *cl; - if (!kgss_gssd_handle) + *minor_status = 0; + cl = kgss_gssd_client(); + if (cl == NULL) return (GSS_S_FAILURE); args.uid = curthread->td_ucred->cr_uid; @@ -69,7 +74,8 @@ gss_acquire_cred(OM_uint32 *minor_status, args.cred_usage = cred_usage; bzero(&res, sizeof(res)); - stat = gssd_acquire_cred_1(&args, &res, kgss_gssd_handle); + stat = gssd_acquire_cred_1(&args, &res, cl); + CLNT_RELEASE(cl); if (stat != RPC_SUCCESS) { *minor_status = stat; return (GSS_S_FAILURE); @@ -80,7 +86,6 @@ gss_acquire_cred(OM_uint32 *minor_status, return (res.major_status); } - *minor_status = 0; cred = malloc(sizeof(struct _gss_cred_id_t), M_GSSAPI, M_WAITOK); cred->handle = res.output_cred; *output_cred_handle = cred; |