All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v5 05/14] bpf: Support __arena and __arena__nullable on struct_ops arguments
Date: Sat, 08 Aug 2026 01:17:08 +0000	[thread overview]
Message-ID: <20260808011708.EEBB51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260808003938.3486067-6-memxor@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Attaching an extension (freplace) or tracing (FENTRY/FEXIT) program to a struct_ops program with arena arguments bypasses arena context argument verification, leading to type confusion and potential privilege escalation.
--

--- Patch [5]: [PATCH bpf-next v5 05/14] bpf: Support __arena and __arena__nullable on struct_ops arguments ---
commit b8ab49b96186f2dfd00ae0e67ee1912d4b9e3fac
Author: Tejun Heo <tj@kernel.org>
bpf: Support __arena and __arena__nullable on struct_ops arguments

This commit adds support for __arena and __arena__nullable suffixes for
arguments in struct_ops stub functions. It allows callbacks to receive
arena pointers directly, with the trampoline handling the conversion between
the kernel address and the BPF arena pointer.

(Note: The format of this report is altered to use a free-form summary
rather than inline diff quotes due to recitation restrictions.)

[Severity: High]
There appears to be an issue in how __bpf_trampoline_link_prog() checks
for arena arguments when linking programs. The security check evaluates
bpf_prog_has_arena_ctx_arg(node->link->prog), which checks the attaching
program rather than the target program (tgt_prog).

Because the attaching extension or tracing program does not have its
ctx_arg_info_size initialized (it is 0), this check is bypassed and the
attachment is allowed.

Furthermore, during verification of the extension program in
btf_ctx_access(), the verifier loops over ctx_arg_info_size. Since it is
0 for the attaching program, the loop is skipped. The verifier then
incorrectly types the 32-bit offset argument as a trusted 64-bit kernel
pointer (PTR_TO_BTF_ID) based on the original BTF signature.

At runtime, the struct_ops indirect trampoline converts the incoming kernel
pointer into a 32-bit arena offset and invokes the extension program. Since
the verifier sees this as a trusted kernel pointer, could this lead to a
type confusion where a user-controlled 32-bit offset is dereferenced as a
kernel pointer? 

Should __bpf_trampoline_link_prog() check tgt_prog instead, and does the
verifier need to inherit or check the ctx_arg_info of the target program
for extension programs?

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

  reply	other threads:[~2026-08-08  1:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-08  0:39 [PATCH bpf-next v5 00/14] Add arena argument support to kfuncs and struct_ops Kumar Kartikeya Dwivedi
2026-08-08  0:39 ` [PATCH bpf-next v5 01/14] bpf: Rename 'early' BTF checking as a preparation phase Kumar Kartikeya Dwivedi
2026-08-08  0:39 ` [PATCH bpf-next v5 02/14] bpf: Split subprogram and kfunc collection Kumar Kartikeya Dwivedi
2026-08-08  1:59   ` bot+bpf-ci
2026-08-08  0:39 ` [PATCH bpf-next v5 03/14] bpf: Collect kfuncs after resolving program resources Kumar Kartikeya Dwivedi
2026-08-08  0:39 ` [PATCH bpf-next v5 04/14] bpf: Support __arena and __arena__nullable kfunc argument suffixes Kumar Kartikeya Dwivedi
2026-08-08  0:39 ` [PATCH bpf-next v5 05/14] bpf: Support __arena and __arena__nullable on struct_ops arguments Kumar Kartikeya Dwivedi
2026-08-08  1:17   ` sashiko-bot [this message]
2026-08-08  9:49   ` Eduard Zingerman
2026-08-08  0:39 ` [PATCH bpf-next v5 06/14] bpf, x86: JIT __arena kfunc argument rebasing Kumar Kartikeya Dwivedi
2026-08-08  0:39 ` [PATCH bpf-next v5 07/14] bpf, x86: Convert struct_ops arena arguments in the trampoline Kumar Kartikeya Dwivedi
2026-08-08  0:39 ` [PATCH bpf-next v5 08/14] selftests/bpf: Add kfunc __arena and __arena__nullable argument tests Kumar Kartikeya Dwivedi
2026-08-08  0:39 ` [PATCH bpf-next v5 09/14] selftests/bpf: Add JIT-sequence tests for __arena kfunc arguments Kumar Kartikeya Dwivedi
2026-08-08  0:39 ` [PATCH bpf-next v5 10/14] selftests/bpf: Add struct_ops __arena and __arena__nullable argument tests Kumar Kartikeya Dwivedi
2026-08-08  1:03   ` sashiko-bot
2026-08-08  0:39 ` [PATCH bpf-next v5 11/14] bpf, x86: Fix stack-passed arguments for indirect trampolines Kumar Kartikeya Dwivedi
2026-08-08  1:04   ` sashiko-bot
2026-08-08  0:39 ` [PATCH bpf-next v5 12/14] selftests/bpf: Test stack-passed struct_ops arena arguments Kumar Kartikeya Dwivedi
2026-08-08  0:39 ` [PATCH bpf-next v5 13/14] bpf: Reject tracing/freplace progs for struct_ops with arena args Kumar Kartikeya Dwivedi
2026-08-08  1:17   ` sashiko-bot
2026-08-08  9:57   ` Eduard Zingerman
2026-08-08  0:39 ` [PATCH bpf-next v5 14/14] selftests/bpf: Test attach rejection for struct_ops arena programs Kumar Kartikeya Dwivedi
2026-08-08  9:58   ` Eduard Zingerman
2026-08-08 10:10 ` [PATCH bpf-next v5 00/14] Add arena argument support to kfuncs and struct_ops 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=20260808011708.EEBB51F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=memxor@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.