git: 2fa185f9bf59 - main - crypto: Remove uses of CRYPTO_F_DONE
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 09 May 2025 00:34:09 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=2fa185f9bf5948ead9c3920d452ddd6bcad8f569
commit 2fa185f9bf5948ead9c3920d452ddd6bcad8f569
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-05-09 00:23:40 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-05-09 00:29:23 +0000
crypto: Remove uses of CRYPTO_F_DONE
Previously OCF set CRYPTO_F_DONE prior to invoking the completion
callback, even if the request failed. This isn't particularly useful
and leads to bugs when consumers retry a failed request, since OCF also
asserts that CRYPTO_F_DONE is clear in crypto_dispatch(). (Really, OCF
should retry requests that fail with EAGAIN, but that's a larger
change.)
For now, just stop setting CRYPTO_F_DONE to simplify consumers (and fix
those which fail to clear the flag before retrying a request).
PR: 286321
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D50104
---
share/man/man9/crypto_request.9 | 13 +------------
sys/contrib/openzfs/module/os/freebsd/zfs/crypto_os.c | 1 -
sys/kgssapi/krb5/kcrypto_aes.c | 1 -
sys/opencrypto/crypto.c | 6 ------
sys/opencrypto/cryptodev.c | 2 --
sys/opencrypto/cryptodev.h | 2 +-
sys/opencrypto/ktls_ocf.c | 2 --
sys/sys/param.h | 2 +-
8 files changed, 3 insertions(+), 26 deletions(-)
diff --git a/share/man/man9/crypto_request.9 b/share/man/man9/crypto_request.9
index 45c3b62eea26..af62b9089561 100644
--- a/share/man/man9/crypto_request.9
+++ b/share/man/man9/crypto_request.9
@@ -28,7 +28,7 @@
.\"
.\" * Other names and brands may be claimed as the property of others.
.\"
-.Dd November 2, 2022
+.Dd May 8, 2025
.Dt CRYPTO_REQUEST 9
.Os
.Sh NAME
@@ -466,17 +466,6 @@ Set by drivers prior to completing a request via
.Fn crypto_done .
.It Fa crp_flags
A bitmask of flags.
-The following flags are available in addition to flags discussed previously:
-.Bl -tag -width CRYPTO_F_DONE
-.It Dv CRYPTO_F_DONE
-Set by
-.Fa crypto_done
-before calling
-.Fa crp_callback .
-This flag is not very useful and will likely be removed in the future.
-It can only be safely checked from the callback routine at which point
-it is always set.
-.El
.It Fa crp_cipher_key
Pointer to a request-specific encryption key.
If this value is not set,
diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/crypto_os.c b/sys/contrib/openzfs/module/os/freebsd/zfs/crypto_os.c
index a4bf3fb6490f..0fc2697717af 100644
--- a/sys/contrib/openzfs/module/os/freebsd/zfs/crypto_os.c
+++ b/sys/contrib/openzfs/module/os/freebsd/zfs/crypto_os.c
@@ -196,7 +196,6 @@ zfs_crypto_dispatch(freebsd_crypt_session_t *session, struct cryptop *crp)
break;
}
crp->crp_etype = 0;
- crp->crp_flags &= ~CRYPTO_F_DONE;
session->fs_done = false;
}
return (error);
diff --git a/sys/kgssapi/krb5/kcrypto_aes.c b/sys/kgssapi/krb5/kcrypto_aes.c
index 6761b7c815ad..5675b7e25b93 100644
--- a/sys/kgssapi/krb5/kcrypto_aes.c
+++ b/sys/kgssapi/krb5/kcrypto_aes.c
@@ -126,7 +126,6 @@ aes_crypto_cb(struct cryptop *crp)
if (crp->crp_etype == EAGAIN) {
crp->crp_etype = 0;
- crp->crp_flags &= ~CRYPTO_F_DONE;
(void)crypto_dispatch(crp);
} else {
mtx_lock(&as->as_lock);
diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c
index 3c7299780a38..c3ae5e8a9ff8 100644
--- a/sys/opencrypto/crypto.c
+++ b/sys/opencrypto/crypto.c
@@ -1263,8 +1263,6 @@ crp_sanity(struct cryptop *crp)
crp->crp_obuf.cb_type <= CRYPTO_BUF_LAST,
("incoming crp with invalid output buffer type"));
KASSERT(crp->crp_etype == 0, ("incoming crp with error"));
- KASSERT(!(crp->crp_flags & CRYPTO_F_DONE),
- ("incoming crp already done"));
csp = &crp->crp_session->csp;
cb_sanity(&crp->crp_buf, "input");
@@ -1653,7 +1651,6 @@ crypto_clonereq(struct cryptop *crp, crypto_session_t cses, int how)
{
struct cryptop *new;
- MPASS((crp->crp_flags & CRYPTO_F_DONE) == 0);
new = crypto_getreq(cses, how);
if (new == NULL)
return (NULL);
@@ -1669,9 +1666,6 @@ crypto_clonereq(struct cryptop *crp, crypto_session_t cses, int how)
void
crypto_done(struct cryptop *crp)
{
- KASSERT((crp->crp_flags & CRYPTO_F_DONE) == 0,
- ("crypto_done: op already done, flags 0x%x", crp->crp_flags));
- crp->crp_flags |= CRYPTO_F_DONE;
if (crp->crp_etype != 0)
CRYPTOSTAT_INC(cs_errs);
diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c
index 9341dd60d47e..85b350ca2998 100644
--- a/sys/opencrypto/cryptodev.c
+++ b/sys/opencrypto/cryptodev.c
@@ -823,7 +823,6 @@ again:
if (crp->crp_etype == EAGAIN) {
crp->crp_etype = 0;
- crp->crp_flags &= ~CRYPTO_F_DONE;
cod->done = false;
goto again;
}
@@ -1026,7 +1025,6 @@ again:
if (crp->crp_etype == EAGAIN) {
crp->crp_etype = 0;
- crp->crp_flags &= ~CRYPTO_F_DONE;
cod->done = false;
goto again;
}
diff --git a/sys/opencrypto/cryptodev.h b/sys/opencrypto/cryptodev.h
index 1e0024407246..71e9c5ac4c0a 100644
--- a/sys/opencrypto/cryptodev.h
+++ b/sys/opencrypto/cryptodev.h
@@ -433,7 +433,7 @@ struct cryptop {
int crp_flags;
#define CRYPTO_F_CBIMM 0x0010 /* Do callback immediately */
-#define CRYPTO_F_DONE 0x0020 /* Operation completed */
+#define CRYPTO_F_DONE 0x0020 /* Deprecated, do not use */
#define CRYPTO_F_CBIFSYNC 0x0040 /* Do CBIMM if op is synchronous */
#define CRYPTO_F_ASYNC_ORDERED 0x0100 /* Completions must happen in order */
#define CRYPTO_F_IV_SEPARATE 0x0200 /* Use crp_iv[] as IV. */
diff --git a/sys/opencrypto/ktls_ocf.c b/sys/opencrypto/ktls_ocf.c
index 74b48f2366c1..ece509f5f969 100644
--- a/sys/opencrypto/ktls_ocf.c
+++ b/sys/opencrypto/ktls_ocf.c
@@ -224,7 +224,6 @@ ktls_ocf_dispatch(struct ktls_ocf_session *os, struct cryptop *crp)
}
crp->crp_etype = 0;
- crp->crp_flags &= ~CRYPTO_F_DONE;
oo.done = false;
counter_u64_add(ocf_retries, 1);
}
@@ -240,7 +239,6 @@ ktls_ocf_dispatch_async_cb(struct cryptop *crp)
state = crp->crp_opaque;
if (crp->crp_etype == EAGAIN) {
crp->crp_etype = 0;
- crp->crp_flags &= ~CRYPTO_F_DONE;
counter_u64_add(ocf_retries, 1);
error = crypto_dispatch(crp);
if (error != 0) {
diff --git a/sys/sys/param.h b/sys/sys/param.h
index f2dd148fcd84..88edc92e65e7 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -73,7 +73,7 @@
* cannot include sys/param.h and should only be updated here.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 1500041
+#define __FreeBSD_version 1500042
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,