eBPF-based security platform
testing: build the CBMC harnesses with the build's include paths
Daniel Borkmann9ac84373b377
diff --git a/.agents/skills/security-audit/SKILL.md b/.agents/skills/security-audit/SKILL.mdindex bfe8535f..2f982e84 100644--- a/.agents/skills/security-audit/SKILL.md+++ b/.agents/skills/security-audit/SKILL.md@@ -307,7 +307,8 @@ CBMC proof a fact box names, and each one the audit leans on:```shcd testing/proofs/cbmc # options: the proof's line in proofs.list-cbmc --function harness -I ../../../include -I ../../../util \+cbmc --function harness -I ../../.. -I ../../../include -I ../../../util \+ -I ../../../vendor/libbpf -I ../../../vendor/libbpf/include/uapi \-D_GNU_SOURCE --unsigned-char <options> [-DLEN=<n>] \--cover location <proof>.c | grep 'util/.*FAILED'```diff --git a/testing/proofs/cbmc/proofs.list b/testing/proofs/cbmc/proofs.listindex 61f61680..24590a7e 100644--- a/testing/proofs/cbmc/proofs.list+++ b/testing/proofs/cbmc/proofs.list@@ -18,11 +18,11 @@ upatch-signed-sections --refine-arithmetic --unwind 2 --unwindset parse_signed_supatch-signed-name --refine-arithmetic --unwind 2 --unwindset parse_signed_sections.0:2,parse_decoders.0:2,parse_policy_labels.0:0 LEN=288upatch-prog-specs --refine-arithmetic --memory-leak-check --malloc-may-fail --malloc-fail-null --unwind 3 --unwindset memchr.0:129,memcmp.0:129,strchr.0:129,strnlen.0:1,strlen.0:1,parse_uprobe_targets.0:0,parse_uprobe_targets.1:0,uprobe_valid.0:1 LEN=3,15,16,176upatch-prog-uprobes --memory-leak-check --malloc-may-fail --malloc-fail-null --unwind 3 --unwindset memchr.0:129,memcmp.0:129,strchr.0:129,strnlen.0:12,strlen.0:12,prog_specs_parse.2:3,prog_specs_parse.3:2,uprobe_valid.0:3 LEN=226-upatch-loader -I ../../../vendor/libbpf/include/uapi -I ../../../vendor/libbpf --unwind 50 LEN=4,5,25,49-upatch-rodata-btf -I ../../../vendor/libbpf/include/uapi -I ../../../vendor/libbpf --refine-arithmetic --object-bits 10 --unwind 16 LEN=4,10,15-upatch-btf -I ../../../vendor/libbpf/include/uapi -I ../../../vendor/libbpf --unwind 6 --unwindset btf_decl_printable.0:33,btf_name_printable.0:7,btf_unwrap.0:9-upatch-btf-int -I ../../../vendor/libbpf/include/uapi -I ../../../vendor/libbpf --unwind 2 --unwindset btf_integer.0:65-upatch-rodata -I ../../../vendor/libbpf/include/uapi -I ../../../vendor/libbpf --refine-arithmetic --object-bits 12 --max-field-sensitivity-array-size 32 --unwind 25 --unwindset memcpy.0:49,strlen.0:18,strcmp.0:18,strnlen.0:18 LEN=6,8,24+upatch-loader --unwind 50 LEN=4,5,25,49+upatch-rodata-btf --refine-arithmetic --object-bits 10 --unwind 16 LEN=4,10,15+upatch-btf --unwind 6 --unwindset btf_decl_printable.0:33,btf_name_printable.0:7,btf_unwrap.0:9+upatch-btf-int --unwind 2 --unwindset btf_integer.0:65+upatch-rodata --refine-arithmetic --object-bits 12 --max-field-sensitivity-array-size 32 --unwind 25 --unwindset memcpy.0:49,strlen.0:18,strcmp.0:18,strnlen.0:18 LEN=6,8,24string-number-model --unwind 6measured-fold-model --unwind 7bpm-tree-follows --unwind 4@@ -56,12 +56,12 @@ log-escape --unwind 7 LEN=0-5json-emit-string --unwind 5 --unwindset json_string.0:27,put_string_n.0:5,put_raw.0:7,well_formed.0:27,replaced.0:5,memchr.0:9,memcmp.0:13 LEN=0-4json-emit-buffer --unwind 1 --unwindset json_raw_value.0:5,harness.0:5 --malloc-may-fail --malloc-fail-null LEN=0-4json-emit-nest --object-bits 12 --unwind 1 --unwindset json_text.0:57,sequences.0:4,sequences.1:5,any_depth.0:4,any_depth.1:4,strcmp.0:12,memchr.0:9,put_string_n.0:2,put_string_n.1:2,put_raw.0:8,json_kv_raw.0:3,json_raw_value.0:3,json_raw.0:5,strlen.0:3,vsnprintf.2:5,vsnprintf.0:2,format_number.0:3,format_number.2:5,format_number.3:3-keepalive-emit -I ../../.. --object-bits 12 --max-field-sensitivity-array-size 896 --unwind 1 --unwindset json_members.0:897,power_of_ten.0:6,put_string_n.0:5,put_string_n.1:66,put_raw.0:7,strlen.0:66,hex_is_lower.0:66,kv_counters.0:43,kv_no_tree.0:8,json_raw_value.0:6,vsnprintf.2:4,vsnprintf.0:2,format_number.0:6,format_number.2:5,format_number.3:6,ends_in_any_number.0:6,ends_in_any_number.1:897,ends_in_any_number.2:5 LEN=0-3+keepalive-emit --object-bits 12 --max-field-sensitivity-array-size 896 --unwind 1 --unwindset json_members.0:897,power_of_ten.0:6,put_string_n.0:5,put_string_n.1:66,put_raw.0:7,strlen.0:66,hex_is_lower.0:66,kv_counters.0:43,kv_no_tree.0:8,json_raw_value.0:6,vsnprintf.2:4,vsnprintf.0:2,format_number.0:6,format_number.2:5,format_number.3:6,ends_in_any_number.0:6,ends_in_any_number.1:897,ends_in_any_number.2:5 LEN=0-3json-string --unwind 5 --unwindset json_string.0:7,parse_string.0:5,parse_string.1:7,memchr.0:9,memcmp.0:7,harness.0:8 LEN=0-6json-escape --unwind 5 --unwindset parse_string.0:4,memcmp.0:9json-roundtrip --unwind 1 --unwindset put_string_n.0:5,put_string_n.1:5,put_raw.0:7,vsnprintf.2:4,vsnprintf.0:2,format_number.0:3,format_number.2:5,format_number.3:3,parse_string.1:6,parse_string.0:4,hex4.0:5,utf8_width.0:4,memcmp.0:5 LEN=0-4-otel-header-fields -I ../../../vendor/libbpf -I ../../../vendor/libbpf/include/uapi -D__NO_CTYPE --unwind 34 --unwindset strchr.0:17 LEN=32-otel-retry-after -I ../../../vendor/libbpf -I ../../../vendor/libbpf/include/uapi -D__NO_CTYPE --unwind 1 --unwindset response_header.0:33,response_header.1:33,otel_retry_after.0:33,otel_retry_after.1:33,delay.0:33,strlen.0:34,strncasecmp.0:13 LEN=32+otel-header-fields -D__NO_CTYPE --unwind 34 --unwindset strchr.0:17 LEN=32+otel-retry-after -D__NO_CTYPE --unwind 1 --unwindset response_header.0:33,response_header.1:33,otel_retry_after.0:33,otel_retry_after.1:33,delay.0:33,strlen.0:34,strncasecmp.0:13 LEN=32json-walk -DJSON_MAX_DEPTH=2 --unwind 3 --unwindset string_end.0:2,code_unit.0:0,hex4.0:0,parse_string.0:1,parse_string.1:2,literal_end.0:4,json_text.0:3,json_text.1:3,utf8_width.0:1,parse_array.0:1,parse_object.0:1,parse_object.1:1,digits_end.0:3,digits.0:3,skip_ws.0:3,strlen.0:6,memcmp.0:1,memchr.0:3,strnlen.0:4 LEN=0-2json-limits -DJSON_MAX_DEPTH=2 -DJSON_MAX_BYTES=24 --unwind 8json-field --unwind 1 --unwindset digits_end.0:7,decimal.0:7,harness.0:7,skip_ws.0:7,parse_string.1:7,parse_string.0:4,hex4.0:0,utf8_width.0:4,parse_base.0:7,parse_base.1:7,digits.0:7,strnlen.0:4,strlen.0:6,memcmp.0:6 LEN=0-6@@ -90,7 +90,7 @@ json-string-model --unwind 5 --unwindset parse_string.0:7,parse_string.1:7,modeljson-escape-model --unwind 5 --unwindset parse_string.0:4,parse_string.1:4,model_read.0:4,memcmp.0:9bpm-archive-path-model --unwind 12 LEN=0-10hex-digest --unwind 74 LEN=0,6-8,70-72-serializer-chunk -I ../../.. --unwind 1+serializer-chunk --unwind 1paths-join --unwind 12paths-pin --unwind 32 LEN=0,1,28-35similar-distance --max-field-sensitivity-array-size 65 --unwind 8 --unwindset memcpy.0:18 LEN=0-15@@ -102,14 +102,14 @@ config-evidence-parse --unwind 1 --unwindset config_evidence_parse.0:7,on_event.config-evidence-roundtrip --unwind 1 --unwindset config_evidence_emit.0:4,hex_encode.0:33,config_evidence_parse.0:7,on_event.0:4,replay.0:4,hex_decode.0:33,strlen.0:66,strcmp.0:15,named.0:7,json_parse.0:7,json_parse.1:4,give_event.0:4,give_text.0:66,json_kv_string.0:66,sequence_overflows.0:4,replays.0:4,same.0:33,blank.0:33,check_read_back.0:4 --memory-leak-check --slice-formula LEN=0-2config-evidence-verify --unwind 1 --unwindset replay.0:4,memcmp.0:33,in_order.0:4,check_event.0:24,same.0:33 --slice-formula LEN=0-3config-evidence-collect --unwind 1 --unwindset config_update_events.0:4,replay.0:4,memcmp.0:33,history.0:4,check_exported.0:4,same.0:33,blank.0:33 --memory-leak-check --slice-formula LEN=0-2-upatch-writer-header -I ../../.. -I ../../../vendor/libbpf/include/uapi -I ../../../vendor/libbpf --unwind 2 --unwindset strnlen.0:257,memchr.0:257,memcmp.0:33-upatch-writer-sections -I ../../.. -I ../../../vendor/libbpf/include/uapi -I ../../../vendor/libbpf --memory-leak-check --max-field-sensitivity-array-size 512 --object-bits 10 --unwind 2 --unwindset harness.0:9,compose_signed_data.0:3,compose_signed_data.1:3,parse_signed_sections.0:3,parse_decoders.0:0,parse_policy_labels.0:0 LEN=0,1,7,8-upatch-writer-load -I ../../.. -I ../../../vendor/libbpf/include/uapi -I ../../../vendor/libbpf --max-field-sensitivity-array-size 8192 --unwind 2 --unwindset compose_signed_data.0:5,compose_signed_data.1:5,parse_signed_sections.0:5,parse_decoders.0:2,parse_policy_labels.0:2 LEN=1-upatch-writer-decoders -I ../../.. -I ../../../vendor/libbpf/include/uapi -I ../../../vendor/libbpf --memory-leak-check --max-field-sensitivity-array-size 512 --unwind 3 --unwindset strnlen.0:65,memchr.0:65,copy_bytes.0:65,viewed.0:4 LEN=0-2-upatch-writer-prog-specs -I ../../.. -I ../../../vendor/libbpf/include/uapi -I ../../../vendor/libbpf --refine-arithmetic --memory-leak-check --max-field-sensitivity-array-size 512 --object-bits 12 --unwind 4 --unwindset strlen.0:161,strcmp.0:161,strncmp.0:21,strchr.0:161,strrchr.0:161,strnlen.0:161,memchr.0:129,memcmp.0:129,parse_base.0:21,parse_base.1:21,digits.0:21,default_attach_section.0:8,uprobe_section_target.0:9,text.0:161,decimal.0:5,resolve.1:65 LEN=0-21-upatch-writer-kprobes -I ../../.. -I ../../../vendor/libbpf/include/uapi -I ../../../vendor/libbpf --refine-arithmetic --memory-leak-check --max-field-sensitivity-array-size 512 --object-bits 12 --unwind 4 --unwindset strlen.0:161,strcmp.0:161,strncmp.0:21,strchr.0:161,strrchr.0:161,strnlen.0:161,memchr.0:129,memcmp.0:129,parse_base.0:21,parse_base.1:21,digits.0:21,default_attach_section.0:8,uprobe_section_target.0:9,text.0:161,decimal.0:5,resolve.1:65 LEN=0-15-upatch-writer-xdp -I ../../.. -I ../../../vendor/libbpf/include/uapi -I ../../../vendor/libbpf --refine-arithmetic --memory-leak-check --max-field-sensitivity-array-size 512 --object-bits 12 --unwind 4 --unwindset strlen.0:161,strcmp.0:161,strncmp.0:21,strchr.0:161,strrchr.0:161,strnlen.0:161,memchr.0:129,memcmp.0:129,parse_base.0:21,parse_base.1:21,digits.0:21,default_attach_section.0:8,uprobe_section_target.0:9,text.0:161,decimal.0:5,resolve.1:65 LEN=0-8-upatch-writer-uprobes -I ../../.. -I ../../../vendor/libbpf/include/uapi -I ../../../vendor/libbpf --refine-arithmetic --memory-leak-check --max-field-sensitivity-array-size 512 --object-bits 12 --unwind 4 --unwindset strlen.0:161,strcmp.0:161,strncmp.0:21,strchr.0:161,strrchr.0:161,strnlen.0:161,memchr.0:129,memcmp.0:129,parse_base.0:21,parse_base.1:21,digits.0:21,default_attach_section.0:8,uprobe_section_target.0:9,text.0:161,decimal.0:5,resolve.1:65 LEN=0-21+upatch-writer-header --unwind 2 --unwindset strnlen.0:257,memchr.0:257,memcmp.0:33+upatch-writer-sections --memory-leak-check --max-field-sensitivity-array-size 512 --object-bits 10 --unwind 2 --unwindset harness.0:9,compose_signed_data.0:3,compose_signed_data.1:3,parse_signed_sections.0:3,parse_decoders.0:0,parse_policy_labels.0:0 LEN=0,1,7,8+upatch-writer-load --max-field-sensitivity-array-size 8192 --unwind 2 --unwindset compose_signed_data.0:5,compose_signed_data.1:5,parse_signed_sections.0:5,parse_decoders.0:2,parse_policy_labels.0:2 LEN=1+upatch-writer-decoders --memory-leak-check --max-field-sensitivity-array-size 512 --unwind 3 --unwindset strnlen.0:65,memchr.0:65,copy_bytes.0:65,viewed.0:4 LEN=0-2+upatch-writer-prog-specs --refine-arithmetic --memory-leak-check --max-field-sensitivity-array-size 512 --object-bits 12 --unwind 4 --unwindset strlen.0:161,strcmp.0:161,strncmp.0:21,strchr.0:161,strrchr.0:161,strnlen.0:161,memchr.0:129,memcmp.0:129,parse_base.0:21,parse_base.1:21,digits.0:21,default_attach_section.0:8,uprobe_section_target.0:9,text.0:161,decimal.0:5,resolve.1:65 LEN=0-21+upatch-writer-kprobes --refine-arithmetic --memory-leak-check --max-field-sensitivity-array-size 512 --object-bits 12 --unwind 4 --unwindset strlen.0:161,strcmp.0:161,strncmp.0:21,strchr.0:161,strrchr.0:161,strnlen.0:161,memchr.0:129,memcmp.0:129,parse_base.0:21,parse_base.1:21,digits.0:21,default_attach_section.0:8,uprobe_section_target.0:9,text.0:161,decimal.0:5,resolve.1:65 LEN=0-15+upatch-writer-xdp --refine-arithmetic --memory-leak-check --max-field-sensitivity-array-size 512 --object-bits 12 --unwind 4 --unwindset strlen.0:161,strcmp.0:161,strncmp.0:21,strchr.0:161,strrchr.0:161,strnlen.0:161,memchr.0:129,memcmp.0:129,parse_base.0:21,parse_base.1:21,digits.0:21,default_attach_section.0:8,uprobe_section_target.0:9,text.0:161,decimal.0:5,resolve.1:65 LEN=0-8+upatch-writer-uprobes --refine-arithmetic --memory-leak-check --max-field-sensitivity-array-size 512 --object-bits 12 --unwind 4 --unwindset strlen.0:161,strcmp.0:161,strncmp.0:21,strchr.0:161,strrchr.0:161,strnlen.0:161,memchr.0:129,memcmp.0:129,parse_base.0:21,parse_base.1:21,digits.0:21,default_attach_section.0:8,uprobe_section_target.0:9,text.0:161,decimal.0:5,resolve.1:65 LEN=0-21vouch-payload --malloc-may-fail --malloc-fail-null --unwind 3 --unwindset memcmp.0:33,harness.0:5 LEN=0-2bpm-tar-writer --unwind 24 --unwindset tar_entry.0:513,bpm_tar_header_ok.0:513,memchr.0:101,memcpy.0:101,strlen.0:101,strnlen.0:101,strcmp.0:102,harness.0:101 --max-field-sensitivity-array-size 512 LEN=1,99,100bpm-beefile-string --unwind 15 LEN=0-12@@ -137,5 +137,5 @@ bpm-tree-state-replay-lines --unwind 8 --unwindset strlen.0:66,hex_decode.0:33,tbpm-tree-state-pending --unwind 5 --unwindset upatch_name_valid.0:10,strnlen.0:74,memcpy.0:257,strlen.0:66,strcmp.0:18,hex_decode.0:33,digest_text.0:65,memcmp.0:8,strncmp.0:8bpm-tree-state-match --unwind 4 --unwindset read_config_stream.0:7,read_config_stream.1:9,read_config_stream.2:9,read_config_stream.3:9,read_config_stream.4:9,read_text_line.0:9,strlen.0:9,strchr.0:9,strnlen.0:9,memcpy.0:9,memcmp.0:26 LEN=0-3bpm-tree-state-options --unwind 4-keepalive-pack -I ../../.. --unwind 9 --unwindset strcmp.0:18,keepalive_mask.0:514,mask.0:514,mask.1:514 LEN=0-9,512,513+keepalive-pack --unwind 9 --unwindset strcmp.0:18,keepalive_mask.0:514,mask.0:514,mask.1:514 LEN=0-9,512,513sysinfo-image --unwind 8 --unwindset strcmp.0:8,memcmp.0:10,os_release_unquote.0:258,cmdline_image_root.0:8,cmdline_image_root.1:76,cmdline_image_root.2:5,strlen.0:11,all_hex.0:65,image_root_normalise.0:65,command_line.0:65,command_line.1:65 LEN=0-6diff --git a/testing/proofs/cbmc/run.sh b/testing/proofs/cbmc/run.shindex 490b33f7..5b47e27a 100755--- a/testing/proofs/cbmc/run.sh+++ b/testing/proofs/cbmc/run.sh@@ -37,6 +37,12 @@ command -v cbmc >/dev/null 2>&1 || {exit 2}+# The build's include paths, so that a harness reads the headers the code+# is built with: the libbpf and UAPI headers of vendor/libbpf, not the+# host's.+includes='-I ../../.. -I ../../../include -I ../../../util+ -I ../../../vendor/libbpf -I ../../../vendor/libbpf/include/uapi'+# --unsigned-char as the build's -funsigned-char.checks='--unsigned-char --bounds-check --pointer-check--pointer-primitive-check --div-by-zero-check --signed-overflow-check@@ -53,22 +59,15 @@ if [ -n "$range" ]; thenfifi-# Whether a harness, built with the -I and -D options and the first-# length of its line, reads a changed file. One the compiler cannot list-# counts as changed.+# Whether a harness, built with the -D options and the first length of+# its line, reads a changed file. One the compiler cannot list counts as+# changed.touched() {name=$1shiftflags=- dir=for o in "$@"; do- if [ -n "$dir" ]; then- flags="$flags -I $o"- dir=- continue- ficase $o in- -I) dir=1 ;;-D*) flags="$flags $o" ;;LEN=*)o=${o#LEN=}@@ -77,8 +76,8 @@ touched() {esacdone# shellcheck disable=SC2086- "${CC:-cc}" -MM -I "$root/include" -I "$root/util" -D_GNU_SOURCE \- $flags "$name.c" >"$work/deps" 2>/dev/null || return 0+ "${CC:-cc}" -MM $includes -D_GNU_SOURCE $flags "$name.c" \+ >"$work/deps" 2>/dev/null || return 0sed 's/\\$//' "$work/deps" | tr -s ' ' '\n' | grep -v ':$' | grep . |xargs realpath --relative-to="$root" |grep -qxF -f "$work/changed"@@ -100,8 +99,8 @@ prove() {log=$1shift# shellcheck disable=SC2086- cbmc --function harness -I "$root/include" -I "$root/util" \- -D_GNU_SOURCE $checks "$@" $verbose >"$log" 2>&1 &&+ cbmc --function harness $includes -D_GNU_SOURCE $checks "$@" \+ $verbose >"$log" 2>&1 &&! grep -q 'no body for function' "$log"}