ipsec: fix use of uninitialized variable

Message ID 20200219002302.1131-1-konstantin.ananyev@intel.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series ipsec: fix use of uninitialized variable |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/Intel-compilation fail apply issues
ci/travis-robot success Travis build: passed

Commit Message

Ananyev, Konstantin Feb. 19, 2020, 12:23 a.m. UTC
  Defects reported by coverity scan
uninit_use_in_call: Using uninitialized element of array clen when
calling cpu_crypto_bulk.

Coverity issue: 354233, 354234
Fixes: 957394f72658 ("ipsec: support CPU crypto mode")

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 lib/librte_ipsec/esp_inb.c  | 4 +++-
 lib/librte_ipsec/esp_outb.c | 4 +++-
 lib/librte_ipsec/misc.h     | 3 ++-
 3 files changed, 8 insertions(+), 3 deletions(-)
  

Comments

Iremonger, Bernard Feb. 19, 2020, 2:14 p.m. UTC | #1
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Konstantin Ananyev
> Sent: Wednesday, February 19, 2020 12:23 AM
> To: dev@dpdk.org
> Cc: akhil.goyal@nxp.com; Ananyev, Konstantin
> <konstantin.ananyev@intel.com>
> Subject: [dpdk-dev] [PATCH] ipsec: fix use of uninitialized variable
> 
> Defects reported by coverity scan
> uninit_use_in_call: Using uninitialized element of array clen when calling
> cpu_crypto_bulk.
> 
> Coverity issue: 354233, 354234
> Fixes: 957394f72658 ("ipsec: support CPU crypto mode")
> 
> Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
  
John McNamara Feb. 19, 2020, 3:27 p.m. UTC | #2
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Iremonger, Bernard
> Sent: Wednesday, February 19, 2020 2:15 PM
> To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; dev@dpdk.org
> Cc: akhil.goyal@nxp.com; Ananyev, Konstantin
> <konstantin.ananyev@intel.com>
> Subject: Re: [dpdk-dev] [PATCH] ipsec: fix use of uninitialized variable
> 
> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of Konstantin Ananyev
> > Sent: Wednesday, February 19, 2020 12:23 AM
> > To: dev@dpdk.org
> > Cc: akhil.goyal@nxp.com; Ananyev, Konstantin
> > <konstantin.ananyev@intel.com>
> > Subject: [dpdk-dev] [PATCH] ipsec: fix use of uninitialized variable
> >
> > Defects reported by coverity scan
> > uninit_use_in_call: Using uninitialized element of array clen when
> > calling cpu_crypto_bulk.
> >
> > Coverity issue: 354233, 354234
> > Fixes: 957394f72658 ("ipsec: support CPU crypto mode")
> >
> > Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> 
> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>

If possible can we get this merged into RC4.
  
Akhil Goyal Feb. 20, 2020, 10:36 a.m. UTC | #3
> > > Defects reported by coverity scan
> > > uninit_use_in_call: Using uninitialized element of array clen when
> > > calling cpu_crypto_bulk.
> > >
> > > Coverity issue: 354233, 354234
> > > Fixes: 957394f72658 ("ipsec: support CPU crypto mode")
> > >
> > > Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> >
> > Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
> 
> If possible can we get this merged into RC4.

Applied to dpdk-next-crypto

Thanks.
  

Patch

diff --git a/lib/librte_ipsec/esp_inb.c b/lib/librte_ipsec/esp_inb.c
index 7b8ab81f6..96eec0131 100644
--- a/lib/librte_ipsec/esp_inb.c
+++ b/lib/librte_ipsec/esp_inb.c
@@ -737,7 +737,9 @@  cpu_inb_pkt_prepare(const struct rte_ipsec_session *ss,
 		move_bad_mbufs(mb, dr, num, num - k);
 
 	/* convert mbufs to iovecs and do actual crypto/auth processing */
-	cpu_crypto_bulk(ss, sa->cofs, mb, iv, aad, dgst, l4ofs, clen, k);
+	if (k != 0)
+		cpu_crypto_bulk(ss, sa->cofs, mb, iv, aad, dgst,
+			l4ofs, clen, k);
 	return k;
 }
 
diff --git a/lib/librte_ipsec/esp_outb.c b/lib/librte_ipsec/esp_outb.c
index b6d9cbe98..fb9d5864c 100644
--- a/lib/librte_ipsec/esp_outb.c
+++ b/lib/librte_ipsec/esp_outb.c
@@ -502,7 +502,9 @@  cpu_outb_pkt_prepare(const struct rte_ipsec_session *ss,
 		move_bad_mbufs(mb, dr, n, n - k);
 
 	/* convert mbufs to iovecs and do actual crypto/auth processing */
-	cpu_crypto_bulk(ss, sa->cofs, mb, iv, aad, dgst, l4ofs, clen, k);
+	if (k != 0)
+		cpu_crypto_bulk(ss, sa->cofs, mb, iv, aad, dgst,
+			l4ofs, clen, k);
 	return k;
 }
 
diff --git a/lib/librte_ipsec/misc.h b/lib/librte_ipsec/misc.h
index 53c0457af..771602950 100644
--- a/lib/librte_ipsec/misc.h
+++ b/lib/librte_ipsec/misc.h
@@ -106,7 +106,8 @@  mbuf_cut_seg_ofs(struct rte_mbuf *mb, struct rte_mbuf *ms, uint32_t ofs,
 }
 
 /*
- * process packets using sync crypto engine
+ * process packets using sync crypto engine.
+ * expects *num* to be greater then zero.
  */
 static inline void
 cpu_crypto_bulk(const struct rte_ipsec_session *ss,