The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Xu Kuohai <xukuohai@huaweicloud.com>
To: bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	Yonghong Song <yonghong.song@linux.dev>,
	Anton Protopopov <a.s.protopopov@gmail.com>
Subject: [PATCH bpf-next v2 0/2] bpf: Eliminate unnecessary clone/restore due to constants blinding
Date: Tue, 28 Jul 2026 20:25:48 +0000	[thread overview]
Message-ID: <cover.1785240296.git.xukuohai@huawei.com> (raw)

From: Xu Kuohai <xukuohai@huawei.com>

This series eliminates the unnecessary clone/restore overhead
introduced by patch d3e945223e0158c8 ("bpf: Move constants blinding
out of arch-specific JITs"), which moved constants blinding from JIT
code to general verifier code, and added env->insn_aux_data and subprog
starts duplication and restoration around constants blinding operations
to resolve the inconsistency between the metadata and instruction arrays.

Patch 1 eliminates the insn_aux_data duplication/restore. After JIT
failure, bpf_clear_insn_aux_data() is the only function that requires
insnsi and insn_aux_data to stay in sync as it accesses them using the
same size and index. However, the insnsi access is unnecessary as it is
checked to skip the second slot of an ldimm64 instruction which can be
absorbed into the jt check itself, so removing it eliminates the need
for the duplication/restore.

Patch 2 eliminates the prog clone and subprog duplication/restore
when the interpreter fallback is not available on JIT failure.

v2:
- Address UAF in bpf_fixup_call_args() (sashiko)

v1: https://lore.kernel.org/bpf/cover.1783775928.git.xukuohai@huaweicloud.com/

Xu Kuohai (2):
  bpf: Eliminate dup/restore of insn_aux_data
  bpf: Remove unnecessary dup/restore subprog_starts and prog clone

 include/linux/bpf_verifier.h |   1 +
 include/linux/filter.h       |  22 ++-----
 kernel/bpf/core.c            | 120 +++++++++++++++++------------------
 kernel/bpf/fixups.c          |  73 ++++++---------------
 kernel/bpf/verifier.c        |   4 +-
 5 files changed, 88 insertions(+), 132 deletions(-)

-- 
2.47.3


             reply	other threads:[~2026-07-28 12:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28 20:25 Xu Kuohai [this message]
2026-07-28 20:25 ` [PATCH bpf-next v2 1/2] bpf: Eliminate dup/restore of insn_aux_data Xu Kuohai
2026-08-10 21:17   ` Eduard Zingerman
2026-07-28 20:25 ` [PATCH bpf-next v2 2/2] bpf: Remove unnecessary dup/restore subprog_starts and prog clone Xu Kuohai
2026-08-10 21:27   ` Eduard Zingerman
2026-08-11 13:00     ` Xu Kuohai

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=cover.1785240296.git.xukuohai@huawei.com \
    --to=xukuohai@huaweicloud.com \
    --cc=a.s.protopopov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=memxor@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox