Compilation broken on Ubuntu 20.04
MatteoNardi opened this issue · 1 comments
MatteoNardi commented
This happens only when using clang version <= 12
This is a regression caused by the argument extraction code:
The verifier complains length might be negative:
; event->exec.data_len = len;
104: (63) *(u32 *)(r8 +276) = r7
R0=inv(id=0) R1=inv(id=0,umax_value=255,var_off=(0x0; 0xff)) R2=inv256 R4=inv(id=8) R6=inv(id=0) R7=inv(id=8) R8=map_value(id=0,off=0,ks=4,vs=536,imm=0) R9=map_value(id=0,off=0,ks=4,vs=536,imm=0) R10=fp0 fp-112=mmmmmmmm fp-120=inv fp-128=ctx fp-136=mmmmmmmm
105: R0=inv(id=0) R1=inv(id=0,umax_value=255,var_off=(0x0; 0xff)) R2=inv256 R4=inv(id=8) R6=inv(id=0) R7=inv(id=8) R8=map_value(id=0,off=0,ks=4,vs=536,imm=0) R9=map_value(id=0,off=0,ks=4,vs=536,imm=0) R10=fp0 fp-112=mmmmmmmm fp-120=inv fp-128=ctx fp-136=mmmmmmmm
; bpf_core_read_user(event->exec.argv, len & (NAME_MAX - 1), (void *)start);
105: (07) r9 += 280
106: R0=inv(id=0) R1=inv(id=0,umax_value=255,var_off=(0x0; 0xff)) R2=inv256 R4=inv(id=8) R6=inv(id=0) R7=inv(id=8) R8=map_value(id=0,off=0,ks=4,vs=536,imm=0) R9_w=map_value(id=0,off=280,ks=4,vs=536,imm=0) R10=fp0 fp-112=mmmmmmmm fp-120=inv fp-128=ctx fp-136=mmmmmmmm
106: (bf) r1 = r9
107: R0=inv(id=0) R1_w=map_value(id=0,off=280,ks=4,vs=536,imm=0) R2=inv256 R4=inv(id=8) R6=inv(id=0) R7=inv(id=8) R8=map_value(id=0,off=0,ks=4,vs=536,imm=0) R9_w=map_value(id=0,off=280,ks=4,vs=536,imm=0) R10=fp0 fp-112=mmmmmmmm fp-120=inv fp-128=ctx fp-136=mmmmmmmm
107: (bf) r2 = r7
108: R0=inv(id=0) R1_w=map_value(id=0,off=280,ks=4,vs=536,imm=0) R2_w=inv(id=8) R4=inv(id=8) R6=inv(id=0) R7=inv(id=8) R8=map_value(id=0,off=0,ks=4,vs=536,imm=0) R9_w=map_value(id=0,off=280,ks=4,vs=536,imm=0) R10=fp0 fp-112=mmmmmmmm fp-120=inv fp-128=ctx fp-136=mmmmmmmm
108: (bf) r3 = r6
109: R0=inv(id=0) R1_w=map_value(id=0,off=280,ks=4,vs=536,imm=0) R2_w=inv(id=8) R3_w=inv(id=18) R4=inv(id=8) R6=inv(id=18) R7=inv(id=8) R8=map_value(id=0,off=0,ks=4,vs=536,imm=0) R9_w=map_value(id=0,off=280,ks=4,vs=536,imm=0) R10=fp0 fp-112=mmmmmmmm fp-120=inv fp-128=ctx fp-136=mmmmmmmm
109: (85) call bpf_probe_read_user#112
R2 min value is negative, either use unsigned or 'var &= const'
verification time 1779 usec
stack depth 136
processed 290 insns (limit 1000000) max_states_per_insn 1 total_states 23 peak_states 23 mark_read 9
1: Permission denied (os error 13)
As a work-around, upgrade llvm:
apt update && apt install -y lsb-release wget software-properties-common gnupg
wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 15
ln -s /usr/bin/clang-15 /usr/bin/clang
ln -s /usr/bin/llvm-strip-15 /usr/bin/llvm-strip
MatteoNardi commented
Closing as LLVM/clang 12 is not supported. Containers can be used with cross on distributions lacking the required LLVM version.