All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Junxi Qian" <qjx1298677004@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf] bpf, sockmap: keep sk_msg copy bitmap in sync
Date: Wed, 20 May 2026 12:19:16 +0000	[thread overview]
Message-ID: <20260520121916.E6A401F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260520112327.189660-1-qjx1298677004@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [Critical] Incorrect page offset calculation when splitting a scatterlist element in bpf_msg_push_data() causes out-of-bounds memory access.
--

commit 68cddb5ca40528f94f0edb5061db37a66f108a6a
Author: Junxi Qian <qjx1298677004@gmail.com>

bpf, sockmap: keep sk_msg copy bitmap in sync

The sk_msg scatterlist ring stores the actual page descriptors in sg.data[]
and stores the copy-required state for each slot in the parallel sg.copy
bitmap. Several SK_MSG helpers move or split sg.data[] entries without
moving the matching sg.copy bit. This patch keeps sg.copy synchronized
whenever these helpers move, split, replace or remove scatterlist entries.

> diff --git a/net/core/filter.c b/net/core/filter.c
> index 9590877b0714f..cb8628300ac66 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c

[ ... ]

> @@ -2866,6 +2871,7 @@ BPF_CALL_4(bpf_msg_push_data, struct sk_msg *, msg, u32, start,
>  			sk_msg_iter_var_prev(i);
>  		psge = sk_msg_elem(msg, i);
>  		rsge = sk_msg_elem_cpy(msg, i);
> +		rsge_copy = test_bit(i, msg->sg.copy);
>  
>  		psge->length = start - offset;
>  		rsge.length -= psge->length;

[Severity: Critical]
This is a pre-existing issue, but when splitting the scatterlist element here,
does the code immediately following this hunk incorrectly advance the physical
page offset?

net/core/filter.c:bpf_msg_push_data() {
    ...
		psge->length = start - offset;
		rsge.length -= psge->length;
		rsge.offset += start;
    ...
}

Does this incorrectly advance the physical page offset by the absolute byte
offset (start) instead of the fragment's consumed length (start - offset)?

If the element being split is not the first in the message (offset > 0),
could adding the absolute start offset push rsge.offset beyond the valid
bounds of the physical page, leading to an out-of-bounds memory access?

Should this be rsge.offset += start - offset; or rsge.offset += psge->length;
instead?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260520112327.189660-1-qjx1298677004@gmail.com?part=1

  reply	other threads:[~2026-05-20 12:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20 11:23 [PATCH bpf] bpf, sockmap: keep sk_msg copy bitmap in sync Junxi Qian
2026-05-20 12:19 ` sashiko-bot [this message]
2026-05-20 12:24 ` Jiayuan Chen

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=20260520121916.E6A401F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=qjx1298677004@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.