From: Marat Khalili <marat.khalili@huawei.com>
To: "Morten Brørup" <mb@smartsharesystems.com>,
"dev@dpdk.org" <dev@dpdk.org>
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Christophe Fontaine <cfontain@redhat.com>,
Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>,
Wathsala Vithanage <wathsala.vithanage@arm.com>,
"stable@dpdk.org" <stable@dpdk.org>
Subject: RE: [PATCH] mbuf: fix read packet data
Date: Thu, 19 Mar 2026 09:36:52 +0000 [thread overview]
Message-ID: <6bda6389ce8e4ad5b081f53eb1241fc8@huawei.com> (raw)
In-Reply-To: <20260319084048.652493-1-mb@smartsharesystems.com>
For the fix:
Acked-by: Marat Khalili <marat.khalili@huawei.com>
The tests will fail though and need to be adjusted to the correct behaviour.
> -----Original Message-----
> From: Morten Brørup <mb@smartsharesystems.com>
> Sent: Thursday 19 March 2026 08:41
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Marat Khalili <marat.khalili@huawei.com>;
> Christophe Fontaine <cfontain@redhat.com>; Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>;
> Wathsala Vithanage <wathsala.vithanage@arm.com>; Morten Brørup <mb@smartsharesystems.com>;
> stable@dpdk.org
> Subject: [PATCH] mbuf: fix read packet data
>
> The sum of offset + length, both 32 bit unsigned integers, could wrap
> around, causing comparisons to give the wrong result.
> This was fixed by using 64 bit instead of 32 bit for calculating the sum.
>
> Note:
> When the branch is not taken for the initial "if ((uint64_t)off + len >
> rte_pktmbuf_pkt_len(m))" comparison, the sum is known to not exceed the
> maximum possible value of rte_pktmbuf_pkt_len(m), UINT32_MAX, and
> following sum calculations can proceed using 32 bit.
>
> Fixes: b84110e7baa2 ("mbuf: add function to read packet data")
> Cc: stable@dpdk.org
>
> Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> ---
> lib/mbuf/rte_mbuf.c | 2 +-
> lib/mbuf/rte_mbuf.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c
> index a5d16e4c97..c2476e7704 100644
> --- a/lib/mbuf/rte_mbuf.c
> +++ b/lib/mbuf/rte_mbuf.c
> @@ -795,7 +795,7 @@ const void *__rte_pktmbuf_read(const struct rte_mbuf *m, uint32_t off,
> const struct rte_mbuf *seg = m;
> uint32_t buf_off = 0, copy_len;
>
> - if (off + len > rte_pktmbuf_pkt_len(m))
> + if ((uint64_t)off + len > rte_pktmbuf_pkt_len(m))
> return NULL;
>
> while (off >= rte_pktmbuf_data_len(seg)) {
> diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h
> index 592af2388c..d6602f74bc 100644
> --- a/lib/mbuf/rte_mbuf.h
> +++ b/lib/mbuf/rte_mbuf.h
> @@ -1843,7 +1843,7 @@ const void *__rte_pktmbuf_read(const struct rte_mbuf *m, uint32_t off,
> static inline const void *rte_pktmbuf_read(const struct rte_mbuf *m,
> uint32_t off, uint32_t len, void *buf)
> {
> - if (likely(off + len <= rte_pktmbuf_data_len(m)))
> + if (likely((uint64_t)off + len <= rte_pktmbuf_data_len(m)))
> return rte_pktmbuf_mtod_offset(m, char *, off);
> else
> return __rte_pktmbuf_read(m, off, len, buf);
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-03-19 9:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 8:40 [PATCH] mbuf: fix read packet data Morten Brørup
2026-03-19 9:36 ` Marat Khalili [this message]
2026-03-19 12:43 ` [PATCH v2] " Morten Brørup
2026-03-19 13:15 ` Konstantin Ananyev
2026-03-19 13:55 ` Morten Brørup
2026-03-19 14:21 ` Marat Khalili
2026-03-19 14:31 ` Morten Brørup
2026-03-25 22:33 ` Thomas Monjalon
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=6bda6389ce8e4ad5b081f53eb1241fc8@huawei.com \
--to=marat.khalili@huawei.com \
--cc=cfontain@redhat.com \
--cc=dev@dpdk.org \
--cc=konstantin.v.ananyev@yandex.ru \
--cc=mb@smartsharesystems.com \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
--cc=wathsala.vithanage@arm.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