From: sashiko-bot@kernel.org
To: "Jiayuan Chen" <jiayuan.chen@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 1/7] bpf, sockmap: reject overflowing copy + len in bpf_msg_push_data()
Date: Fri, 12 Jun 2026 13:28:18 +0000 [thread overview]
Message-ID: <20260612132819.1D9D41F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260612130919.299124-2-jiayuan.chen@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Heap buffer overflow and scatterlist corruption in `bpf_msg_push_data` due to reading a stale length when appending to a full scatterlist ring.
--
commit 03e879f94c0eac25b2f497170c4a5ac1a5564d33
Author: Weiming Shi <bestswngs@gmail.com>
bpf, sockmap: reject overflowing copy + len in bpf_msg_push_data()
This commit adds an overflow check for the copy + len calculation in the
fallback path of bpf_msg_push_data() to prevent undersized allocations
and subsequent out-of-bounds memcpy operations.
Link: https://lore.kernel.org/all/20260424155913.A19FDC19425@smtp.kernel.org
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 9590877b0714f..3c8f1cedb217f 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -2829,6 +2829,9 @@ BPF_CALL_4(bpf_msg_push_data, struct sk_msg *, msg, u32, start,
> if (!space || (space == 1 && start != offset))
> copy = msg->sg.data[i].length;
[Severity: Critical]
This is a pre-existing issue, but does this copy assignment read a stale
length when appending to a full scatterlist ring?
When appending data to a message where start == msg->sg.size, the
scatterlist traversal loop terminates with i == msg->sg.end. If the ring is
full (space == 0) or has one slot left (space == 1), copy is computed using
msg->sg.data[i].length.
Because i == msg->sg.end, this reads the length of an unrelated element
(either the first element if full, or an unused stale slot) instead of the
actual element being split or coalesced.
Later in bpf_msg_push_data(), a memcpy occurs:
memcpy(raw, from, front);
Can this cause a heap buffer overflow?
The memcpy uses front (which equals the true length of the last element)
to write into the newly allocated page, which is bounded by the unrelated
copy length.
If the stale length read into copy is very small, but the last element is
large, it appears this would write out-of-bounds into the allocation.
> + if (unlikely(copy + len < copy))
> + return -EINVAL;
> +
> page = alloc_pages(__GFP_NOWARN | GFP_ATOMIC | __GFP_COMP,
> get_order(copy + len));
> if (unlikely(!page))
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260612130919.299124-1-jiayuan.chen@linux.dev?part=1
next prev parent reply other threads:[~2026-06-12 13:28 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 13:07 [PATCH bpf-next v3 0/7] bpf, skmsg: some fixes for skmsg Jiayuan Chen
2026-06-12 13:07 ` [PATCH bpf-next v3 1/7] bpf, sockmap: reject overflowing copy + len in bpf_msg_push_data() Jiayuan Chen
2026-06-12 13:28 ` sashiko-bot [this message]
2026-06-13 0:09 ` Kuniyuki Iwashima
2026-06-12 13:07 ` [PATCH bpf-next v3 2/7] bpf, sockmap: Fix wrong rsge offset " Jiayuan Chen
2026-06-12 13:27 ` sashiko-bot
2026-06-13 0:17 ` Kuniyuki Iwashima
2026-06-12 13:07 ` [PATCH bpf-next v3 3/7] bpf, sockmap: zero-initialize pages allocated in bpf_msg_push_data Jiayuan Chen
2026-06-12 13:34 ` sashiko-bot
2026-06-13 0:28 ` Kuniyuki Iwashima
2026-06-13 1:36 ` Alexei Starovoitov
2026-06-12 13:07 ` [PATCH bpf-next v3 4/7] bpf, sockmap: keep sk_msg copy state in sync Jiayuan Chen
2026-06-12 13:57 ` bot+bpf-ci
2026-06-13 0:40 ` Kuniyuki Iwashima
2026-06-12 13:07 ` [PATCH bpf-next v3 5/7] sockmap: Fix use-after-free in udp_bpf_recvmsg() Jiayuan Chen
2026-06-12 13:24 ` sashiko-bot
2026-06-12 13:07 ` [PATCH bpf-next v3 6/7] bpf, sockmap: fix integer overflow in bpf_msg_pop_data() bounds check Jiayuan Chen
2026-06-13 0:44 ` Kuniyuki Iwashima
2026-06-12 13:07 ` [PATCH bpf-next v3 7/7] selftests/bpf: add test for bpf_msg_pop_data() overflow Jiayuan Chen
2026-06-12 17:09 ` [PATCH bpf-next v3 0/7] bpf, skmsg: some fixes for skmsg Alexei Starovoitov
2026-06-12 18:43 ` Kuniyuki Iwashima
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=20260612132819.1D9D41F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=jiayuan.chen@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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