From: Stephen Hemminger <stephen@networkplumber.org>
To: "Morten Brørup" <mb@smartsharesystems.com>
Cc: <dev@dpdk.org>, <stable@dpdk.org>,
"Konstantin Ananyev" <konstantin.ananyev@huawei.com>
Subject: Re: [PATCH v2] mbuf: fix packet copy
Date: Fri, 16 Jan 2026 09:18:31 -0800 [thread overview]
Message-ID: <20260116091831.37cec333@phoenix.local> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35F6566E@smartserver.smartshare.dk>
On Fri, 16 Jan 2026 18:16:15 +0100
Morten Brørup <mb@smartsharesystems.com> wrote:
> > From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> > Sent: Friday, 16 January 2026 18.06
> >
> > On Fri, 16 Jan 2026 11:16:21 +0000
> > Morten Brørup <mb@smartsharesystems.com> wrote:
> >
> > > buf: fix packet copy
> > >
> > > Requests for copying the at the end of a packet incorrectly returned
> > NULL,
> > > as if copying past the end of a packet.
> > >
> > > When allocating the mbuf for the copy from a mempool using pinned
> > external
> > > buffers, the external flag in this mbuf was not preserved.
> > >
> > > Fixes: c3a90c381daa ("mbuf: add a copy routine")
> > >
> > > Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> > > Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> > > ---
> > > v2:
> > > * Improved comment about preserving flags for newly allocated mbuf
> > > potentially using pinned external buffer.
> > > * Added missing spaces in expression. (Stephen)
> > > ---
> > > lib/mbuf/rte_mbuf.c | 10 +++++++---
> > > 1 file changed, 7 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c
> > > index 0d931c7a15..a5d16e4c97 100644
> > > --- a/lib/mbuf/rte_mbuf.c
> > > +++ b/lib/mbuf/rte_mbuf.c
> > > @@ -675,7 +675,7 @@ rte_pktmbuf_copy(const struct rte_mbuf *m, struct
> > rte_mempool *mp,
> > > __rte_mbuf_sanity_check(m, 1);
> > >
> > > /* check for request to copy at offset past end of mbuf */
> > > - if (unlikely(off >= m->pkt_len))
> > > + if (unlikely(off > m->pkt_len))
> > > return NULL;
> > >
> >
> > I still think asking for a copy of data that isn't there should return
> > NULL
> > not a zero length mbuf. Kind of academic since I dont think any code
> > uses
> > non-zero offset now.
>
> Yes, I totally agree it's kind of academic.
> But I insist that it is an off-by-one bug, so I fixed it.
>
> Consider the function documentation:
>
> * @param offset
> * The number of bytes to skip before copying.
> * If the mbuf does not have that many bytes, it is an error
> * and NULL is returned.
>
> An offset resulting in copying zero bytes is not an error according to this.
>
> Also consider the comment at the comparison in the source code:
> /* check for request to copy at offset past end of mbuf */
>
> It says "past the end", not "at the end"... although I'm not confident enough in my English skills to determine if this means ">=" or ">".
>
OK, the documentation does match your change. Maybe there should be a test for that?
next prev parent reply other threads:[~2026-01-16 17:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 12:04 [PATCH] mbuf: fix packet copy Morten Brørup
2025-11-24 13:35 ` Morten Brørup
2025-11-28 10:50 ` Morten Brørup
2025-12-18 16:12 ` Morten Brørup
2026-01-03 17:46 ` Morten Brørup
2026-01-11 15:19 ` Konstantin Ananyev
2026-01-11 17:43 ` Morten Brørup
2026-01-12 10:56 ` Konstantin Ananyev
2026-01-12 10:58 ` Konstantin Ananyev
2026-01-16 11:16 ` [PATCH v2] " Morten Brørup
2026-01-16 17:06 ` Stephen Hemminger
2026-01-16 17:16 ` Morten Brørup
2026-01-16 17:18 ` Stephen Hemminger [this message]
2026-01-20 7:24 ` [PATCH v3] " Morten Brørup
2026-02-10 17:21 ` Thomas Monjalon
2026-02-25 15:58 ` Kevin Traynor
2026-02-25 17:17 ` Morten Brørup
2026-02-26 10:01 ` Kevin Traynor
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=20260116091831.37cec333@phoenix.local \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=konstantin.ananyev@huawei.com \
--cc=mb@smartsharesystems.com \
--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