public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiayuan Chen" <jiayuan.chen@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf v2 1/3] bpf, tcx: reject offloaded programs on attach
Date: Sat, 25 Apr 2026 10:44:33 +0000	[thread overview]
Message-ID: <20260425104434.7E4D8C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260424104201.217604-2-jiayuan.chen@linux.dev>

Sashiko AI review found 1 potential issue(s):
- [Low] The `bpf_prog_is_offloaded()` check added to `tcx_prog_attach()` is unreachable (dead code).
--

commit 4bde7a6b1e8fdca118910a3c0f4b35254f1c6e42
Author: Jiayuan Chen <jiayuan.chen@linux.dev>

bpf, tcx: reject offloaded programs on attach

This commit adds checks to prevent offloaded BPF programs from being
attached via tcx, as they are meant to run on the NIC rather than the
host. The guards are added to tcx_prog_attach(), tcx_link_attach(),
and tcx_link_update().

Closes: https://lore.kernel.org/bpf/64d8e2b5-a214-4f3c-b9e8-bcedbcb2c602@hust.edu.cn/

> diff --git a/kernel/bpf/tcx.c b/kernel/bpf/tcx.c
> index 02db0113b8e7c6..1144627483d53d 100644
> --- a/kernel/bpf/tcx.c
> +++ b/kernel/bpf/tcx.c
> @@ -16,6 +16,9 @@ int tcx_prog_attach(const union bpf_attr *attr, struct bpf_prog *prog)
>  	struct net_device *dev;
>  	int ret;
>  
> +	if (bpf_prog_is_offloaded(prog->aux))
> +		return -EINVAL;
> +

Is it possible for an offloaded program to actually reach this check
in tcx_prog_attach()?

Looking at the prog attach syscall handler, it acquires the program
using bpf_prog_get_type(). This function hardcodes attach_drv = false
when calling __bpf_prog_get().

As a result, bpf_prog_get_ok() explicitly rejects any offloaded program
with -EINVAL before tcx_prog_attach() is ever called.

While the checks added to tcx_link_attach() and tcx_link_update() lower
in this patch appear necessary (since link creation uses bpf_prog_get(),
which skips attach-type validation and bypasses bpf_prog_get_ok()), does
the caller environment make this specific check in tcx_prog_attach()
unreachable?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260424104201.217604-1-jiayuan.chen@linux.dev?part=1

  parent reply	other threads:[~2026-04-25 10:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-24 10:41 [PATCH bpf v2 0/3] bpf: prevent offloaded programs from running on host via tcx/netkit Jiayuan Chen
2026-04-24 10:41 ` [PATCH bpf v2 1/3] bpf, tcx: reject offloaded programs on attach Jiayuan Chen
2026-04-24 13:57   ` Alexei Starovoitov
2026-04-25 10:44   ` sashiko-bot [this message]
2026-04-24 10:41 ` [PATCH bpf v2 2/3] bpf, netkit: " Jiayuan Chen
2026-04-24 10:41 ` [PATCH bpf v2 3/3] bpf, xdp: reject offloaded programs on link update Jiayuan Chen
2026-04-25 10:44   ` sashiko-bot

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=20260425104434.7E4D8C2BCB0@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=jiayuan.chen@linux.dev \
    --cc=sashiko@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