From c90c9c4f6d44f2b7aa74cddc16ead5e27ee0e53b Mon Sep 17 00:00:00 2001 From: fcambus Date: Sun, 24 Dec 2017 16:19:27 +0000 Subject: [PATCH] Somes fixes for the VIA PadLock drivers. - Do not ignore the return value of m_copyback() on i386 - Always free sc->op_buf before returning on both amd64 and i386, pointed out by mikeb@, thanks! OK mikeb@ --- sys/arch/amd64/amd64/via.c | 5 +++-- sys/arch/i386/i386/via.c | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/arch/amd64/amd64/via.c b/sys/arch/amd64/amd64/via.c index d65eb5a3747..c0e1e540b12 100644 --- a/sys/arch/amd64/amd64/via.c +++ b/sys/arch/amd64/amd64/via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: via.c,v 1.25 2017/11/14 13:09:22 fcambus Exp $ */ +/* $OpenBSD: via.c,v 1.26 2017/12/24 16:19:27 fcambus Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -366,7 +366,7 @@ viac3_crypto_encdec(struct cryptop *crp, struct cryptodesc *crd, memcpy(crp->crp_buf + crd->crd_inject, sc->op_iv, 16); if (err) - return (err); + goto errout; } } else { sc->op_cw[0] = ses->ses_cw0 | C3_CRYPT_CWLO_DECRYPT; @@ -409,6 +409,7 @@ viac3_crypto_encdec(struct cryptop *crp, struct cryptodesc *crd, memcpy(crp->crp_buf + crd->crd_skip, sc->op_buf, crd->crd_len); + errout: if (sc->op_buf != NULL) { explicit_bzero(sc->op_buf, crd->crd_len); free(sc->op_buf, M_DEVBUF, crd->crd_len); diff --git a/sys/arch/i386/i386/via.c b/sys/arch/i386/i386/via.c index 7f2686391ce..45a729c1a68 100644 --- a/sys/arch/i386/i386/via.c +++ b/sys/arch/i386/i386/via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: via.c,v 1.38 2017/12/14 09:14:30 fcambus Exp $ */ +/* $OpenBSD: via.c,v 1.39 2017/12/24 16:19:27 fcambus Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -385,7 +385,7 @@ viac3_crypto_encdec(struct cryptop *crp, struct cryptodesc *crd, memcpy(crp->crp_buf + crd->crd_inject, sc->op_iv, 16); if (err) - return (err); + goto errout; } } else { sc->op_cw[0] = ses->ses_cw0 | C3_CRYPT_CWLO_DECRYPT; @@ -419,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, @@ -428,6 +428,7 @@ viac3_crypto_encdec(struct cryptop *crp, struct cryptodesc *crd, memcpy(crp->crp_buf + crd->crd_skip, sc->op_buf, crd->crd_len); + errout: if (sc->op_buf != NULL) { explicit_bzero(sc->op_buf, crd->crd_len); free(sc->op_buf, M_DEVBUF, crd->crd_len); -- 2.20.1