This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 0642dd346cd6e800cf7f65d0ce08e46b25ce69b4
Author: makejian <[email protected]>
AuthorDate: Fri Nov 13 22:28:26 2026 +0800

    drivers/vhost/vhost-crypto: report a driver error on cipher, hash and MAC
    
    crypto_invoke() leaves a driver error in crp_etype, and the cipher,
    hash and MAC paths of vhost-crypto return crypto_invoke() alone, so a
    failed request reaches the peer as a success. Read crp_etype after it,
    as the AEAD paths already do.
    
    Signed-off-by: makejian <[email protected]>
    Signed-off-by: Bowen Wang <[email protected]>
---
 drivers/vhost/vhost-crypto.c | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/vhost/vhost-crypto.c b/drivers/vhost/vhost-crypto.c
index 0538d08e01f..7c8388205eb 100644
--- a/drivers/vhost/vhost-crypto.c
+++ b/drivers/vhost/vhost-crypto.c
@@ -548,6 +548,7 @@ static int vhost_crypto_process_cipher(
   FAR struct cryptop *crp = &sess->u.sym.crp;
   FAR void *buf;
   uint32_t len;
+  int ret;
 
   crde->crd_alg = virtio_crypto_get_cipher_alg(data->header.algo);
   if (crde->crd_alg < 0)
@@ -620,7 +621,13 @@ static int vhost_crypto_process_cipher(
 
   crp->crp_dst = buf;
 
-  return crypto_invoke(crp);
+  ret = crypto_invoke(crp);
+  if (ret == 0)
+    {
+      ret = crp->crp_etype;
+    }
+
+  return ret;
 }
 
 /****************************************************************************
@@ -640,6 +647,7 @@ static int vhost_crypto_process_hash(
   FAR struct cryptop *crp = &sess->u.sym.crp;
   FAR void *buf;
   uint32_t len;
+  int ret;
 
   crda->crd_alg = virtio_crypto_get_hash_alg(data->header.algo);
   if (crda->crd_alg < 0)
@@ -691,7 +699,13 @@ static int vhost_crypto_process_hash(
       crda->crd_flags |= CRD_F_UPDATE;
     }
 
-  return crypto_invoke(crp);
+  ret = crypto_invoke(crp);
+  if (ret == 0)
+    {
+      ret = crp->crp_etype;
+    }
+
+  return ret;
 }
 
 /****************************************************************************
@@ -712,6 +726,7 @@ static int vhost_crypto_process_mac(
   FAR struct cryptop *crp = &sess->u.sym.crp;
   FAR void *buf;
   uint32_t len;
+  int ret;
 
   if (crda->crd_alg == CRYPTO_AES_128_CMAC ||
       crda->crd_alg == CRYPTO_AES_256_CMAC)
@@ -766,7 +781,13 @@ static int vhost_crypto_process_mac(
       crda->crd_flags |= CRD_F_UPDATE;
     }
 
-  return crypto_invoke(crp);
+  ret = crypto_invoke(crp);
+  if (ret == 0)
+    {
+      ret = crp->crp_etype;
+    }
+
+  return ret;
 }
 
 /****************************************************************************

Reply via email to