mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-27 11:46:46 -04:00
bpf: Inline bpf_iter_num_destroy() as a no-op
Once destroy() returns the stack slot is no longer tracked as iterator state, so zeroing it is dead work. Make the kfunc a no-op and inline the call to a single BPF_JA 0 (the fixup can't drop the instruction outright, so emit a nop; the JITs elide it). Suggested-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Puranjay Mohan <puranjay@kernel.org> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20260804134601.2305303-5-puranjay@kernel.org
This commit is contained in:
committed by
Andrii Nakryiko
parent
e933477048
commit
39f047682f
@@ -818,9 +818,7 @@ __bpf_kfunc int *bpf_iter_num_next(struct bpf_iter_num* it)
|
||||
|
||||
__bpf_kfunc void bpf_iter_num_destroy(struct bpf_iter_num *it)
|
||||
{
|
||||
struct bpf_iter_num_kern *s = (void *)it;
|
||||
|
||||
s->cur = s->end = 0;
|
||||
/* no-op */
|
||||
}
|
||||
|
||||
__bpf_kfunc_end_defs();
|
||||
|
||||
@@ -20047,6 +20047,10 @@ int bpf_fixup_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
|
||||
insn_buf[i++] = BPF_ST_MEM(BPF_DW, BPF_REG_1, 0, 0);
|
||||
insn_buf[i++] = BPF_MOV64_IMM(BPF_REG_0, 0);
|
||||
*cnt = i;
|
||||
} else if (desc->func_id == special_kfunc_list[KF_bpf_iter_num_destroy]) {
|
||||
/* bpf_iter_num_destroy() is a no-op; emit a nop to drop the call */
|
||||
insn_buf[0] = BPF_JMP_A(0);
|
||||
*cnt = 1;
|
||||
}
|
||||
|
||||
if (env->insn_aux_data[insn_idx].arg_prog) {
|
||||
|
||||
Reference in New Issue
Block a user