[v2] crypto/virtio: fix out of bounds access bug

Message ID 20220222095451.731405-1-brian.dooley@intel.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series [v2] crypto/virtio: fix out of bounds access bug |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS

Commit Message

Dooley, Brian Feb. 22, 2022, 9:54 a.m. UTC
  Coverity flags an untrusted loop bound. Check length of session iv.

Coverity issue: 375802

Fixes: b063e843fa03 ("crypto/virtio: fix IV physical address")
Cc: roy.fan.zhang@intel.com
Cc: stable@dpdk.org

Signed-off-by: Brian Dooley <brian.dooley@intel.com>

---
v2: Fix checkpatch warning
---
 drivers/crypto/virtio/virtio_rxtx.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Fan Zhang Feb. 23, 2022, 10:58 a.m. UTC | #1
> -----Original Message-----
> From: Dooley, Brian <brian.dooley@intel.com>
> Sent: Tuesday, February 22, 2022 9:55 AM
> To: dev@dpdk.org
> Cc: Dooley, Brian <brian.dooley@intel.com>; Zhang, Roy Fan
> <roy.fan.zhang@intel.com>; stable@dpdk.org; Jay Zhou
> <jianjay.zhou@huawei.com>
> Subject: [PATCH v2] crypto/virtio: fix out of bounds access bug
> 
> Coverity flags an untrusted loop bound. Check length of session iv.
> 
> Coverity issue: 375802
> 
> Fixes: b063e843fa03 ("crypto/virtio: fix IV physical address")
> Cc: roy.fan.zhang@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Brian Dooley <brian.dooley@intel.com>
> 
> ---
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
  
Fan Zhang Feb. 23, 2022, 11:10 a.m. UTC | #2
> -----Original Message-----
> From: Dooley, Brian <brian.dooley@intel.com>
> Sent: Tuesday, February 22, 2022 9:55 AM
> To: dev@dpdk.org
> Cc: Dooley, Brian <brian.dooley@intel.com>; Zhang, Roy Fan
> <roy.fan.zhang@intel.com>; stable@dpdk.org; Jay Zhou
> <jianjay.zhou@huawei.com>
> Subject: [PATCH v2] crypto/virtio: fix out of bounds access bug
> 
> Coverity flags an untrusted loop bound. Check length of session iv.
> 
> Coverity issue: 375802
> 
> Fixes: b063e843fa03 ("crypto/virtio: fix IV physical address")
> Cc: roy.fan.zhang@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Brian Dooley <brian.dooley@intel.com>
> 
> ---
Reacking as the last ack not shown in patchwork
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
  
Akhil Goyal Feb. 23, 2022, 11:12 a.m. UTC | #3
> > Coverity flags an untrusted loop bound. Check length of session iv.
> >
> > Coverity issue: 375802
> >
> > Fixes: b063e843fa03 ("crypto/virtio: fix IV physical address")
> > Cc: roy.fan.zhang@intel.com
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Brian Dooley <brian.dooley@intel.com>
> >
> > ---
> Reacking as the last ack not shown in patchwork
> Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

Applied to dpdk-next-crypto

Thanks.
  

Patch

diff --git a/drivers/crypto/virtio/virtio_rxtx.c b/drivers/crypto/virtio/virtio_rxtx.c
index a65524a306..08359b3a39 100644
--- a/drivers/crypto/virtio/virtio_rxtx.c
+++ b/drivers/crypto/virtio/virtio_rxtx.c
@@ -264,6 +264,9 @@  virtqueue_crypto_sym_enqueue_xmit(
 		if (cop->phys_addr)
 			desc[idx].addr = cop->phys_addr + session->iv.offset;
 		else {
+			if (session->iv.length > VIRTIO_CRYPTO_MAX_IV_SIZE)
+				return -ENOMEM;
+
 			rte_memcpy(crypto_op_cookie->iv,
 					rte_crypto_op_ctod_offset(cop,
 					uint8_t *, session->iv.offset),