[PATCH OLK-6.6 0/2] Fix CVE-2026-98044
Fix CVE-2026-98044 and the kabi breakage. Chen Yuxi (1): bpf: Fix kabi breakage in struct bpf_subprog_info Kumar Kartikeya Dwivedi (1): bpf: Reject legacy packet loads from callbacks include/linux/bpf_verifier.h | 1 + kernel/bpf/verifier.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) -- 2.34.1
From: Kumar Kartikeya Dwivedi <memxor@gmail.com> mainline inclusion from mainline-v7.3-rc2 commit e7d28823c662128caae63f14e16bd394916c139b category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/19749 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... -------------------------------- check_ld_abs() models a failed BPF_LD_ABS or BPF_LD_IND in a subprogram as an implicit return with R0 set to zero. It calls prepare_func_exit() to explore this synthesized path. When the load is reached directly from a synchronous callback, prepare_func_exit() enforces the callback return contract and marks R0 precise. R0 is not derived from a real instruction on this path, so precision backtracking reaches the callback call with R0 still requested and triggers the "callback unexpected regs" verifier bug. A privileged program loader can therefore cause a verifier warning and an -EFAULT BPF_PROG_LOAD. These legacy packet-load instructions are deprecated. Reject them from callbacks rather than complicating their implicit-return model. Check all active frames before constructing the implicit return so nested static subprograms cannot hide the callback context. Global functions are verified independently with a fresh frame zero, so an active-frame check cannot identify a global function called from a callback. Also check the complete subprogram call graph during stack-depth validation and reject a function containing a legacy load when any caller is a callback. This covers global and static descendants without making has_ld_abs transitive, preserving its per-function BTF return-type check. Ordinary uses outside callbacks remain supported. Fixes: ee861486e377 ("bpf: Fix ld_{abs,ind} failure path analysis in subprogs") Reported-by: Sashiko <sashiko-bot@kernel.org> Link: https://lore.kernel.org/bpf/20260903152147.C0E241F00A3A@smtp.kernel.org Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Link: https://lore.kernel.org/r/20260903214758.2727663-8-memxor@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org> Conflicts: include/linux/bpf_verifier.h kernel/bpf/verifier.c [Commit relies on the dinfo call-depth tracking and the is_cb subprog flag from later commits absent in this tree; walk the active frames via the existing ret_prog[]/frame stack, add is_cb and set it in push_callback_call().] Signed-off-by: Chen Yuxi <chenyuxi19@huawei.com> --- include/linux/bpf_verifier.h | 1 + kernel/bpf/verifier.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h index 52e1bdfe65a0..28dc133d9763 100644 --- a/include/linux/bpf_verifier.h +++ b/include/linux/bpf_verifier.h @@ -642,6 +642,7 @@ struct bpf_subprog_info { bool has_ld_abs; bool is_async_cb; KABI_FILL_HOLE(bool changes_pkt_data) + bool is_cb; KABI_RESERVE(1) KABI_RESERVE(2) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 6150ee2a1633..aa615ccf886d 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -6009,6 +6009,19 @@ static int check_max_stack_depth_subprog(struct bpf_verifier_env *env, int idx) i = subprog[idx].start; process_func: + if (subprog[idx].has_ld_abs) { + if (subprog[idx].is_cb) { + verbose(env, "cannot use BPF_LD_[ABS|IND] within callback\n"); + return -EINVAL; + } + for (j = 0; j < frame; j++) { + if (subprog[ret_prog[j]].is_cb) { + verbose(env, "cannot use BPF_LD_[ABS|IND] within callback\n"); + return -EINVAL; + } + } + } + /* protect against potential stack overflow that might happen when * bpf2bpf calls get combined with tailcalls. Limit the caller's stack * depth for such case down to 256 so that the worst case scenario @@ -9499,6 +9512,7 @@ static int push_callback_call(struct bpf_verifier_env *env, struct bpf_insn *ins * interested in validating only BPF helpers that can call subprogs as * callbacks */ + env->subprog_info[subprog].is_cb = true; if (bpf_pseudo_kfunc_call(insn) && !is_sync_callback_calling_kfunc(insn->imm)) { verbose(env, "verifier bug: kfunc %s#%d not marked as callback-calling\n", @@ -15284,6 +15298,7 @@ static bool may_access_skb(enum bpf_prog_type type) */ static int check_ld_abs(struct bpf_verifier_env *env, struct bpf_insn *insn) { + struct bpf_verifier_state *state = env->cur_state; struct bpf_reg_state *regs = cur_regs(env); static const int ctx_reg = BPF_REG_6; u8 mode = BPF_MODE(insn->code); @@ -15294,6 +15309,13 @@ static int check_ld_abs(struct bpf_verifier_env *env, struct bpf_insn *insn) return -EINVAL; } + for (i = state->curframe; i; i--) { + if (state->frame[i]->in_callback_fn) { + verbose(env, "cannot use BPF_LD_[ABS|IND] within callback\n"); + return -EINVAL; + } + } + if (!env->ops->gen_ld_abs) { verbose(env, "bpf verifier is misconfigured\n"); return -EINVAL; -- 2.34.1
hulk inclusion category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/19749 CVE: CVE-2026-98044 -------------------------------- There has 1 hole in struct bpf_subprog_info, it can use KABI_FILL_HOLE to fix this kabi breakage. $ pahole -C bpf_subprog_info vmlinux struct bpf_subprog_info { u32 start; /* 0 4 */ u32 linfo_idx; /* 4 4 */ u16 stack_depth; /* 8 2 */ bool has_tail_call; /* 10 1 */ bool tail_call_reachable; /* 11 1 */ bool has_ld_abs; /* 12 1 */ bool is_async_cb; /* 13 1 */ bool changes_pkt_data; /* 14 1 */ /* XXX 1 byte hole, try to pack */ u64 kabi_reserved1; /* 16 8 */ u64 kabi_reserved2; /* 24 8 */ u64 kabi_reserved3; /* 32 8 */ u64 kabi_reserved4; /* 40 8 */ /* size: 48, cachelines: 1, members: 12 */ /* sum members: 47, holes: 1, sum holes: 1 */ /* last cacheline: 48 bytes */ }; Fixes: 22163807fcf4 ("bpf: Reject legacy packet loads from callbacks") Signed-off-by: Chen Yuxi <chenyuxi19@huawei.com> --- include/linux/bpf_verifier.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h index 28dc133d9763..4266820a86c2 100644 --- a/include/linux/bpf_verifier.h +++ b/include/linux/bpf_verifier.h @@ -642,7 +642,7 @@ struct bpf_subprog_info { bool has_ld_abs; bool is_async_cb; KABI_FILL_HOLE(bool changes_pkt_data) - bool is_cb; + KABI_FILL_HOLE(bool is_cb) KABI_RESERVE(1) KABI_RESERVE(2) -- 2.34.1
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://atomgit.com/openeuler/kernel/merge_requests/30206 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/6VD... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://atomgit.com/openeuler/kernel/merge_requests/30206 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/6VD...
participants (2)
-
Chen Yuxi -
patchwork bot