All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: Jakub Kicinski <kuba@kernel.org>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	John Fastabend <john.fastabend@gmail.com>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	Jiri Olsa <jolsa@kernel.org>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	Ihor Solodrai <ihor.solodrai@linux.dev>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>,
	Shuah Khan <shuah@kernel.org>,
	Kuniyuki Iwashima <kuniyu@google.com>,
	Hangbin Liu <liuhangbin@gmail.com>,
	Krishna Kumar <krikku@gmail.com>,
	Samiullah Khawaja <skhawaja@google.com>,
	Martin Karsten <mkarsten@uwaterloo.ca>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH bpf-next v4 2/3] bpf, xdp: move offload check into dev_xdp_install()
Date: Tue, 11 Aug 2026 11:06:34 +0800	[thread overview]
Message-ID: <cf8655ff-4e45-40ab-898e-aff2aa7145c5@linux.dev> (raw)
In-Reply-To: <20260810114958.64e6a83d@kernel.org>


On 8/11/26 2:49 AM, Jakub Kicinski wrote:
> On Mon, 10 Aug 2026 13:06:00 +0800 Jiayuan Chen wrote:
>> bpf_xdp_link_update() calls dev_xdp_install() directly and skips
>> dev_xdp_attach(), so the checks in dev_xdp_attach() do not run. A user can
>> make an XDP link with a normal program and then swap in an offloaded or
>> device-bound program with BPF_LINK_UPDATE, which puts it on the software
>> path.
>>
>> Move the three program checks (offloaded, bound to another device, and
>> device-bound in generic mode) from dev_xdp_attach() into
>> dev_xdp_install(), so both the attach path and the link update path are
>> covered.
> Shouldn't we move all the checks that are not explicitly about the
> netlink API (so all but the first?)

Sounds great, the code would be much cleaner.


>
> It may be better to split the series and send this patch to net,
> the netdev CI has a netdevsim test for the prog offload, would be
> good to run that.


Though for now bpf_xdp_link_update() already does:

     if (old_prog->type != new_prog->type ||
         old_prog->expected_attach_type != new_prog->expected_attach_type) {
         err = -EINVAL;
         goto out_unlock;
     }

so the other checks can't be triggered on the update path even without 
them in dev_xdp_install().


So I'm thinking this patch works as a standalone fix (good for 
backport), and the cleanup goes as a followup (if necessary)?


  reply	other threads:[~2026-08-11  3:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10  5:05 [PATCH bpf-next v4 0/3] bpf: prevent offloaded programs from running on host via tcx/netkit Jiayuan Chen
2026-08-10  5:05 ` [PATCH bpf-next v4 1/3] bpf, tcx, netkit: reject offloaded programs Jiayuan Chen
2026-08-10  5:06 ` [PATCH bpf-next v4 2/3] bpf, xdp: move offload check into dev_xdp_install() Jiayuan Chen
2026-08-10 18:49   ` Jakub Kicinski
2026-08-11  3:06     ` Jiayuan Chen [this message]
2026-08-10  5:06 ` [PATCH bpf-next v4 3/3] selftests/bpf: xdp: test dev_xdp_install() rejects device-bound program Jiayuan Chen
2026-08-10  5:23   ` sashiko-bot
2026-08-10  6:30   ` bot+bpf-ci

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=cf8655ff-4e45-40ab-898e-aff2aa7145c5@linux.dev \
    --to=jiayuan.chen@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@google.com \
    --cc=emil@etsalapatis.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=ihor.solodrai@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=krikku@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=liuhangbin@gmail.com \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=mkarsten@uwaterloo.ca \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=skhawaja@google.com \
    --cc=song@kernel.org \
    --cc=yonghong.song@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.