Skip to content

Commit c9287d1

Browse files
gnqsqmonnet
authored andcommitted
bpf: Mask pseudo pointer values in verifier logs
print_bpf_insn() masks ldimm64 immediates for pointer-bearing pseudo sources when pointer leaks are not allowed, but the mask only covers BPF_PSEUDO_MAP_FD and BPF_PSEUDO_MAP_VALUE. BPF_PSEUDO_MAP_IDX, BPF_PSEUDO_MAP_IDX_VALUE, and BPF_PSEUDO_BTF_ID can also be resolved to kernel pointer values before the verifier log prints the instruction. Include them in the existing pointer classification so the log prints 0x0 instead of the rewritten address. Fixes: 4976b718c355 ("bpf: Introduce pseudo_btf_id") Fixes: 387544bfa291 ("bpf: Introduce fd_idx") Signed-off-by: Nuoqi Gui <gnq25@mails.tsinghua.edu.cn> Link: https://lore.kernel.org/r/20260623-f01-13-pseudo-btf-id-cap-bpf-v2-1-a190ebb8f3e2@mails.tsinghua.edu.cn Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
1 parent 5ce09ea commit c9287d1

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/kernel/bpf/disasm.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,10 @@ void print_bpf_insn(const struct bpf_insn_cbs *cbs,
323323
*/
324324
u64 imm = ((u64)(insn + 1)->imm << 32) | (u32)insn->imm;
325325
bool is_ptr = insn->src_reg == BPF_PSEUDO_MAP_FD ||
326-
insn->src_reg == BPF_PSEUDO_MAP_VALUE;
326+
insn->src_reg == BPF_PSEUDO_MAP_VALUE ||
327+
insn->src_reg == BPF_PSEUDO_MAP_IDX ||
328+
insn->src_reg == BPF_PSEUDO_MAP_IDX_VALUE ||
329+
insn->src_reg == BPF_PSEUDO_BTF_ID;
327330
char tmp[64];
328331

329332
if (is_ptr && !allow_ptr_leaks)

0 commit comments

Comments
 (0)