vbpf / ebpf-verifier

eBPF verifier based on abstract interpretation
MIT License
392 stars 43 forks source link

Add support for LDDW with src_reg > 1 #533

Open Officeyutong opened 1 year ago

Officeyutong commented 1 year ago

It seems that ebpf-verifier will reject programs containing LDDW instructions with src_reg greater than 1.

At https://github.com/vbpf/ebpf-verifier/blob/fd85b8a6ac2c0cb5621d9c1f38368089d616b8b9/src/asm_unmarshal.cpp#L261

But the eBPF standard defined the usage when specifying src_reg to 2,3,4,5,6. See https://docs.kernel.org/bpf/standardization/instruction-set.html#id20

As a result, ebpf-verifier will reject the probe program produced by libbpf (See https://github.com/libbpf/libbpf/blob/e26b84dc330c9644c07428c271ab491b0f01f4e1/src/libbpf.c#L4650)

dthaler commented 9 months ago

llvm-objdump shows these instructions as ld_pseudo:

18 00 00 00 ff ff ff ff 00 00 00 00 ff ff ff ff r0 = -0x1 ll
18 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ld_pseudo       r1, 0x1, 0x0
18 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ld_pseudo       r2, 0x2, 0x0
18 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ld_pseudo       r3, 0x3, 0x0
18 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ld_pseudo       r4, 0x4, 0x0
18 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ld_pseudo       r5, 0x5, 0x0
18 66 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ld_pseudo       r6, 0x6, 0x0
18 77 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ld_pseudo       r7, 0x7, 0x0
dthaler commented 9 months ago

The IETF specification does cover these now.