aboutsummaryrefslogtreecommitdiffstats
path: root/sys/linux
diff options
context:
space:
mode:
authorPaul Chaignon <paul.chaignon@gmail.com>2023-11-27 17:30:48 +0100
committerAleksandr Nogikh <nogikh@google.com>2023-11-27 17:13:18 +0000
commit9fe51b7c608bca7b80c06c30f78c7c60810d51f1 (patch)
tree27e26e7262c6f091d92057ed2710e621a775f9ec /sys/linux
parente60264f30163b15b659d0c84a6a4c8e7edb7a0a3 (diff)
sys/linux: support more complex bpf_snprintf modifiers
This commit adds more complex format modifiers for the bpf_snprintf BPF helper. Those correspond to a bunch of cases that are uncovered in syzbot's coverage of bpf_bprintf_prepare. Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Diffstat (limited to 'sys/linux')
-rw-r--r--sys/linux/bpf.txt2
-rw-r--r--sys/linux/test/bpf_helpers2
2 files changed, 2 insertions, 2 deletions
diff --git a/sys/linux/bpf.txt b/sys/linux/bpf.txt
index 9a6c4f498..8821ee933 100644
--- a/sys/linux/bpf.txt
+++ b/sys/linux/bpf.txt
@@ -158,7 +158,7 @@ map_bpf_const_str {
out fd_bpf_const_str (out_overlay)
}
-bpf_printf_str = "%d ", "%p "
+bpf_printf_str = "%-010d ", "%pK ", "%+9llu ", "%pS ", "%ps ", "%pB ", "%pI4 ", "%pi6 ", "%-5lx "
bpf_map_update_const_str_arg {
map map_bpf_const_str
diff --git a/sys/linux/test/bpf_helpers b/sys/linux/test/bpf_helpers
index e1f994afa..b1d1503e2 100644
--- a/sys/linux/test/bpf_helpers
+++ b/sys/linux/test/bpf_helpers
@@ -7,7 +7,7 @@ r2 = bpf$BPF_PROG_TEST_RUN(AUTO, &AUTO={r1, AUTO, 0x10, 0x10, &AUTO="00000000000
# Prepare, load, and execute a BPF program that calls bpf_snprintf
r1 = bpf$MAP_CREATE_CONST_STR(AUTO, &AUTO={AUTO, AUTO, AUTO, AUTO, AUTO, 0x0, 0x0, "00000000000000000000000000000000", 0x0, 0x0, 0x0, 0x0, 0x0, AUTO}, 0x48)
-r2 = bpf$MAP_UPDATE_CONST_STR(AUTO, &AUTO={{r1, r1}, &AUTO=0x0, &AUTO='%d \x00', AUTO}, 0x1c)
+r2 = bpf$MAP_UPDATE_CONST_STR(AUTO, &AUTO={{r1, r1}, &AUTO=0x0, &AUTO='%-010d \x00', AUTO}, 0x1c)
r3 = bpf$BPF_MAP_CONST_STR_FREEZE(AUTO, &AUTO={r1, r1}, 0x4)
r4 = bpf$PROG_LOAD(AUTO, &AUTO={0x3, AUTO, &AUTO=@framed={{AUTO, AUTO, AUTO, AUTO, 0x0, AUTO, AUTO, AUTO, 0x0}, [@snprintf={AUTO, AUTO, {AUTO, AUTO, AUTO, AUTO, AUTO, AUTO, 0x1234}, AUTO, AUTO, AUTO, AUTO, AUTO, AUTO, {AUTO, AUTO, AUTO, AUTO, r1, AUTO, AUTO, AUTO, AUTO}, AUTO, AUTO}], AUTO}, &AUTO='GPL\x00', 0x0, 0x0, 0x0, 0x0, 0x0, "00000000000000000000000000000000", 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, 0xa0)