aboutsummaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-04-29 07:55:42 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-04-29 14:53:56 +0000
commitee541933d6cdece196c947c5aeecf496cab5e983 (patch)
treea71a35dce425a0b48243884cc21ebbe6c9995f76 /sys
parentff7c0a076c7baabdc6797179f649803250f21bd9 (diff)
prog: add raw deserialization mode
Raw deserialization mode does not do any program sanitization and allows to use global file names, prohibited ioctl's, etc. This will be useful for moving syscall/feature checking code to the host, we will need to probe opening global files, etc.
Diffstat (limited to 'sys')
-rw-r--r--sys/linux/init_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/sys/linux/init_test.go b/sys/linux/init_test.go
index c273a2519..7379f74c0 100644
--- a/sys/linux/init_test.go
+++ b/sys/linux/init_test.go
@@ -155,3 +155,31 @@ syz_open_dev$tty1(0xc, 0x4, 0x1)
},
})
}
+
+func TestDeserializeStrictUnsafe(t *testing.T) {
+ t.Parallel()
+ target, _ := prog.GetTarget("linux", "amd64")
+ // Raw mode must preserve the global file name, allow to use mmap with non-fixed addr,
+ // and allow to use disabled syscalls.
+ had := `openat(0x0, &(0x7f0000000000)='/dev/foo', 0x0, 0x0)
+mmap(0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
+clone(0x0, &(0x7f0000000000), &(0x7f0000000010), &(0x7f0000000020), &(0x7f0000000030))
+`
+ p, err := target.Deserialize([]byte(had), prog.StrictUnsafe)
+ if err != nil {
+ t.Fatal(err)
+ }
+ got := string(p.Serialize())
+ if had != got {
+ t.Fatalf("program was changed:\n%s\ngot:\n%s", had, got)
+ }
+}
+
+func TestDeserializeNonStrictUnsafe(t *testing.T) {
+ t.Parallel()
+ target, _ := prog.GetTarget("linux", "amd64")
+ _, err := target.Deserialize([]byte("clone()"), prog.NonStrictUnsafe)
+ if err != nil {
+ t.Fatal(err)
+ }
+}