Module Name: src Committed By: drochner Date: Thu Feb 10 21:00:42 UTC 2011
Modified Files: src/sys/opencrypto: cryptosoft.c cryptosoft.h Log Message: Don't store temporary values in the opencrypto session data struct which can be shared by multiple threads -- pass them on the stack instead. Add some "const" to document this. (One _could_ use the session struct for temporary stuff with proper locking, but it seems unnecessary here.) Also remove the unused SW_crc member in the session struct. >From Wolfgang Stukenbrock per PR kern/44472. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/opencrypto/cryptosoft.c cvs rdiff -u -r1.6 -r1.7 src/sys/opencrypto/cryptosoft.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/opencrypto/cryptosoft.c diff -u src/sys/opencrypto/cryptosoft.c:1.26 src/sys/opencrypto/cryptosoft.c:1.27 --- src/sys/opencrypto/cryptosoft.c:1.26 Mon Aug 2 19:59:35 2010 +++ src/sys/opencrypto/cryptosoft.c Thu Feb 10 21:00:42 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cryptosoft.c,v 1.26 2010/08/02 19:59:35 jakllsch Exp $ */ +/* $NetBSD: cryptosoft.c,v 1.27 2011/02/10 21:00:42 drochner Exp $ */ /* $FreeBSD: src/sys/opencrypto/cryptosoft.c,v 1.2.2.1 2002/11/21 23:34:23 sam Exp $ */ /* $OpenBSD: cryptosoft.c,v 1.35 2002/04/26 08:43:50 deraadt Exp $ */ @@ -24,7 +24,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.26 2010/08/02 19:59:35 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.27 2011/02/10 21:00:42 drochner Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -60,8 +60,8 @@ (x) == CRYPTO_BUF_MBUF ? m_copydata((struct mbuf *)a,b,c,d) \ : cuio_copydata((struct uio *)a,b,c,d) -static int swcr_encdec(struct cryptodesc *, struct swcr_data *, void *, int); -static int swcr_compdec(struct cryptodesc *, struct swcr_data *, void *, int); +static int swcr_encdec(struct cryptodesc *, const struct swcr_data *, void *, int); +static int swcr_compdec(struct cryptodesc *, const struct swcr_data *, void *, int, int *); static int swcr_process(void *, struct cryptop *, int); static int swcr_newsession(void *, u_int32_t *, struct cryptoini *); static int swcr_freesession(void *, u_int64_t); @@ -70,7 +70,7 @@ * Apply a symmetric encryption/decryption algorithm. */ static int -swcr_encdec(struct cryptodesc *crd, struct swcr_data *sw, void *bufv, +swcr_encdec(struct cryptodesc *crd, const struct swcr_data *sw, void *bufv, int outtype) { char *buf = bufv; @@ -418,7 +418,7 @@ */ int swcr_authcompute(struct cryptop *crp, struct cryptodesc *crd, - struct swcr_data *sw, void *buf, int outtype) + const struct swcr_data *sw, void *buf, int outtype) { unsigned char aalg[AALG_MAX_RESULT_LEN]; const struct swcr_auth_hash *axf; @@ -512,8 +512,8 @@ * Apply a compression/decompression algorithm */ static int -swcr_compdec(struct cryptodesc *crd, struct swcr_data *sw, - void *buf, int outtype) +swcr_compdec(struct cryptodesc *crd, const struct swcr_data *sw, + void *buf, int outtype, int *res_size) { u_int8_t *data, *out; const struct swcr_comp_algo *cxf; @@ -544,7 +544,7 @@ /* Copy back the (de)compressed data. m_copyback is * extending the mbuf as necessary. */ - sw->sw_size = result; + *res_size = (int)result; /* Check the compressed size when doing compression */ if (crd->crd_flags & CRD_F_COMP) { if (result > crd->crd_len) { @@ -986,10 +986,8 @@ case CRYPTO_GZIP_COMP: DPRINTF(("swcr_process: compdec for %d\n", sw->sw_alg)); if ((crp->crp_etype = swcr_compdec(crd, sw, - crp->crp_buf, type)) != 0) + crp->crp_buf, type, &crp->crp_olen)) != 0) goto done; - else - crp->crp_olen = (int)sw->sw_size; break; default: Index: src/sys/opencrypto/cryptosoft.h diff -u src/sys/opencrypto/cryptosoft.h:1.6 src/sys/opencrypto/cryptosoft.h:1.7 --- src/sys/opencrypto/cryptosoft.h:1.6 Wed Mar 25 01:26:13 2009 +++ src/sys/opencrypto/cryptosoft.h Thu Feb 10 21:00:42 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cryptosoft.h,v 1.6 2009/03/25 01:26:13 darran Exp $ */ +/* $NetBSD: cryptosoft.h,v 1.7 2011/02/10 21:00:42 drochner Exp $ */ /* $OpenBSD: cryptosoft.h,v 1.10 2002/04/22 23:10:09 deraadt Exp $ */ /* @@ -40,8 +40,6 @@ const struct swcr_enc_xform *SW_exf; } SWCR_ENC; struct { - u_int32_t SW_size; - u_int32_t SW_crc; const struct swcr_comp_algo *SW_cxf; } SWCR_COMP; } SWCR_UN; @@ -52,7 +50,6 @@ #define sw_axf SWCR_UN.SWCR_AUTH.SW_axf #define sw_kschedule SWCR_UN.SWCR_ENC.SW_kschedule #define sw_exf SWCR_UN.SWCR_ENC.SW_exf -#define sw_size SWCR_UN.SWCR_COMP.SW_size #define sw_cxf SWCR_UN.SWCR_COMP.SW_cxf struct swcr_data *sw_next; @@ -60,7 +57,7 @@ #ifdef _KERNEL int swcr_authcompute(struct cryptop *crp, struct cryptodesc *crd, - struct swcr_data *sw, void *buf, int outtype); + const struct swcr_data *sw, void *buf, int outtype); #endif /* _KERNEL */ #endif /* _CRYPTO_CRYPTO_H_ */