DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] compress/nitrox: fix dereference after null check
@ 2024-03-13  6:02 Nagadheeraj Rottela
  2024-03-13 14:50 ` Akhil Goyal
  0 siblings, 1 reply; 2+ messages in thread
From: Nagadheeraj Rottela @ 2024-03-13  6:02 UTC (permalink / raw)
  To: gakhil, fanzhang.oss, ashishg; +Cc: dev, Nagadheeraj Rottela

In nitrox_check_comp_req() while updating the last byte during FINAL
flush there is possibility of accessing null mbuf in two rare cases.
First case is when the application changes the dst mbuf between
enqueue and dequeue. Second case is when data length reported by
hardware is greater than the mbuf length. Fix this issue by adding
mbuf null checks.

Coverity issue: 415046
Fixes: f008628a6d08 ("compress/nitrox: support stateless request")
Signed-off-by: Nagadheeraj Rottela <rnagadheeraj@marvell.com>
---
 drivers/compress/nitrox/nitrox_comp_reqmgr.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/compress/nitrox/nitrox_comp_reqmgr.c b/drivers/compress/nitrox/nitrox_comp_reqmgr.c
index 0a25672d6e..ca45c3e322 100644
--- a/drivers/compress/nitrox/nitrox_comp_reqmgr.c
+++ b/drivers/compress/nitrox/nitrox_comp_reqmgr.c
@@ -1096,10 +1096,20 @@ nitrox_check_comp_req(struct nitrox_softreq *sr, struct rte_comp_op **op)
 		for (; m && off > rte_pktmbuf_data_len(m); m = m->next)
 			off -= rte_pktmbuf_data_len(m);
 
+		if (unlikely(m == NULL)) {
+			err = -EINVAL;
+			goto exit;
+		}
+
 		mlen = rte_pktmbuf_data_len(m) - off;
 		for (; m && (datalen > mlen); m = m->next)
 			datalen -= mlen;
 
+		if (unlikely(m == NULL)) {
+			err = -EINVAL;
+			goto exit;
+		}
+
 		last_byte = rte_pktmbuf_mtod_offset(m, uint8_t *, datalen - 1);
 		*last_byte = zip_res.w2.exbits & 0xFF;
 	}
-- 
2.42.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: [PATCH] compress/nitrox: fix dereference after null check
  2024-03-13  6:02 [PATCH] compress/nitrox: fix dereference after null check Nagadheeraj Rottela
@ 2024-03-13 14:50 ` Akhil Goyal
  0 siblings, 0 replies; 2+ messages in thread
From: Akhil Goyal @ 2024-03-13 14:50 UTC (permalink / raw)
  To: Nagadheeraj Rottela, fanzhang.oss, Ashish Gupta; +Cc: dev, Nagadheeraj Rottela

> Subject: [PATCH] compress/nitrox: fix dereference after null check
> 
> In nitrox_check_comp_req() while updating the last byte during FINAL
> flush there is possibility of accessing null mbuf in two rare cases.
> First case is when the application changes the dst mbuf between
> enqueue and dequeue. Second case is when data length reported by
> hardware is greater than the mbuf length. Fix this issue by adding
> mbuf null checks.
> 
> Coverity issue: 415046
> Fixes: f008628a6d08 ("compress/nitrox: support stateless request")
> Signed-off-by: Nagadheeraj Rottela <rnagadheeraj@marvell.com>
Applied to dpdk-next-crypto
Thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-13 14:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-13  6:02 [PATCH] compress/nitrox: fix dereference after null check Nagadheeraj Rottela
2024-03-13 14:50 ` Akhil Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).