[v3,2/2] crypto/nitrox: fix array out of bounds access

Message ID 20200327134239.23358-2-rnagadheeraj@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series [v3,1/2] crypto/nitrox: fix invalid CSR register address generation |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK

Commit Message

Nagadheeraj Rottela March 27, 2020, 1:42 p.m. UTC
  In nitrox_sym_pmd_create() the name array will overflow if the pci
device name is greater than 57 bytes. To fix this issue subtract pci
device name length from array length while appending substring to the
name.

Coverity issue: 349926

Fixes: 9fdef0cc2385 ("crypto/nitrox: create symmetric cryptodev")

Signed-off-by: Nagadheeraj Rottela <rnagadheeraj@marvell.com>
---
 drivers/crypto/nitrox/nitrox_sym.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Akhil Goyal April 5, 2020, 4:55 p.m. UTC | #1
> -----Original Message-----
> From: Nagadheeraj Rottela <rnagadheeraj@marvell.com>
> Sent: Friday, March 27, 2020 7:13 PM
> To: Akhil Goyal <akhil.goyal@nxp.com>
> Cc: dev@dpdk.org; thomas@monjalon.net; jsrikanth@marvell.com;
> Nagadheeraj Rottela <rnagadheeraj@marvell.com>
> Subject: [PATCH v3 2/2] crypto/nitrox: fix array out of bounds access
> 
> In nitrox_sym_pmd_create() the name array will overflow if the pci
> device name is greater than 57 bytes. To fix this issue subtract pci
> device name length from array length while appending substring to the
> name.
> 
> Coverity issue: 349926
> 
> Fixes: 9fdef0cc2385 ("crypto/nitrox: create symmetric cryptodev")
> 
> Signed-off-by: Nagadheeraj Rottela <rnagadheeraj@marvell.com>
> ---
Cc:stable@dpdk.org

Applied to dpdk-next-crypto

Thanks.
  

Patch

diff --git a/drivers/crypto/nitrox/nitrox_sym.c b/drivers/crypto/nitrox/nitrox_sym.c
index 56410c44d..d1b32fec9 100644
--- a/drivers/crypto/nitrox/nitrox_sym.c
+++ b/drivers/crypto/nitrox/nitrox_sym.c
@@ -683,7 +683,8 @@  nitrox_sym_pmd_create(struct nitrox_device *ndev)
 	struct rte_cryptodev *cdev;
 
 	rte_pci_device_name(&ndev->pdev->addr, name, sizeof(name));
-	snprintf(name + strlen(name), RTE_CRYPTODEV_NAME_MAX_LEN, "_n5sym");
+	snprintf(name + strlen(name), RTE_CRYPTODEV_NAME_MAX_LEN - strlen(name),
+		 "_n5sym");
 	ndev->rte_sym_dev.driver = &nitrox_rte_sym_drv;
 	ndev->rte_sym_dev.numa_node = ndev->pdev->device.numa_node;
 	ndev->rte_sym_dev.devargs = NULL;