DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniil Iskhakov <dish@amicon.ru>
To: <dev@dpdk.org>
Cc: Daniil Iskhakov <dish@amicon.ru>, <stable@dpdk.org>,
	<sdl.dpdk@linuxtesting.org>, <rrv@amicon.ru>
Subject: [PATCH v2] cmdline: prevent out-of-bounds read in completion buffer
Date: Mon, 27 Apr 2026 18:34:30 +0300	[thread overview]
Message-ID: <20260427153430.1805689-1-dish@amicon.ru> (raw)

tmp_buf is populated by the completion callback and is not guaranteed
to be NUL-terminated.

The code already accounts for this when computing tmp_size with
strnlen(tmp_buf, sizeof(tmp_buf)). However, another loop in the same
path still walks tmp_buf until a NUL byte is found, without checking
the buffer limit.

If the callback writes a full-sized non-NUL-terminated string, the loop
may read past the end of tmp_buf.

Fix this by bounding the iteration with sizeof(tmp_buf).

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Daniil Iskhakov <dish@amicon.ru>
---
v2:
- Resent to dev@dpdk.org because v1 was accidentally sent only to
maintainers.

Cc: sdl.dpdk@linuxtesting.org
Cc: rrv@amicon.ru
---
 lib/cmdline/cmdline_rdline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/cmdline/cmdline_rdline.c b/lib/cmdline/cmdline_rdline.c
index ee070f0af3..bc91dc6002 100644
--- a/lib/cmdline/cmdline_rdline.c
+++ b/lib/cmdline/cmdline_rdline.c
@@ -445,7 +445,7 @@ rdline_char_in(struct rdline *rdl, char c)
 				rdline_puts(rdl, "\r\n");
 				while (ret) {
 					rdl->write_char(rdl, ' ');
-					for (i=0 ; i < sizeof(tmp_buf) && tmp_buf[i]; i++)
+					for (i = 0 ; i < tmp_buf[i]; i++)
 						rdl->write_char(rdl, tmp_buf[i]);
 					rdline_puts(rdl, "\r\n");
 					ret = rdl->complete(rdl, rdl->left_buf,
-- 
2.43.0


             reply	other threads:[~2026-04-29  9:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27 15:34 Daniil Iskhakov [this message]
2026-04-30 11:55 ` [PATCH v2] cmdline: prevent out-of-bounds read in completion buffer Konstantin Ananyev
2026-04-30 17:01 ` [PATCH v3] " Daniil Iskhakov

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=20260427153430.1805689-1-dish@amicon.ru \
    --to=dish@amicon.ru \
    --cc=dev@dpdk.org \
    --cc=rrv@amicon.ru \
    --cc=sdl.dpdk@linuxtesting.org \
    --cc=stable@dpdk.org \
    /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