DPDK patches and discussions
 help / color / mirror / Atom feed
From: Nagadheeraj Rottela <rnagadheeraj@marvell.com>
To: <gakhil@marvell.com>, <fanzhang.oss@gmail.com>, <ashishg@marvell.com>
Cc: <dev@dpdk.org>, Nagadheeraj Rottela <rnagadheeraj@marvell.com>
Subject: [PATCH] compress/nitrox: fix dereference after null check
Date: Wed, 13 Mar 2024 11:32:08 +0530	[thread overview]
Message-ID: <20240313060208.17791-1-rnagadheeraj@marvell.com> (raw)

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


             reply	other threads:[~2024-03-13  6:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13  6:02 Nagadheeraj Rottela [this message]
2024-03-13 14:50 ` Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240313060208.17791-1-rnagadheeraj@marvell.com \
    --to=rnagadheeraj@marvell.com \
    --cc=ashishg@marvell.com \
    --cc=dev@dpdk.org \
    --cc=fanzhang.oss@gmail.com \
    --cc=gakhil@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).