diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2012-01-13 09:53:25 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2012-01-13 09:53:25 +0000 |
commit | 5d33e89a6956aa9eba1522836d491556f72848b5 (patch) | |
tree | 5e050a3d5a3d4ed5e6844a3a0ad68c3bb4568817 /sys | |
parent | ffe459cb7def60bf29c44f2c53b5c82ca24713e2 (diff) |
handle m_copyback errors, this code is too sensitive for such
failures to be neglected; ok markus
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/amd64/via.c | 8 | ||||
-rw-r--r-- | sys/arch/i386/i386/via.c | 6 | ||||
-rw-r--r-- | sys/arch/i386/pci/glxsb.c | 10 | ||||
-rw-r--r-- | sys/dev/pci/hifn7751.c | 16 | ||||
-rw-r--r-- | sys/dev/pci/safe.c | 9 | ||||
-rw-r--r-- | sys/dev/pci/ubsec.c | 8 |
6 files changed, 39 insertions, 18 deletions
diff --git a/sys/arch/amd64/amd64/via.c b/sys/arch/amd64/amd64/via.c index 2dbc9305235..b6ac5c47522 100644 --- a/sys/arch/amd64/amd64/via.c +++ b/sys/arch/amd64/amd64/via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: via.c,v 1.11 2011/04/20 06:51:34 deraadt Exp $ */ +/* $OpenBSD: via.c,v 1.12 2012/01/13 09:53:24 mikeb Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -376,7 +376,7 @@ viac3_crypto_encdec(struct cryptop *crp, struct cryptodesc *crd, if ((crd->crd_flags & CRD_F_IV_PRESENT) == 0) { if (crp->crp_flags & CRYPTO_F_IMBUF) - m_copyback((struct mbuf *)crp->crp_buf, + err = m_copyback((struct mbuf *)crp->crp_buf, crd->crd_inject, 16, sc->op_iv, M_NOWAIT); else if (crp->crp_flags & CRYPTO_F_IOV) cuio_copyback((struct uio *)crp->crp_buf, @@ -384,6 +384,8 @@ viac3_crypto_encdec(struct cryptop *crp, struct cryptodesc *crd, else bcopy(sc->op_iv, crp->crp_buf + crd->crd_inject, 16); + if (err) + return (err); } } else { sc->op_cw[0] = ses->ses_cw0 | C3_CRYPT_CWLO_DECRYPT; @@ -417,7 +419,7 @@ viac3_crypto_encdec(struct cryptop *crp, struct cryptodesc *crd, crd->crd_len / 16, sc->op_iv); if (crp->crp_flags & CRYPTO_F_IMBUF) - m_copyback((struct mbuf *)crp->crp_buf, + err = m_copyback((struct mbuf *)crp->crp_buf, crd->crd_skip, crd->crd_len, sc->op_buf, M_NOWAIT); else if (crp->crp_flags & CRYPTO_F_IOV) cuio_copyback((struct uio *)crp->crp_buf, diff --git a/sys/arch/i386/i386/via.c b/sys/arch/i386/i386/via.c index f3c8823f559..534257fbc7a 100644 --- a/sys/arch/i386/i386/via.c +++ b/sys/arch/i386/i386/via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: via.c,v 1.28 2011/04/20 06:51:35 deraadt Exp $ */ +/* $OpenBSD: via.c,v 1.29 2012/01/13 09:53:24 mikeb Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -377,7 +377,7 @@ viac3_crypto_encdec(struct cryptop *crp, struct cryptodesc *crd, if ((crd->crd_flags & CRD_F_IV_PRESENT) == 0) { if (crp->crp_flags & CRYPTO_F_IMBUF) - m_copyback((struct mbuf *)crp->crp_buf, + err = m_copyback((struct mbuf *)crp->crp_buf, crd->crd_inject, 16, sc->op_iv, M_NOWAIT); else if (crp->crp_flags & CRYPTO_F_IOV) cuio_copyback((struct uio *)crp->crp_buf, @@ -385,6 +385,8 @@ viac3_crypto_encdec(struct cryptop *crp, struct cryptodesc *crd, else bcopy(sc->op_iv, crp->crp_buf + crd->crd_inject, 16); + if (err) + return (err); } } else { sc->op_cw[0] = ses->ses_cw0 | C3_CRYPT_CWLO_DECRYPT; diff --git a/sys/arch/i386/pci/glxsb.c b/sys/arch/i386/pci/glxsb.c index f0d7565c2ec..241053e8a71 100644 --- a/sys/arch/i386/pci/glxsb.c +++ b/sys/arch/i386/pci/glxsb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: glxsb.c,v 1.23 2011/01/12 17:15:23 deraadt Exp $ */ +/* $OpenBSD: glxsb.c,v 1.24 2012/01/13 09:53:24 mikeb Exp $ */ /* * Copyright (c) 2006 Tom Cosgrove <tom@openbsd.org> @@ -673,7 +673,7 @@ glxsb_crypto_encdec(struct cryptop *crp, struct cryptodesc *crd, if ((crd->crd_flags & CRD_F_IV_PRESENT) == 0) { if (crp->crp_flags & CRYPTO_F_IMBUF) - m_copyback((struct mbuf *)crp->crp_buf, + err = m_copyback((struct mbuf *)crp->crp_buf, crd->crd_inject, sizeof(op_iv), op_iv, M_NOWAIT); else if (crp->crp_flags & CRYPTO_F_IOV) @@ -682,6 +682,8 @@ glxsb_crypto_encdec(struct cryptop *crp, struct cryptodesc *crd, else bcopy(op_iv, crp->crp_buf + crd->crd_inject, sizeof(op_iv)); + if (err) + goto out; } } else { control = SB_CTL_DEC; @@ -725,7 +727,7 @@ glxsb_crypto_encdec(struct cryptop *crp, struct cryptodesc *crd, glxsb_dma_post_op(sc, &sc->sc_dma); if (crp->crp_flags & CRYPTO_F_IMBUF) - m_copyback((struct mbuf *)crp->crp_buf, + err = m_copyback((struct mbuf *)crp->crp_buf, crd->crd_skip + offset, len, op_dst, M_NOWAIT); else if (crp->crp_flags & CRYPTO_F_IOV) cuio_copyback((struct uio *)crp->crp_buf, @@ -733,6 +735,8 @@ glxsb_crypto_encdec(struct cryptop *crp, struct cryptodesc *crd, else bcopy(op_dst, crp->crp_buf + crd->crd_skip + offset, len); + if (err) + break; offset += len; tlen -= len; diff --git a/sys/dev/pci/hifn7751.c b/sys/dev/pci/hifn7751.c index c2143f0f5e5..1bfe3959c5f 100644 --- a/sys/dev/pci/hifn7751.c +++ b/sys/dev/pci/hifn7751.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hifn7751.c,v 1.166 2011/04/05 11:48:28 blambert Exp $ */ +/* $OpenBSD: hifn7751.c,v 1.167 2012/01/13 09:53:24 mikeb Exp $ */ /* * Invertex AEON / Hifn 7751 driver @@ -2076,13 +2076,16 @@ hifn_process(struct cryptop *crp) if ((enccrd->crd_flags & CRD_F_IV_PRESENT) == 0) { if (crp->crp_flags & CRYPTO_F_IMBUF) - m_copyback(cmd->srcu.src_m, + err = + m_copyback(cmd->srcu.src_m, enccrd->crd_inject, ivlen, cmd->iv, M_NOWAIT); else if (crp->crp_flags & CRYPTO_F_IOV) cuio_copyback(cmd->srcu.src_io, enccrd->crd_inject, ivlen, cmd->iv); + if (err) + goto errout; } } else { if (enccrd->crd_flags & CRD_F_IV_EXPLICIT) @@ -2290,7 +2293,8 @@ hifn_callback(struct hifn_softc *sc, struct hifn_command *cmd, if (cmd->sloplen != 0) { if (crp->crp_flags & CRYPTO_F_IMBUF) - m_copyback((struct mbuf *)crp->crp_buf, + crp->crp_etype = + m_copyback((struct mbuf *)crp->crp_buf, cmd->src_map->dm_mapsize - cmd->sloplen, cmd->sloplen, &dma->slop[cmd->slopidx], M_NOWAIT); @@ -2298,6 +2302,8 @@ hifn_callback(struct hifn_softc *sc, struct hifn_command *cmd, cuio_copyback((struct uio *)crp->crp_buf, cmd->src_map->dm_mapsize - cmd->sloplen, cmd->sloplen, &dma->slop[cmd->slopidx]); + if (crp->crp_etype) + goto out; } i = dma->dstk; u = dma->dstu; @@ -2343,7 +2349,8 @@ hifn_callback(struct hifn_softc *sc, struct hifn_command *cmd, continue; if (crp->crp_flags & CRYPTO_F_IMBUF) - m_copyback((struct mbuf *)crp->crp_buf, + crp->crp_etype = + m_copyback((struct mbuf *)crp->crp_buf, crd->crd_inject, len, macbuf, M_NOWAIT); else if ((crp->crp_flags & CRYPTO_F_IOV) && crp->crp_mac) bcopy((caddr_t)macbuf, crp->crp_mac, len); @@ -2351,6 +2358,7 @@ hifn_callback(struct hifn_softc *sc, struct hifn_command *cmd, } } +out: if (cmd->src_map != cmd->dst_map) { bus_dmamap_unload(sc->sc_dmat, cmd->dst_map); bus_dmamap_destroy(sc->sc_dmat, cmd->dst_map); diff --git a/sys/dev/pci/safe.c b/sys/dev/pci/safe.c index 436caa04ac0..4b3441b2b17 100644 --- a/sys/dev/pci/safe.c +++ b/sys/dev/pci/safe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: safe.c,v 1.33 2011/04/05 11:48:28 blambert Exp $ */ +/* $OpenBSD: safe.c,v 1.34 2012/01/13 09:53:24 mikeb Exp $ */ /*- * Copyright (c) 2003 Sam Leffler, Errno Consulting @@ -476,12 +476,14 @@ safe_process(struct cryptop *crp) if ((enccrd->crd_flags & CRD_F_IV_PRESENT) == 0) { if (crp->crp_flags & CRYPTO_F_IMBUF) - m_copyback(re->re_src_m, + err = m_copyback(re->re_src_m, enccrd->crd_inject, ivsize, iv, M_NOWAIT); else if (crp->crp_flags & CRYPTO_F_IOV) cuio_copyback(re->re_src_io, enccrd->crd_inject, ivsize, iv); + if (err) + goto errout; } for (i = 0; i < ivsize / sizeof(iv[0]); i++) re->re_sastate.sa_saved_iv[i] = htole32(iv[i]); @@ -1689,7 +1691,8 @@ safe_callback(struct safe_softc *sc, struct safe_ringentry *re) bswap32(re->re_sastate.sa_saved_indigest[2]); } if (crp->crp_flags & CRYPTO_F_IMBUF) { - m_copyback((struct mbuf *)crp->crp_buf, + crp->crp_etype = + m_copyback((struct mbuf *)crp->crp_buf, crd->crd_inject, 12, (caddr_t)re->re_sastate.sa_saved_indigest, M_NOWAIT); diff --git a/sys/dev/pci/ubsec.c b/sys/dev/pci/ubsec.c index 5fa1bd59a3f..2abd2abfd06 100644 --- a/sys/dev/pci/ubsec.c +++ b/sys/dev/pci/ubsec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ubsec.c,v 1.153 2011/05/06 17:55:00 mikeb Exp $ */ +/* $OpenBSD: ubsec.c,v 1.154 2012/01/13 09:53:24 mikeb Exp $ */ /* * Copyright (c) 2000 Jason L. Wright (jason@thought.net) @@ -949,13 +949,15 @@ ubsec_process(struct cryptop *crp) if ((enccrd->crd_flags & CRD_F_IV_PRESENT) == 0) { if (crp->crp_flags & CRYPTO_F_IMBUF) - m_copyback(q->q_src_m, + err = m_copyback(q->q_src_m, enccrd->crd_inject, ivlen, key.ses_iv, M_NOWAIT); else if (crp->crp_flags & CRYPTO_F_IOV) cuio_copyback(q->q_src_io, enccrd->crd_inject, ivlen, key.ses_iv); + if (err) + goto errout; } } else { flags |= htole16(UBS_PKTCTX_INBOUND); @@ -1443,7 +1445,7 @@ ubsec_callback(struct ubsec_softc *sc, struct ubsec_q *q) crd->crd_alg != CRYPTO_SHA1_HMAC) continue; if (crp->crp_flags & CRYPTO_F_IMBUF) - m_copyback((struct mbuf *)crp->crp_buf, + crp->crp_etype = m_copyback((struct mbuf *)crp->crp_buf, crd->crd_inject, 12, dmap->d_dma->d_macbuf, M_NOWAIT); else if (crp->crp_flags & CRYPTO_F_IOV && crp->crp_mac) |