aboutsummaryrefslogtreecommitdiffstats
path: root/sys/linux
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-03-14 16:42:00 +0100
committerDmitry Vyukov <dvyukov@google.com>2020-03-17 21:19:13 +0100
commit80d43738f1e4c648ccfc4599e17dc8ba455fe1ea (patch)
treea2adb84b67e9d760a35fee40ddf06d271f70bab1 /sys/linux
parenta2f9a446496d23c4bf6db95e0d4337583595c78c (diff)
prog: rename target.SanitizeCall to Neutralize
We will need a wrapper for target.SanitizeCall that will do more than just calling the target-provided function. To avoid confusion and potential mistakes, give the target function and prog function different names. Prog package will continue to call this "sanitize", which will include target's "neutralize" + more. Also refactor API a bit: we need a helper function that sanitizes the whole program because that's needed most of the time. Fixes #477 Fixes #502
Diffstat (limited to 'sys/linux')
-rw-r--r--sys/linux/init.go18
-rw-r--r--sys/linux/init_iptables.go2
-rw-r--r--sys/linux/init_test.go2
3 files changed, 11 insertions, 11 deletions
diff --git a/sys/linux/init.go b/sys/linux/init.go
index cf54ffcd0..e1474995b 100644
--- a/sys/linux/init.go
+++ b/sys/linux/init.go
@@ -12,7 +12,7 @@ import (
func InitTarget(target *prog.Target) {
arch := &arch{
- unix: targets.MakeUnixSanitizer(target),
+ unix: targets.MakeUnixNeutralizer(target),
clockGettimeSyscall: target.SyscallMap["clock_gettime"],
MREMAP_MAYMOVE: target.GetConst("MREMAP_MAYMOVE"),
MREMAP_FIXED: target.GetConst("MREMAP_FIXED"),
@@ -49,7 +49,7 @@ func InitTarget(target *prog.Target) {
}
target.MakeMmap = targets.MakePosixMmap(target)
- target.SanitizeCall = arch.sanitizeCall
+ target.Neutralize = arch.neutralize
target.SpecialTypes = map[string]func(g *prog.Gen, typ prog.Type, old prog.Arg) (
prog.Arg, []*prog.Call){
"timespec": arch.generateTimespec,
@@ -118,7 +118,7 @@ var (
)
type arch struct {
- unix *targets.UnixSanitizer
+ unix *targets.UnixNeutralizer
clockGettimeSyscall *prog.Syscall
@@ -155,8 +155,8 @@ type arch struct {
TIOCGSERIAL uint64
}
-func (arch *arch) sanitizeCall(c *prog.Call) {
- arch.unix.SanitizeCall(c)
+func (arch *arch) neutralize(c *prog.Call) {
+ arch.unix.Neutralize(c)
switch c.Meta.CallName {
case "mremap":
// Add MREMAP_FIXED flag, otherwise it produces non-deterministic results.
@@ -175,7 +175,7 @@ func (arch *arch) sanitizeCall(c *prog.Call) {
cmd.Val = arch.SYSLOG_ACTION_SIZE_UNREAD
}
case "ioctl":
- arch.sanitizeIoctl(c)
+ arch.neutralizeIoctl(c)
case "fanotify_mark":
// FAN_*_PERM require the program to reply to open requests.
// If that does not happen, the program will hang in an unkillable state forever.
@@ -222,7 +222,7 @@ func (arch *arch) sanitizeCall(c *prog.Call) {
switch c.Meta.Name {
case "setsockopt$EBT_SO_SET_ENTRIES":
- arch.sanitizeEbtables(c)
+ arch.neutralizeEbtables(c)
}
}
@@ -241,7 +241,7 @@ func enforceIntArg(a prog.Arg) {
}
}
-func (arch *arch) sanitizeIoctl(c *prog.Call) {
+func (arch *arch) neutralizeIoctl(c *prog.Call) {
cmd := c.Args[1].(*prog.ConstArg)
switch uint64(uint32(cmd.Val)) {
case arch.FIFREEZE:
@@ -270,7 +270,7 @@ func (arch *arch) sanitizeIoctl(c *prog.Call) {
// https://groups.google.com/g/syzkaller-bugs/c/1rVENJf9P4U/m/QtGpapRxAgAJ
// https://syzkaller.appspot.com/bug?extid=f4f1e871965064ae689e
// TODO: TIOCSSERIAL does some other things that are not dangerous
- // and would be nice to test, if/when we can sanitize based on sandbox value
+ // and would be nice to test, if/when we can neutralize based on sandbox value
// we could prohibit it only under sandbox=none.
cmd.Val = arch.TIOCGSERIAL
}
diff --git a/sys/linux/init_iptables.go b/sys/linux/init_iptables.go
index 2a49bffe4..a1adf3fb0 100644
--- a/sys/linux/init_iptables.go
+++ b/sys/linux/init_iptables.go
@@ -164,7 +164,7 @@ func (arch *arch) generateEbtables(g *prog.Gen, typ prog.Type, old prog.Arg) (
return
}
-func (arch *arch) sanitizeEbtables(c *prog.Call) {
+func (arch *arch) neutralizeEbtables(c *prog.Call) {
// This is very hacky... just as netfilter interfaces.
// setsockopt's len argument must be equal to size of ebt_replace + entries size.
lenArg := c.Args[4].(*prog.ConstArg)
diff --git a/sys/linux/init_test.go b/sys/linux/init_test.go
index ae1a49698..fb3068295 100644
--- a/sys/linux/init_test.go
+++ b/sys/linux/init_test.go
@@ -10,7 +10,7 @@ import (
_ "github.com/google/syzkaller/sys/linux/gen"
)
-func TestSanitize(t *testing.T) {
+func TestNeutralize(t *testing.T) {
prog.TestDeserializeHelper(t, "linux", "amd64", nil, []prog.DeserializeTest{
{
In: `syslog(0x10000000006, 0x0, 0x0)`,