aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2026-07-27 15:36:22 +0000
committerMark Johnston <markj@FreeBSD.org>2026-07-29 17:45:02 +0000
commit98bbfef2ea33a42b7f06ad3a64c892108ede8871 (patch)
tree99a4ab7effce8dcbc49d5f8722148a5cf818a9e8
parentd8bdcb08d0ebe8cdc7f589cf05283882bff94d3a (diff)
OCF: Add a fail point to inject EBADMSG decryption errors
Approved by: so Security: FreeBSD-SA-26:52.if_wg Security: CVE-2026-58085 Reviewed by: markj Sponsored by: Chelsio Communications
-rw-r--r--sys/opencrypto/crypto.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c
index c3ae5e8a9ff8..9fa017902a19 100644
--- a/sys/opencrypto/crypto.c
+++ b/sys/opencrypto/crypto.c
@@ -61,6 +61,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/counter.h>
+#include <sys/fail.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
#include <sys/linker.h>
@@ -145,6 +146,9 @@ static struct mtx crypto_q_mtx;
SYSCTL_NODE(_kern, OID_AUTO, crypto, CTLFLAG_RW, 0,
"In-kernel cryptography");
+static SYSCTL_NODE(_debug_fail_point, OID_AUTO, crypto, CTLFLAG_RW, 0,
+ "OCF fail points");
+
/*
* Taskqueue used to dispatch the crypto requests submitted with
* crypto_dispatch_async .
@@ -1666,6 +1670,17 @@ crypto_clonereq(struct cryptop *crp, crypto_session_t cses, int how)
void
crypto_done(struct cryptop *crp)
{
+ if (crp->crp_etype == 0) {
+ switch (crp->crp_session->csp.csp_mode) {
+ case CSP_MODE_DIGEST:
+ case CSP_MODE_AEAD:
+ if ((crp->crp_op & CRYPTO_OP_VERIFY_DIGEST) != 0)
+ KFAIL_POINT_CODE(_debug_fail_point_crypto,
+ inject_badmsg, crp->crp_etype = EBADMSG);
+ break;
+ }
+ }
+
if (crp->crp_etype != 0)
CRYPTOSTAT_INC(cs_errs);