aboutsummaryrefslogtreecommitdiffstats
path: root/prog/resources_test.go
diff options
context:
space:
mode:
authorPaul Chaignon <paul.chaignon@gmail.com>2023-10-05 12:32:04 +0200
committerAleksandr Nogikh <nogikh@google.com>2023-10-09 10:22:31 +0000
commit7236594a2c63f3be360ed0a3feb63b4621530e27 (patch)
tree721ff6a37c87fb7435fb1bbe1281926b8529ae9c /prog/resources_test.go
parent5e837c76f52db819969341086d19d650156d1dc1 (diff)
prog: skip optional input resources
If trying to fuzz only bpf$PROG_LOAD, the executors fail with: SYZFATAL: Manager.Check call failed: machine check failed: all system calls are disabled That is happening because it detects a dependency on fd_bpf_map via two paths: 1. bpf_prog_t.fd_array is an optional pointer to an array of fd_bpf_map. 2. The bpf_insn union contains descriptions for two instructions, bpf_insn_map_fd and bpf_insn_map_value, that reference fd_bpf_map. Both of those cases point to optional uses of fd_bpf_map, but syzkaller isn't able to recognize that today. This commit addresses the first case, when a resource or one of the types using it are explicitly marked as optional. Before this commit, syzkaller was only able to recognize the case where the resource itself is marked as optional. However, in the case of e.g. bpf_prog_t.fd_array, it's the pointer to the array of fd_bpf_map that is marked optional. To fix this, we propagate the optional bit when walking down the AST. We then pass this propagated bit to the callback function via the context. This change was tested on the above bpf$PROG_LOAD case 1, by removing bpf_insn_map_fd and bpf_insn_map_value from the bpf(2) description to avoid hitting case 2. Addressing case 2 will require more changes to the same logic. Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Diffstat (limited to 'prog/resources_test.go')
-rw-r--r--prog/resources_test.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/prog/resources_test.go b/prog/resources_test.go
index e48efa65c..f0ba81adf 100644
--- a/prog/resources_test.go
+++ b/prog/resources_test.go
@@ -153,7 +153,7 @@ func testCreateResource(t *testing.T, target *Target, calls map[*Syscall]bool, r
if res, ok := typ.(*ResourceType); ok && ctx.Dir != DirOut {
s := newState(target, ct, nil)
arg, calls := r.createResource(s, res, DirIn)
- if arg == nil && !res.Optional() {
+ if arg == nil && !ctx.Optional {
t.Fatalf("failed to create resource %v", res.Name())
}
if arg != nil && len(calls) == 0 {