git: 8191ad0c0302 - stable/13 - crypto: Validate return values from CRYPTODEV_PROCESS()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 15 Jul 2022 16:34:03 UTC
The branch stable/13 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=8191ad0c03023872a59354a8c542453273a06da8
commit 8191ad0c03023872a59354a8c542453273a06da8
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-07-01 15:09:39 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-07-15 16:33:49 +0000
crypto: Validate return values from CRYPTODEV_PROCESS()
Errors are always handled by the completion callback, so we should check
that they're not also passed back to the caller.
No functional change intended.
Reviewed by: kp, mav, jhb
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 99df914899f56efe63afd9e0fef79148fa6ca162)
---
sys/opencrypto/crypto.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c
index c9ba66650807..c28f0ff72a43 100644
--- a/sys/opencrypto/crypto.c
+++ b/sys/opencrypto/crypto.c
@@ -1731,6 +1731,7 @@ crypto_task_invoke(void *ctx, int pending)
static int
crypto_invoke(struct cryptocap *cap, struct cryptop *crp, int hint)
{
+ int error;
KASSERT(crp != NULL, ("%s: crp == NULL", __func__));
KASSERT(crp->crp_callback != NULL,
@@ -1779,13 +1780,19 @@ crypto_invoke(struct cryptocap *cap, struct cryptop *crp, int hint)
crp->crp_etype = EAGAIN;
crypto_done(crp);
- return 0;
+ error = 0;
} else {
/*
- * Invoke the driver to process the request.
+ * Invoke the driver to process the request. Errors are
+ * signaled by setting crp_etype before invoking the completion
+ * callback.
*/
- return CRYPTODEV_PROCESS(cap->cc_dev, crp, hint);
+ error = CRYPTODEV_PROCESS(cap->cc_dev, crp, hint);
+ KASSERT(error == 0 || error == ERESTART,
+ ("%s: invalid error %d from CRYPTODEV_PROCESS",
+ __func__, error));
}
+ return (error);
}
void