diff options
-rw-r--r-- | sys/arch/amd64/amd64/aesni.c | 10 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/via.c | 8 | ||||
-rw-r--r-- | sys/arch/i386/i386/via.c | 8 | ||||
-rw-r--r-- | sys/arch/i386/pci/glxsb.c | 8 | ||||
-rw-r--r-- | sys/crypto/cmac.c | 4 | ||||
-rw-r--r-- | sys/crypto/crypto.c | 4 | ||||
-rw-r--r-- | sys/crypto/cryptosoft.c | 29 | ||||
-rw-r--r-- | sys/crypto/hmac.c | 14 | ||||
-rw-r--r-- | sys/crypto/key_wrap.c | 6 | ||||
-rw-r--r-- | sys/crypto/md5.c | 4 | ||||
-rw-r--r-- | sys/crypto/rmd160.c | 4 | ||||
-rw-r--r-- | sys/crypto/sha2.c | 8 | ||||
-rw-r--r-- | sys/crypto/xform.c | 18 | ||||
-rw-r--r-- | sys/dev/pci/ubsec.c | 10 | ||||
-rw-r--r-- | sys/net/if_spppsubr.c | 11 | ||||
-rw-r--r-- | sys/net80211/ieee80211_crypto.c | 10 | ||||
-rw-r--r-- | sys/netinet/ip_ah.c | 4 | ||||
-rw-r--r-- | sys/netinet/ip_esp.c | 6 | ||||
-rw-r--r-- | sys/netinet/tcp_subr.c | 4 | ||||
-rw-r--r-- | sys/uvm/uvm_swap_encrypt.c | 6 |
20 files changed, 95 insertions, 81 deletions
diff --git a/sys/arch/amd64/amd64/aesni.c b/sys/arch/amd64/amd64/aesni.c index a8adc77bcfc..afb6e593fd3 100644 --- a/sys/arch/amd64/amd64/aesni.c +++ b/sys/arch/amd64/amd64/aesni.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aesni.c,v 1.17 2010/12/15 23:34:23 mikeb Exp $ */ +/* $OpenBSD: aesni.c,v 1.18 2011/01/11 15:42:05 deraadt Exp $ */ /*- * Copyright (c) 2003 Jason Wright * Copyright (c) 2003, 2004 Theo de Raadt @@ -265,11 +265,11 @@ aesni_freesession(u_int64_t tid) axf = swd->sw_axf; if (swd->sw_ictx) { - bzero(swd->sw_ictx, axf->ctxsize); + explicit_bzero(swd->sw_ictx, axf->ctxsize); free(swd->sw_ictx, M_CRYPTO_DATA); } if (swd->sw_octx) { - bzero(swd->sw_octx, axf->ctxsize); + explicit_bzero(swd->sw_octx, axf->ctxsize); free(swd->sw_octx, M_CRYPTO_DATA); } free(swd, M_CRYPTO_DATA); @@ -311,7 +311,7 @@ aesni_encdec(struct cryptop *crp, struct cryptodesc *crd, if (crd->crd_len > aesni_sc->sc_buflen) { if (buf != NULL) { - bzero(buf, aesni_sc->sc_buflen); + explicit_bzero(buf, aesni_sc->sc_buflen); free(buf, M_DEVBUF); } @@ -399,7 +399,7 @@ aesni_encdec(struct cryptop *crp, struct cryptodesc *crd, crd->crd_len, buf); out: - bzero(buf, roundup(crd->crd_len, EALG_MAX_BLOCK_LEN)); + explicit_bzero(buf, roundup(crd->crd_len, EALG_MAX_BLOCK_LEN)); return (err); } diff --git a/sys/arch/amd64/amd64/via.c b/sys/arch/amd64/amd64/via.c index 3f1a3985db6..45a245b18b8 100644 --- a/sys/arch/amd64/amd64/via.c +++ b/sys/arch/amd64/amd64/via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: via.c,v 1.8 2010/12/15 23:34:23 mikeb Exp $ */ +/* $OpenBSD: via.c,v 1.9 2011/01/11 15:42:05 deraadt Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -302,11 +302,11 @@ viac3_crypto_freesession(u_int64_t tid) axf = swd->sw_axf; if (swd->sw_ictx) { - bzero(swd->sw_ictx, axf->ctxsize); + explicit_bzero(swd->sw_ictx, axf->ctxsize); free(swd->sw_ictx, M_CRYPTO_DATA); } if (swd->sw_octx) { - bzero(swd->sw_octx, axf->ctxsize); + explicit_bzero(swd->sw_octx, axf->ctxsize); free(swd->sw_octx, M_CRYPTO_DATA); } free(swd, M_CRYPTO_DATA); @@ -427,7 +427,7 @@ viac3_crypto_encdec(struct cryptop *crp, struct cryptodesc *crd, crd->crd_len); if (sc->op_buf != NULL) { - bzero(sc->op_buf, crd->crd_len); + explicit_bzero(sc->op_buf, crd->crd_len); free(sc->op_buf, M_DEVBUF); sc->op_buf = NULL; } diff --git a/sys/arch/i386/i386/via.c b/sys/arch/i386/i386/via.c index 19650e3b92f..351091a7580 100644 --- a/sys/arch/i386/i386/via.c +++ b/sys/arch/i386/i386/via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: via.c,v 1.25 2010/12/15 23:34:23 mikeb Exp $ */ +/* $OpenBSD: via.c,v 1.26 2011/01/11 15:42:04 deraadt Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -303,11 +303,11 @@ viac3_crypto_freesession(u_int64_t tid) axf = swd->sw_axf; if (swd->sw_ictx) { - bzero(swd->sw_ictx, axf->ctxsize); + explicit_bzero(swd->sw_ictx, axf->ctxsize); free(swd->sw_ictx, M_CRYPTO_DATA); } if (swd->sw_octx) { - bzero(swd->sw_octx, axf->ctxsize); + explicit_bzero(swd->sw_octx, axf->ctxsize); free(swd->sw_octx, M_CRYPTO_DATA); } free(swd, M_CRYPTO_DATA); @@ -428,7 +428,7 @@ viac3_crypto_encdec(struct cryptop *crp, struct cryptodesc *crd, crd->crd_len); if (sc->op_buf != NULL) { - bzero(sc->op_buf, crd->crd_len); + explicit_bzero(sc->op_buf, crd->crd_len); free(sc->op_buf, M_DEVBUF); sc->op_buf = NULL; } diff --git a/sys/arch/i386/pci/glxsb.c b/sys/arch/i386/pci/glxsb.c index 51c5cec9970..a3e4d6685f4 100644 --- a/sys/arch/i386/pci/glxsb.c +++ b/sys/arch/i386/pci/glxsb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: glxsb.c,v 1.21 2010/12/15 23:34:23 mikeb Exp $ */ +/* $OpenBSD: glxsb.c,v 1.22 2011/01/11 15:42:05 deraadt Exp $ */ /* * Copyright (c) 2006 Tom Cosgrove <tom@openbsd.org> @@ -522,11 +522,11 @@ glxsb_crypto_freesession(uint64_t tid) axf = swd->sw_axf; if (swd->sw_ictx) { - bzero(swd->sw_ictx, axf->ctxsize); + explicit_bzero(swd->sw_ictx, axf->ctxsize); free(swd->sw_ictx, M_CRYPTO_DATA); } if (swd->sw_octx) { - bzero(swd->sw_octx, axf->ctxsize); + explicit_bzero(swd->sw_octx, axf->ctxsize); free(swd->sw_octx, M_CRYPTO_DATA); } free(swd, M_CRYPTO_DATA); @@ -749,7 +749,7 @@ glxsb_crypto_encdec(struct cryptop *crp, struct cryptodesc *crd, } /* All AES processing has now been done. */ - bzero(sc->sc_dma.dma_vaddr, xlen * 2); + explicit_bzero(sc->sc_dma.dma_vaddr, xlen * 2); out: return (err); diff --git a/sys/crypto/cmac.c b/sys/crypto/cmac.c index 81ab6af204c..366f30f5749 100644 --- a/sys/crypto/cmac.c +++ b/sys/crypto/cmac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmac.c,v 1.1 2008/08/12 15:43:00 damien Exp $ */ +/* $OpenBSD: cmac.c,v 1.2 2011/01/11 15:42:05 deraadt Exp $ */ /*- * Copyright (c) 2008 Damien Bergamini <damien.bergamini@free.fr> @@ -116,5 +116,5 @@ AES_CMAC_Final(u_int8_t digest[AES_CMAC_DIGEST_LENGTH], AES_CMAC_CTX *ctx) XOR(ctx->M_last, ctx->X); rijndael_encrypt(&ctx->rijndael, ctx->X, digest); - memset(K, 0, sizeof K); + explicit_bzero(K, sizeof K); } diff --git a/sys/crypto/crypto.c b/sys/crypto/crypto.c index f30bf32f6b9..434c70309b2 100644 --- a/sys/crypto/crypto.c +++ b/sys/crypto/crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.c,v 1.58 2010/09/08 14:15:56 jsing Exp $ */ +/* $OpenBSD: crypto.c,v 1.59 2011/01/11 15:42:05 deraadt Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) * @@ -201,7 +201,7 @@ crypto_freesession(u_int64_t sid) */ if ((crypto_drivers[hid].cc_flags & CRYPTOCAP_F_CLEANUP) && crypto_drivers[hid].cc_sessions == 0) - bzero(&crypto_drivers[hid], sizeof(struct cryptocap)); + explicit_bzero(&crypto_drivers[hid], sizeof(struct cryptocap)); splx(s); return err; diff --git a/sys/crypto/cryptosoft.c b/sys/crypto/cryptosoft.c index 8ab270b8607..197cf2c1404 100644 --- a/sys/crypto/cryptosoft.c +++ b/sys/crypto/cryptosoft.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cryptosoft.c,v 1.59 2010/12/22 00:55:45 deraadt Exp $ */ +/* $OpenBSD: cryptosoft.c,v 1.60 2011/01/11 15:42:05 deraadt Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) @@ -293,7 +293,7 @@ swcr_encdec(struct cryptodesc *crd, struct swcr_data *sw, caddr_t buf, */ if (uio->uio_iov[ind].iov_len < k + blks && uio->uio_iov[ind].iov_len != k) { - cuio_copydata(uio, k, blks, blk); + cuio_copydata(uio, count, blks, blk); /* Actual encryption/decryption */ if (exf->reinit) { @@ -334,7 +334,7 @@ swcr_encdec(struct cryptodesc *crd, struct swcr_data *sw, caddr_t buf, } /* Copy back decrypted block */ - cuio_copyback(uio, k, blks, blk); + cuio_copyback(uio, count, blks, blk); count += blks; @@ -395,6 +395,19 @@ swcr_encdec(struct cryptodesc *crd, struct swcr_data *sw, caddr_t buf, k += blks; i -= blks; } + + /* + * Advance to the next iov if the end of the current iov + * is aligned with the end of a cipher block. + * Note that the code is equivalent to calling: + * ind = cuio_getptr(uio, count, &k); + */ + if (i > 0 && k == uio->uio_iov[ind].iov_len) { + k = 0; + ind++; + if (ind >= uio->uio_iovcnt) + return (EINVAL); + } } } @@ -984,11 +997,11 @@ swcr_freesession(u_int64_t tid) axf = swd->sw_axf; if (swd->sw_ictx) { - bzero(swd->sw_ictx, axf->ctxsize); + explicit_bzero(swd->sw_ictx, axf->ctxsize); free(swd->sw_ictx, M_CRYPTO_DATA); } if (swd->sw_octx) { - bzero(swd->sw_octx, axf->ctxsize); + explicit_bzero(swd->sw_octx, axf->ctxsize); free(swd->sw_octx, M_CRYPTO_DATA); } break; @@ -998,11 +1011,11 @@ swcr_freesession(u_int64_t tid) axf = swd->sw_axf; if (swd->sw_ictx) { - bzero(swd->sw_ictx, axf->ctxsize); + explicit_bzero(swd->sw_ictx, axf->ctxsize); free(swd->sw_ictx, M_CRYPTO_DATA); } if (swd->sw_octx) { - bzero(swd->sw_octx, swd->sw_klen); + explicit_bzero(swd->sw_octx, swd->sw_klen); free(swd->sw_octx, M_CRYPTO_DATA); } break; @@ -1015,7 +1028,7 @@ swcr_freesession(u_int64_t tid) axf = swd->sw_axf; if (swd->sw_ictx) { - bzero(swd->sw_ictx, axf->ctxsize); + explicit_bzero(swd->sw_ictx, axf->ctxsize); free(swd->sw_ictx, M_CRYPTO_DATA); } break; diff --git a/sys/crypto/hmac.c b/sys/crypto/hmac.c index 0922af34b79..118f9a760d9 100644 --- a/sys/crypto/hmac.c +++ b/sys/crypto/hmac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hmac.c,v 1.2 2008/09/06 22:23:20 djm Exp $ */ +/* $OpenBSD: hmac.c,v 1.3 2011/01/11 15:42:05 deraadt Exp $ */ /*- * Copyright (c) 2008 Damien Bergamini <damien.bergamini@free.fr> @@ -53,7 +53,7 @@ HMAC_MD5_Init(HMAC_MD5_CTX *ctx, const u_int8_t *key, u_int key_len) MD5Init(&ctx->ctx); MD5Update(&ctx->ctx, k_ipad, MD5_BLOCK_LENGTH); - bzero(k_ipad, sizeof k_ipad); + explicit_bzero(k_ipad, sizeof k_ipad); } void @@ -80,7 +80,7 @@ HMAC_MD5_Final(u_int8_t digest[MD5_DIGEST_LENGTH], HMAC_MD5_CTX *ctx) MD5Update(&ctx->ctx, digest, MD5_DIGEST_LENGTH); MD5Final(digest, &ctx->ctx); - bzero(k_opad, sizeof k_opad); + explicit_bzero(k_opad, sizeof k_opad); } void @@ -107,7 +107,7 @@ HMAC_SHA1_Init(HMAC_SHA1_CTX *ctx, const u_int8_t *key, u_int key_len) SHA1Init(&ctx->ctx); SHA1Update(&ctx->ctx, k_ipad, SHA1_BLOCK_LENGTH); - bzero(k_ipad, sizeof k_ipad); + explicit_bzero(k_ipad, sizeof k_ipad); } void @@ -134,7 +134,7 @@ HMAC_SHA1_Final(u_int8_t digest[SHA1_DIGEST_LENGTH], HMAC_SHA1_CTX *ctx) SHA1Update(&ctx->ctx, digest, SHA1_DIGEST_LENGTH); SHA1Final(digest, &ctx->ctx); - bzero(k_opad, sizeof k_opad); + explicit_bzero(k_opad, sizeof k_opad); } void @@ -161,7 +161,7 @@ HMAC_SHA256_Init(HMAC_SHA256_CTX *ctx, const u_int8_t *key, u_int key_len) SHA256Init(&ctx->ctx); SHA256Update(&ctx->ctx, k_ipad, SHA256_BLOCK_LENGTH); - bzero(k_ipad, sizeof k_ipad); + explicit_bzero(k_ipad, sizeof k_ipad); } void @@ -188,5 +188,5 @@ HMAC_SHA256_Final(u_int8_t digest[SHA256_DIGEST_LENGTH], HMAC_SHA256_CTX *ctx) SHA256Update(&ctx->ctx, digest, SHA256_DIGEST_LENGTH); SHA256Final(digest, &ctx->ctx); - bzero(k_opad, sizeof k_opad); + explicit_bzero(k_opad, sizeof k_opad); } diff --git a/sys/crypto/key_wrap.c b/sys/crypto/key_wrap.c index b9009ad54b3..4605bd6b3e7 100644 --- a/sys/crypto/key_wrap.c +++ b/sys/crypto/key_wrap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key_wrap.c,v 1.2 2010/07/20 15:36:03 matthew Exp $ */ +/* $OpenBSD: key_wrap.c,v 1.3 2011/01/11 15:42:05 deraadt Exp $ */ /*- * Copyright (c) 2008 Damien Bergamini <damien.bergamini@free.fr> @@ -72,7 +72,7 @@ aes_key_wrap(aes_key_wrap_ctx *ctx, const u_int8_t *P, size_t n, u_int8_t *C) R += 8; } } - memset(B, 0, sizeof B); + explicit_bzero(B, sizeof B); } int @@ -105,7 +105,7 @@ aes_key_unwrap(aes_key_wrap_ctx *ctx, const u_int8_t *C, u_int8_t *P, size_t n) R -= 8; } } - memset(B, 0, sizeof B); + explicit_bzero(B, sizeof B); /* check that A is an appropriate initial value */ return timingsafe_bcmp(A, IV, 8) != 0; diff --git a/sys/crypto/md5.c b/sys/crypto/md5.c index a9b9ffac8db..ac90af873e4 100644 --- a/sys/crypto/md5.c +++ b/sys/crypto/md5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: md5.c,v 1.1 2004/05/07 14:42:26 millert Exp $ */ +/* $OpenBSD: md5.c,v 1.2 2011/01/11 15:42:05 deraadt Exp $ */ /* * This code implements the MD5 message-digest algorithm. @@ -121,7 +121,7 @@ MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5_CTX *ctx) for (i = 0; i < 4; i++) PUT_32BIT_LE(digest + i * 4, ctx->state[i]); } - bzero(ctx, sizeof(*ctx)); /* in case it's sensitive */ + explicit_bzero(ctx, sizeof(*ctx)); /* in case it's sensitive */ } diff --git a/sys/crypto/rmd160.c b/sys/crypto/rmd160.c index b627a61f375..e2af9ace7a0 100644 --- a/sys/crypto/rmd160.c +++ b/sys/crypto/rmd160.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rmd160.c,v 1.4 2003/12/14 11:22:35 markus Exp $ */ +/* $OpenBSD: rmd160.c,v 1.5 2011/01/11 15:42:05 deraadt Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -150,7 +150,7 @@ RMD160Final(u_char digest[20], RMD160_CTX *ctx) for (i = 0; i < 5; i++) PUT_32BIT_LE(digest + i*4, ctx->state[i]); - memset(ctx, 0, sizeof (*ctx)); + explicit_bzero(ctx, sizeof (*ctx)); } void diff --git a/sys/crypto/sha2.c b/sys/crypto/sha2.c index bca331f1e64..01a8e4d1bfe 100644 --- a/sys/crypto/sha2.c +++ b/sys/crypto/sha2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sha2.c,v 1.7 2008/09/06 22:23:20 djm Exp $ */ +/* $OpenBSD: sha2.c,v 1.8 2011/01/11 15:42:05 deraadt Exp $ */ /* * FILE: sha2.c @@ -548,7 +548,7 @@ SHA256Final(u_int8_t digest[], SHA2_CTX *context) } /* Clean up state data: */ - bzero(context, sizeof(*context)); + explicit_bzero(context, sizeof(*context)); usedspace = 0; } @@ -844,7 +844,7 @@ SHA512Final(u_int8_t digest[], SHA2_CTX *context) } /* Zero out state data */ - bzero(context, sizeof(*context)); + explicit_bzero(context, sizeof(*context)); } @@ -892,5 +892,5 @@ SHA384Final(u_int8_t digest[], SHA2_CTX *context) } /* Zero out state data */ - bzero(context, sizeof(*context)); + explicit_bzero(context, sizeof(*context)); } diff --git a/sys/crypto/xform.c b/sys/crypto/xform.c index daacd682737..f35a2b8ed80 100644 --- a/sys/crypto/xform.c +++ b/sys/crypto/xform.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xform.c,v 1.40 2010/10/06 22:19:20 mikeb Exp $ */ +/* $OpenBSD: xform.c,v 1.41 2011/01/11 15:42:05 deraadt Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr), @@ -386,7 +386,7 @@ des1_setkey(u_int8_t **sched, u_int8_t *key, int len) void des1_zerokey(u_int8_t **sched) { - bzero(*sched, 128); + explicit_bzero(*sched, 128); free(*sched, M_CRYPTO_DATA); *sched = NULL; } @@ -420,7 +420,7 @@ des3_setkey(u_int8_t **sched, u_int8_t *key, int len) void des3_zerokey(u_int8_t **sched) { - bzero(*sched, 384); + explicit_bzero(*sched, 384); free(*sched, M_CRYPTO_DATA); *sched = NULL; } @@ -449,7 +449,7 @@ blf_setkey(u_int8_t **sched, u_int8_t *key, int len) void blf_zerokey(u_int8_t **sched) { - bzero(*sched, sizeof(blf_ctx)); + explicit_bzero(*sched, sizeof(blf_ctx)); free(*sched, M_CRYPTO_DATA); *sched = NULL; } @@ -499,7 +499,7 @@ cast5_setkey(u_int8_t **sched, u_int8_t *key, int len) void cast5_zerokey(u_int8_t **sched) { - bzero(*sched, sizeof(cast_key)); + explicit_bzero(*sched, sizeof(cast_key)); free(*sched, M_CRYPTO_DATA); *sched = NULL; } @@ -533,7 +533,7 @@ rijndael128_setkey(u_int8_t **sched, u_int8_t *key, int len) void rijndael128_zerokey(u_int8_t **sched) { - bzero(*sched, sizeof(rijndael_ctx)); + explicit_bzero(*sched, sizeof(rijndael_ctx)); free(*sched, M_CRYPTO_DATA); *sched = NULL; } @@ -615,7 +615,7 @@ aes_ctr_setkey(u_int8_t **sched, u_int8_t *key, int len) void aes_ctr_zerokey(u_int8_t **sched) { - bzero(*sched, sizeof(struct aes_ctr_ctx)); + explicit_bzero(*sched, sizeof(struct aes_ctr_ctx)); free(*sched, M_CRYPTO_DATA); *sched = NULL; } @@ -678,7 +678,7 @@ aes_xts_crypt(struct aes_xts_ctx *ctx, u_int8_t *data, u_int do_encrypt) } if (carry_in) ctx->tweak[0] ^= AES_XTS_ALPHA; - bzero(block, sizeof(block)); + explicit_bzero(block, sizeof(block)); } void @@ -714,7 +714,7 @@ aes_xts_setkey(u_int8_t **sched, u_int8_t *key, int len) void aes_xts_zerokey(u_int8_t **sched) { - bzero(*sched, sizeof(struct aes_xts_ctx)); + explicit_bzero(*sched, sizeof(struct aes_xts_ctx)); free(*sched, M_CRYPTO_DATA); *sched = NULL; } diff --git a/sys/dev/pci/ubsec.c b/sys/dev/pci/ubsec.c index 1311358e826..9837aed5e9f 100644 --- a/sys/dev/pci/ubsec.c +++ b/sys/dev/pci/ubsec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ubsec.c,v 1.148 2010/12/15 23:34:23 mikeb Exp $ */ +/* $OpenBSD: ubsec.c,v 1.149 2011/01/11 15:42:05 deraadt Exp $ */ /* * Copyright (c) 2000 Jason L. Wright (jason@thought.net) @@ -1604,10 +1604,10 @@ ubsec_callback2(struct ubsec_softc *sc, struct ubsec_q2 *q) crypto_kdone(krp); /* bzero all potentially sensitive data */ - bzero(me->me_E.dma_vaddr, me->me_E.dma_size); - bzero(me->me_M.dma_vaddr, me->me_M.dma_size); - bzero(me->me_C.dma_vaddr, me->me_C.dma_size); - bzero(me->me_q.q_ctx.dma_vaddr, me->me_q.q_ctx.dma_size); + explicit_bzero(me->me_E.dma_vaddr, me->me_E.dma_size); + explicit_bzero(me->me_M.dma_vaddr, me->me_M.dma_size); + explicit_bzero(me->me_C.dma_vaddr, me->me_C.dma_size); + explicit_bzero(me->me_q.q_ctx.dma_vaddr, me->me_q.q_ctx.dma_size); /* Can't free here, so put us on the free list. */ SIMPLEQ_INSERT_TAIL(&sc->sc_q2free, &me->me_q, q_next); diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c index 6b5cd37ac03..86478c2bdb8 100644 --- a/sys/net/if_spppsubr.c +++ b/sys/net/if_spppsubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_spppsubr.c,v 1.83 2010/11/17 19:25:49 henning Exp $ */ +/* $OpenBSD: if_spppsubr.c,v 1.84 2011/01/11 15:42:05 deraadt Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. * Keepalive protocol implemented in both Cisco and PPP modes. @@ -4945,9 +4945,10 @@ sppp_get_params(struct sppp *sp, struct ifreq *ifr) spr->cmd = cmd; bcopy(sp, &spr->defs, sizeof(struct sppp)); - bzero(&spr->defs.myauth, sizeof(spr->defs.myauth)); - bzero(&spr->defs.hisauth, sizeof(spr->defs.hisauth)); - bzero(&spr->defs.chap_challenge, sizeof(spr->defs.chap_challenge)); + explicit_bzero(&spr->defs.myauth, sizeof(spr->defs.myauth)); + explicit_bzero(&spr->defs.hisauth, sizeof(spr->defs.hisauth)); + explicit_bzero(&spr->defs.chap_challenge, + sizeof(spr->defs.chap_challenge)); if (copyout(spr, (caddr_t)ifr->ifr_data, sizeof(*spr)) != 0) { free(spr, M_DEVBUF); @@ -5069,7 +5070,7 @@ sppp_set_params(struct sppp *sp, struct ifreq *ifr) if (auth->secret != NULL) free(auth->secret, M_DEVBUF); bzero(auth, sizeof *auth); - bzero(sp->chap_challenge, sizeof sp->chap_challenge); + explicit_bzero(sp->chap_challenge, sizeof sp->chap_challenge); } else { /* setting/changing auth */ auth->proto = spa->proto; diff --git a/sys/net80211/ieee80211_crypto.c b/sys/net80211/ieee80211_crypto.c index 28afffa824c..a2a4461d07e 100644 --- a/sys/net80211/ieee80211_crypto.c +++ b/sys/net80211/ieee80211_crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_crypto.c,v 1.59 2010/07/20 15:36:03 matthew Exp $ */ +/* $OpenBSD: ieee80211_crypto.c,v 1.60 2011/01/11 15:42:05 deraadt Exp $ */ /*- * Copyright (c) 2008 Damien Bergamini <damien.bergamini@free.fr> @@ -87,7 +87,7 @@ ieee80211_crypto_detach(struct ifnet *ifp) /* purge the PMKSA cache */ while ((pmk = TAILQ_FIRST(&ic->ic_pmksa)) != NULL) { TAILQ_REMOVE(&ic->ic_pmksa, pmk, pmk_next); - memset(pmk, 0, sizeof(*pmk)); + explicit_bzero(pmk, sizeof(*pmk)); free(pmk, M_DEVBUF); } @@ -96,11 +96,11 @@ ieee80211_crypto_detach(struct ifnet *ifp) struct ieee80211_key *k = &ic->ic_nw_keys[i]; if (k->k_cipher != IEEE80211_CIPHER_NONE) (*ic->ic_delete_key)(ic, NULL, k); - memset(k, 0, sizeof(*k)); + explicit_bzero(k, sizeof(*k)); } /* clear pre-shared key from memory */ - memset(ic->ic_psk, 0, IEEE80211_PMK_LEN); + explicit_bzero(ic->ic_psk, IEEE80211_PMK_LEN); } /* @@ -174,7 +174,7 @@ ieee80211_delete_key(struct ieee80211com *ic, struct ieee80211_node *ni, /* should not get there */ break; } - memset(k, 0, sizeof(*k)); + explicit_bzero(k, sizeof(*k)); } struct ieee80211_key * diff --git a/sys/netinet/ip_ah.c b/sys/netinet/ip_ah.c index 013c0fdb9ad..0d0d4b62cb4 100644 --- a/sys/netinet/ip_ah.c +++ b/sys/netinet/ip_ah.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ah.c,v 1.98 2010/07/20 15:36:03 matthew Exp $ */ +/* $OpenBSD: ip_ah.c,v 1.99 2011/01/11 15:42:05 deraadt Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -178,7 +178,7 @@ ah_zeroize(struct tdb *tdbp) int err; if (tdbp->tdb_amxkey) { - bzero(tdbp->tdb_amxkey, tdbp->tdb_amxkeylen); + explicit_bzero(tdbp->tdb_amxkey, tdbp->tdb_amxkeylen); free(tdbp->tdb_amxkey, M_XDATA); tdbp->tdb_amxkey = NULL; } diff --git a/sys/netinet/ip_esp.c b/sys/netinet/ip_esp.c index dc3705b3c7c..86b056bfff9 100644 --- a/sys/netinet/ip_esp.c +++ b/sys/netinet/ip_esp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_esp.c,v 1.115 2010/12/21 14:45:57 markus Exp $ */ +/* $OpenBSD: ip_esp.c,v 1.116 2011/01/11 15:42:05 deraadt Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -297,13 +297,13 @@ esp_zeroize(struct tdb *tdbp) int err; if (tdbp->tdb_amxkey) { - bzero(tdbp->tdb_amxkey, tdbp->tdb_amxkeylen); + explicit_bzero(tdbp->tdb_amxkey, tdbp->tdb_amxkeylen); free(tdbp->tdb_amxkey, M_XDATA); tdbp->tdb_amxkey = NULL; } if (tdbp->tdb_emxkey) { - bzero(tdbp->tdb_emxkey, tdbp->tdb_emxkeylen); + explicit_bzero(tdbp->tdb_emxkey, tdbp->tdb_emxkeylen); free(tdbp->tdb_emxkey, M_XDATA); tdbp->tdb_emxkey = NULL; } diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 3d04fac05ef..2f10358d2f2 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_subr.c,v 1.111 2010/07/03 04:44:51 guenther Exp $ */ +/* $OpenBSD: tcp_subr.c,v 1.112 2011/01/11 15:42:05 deraadt Exp $ */ /* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */ /* @@ -1041,7 +1041,7 @@ tcp_signature_tdb_zeroize(tdbp) struct tdb *tdbp; { if (tdbp->tdb_amxkey) { - bzero(tdbp->tdb_amxkey, tdbp->tdb_amxkeylen); + explicit_bzero(tdbp->tdb_amxkey, tdbp->tdb_amxkeylen); free(tdbp->tdb_amxkey, M_XDATA); tdbp->tdb_amxkey = NULL; } diff --git a/sys/uvm/uvm_swap_encrypt.c b/sys/uvm/uvm_swap_encrypt.c index 85f5332385f..4400a1aeaca 100644 --- a/sys/uvm/uvm_swap_encrypt.c +++ b/sys/uvm/uvm_swap_encrypt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_swap_encrypt.c,v 1.16 2010/04/20 22:05:44 tedu Exp $ */ +/* $OpenBSD: uvm_swap_encrypt.c,v 1.17 2011/01/11 15:42:06 deraadt Exp $ */ /* * Copyright 1999 Niels Provos <provos@citi.umich.edu> @@ -95,7 +95,7 @@ swap_key_delete(struct swap_key *key) /* Make sure that this key gets removed if we just used it */ swap_key_cleanup(key); - memset(key, 0, sizeof(*key)); + explicit_bzero(key, sizeof(*key)); uvm_swpkeysdeleted++; } @@ -223,7 +223,7 @@ swap_key_cleanup(struct swap_key *key) return; /* Zero out the subkeys */ - memset(&swap_ctxt, 0, sizeof(swap_ctxt)); + explicit_bzero(&swap_ctxt, sizeof(swap_ctxt)); kcur = NULL; } |