All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ren Wei" <n05ec@lzu.edu.cn>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf v2] bpf: devmap: reject fragmented frames in clone-based broadcasts
Date: Tue, 02 Jun 2026 09:04:28 +0000	[thread overview]
Message-ID: <20260602090428.8D1CC1F00898@smtp.kernel.org> (raw)
In-Reply-To: <21c2d153dd25603d359069a02bf06779b51f6423.1780385378.git.zzhan461@ucr.edu>

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

Pre-existing issues:
- [High] Generic XDP devmap broadcast executes eBPF programs on cloned SKBs without unsharing the data buffer, causing silent data corruption across destinations.
--

commit aa9501e9eb38c9d016ad75d6259b7ed07d668fb0
Author: Zhao Zhang <zzhan461@ucr.edu>
Subject: bpf: devmap: reject fragmented frames in clone-based broadcasts

This commit rejects fragmented native and generic XDP frames in clone-based 
broadcasts. By adding checks in the generic and native clone paths, it 
prevents potential out-of-bounds access.

> diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
> index cc0a43ebab6b9..5b9eac5342a90 100644
> --- a/kernel/bpf/devmap.c
> +++ b/kernel/bpf/devmap.c

[ ... ]

> @@ -726,6 +730,9 @@ static int dev_map_redirect_clone(struct bpf_dtab_netdev *dst,
>  	struct sk_buff *nskb;
>  	int err;
>  
> +	if (unlikely(skb_is_nonlinear(skb)))
> +		return -EOPNOTSUPP;
> +
>  	nskb = skb_clone(skb, GFP_ATOMIC);

[Severity: High]
This isn't a bug introduced by this patch, but is it safe to use skb_clone 
here without unsharing the buffer before executing the eBPF program?

Since nskb is passed to dev_map_generic_redirect, which eventually calls 
dev_map_bpf_prog_run_skb to execute the destination's eBPF program:

dev_map_bpf_prog_run_skb()
    ...
    act = bpf_prog_run_generic_xdp(skb, &xdp, dst->xdp_prog);

Does this grant the XDP program direct write access to the cloned SKB 
payload? If the data buffer is shared and never unshared, could modifications 
made by the eBPF program for one destination silently corrupt the packet 
data for the original SKB and all other clones in the broadcast loop?

>  	if (!nskb)
>  		return -ENOMEM;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/21c2d153dd25603d359069a02bf06779b51f6423.1780385378.git.zzhan461@ucr.edu?part=1

  reply	other threads:[~2026-06-02  9:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-02  8:43 [PATCH bpf v2] bpf: devmap: reject fragmented frames in clone-based broadcasts Ren Wei
2026-06-02  9:04 ` sashiko-bot [this message]
2026-06-02 17:11 ` Emil Tsalapatis
2026-06-03 14:30 ` Toke Høiland-Jørgensen
2026-06-05 15:30 ` patchwork-bot+netdevbpf

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=20260602090428.8D1CC1F00898@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=n05ec@lzu.edu.cn \
    --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.