patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] test/mbuf: fix mbuf data content check
@ 2022-02-03  9:39 David Marchand
  2022-02-03  9:47 ` Olivier Matz
  0 siblings, 1 reply; 3+ messages in thread
From: David Marchand @ 2022-02-03  9:39 UTC (permalink / raw)
  To: dev; +Cc: dkozlyuk, stable, Olivier Matz, Lavanya Govindarajan, Reshma Pattan

When allocating a mbuf, its data content is most of the time zero'd but
nothing ensures this. This is especially wrong when building with
RTE_MALLOC_DEBUG, where data is poisoned to 0x6b on free.

This test reserves MBUF_TEST_DATA_LEN2 bytes in the mbuf data segment,
and sets this data to 0xcc.
Calling strlen(), the test may try to read more than MBUF_TEST_DATA_LEN2
which has been noticed when memory had been poisoned.

The mbuf data content is checked right after, so we can simply remove
strlen().

Fixes: 7b295dceea07 ("test/mbuf: add unit test cases")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 app/test/test_mbuf.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c
index f54d1d7c00..2a037a12da 100644
--- a/app/test/test_mbuf.c
+++ b/app/test/test_mbuf.c
@@ -2031,8 +2031,6 @@ test_pktmbuf_read_from_offset(struct rte_mempool *pktmbuf_pool)
 			NULL);
 	if (data_copy == NULL)
 		GOTO_FAIL("%s: Error in reading packet data!\n", __func__);
-	if (strlen(data_copy) != MBUF_TEST_DATA_LEN2 - 5)
-		GOTO_FAIL("%s: Incorrect data length!\n", __func__);
 	for (off = 0; off < MBUF_TEST_DATA_LEN2 - 5; off++) {
 		if (data_copy[off] != (char)0xcc)
 			GOTO_FAIL("Data corrupted at offset %u", off);
@@ -2054,8 +2052,6 @@ test_pktmbuf_read_from_offset(struct rte_mempool *pktmbuf_pool)
 	data_copy = rte_pktmbuf_read(m, hdr_len, 0, NULL);
 	if (data_copy == NULL)
 		GOTO_FAIL("%s: Error in reading packet data!\n", __func__);
-	if (strlen(data_copy) != MBUF_TEST_DATA_LEN2)
-		GOTO_FAIL("%s: Corrupted data content!\n", __func__);
 	for (off = 0; off < MBUF_TEST_DATA_LEN2; off++) {
 		if (data_copy[off] != (char)0xcc)
 			GOTO_FAIL("Data corrupted at offset %u", off);
-- 
2.23.0


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

* Re: [PATCH] test/mbuf: fix mbuf data content check
  2022-02-03  9:39 [PATCH] test/mbuf: fix mbuf data content check David Marchand
@ 2022-02-03  9:47 ` Olivier Matz
  2022-02-11  7:56   ` David Marchand
  0 siblings, 1 reply; 3+ messages in thread
From: Olivier Matz @ 2022-02-03  9:47 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, dkozlyuk, stable, Reshma Pattan

On Thu, Feb 03, 2022 at 10:39:12AM +0100, David Marchand wrote:
> When allocating a mbuf, its data content is most of the time zero'd but
> nothing ensures this. This is especially wrong when building with
> RTE_MALLOC_DEBUG, where data is poisoned to 0x6b on free.
> 
> This test reserves MBUF_TEST_DATA_LEN2 bytes in the mbuf data segment,
> and sets this data to 0xcc.
> Calling strlen(), the test may try to read more than MBUF_TEST_DATA_LEN2
> which has been noticed when memory had been poisoned.
> 
> The mbuf data content is checked right after, so we can simply remove
> strlen().
> 
> Fixes: 7b295dceea07 ("test/mbuf: add unit test cases")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>

Acked-by: Olivier Matz <olivier.matz@6wind.com>

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

* Re: [PATCH] test/mbuf: fix mbuf data content check
  2022-02-03  9:47 ` Olivier Matz
@ 2022-02-11  7:56   ` David Marchand
  0 siblings, 0 replies; 3+ messages in thread
From: David Marchand @ 2022-02-11  7:56 UTC (permalink / raw)
  To: David Marchand
  Cc: dev, Dmitry Kozlyuk, dpdk stable, Reshma Pattan, Olivier Matz

On Thu, Feb 3, 2022 at 10:47 AM Olivier Matz <olivier.matz@6wind.com> wrote:
>
> On Thu, Feb 03, 2022 at 10:39:12AM +0100, David Marchand wrote:
> > When allocating a mbuf, its data content is most of the time zero'd but
> > nothing ensures this. This is especially wrong when building with
> > RTE_MALLOC_DEBUG, where data is poisoned to 0x6b on free.
> >
> > This test reserves MBUF_TEST_DATA_LEN2 bytes in the mbuf data segment,
> > and sets this data to 0xcc.
> > Calling strlen(), the test may try to read more than MBUF_TEST_DATA_LEN2
> > which has been noticed when memory had been poisoned.
> >
> > The mbuf data content is checked right after, so we can simply remove
> > strlen().
> >
> > Fixes: 7b295dceea07 ("test/mbuf: add unit test cases")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> Acked-by: Olivier Matz <olivier.matz@6wind.com>

Applied.


-- 
David Marchand


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

end of thread, other threads:[~2022-02-11  7:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-03  9:39 [PATCH] test/mbuf: fix mbuf data content check David Marchand
2022-02-03  9:47 ` Olivier Matz
2022-02-11  7:56   ` David Marchand

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).