summaryrefslogtreecommitdiff
path: root/sys/dev/pci/ubsec.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2011-01-12 20:55:23 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2011-01-12 20:55:23 +0000
commit63d57c5f334d114ba67ba6396f5f26582f886b89 (patch)
tree7137e16106f5194750a07ed8e3cbc2a43ef7c1f8 /sys/dev/pci/ubsec.c
parentaaef7b6e981151d61c98a86c55d6f638feec1554 (diff)
A bunch more explicit_bzero calls for key material
ubsec tested by mikeb, hifn tested by kettenis ok mikeb
Diffstat (limited to 'sys/dev/pci/ubsec.c')
-rw-r--r--sys/dev/pci/ubsec.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/sys/dev/pci/ubsec.c b/sys/dev/pci/ubsec.c
index 9837aed5e9f..89151d9cfba 100644
--- a/sys/dev/pci/ubsec.c
+++ b/sys/dev/pci/ubsec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ubsec.c,v 1.149 2011/01/11 15:42:05 deraadt Exp $ */
+/* $OpenBSD: ubsec.c,v 1.150 2011/01/12 20:55:22 deraadt Exp $ */
/*
* Copyright (c) 2000 Jason L. Wright (jason@thought.net)
@@ -699,7 +699,7 @@ ubsec_newsession(u_int32_t *sidp, struct cryptoini *cri)
return (ENOMEM);
bcopy(sc->sc_sessions, ses, sesn *
sizeof(struct ubsec_session));
- bzero(sc->sc_sessions, sesn *
+ explicit_bzero(sc->sc_sessions, sesn *
sizeof(struct ubsec_session));
free(sc->sc_sessions, M_DEVBUF);
sc->sc_sessions = ses;
@@ -798,7 +798,7 @@ ubsec_freesession(u_int64_t tid)
return (EINVAL);
sc = ubsec_cd.cd_devs[card];
session = UBSEC_SESSION(sid);
- bzero(&sc->sc_sessions[session], sizeof(sc->sc_sessions[session]));
+ explicit_bzero(&sc->sc_sessions[session], sizeof(sc->sc_sessions[session]));
return (0);
}
@@ -1370,6 +1370,7 @@ ubsec_process(struct cryptop *crp)
ubsecstats.hst_ibytes += dmap->d_alloc.dma_map->dm_mapsize;
ubsec_feed(sc);
splx(s);
+ explicit_bzero(&key, sizeof(key));
return (0);
errout:
@@ -1397,6 +1398,7 @@ errout:
errout2:
crp->crp_etype = err;
crypto_done(crp);
+ explicit_bzero(&key, sizeof(key));
return (0);
}
@@ -1406,6 +1408,9 @@ ubsec_callback(struct ubsec_softc *sc, struct ubsec_q *q)
struct cryptop *crp = (struct cryptop *)q->q_crp;
struct cryptodesc *crd;
struct ubsec_dma *dmap = q->q_dma;
+ u_int8_t *ctx = (u_int8_t *)(dmap->d_alloc.dma_vaddr +
+ offsetof(struct ubsec_dmachunk, d_ctx));
+ struct ubsec_pktctx_hdr *ph = (struct ubsec_pktctx_hdr *)ctx;
ubsecstats.hst_opackets++;
ubsecstats.hst_obytes += dmap->d_alloc.dma_size;
@@ -1424,6 +1429,8 @@ ubsec_callback(struct ubsec_softc *sc, struct ubsec_q *q)
bus_dmamap_unload(sc->sc_dmat, q->q_src_map);
bus_dmamap_destroy(sc->sc_dmat, q->q_src_map);
+ explicit_bzero(ctx, ph->ph_len);
+
if ((crp->crp_flags & CRYPTO_F_IMBUF) && (q->q_src_m != q->q_dst_m)) {
m_freem(q->q_src_m);
crp->crp_buf = (caddr_t)q->q_dst_m;
@@ -1629,9 +1636,9 @@ ubsec_callback2(struct ubsec_softc *sc, struct ubsec_q2 *q)
crypto_kdone(krp);
- bzero(rp->rpr_msgin.dma_vaddr, rp->rpr_msgin.dma_size);
- bzero(rp->rpr_msgout.dma_vaddr, rp->rpr_msgout.dma_size);
- bzero(rp->rpr_q.q_ctx.dma_vaddr, rp->rpr_q.q_ctx.dma_size);
+ explicit_bzero(rp->rpr_msgin.dma_vaddr, rp->rpr_msgin.dma_size);
+ explicit_bzero(rp->rpr_msgout.dma_vaddr, rp->rpr_msgout.dma_size);
+ explicit_bzero(rp->rpr_q.q_ctx.dma_vaddr, rp->rpr_q.q_ctx.dma_size);
/* Can't free here, so put us on the free list. */
SIMPLEQ_INSERT_TAIL(&sc->sc_q2free, &rp->rpr_q, q_next);
@@ -2189,19 +2196,20 @@ errout:
if (me->me_q.q_mcr.dma_map != NULL)
ubsec_dma_free(sc, &me->me_q.q_mcr);
if (me->me_q.q_ctx.dma_map != NULL) {
- bzero(me->me_q.q_ctx.dma_vaddr, me->me_q.q_ctx.dma_size);
+ explicit_bzero(me->me_q.q_ctx.dma_vaddr,
+ me->me_q.q_ctx.dma_size);
ubsec_dma_free(sc, &me->me_q.q_ctx);
}
if (me->me_M.dma_map != NULL) {
- bzero(me->me_M.dma_vaddr, me->me_M.dma_size);
+ explicit_bzero(me->me_M.dma_vaddr, me->me_M.dma_size);
ubsec_dma_free(sc, &me->me_M);
}
if (me->me_E.dma_map != NULL) {
- bzero(me->me_E.dma_vaddr, me->me_E.dma_size);
+ explicit_bzero(me->me_E.dma_vaddr, me->me_E.dma_size);
ubsec_dma_free(sc, &me->me_E);
}
if (me->me_C.dma_map != NULL) {
- bzero(me->me_C.dma_vaddr, me->me_C.dma_size);
+ explicit_bzero(me->me_C.dma_vaddr, me->me_C.dma_size);
ubsec_dma_free(sc, &me->me_C);
}
if (me->me_epb.dma_map != NULL)
@@ -2387,19 +2395,20 @@ errout:
if (me->me_q.q_mcr.dma_map != NULL)
ubsec_dma_free(sc, &me->me_q.q_mcr);
if (me->me_q.q_ctx.dma_map != NULL) {
- bzero(me->me_q.q_ctx.dma_vaddr, me->me_q.q_ctx.dma_size);
+ explicit_bzero(me->me_q.q_ctx.dma_vaddr,
+ me->me_q.q_ctx.dma_size);
ubsec_dma_free(sc, &me->me_q.q_ctx);
}
if (me->me_M.dma_map != NULL) {
- bzero(me->me_M.dma_vaddr, me->me_M.dma_size);
+ explicit_bzero(me->me_M.dma_vaddr, me->me_M.dma_size);
ubsec_dma_free(sc, &me->me_M);
}
if (me->me_E.dma_map != NULL) {
- bzero(me->me_E.dma_vaddr, me->me_E.dma_size);
+ explicit_bzero(me->me_E.dma_vaddr, me->me_E.dma_size);
ubsec_dma_free(sc, &me->me_E);
}
if (me->me_C.dma_map != NULL) {
- bzero(me->me_C.dma_vaddr, me->me_C.dma_size);
+ explicit_bzero(me->me_C.dma_vaddr, me->me_C.dma_size);
ubsec_dma_free(sc, &me->me_C);
}
if (me->me_epb.dma_map != NULL)
@@ -2581,11 +2590,13 @@ errout:
if (rp->rpr_q.q_mcr.dma_map != NULL)
ubsec_dma_free(sc, &rp->rpr_q.q_mcr);
if (rp->rpr_msgin.dma_map != NULL) {
- bzero(rp->rpr_msgin.dma_vaddr, rp->rpr_msgin.dma_size);
+ explicit_bzero(rp->rpr_msgin.dma_vaddr,
+ rp->rpr_msgin.dma_size);
ubsec_dma_free(sc, &rp->rpr_msgin);
}
if (rp->rpr_msgout.dma_map != NULL) {
- bzero(rp->rpr_msgout.dma_vaddr, rp->rpr_msgout.dma_size);
+ explicit_bzero(rp->rpr_msgout.dma_vaddr,
+ rp->rpr_msgout.dma_size);
ubsec_dma_free(sc, &rp->rpr_msgout);
}
free(rp, M_DEVBUF);