diff options
| author | riastradh <riastradh@NetBSD.org> | 2022-05-22 11:40:03 +0000 |
|---|---|---|
| committer | riastradh <riastradh@NetBSD.org> | 2022-05-22 11:40:03 +0000 |
| commit | e551848a610c4f86473cae62adbc842f4e446e6f (patch) | |
| tree | f7f5b5983b74970ae5cf2497fc64ed2fe23f485d /sys/opencrypto | |
| parent | b546167f902315f9d15a0ac5b531e7985fb9314a (diff) | |
opencrypto: Rip out EAGAIN logic when unregistering crypto drivers.
I'm pretty sure this never worked reliably based on code inspection,
and it's unlikely to have ever been tested because it only applies
when unregistering a driver -- but we have no crypto drivers for
removable devices, so it would only apply if we went out of our way
to trigger detach with drvctl.
Instead, just make the operation fail with ENODEV, and remove all the
callback logic to resubmit the request on EAGAIN. (Maybe this should
be ENXIO, but crypto_kdispatch already does ENODEV.)
Diffstat (limited to 'sys/opencrypto')
| -rw-r--r-- | sys/opencrypto/crypto.c | 27 | ||||
| -rw-r--r-- | sys/opencrypto/cryptodev.c | 22 | ||||
| -rw-r--r-- | sys/opencrypto/cryptodev.h | 4 |
3 files changed, 12 insertions, 41 deletions
diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c index 9750eeb9932..43a6053461d 100644 --- a/sys/opencrypto/crypto.c +++ b/sys/opencrypto/crypto.c @@ -1,4 +1,4 @@ -/* $NetBSD: crypto.c,v 1.126 2022/05/22 11:39:54 riastradh Exp $ */ +/* $NetBSD: crypto.c,v 1.127 2022/05/22 11:40:03 riastradh Exp $ */ /* $FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $ */ /* $OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $ */ @@ -53,7 +53,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.126 2022/05/22 11:39:54 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.127 2022/05/22 11:40:03 riastradh Exp $"); #include <sys/param.h> #include <sys/reboot.h> @@ -1569,26 +1569,11 @@ crypto_invoke(struct cryptop *crp, int hint) crypto_driver_unlock(cap); return (*process)(arg, crp, hint); } else { - struct cryptodesc *crd; - u_int64_t nid = 0; - - if (cap != NULL) + if (cap != NULL) { crypto_driver_unlock(cap); - - /* - * Driver has unregistered; migrate the session and return - * an error to the caller so they'll resubmit the op. - */ - crypto_freesession(crp->crp_sid); - - for (crd = crp->crp_desc; crd->crd_next; crd = crd->crd_next) - crd->CRD_INI.cri_next = &(crd->crd_next->CRD_INI); - - if (crypto_newsession(&nid, &(crp->crp_desc->CRD_INI), 0) == 0) - crp->crp_sid = nid; - - crp->crp_etype = EAGAIN; - + crypto_freesession(crp->crp_sid); + } + crp->crp_etype = ENODEV; crypto_done(crp); return 0; } diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index ef296b19a07..dfc9f581141 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -1,4 +1,4 @@ -/* $NetBSD: cryptodev.c,v 1.121 2022/05/22 11:39:45 riastradh Exp $ */ +/* $NetBSD: cryptodev.c,v 1.122 2022/05/22 11:40:03 riastradh Exp $ */ /* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */ /* $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $ */ @@ -64,7 +64,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.121 2022/05/22 11:39:45 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.122 2022/05/22 11:40:03 riastradh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -718,16 +718,9 @@ static void cryptodev_cb(struct cryptop *crp) { struct csession *cse = crp->crp_opaque; - int error; - - if ((error = crp->crp_etype) == EAGAIN) { - error = crypto_dispatch(crp); - if (error == 0) - return; - } mutex_enter(&cryptodev_mtx); - cse->error = error; + cse->error = crp->crp_etype; crp->crp_devflags |= CRYPTODEV_F_RET; cv_signal(&crp->crp_cv); mutex_exit(&cryptodev_mtx); @@ -737,16 +730,9 @@ static void cryptodev_mcb(struct cryptop *crp) { struct csession *cse = crp->crp_opaque; - int error; - - if ((error = crp->crp_etype) == EAGAIN) { - error = crypto_dispatch(crp); - if (error == 0) - return; - } mutex_enter(&cryptodev_mtx); - cse->error = error; + cse->error = crp->crp_etype; TAILQ_INSERT_TAIL(&crp->fcrp->crp_ret_mq, crp, crp_next); selnotify(&crp->fcrp->sinfo, 0, 0); mutex_exit(&cryptodev_mtx); diff --git a/sys/opencrypto/cryptodev.h b/sys/opencrypto/cryptodev.h index cf3e25905a2..283c85af1cc 100644 --- a/sys/opencrypto/cryptodev.h +++ b/sys/opencrypto/cryptodev.h @@ -1,4 +1,4 @@ -/* $NetBSD: cryptodev.h,v 1.48 2022/05/22 11:39:37 riastradh Exp $ */ +/* $NetBSD: cryptodev.h,v 1.49 2022/05/22 11:40:03 riastradh Exp $ */ /* $FreeBSD: src/sys/opencrypto/cryptodev.h,v 1.2.2.6 2003/07/02 17:04:50 sam Exp $ */ /* $OpenBSD: cryptodev.h,v 1.33 2002/07/17 23:52:39 art Exp $ */ @@ -453,7 +453,7 @@ struct cryptop { int crp_etype; /* * Error type (zero means no error). - * All error codes except EAGAIN + * All error codes * indicate possible data corruption (as in, * the data have been touched). On all * errors, the crp_sid may have changed |
