The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=34271824525e18d82c051177de265c8d8a113fb8

commit 34271824525e18d82c051177de265c8d8a113fb8
Author:     John Baldwin <[email protected]>
AuthorDate: 2026-07-27 15:36:55 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2026-07-29 17:45:02 +0000

    wg(4): Check for crypto operation errors
    
    In particular, handle authentication errors due to bad MACs when
    decrypting packets.
    
    Since the current dispatch code assumes synchronous OCF sessions by
    design, explicitly reject any created OCF session that is not
    synchronous.  Software sessions are always synchronous in practice, so
    this should be a nop.
    
    Approved by:    so
    Security:       FreeBSD-SA-26:52.if_wg
    Security:       CVE-2026-58085
    Reviewed by:    markj
    Sponsored by:   Chelsio Communications
---
 sys/dev/wg/wg_crypto.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/sys/dev/wg/wg_crypto.c b/sys/dev/wg/wg_crypto.c
index 53441ef25b40..82b80c7fd451 100644
--- a/sys/dev/wg/wg_crypto.c
+++ b/sys/dev/wg/wg_crypto.c
@@ -230,6 +230,8 @@ chacha20poly1305_encrypt_mbuf(struct mbuf *m, const 
uint64_t nonce,
        crp.crp_cipher_key = key;
        crp.crp_callback = crypto_callback;
        ret = crypto_dispatch(&crp);
+       if (ret == 0)
+               ret = crp.crp_etype;
        crypto_destroyreq(&crp);
        return (ret);
 }
@@ -253,6 +255,8 @@ chacha20poly1305_decrypt_mbuf(struct mbuf *m, const 
uint64_t nonce,
        crp.crp_cipher_key = key;
        crp.crp_callback = crypto_callback;
        ret = crypto_dispatch(&crp);
+       if (ret == 0)
+               ret = crp.crp_etype;
        crypto_destroyreq(&crp);
        if (ret)
                return (ret);
@@ -270,9 +274,14 @@ crypto_init(void)
                .csp_cipher_klen = CHACHA20POLY1305_KEY_SIZE,
                .csp_flags = CSP_F_SEPARATE_AAD | CSP_F_SEPARATE_OUTPUT
        };
-       int ret = crypto_newsession(&chacha20_poly1305_sid, &csp, 
CRYPTOCAP_F_SOFTWARE);
+       int ret = crypto_newsession(&chacha20_poly1305_sid, &csp,
+           CRYPTOCAP_F_SOFTWARE);
        if (ret != 0)
                return (ret);
+       if (!CRYPTO_SESS_SYNC(chacha20_poly1305_sid)) {
+               crypto_freesession(chacha20_poly1305_sid);
+               return (ENXIO);
+       }
        return (0);
 }
 

Reply via email to