1519 Commits

Author SHA1 Message Date
Dmitry Vyukov
fca6a74d0c executor: connect virt_wifi to veth
virt_wifi docs say that the enslaved device won't be usable
on itself. It's probably not a good idea to make lo unusable.
Enslave a dedicated veth instead.
2020-01-03 16:11:49 +01:00
Dmitry Vyukov
5e3bc74104 pkg/cover: support out-of-tree linux build
Looks for source files in object dir.
This is required for out-of-tree linux builds.
E.g. security/selinux/flask.h contains some sources
with coverage callbacks, but it's auto-generated
and located in the build dir.
2020-01-03 16:11:49 +01:00
Anton Lindqvist
9dcc1191cb pkg/report: normalize unhandled af report on OpenBSD 2020-01-03 08:37:12 +01:00
Dmitry Vyukov
7f117e28b8 sys/linux: add virt_wifi and xfrm devices
+ some netlink descriptions
2019-12-30 20:18:14 +01:00
Dmitry Vyukov
6b36d33868 syz-manager: corpus rotation
Use a random subset of syscalls/corpus/coverage for each individual VM run.
Hypothesis is that this should allow fuzzer to get more coverage
find more bugs in saturated state (stuck in local optimum).
See the issue and comments for details.

Update #1348
2019-12-30 16:37:38 +01:00
Dmitry Vyukov
4b042b7d67 sys/linux: fix int64 alignment on 386
Turns out int64 alignment is 4 on 386...
But on arm it's still 8.

Another amusing finding thanks to syz-check.

Update #590
2019-12-23 08:57:42 +01:00
Dmitry Vyukov
ae5ed0b140 pkg/compiler: fix bitfield layout bug
Fixes #1542

Found thanks to syz-check. Update #590
2019-12-20 16:45:34 +01:00
Dmitry Vyukov
4bba9fd162 pkg/compiler: fix alignment of string-formatted values
We used size as alignment, this is very wrong.

Found thanks to syz-check. Update #590
2019-12-20 16:45:34 +01:00
Dmitry Vyukov
5655dc58a9 executor: make syz_compare output more handy to use 2019-12-20 16:45:33 +01:00
Dmitry Vyukov
08f0467614 sys/test: and another set of bitfield tests
Just trying to get my head around it (and fix this in tests).

Update #1542
2019-12-20 16:45:33 +01:00
Dmitry Vyukov
9be5bbcf09 pkg/compiler: refactor struct layout
Combine markBitfields and addAlignment functions.
Fixing #1542 will require doing both at the same time,
they are not really independent.
Also remove the special case for packed structs,
pad them as part of the common procedure.
No functional changes.
2019-12-20 16:45:33 +01:00
Jouni Hogander
aa56acc6b7 pkg/cover: Fix PreviousInstructionPC for MIPS64LE
PC from the target is address of "jal __sanitizer_cov_trace_pc" + 8.
E.g. case below has address ffffffff80b4eec4 in PC

ffffffff80b4eebc:       jal     ffffffff80232080 <__sanitizer_cov_trace_pc>
ffffffff80b4eec0:       nop
ffffffff80b4eec4:       move    a1,s0
2019-12-20 15:07:10 +01:00
Dmitry Vyukov
20c6855484 prog: refactor bitfields representation
All callers of BitfieldMiddle just want static size (0 for middle).
Make it so: Size for middle bitfields just returns 0. Removes lots of if's.
Introduce Type.UnitSize, which now holds the underlying type for bitfields.
This will be needed to fix #1542 b/c even if UnitSize=4 for last bitfield
Size can be anywhere from 0 to 4 (not necessary equal to UnitSize due to overlapping).
2019-12-19 19:32:45 +01:00
Dmitry Vyukov
6a19144a4d pkg/ipc: don't use rate limiting for test os
It's not needed for test os and slows down pkg/runtest tests.
2019-12-18 16:35:53 +01:00
Dmitry Vyukov
73c3845438 pkg/compiler: fix incorrect alignment calculation for padding
We assumed that for ConstType alignment is equal to size,
which is perfectly reasonable for normal int8/16/32/64/ptr.
However, padding is also represented by ConstType of arbitrary size,
so if we added 157 bytes of padding that becomes alignment of
the padding field and as the result of the whole struct.
This affects very few structs, but quite radically and quite
important structs.

Discovered thanks to syz-check.

Update #590
2019-12-18 14:44:12 +01:00
Dmitry Vyukov
8ab1308e06 pkg/gce: fix creation of non-preemptible E2 instances 2019-12-18 09:11:16 +01:00
Siddharth Muralee
1af3875f3f pkg/build: Fix always true case 2019-12-17 15:02:51 +01:00
Jouni Hogander
2b31345f36 Autogenerated files for linux/mips64le
This patch adds all autogenerated files for linux/mips64le. Files are
generated by following commands:

make extract
bin/syz-extract -build -os=linux -arch=mips64le -sourcedir=linux
make generate
2019-12-17 11:10:52 +01:00
Jouni Hogander
07bfd71dac Implement basic support for MIPS64LE
Add basic stuff to enable MIPS64ELR2 target:
 - build
 - make extract
 - make generate
 - qemu execution
 - system call parsing from /proc/kallsyms
2019-12-17 11:10:52 +01:00
Dmitry Vyukov
d13d795888 tools/syz-runtest: debug all programs in debug mode 2019-12-16 19:37:38 +01:00
Dmitry Vyukov
f9ae583e77 executor: fix FUTEX_WAKE call
Amusingly we never passed number of threads to wake for FUTEX_WAKE.
It somehow worked reliably on linux (we just needed it to not be 0,
so presumably garbage in registers did it).
However, in gVisor every other syscall wasn't even started
(first syscall on a thread started, but second on the same worker
thread wasn't unable to start).
2019-12-16 19:37:38 +01:00
Andrew Donnellan
08003f6440 pkg/vcs: Unset various git environment variables when invoking git
If you try to run git-using tests while the GIT_DIR environment variable
(and GIT_WORK_TREE, etc) happens to be set, the tests are going to do fun
and exciting things on a repository that isn't the test repository it tries
to set up.

As it turns out, if you try to run "make test" using git rebase -x, you'll
end up with GIT_DIR set to the syzkaller tree. Hilarity ensues.

Unset GIT_DIR, GIT_WORK_TREE and a few other environment variables when
invoking git - that way it'll default to looking at the working directory
that we have given it, which is what we expect.

Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
2019-12-12 09:56:25 +01:00
Andrey Konovalov
d973f52833 executor: update raw gadget interface 2019-12-11 19:20:07 +01:00
Dmitry Vyukov
7dbfdaf076 pkg/build: improve extraction of build errors
1. Extract multiple error lines (up to 10).
Gives more complete picture, maybe the first one
is not the most indicative one.

2. Replace weird unicode quotes with normal quotes.
These may be mishandled by some systems that don't understand utf-8.
2019-12-11 10:36:35 +01:00
Dmitry Vyukov
101194ebf6 executor: check pwrite return values again
Build with some gcc's fails:

In file included from executor/executor.cc:133:0:
executor/common_linux.h: In function ‘long int syz_read_part_table(long unsigned int, long unsigned int, long int)’:
executor/common.h:117:15: error: ignoring return value of ‘ssize_t pwrite(int, const void*, size_t, __off_t)’, declared with attribute warn_unused_result [-Werror=unused-result]
    __VA_ARGS__;                                 \
               ^
executor/common_linux.h:1279:3: note: in expansion of macro ‘NONFAILING’
   NONFAILING(pwrite(memfd, segs[i].data, segs[i].size, segs[i].offset));
   ^
executor/common_linux.h: In function ‘long int syz_mount_image(long int, long int, long unsigned int, long unsigned int, long int, long int, long int)’:
executor/common.h:117:15: error: ignoring return value of ‘ssize_t pwrite(int, const void*, size_t, __off_t)’, declared with attribute warn_unused_result [-Werror=unused-result]
    __VA_ARGS__;                                 \
               ^
executor/common_linux.h:1364:3: note: in expansion of macro ‘NONFAILING’
   NONFAILING(pwrite(memfd, segs[i].data, segs[i].size, segs[i].offset));
   ^
cc1plus: all warnings being treated as errors
2019-12-10 18:59:06 +01:00
Dmitry Vyukov
cb704a294c executor: fix syz_mount_image
1. It always crashed in cover_reset when coverage is disabled.
2. Use NONFAILING when accessing image segments.
3. Give it additional 100 ms as it may be slow.
4. Add a test for syz_mount_image.
2019-12-10 16:08:35 +01:00
Dmitry Vyukov
b730d26a8d pkg/vcs: don't CC people on CC (sic)
Update #1441
2019-12-10 12:35:10 +01:00
Dmitry Vyukov
f9f80dd437 pkg/report: use --git-min-percent=15 for get_maintainer.pl
Update #1441
2019-12-10 12:35:10 +01:00
Dmitry Vyukov
c2c19edbcd pkg/vcs: don't bisect linux past 4.6
Fixes #1532
2019-12-10 12:35:10 +01:00
Dmitry Vyukov
7c14332a03 pkg/bisect: minor refactoring
Define the bisection predicate closure in a separate statement,
it become too large over time.
2019-12-10 12:35:10 +01:00
Dmitry Vyukov
277181a63c pkg/bisect: always test parent commit
Fixes #1527
2019-12-10 12:35:10 +01:00
Dmitry Vyukov
4538d6d746 pkg/bisect: add test for #1527
Update #1527
2019-12-10 12:35:10 +01:00
Marco Vanotti
4b83c8fbed pkg/repro: refactor vm initialization into new fn
This commit moves the instance initialization inside Run() to a
subroutine to decrease cyclomatic complexity in the Run function.
2019-12-09 15:13:49 -08:00
Matthew Dempsky
0c158fbe77 pkg/build: include syz-executor in Fuchsia base image
Also, build using source from our own copy of syz-executor instead of
what's currently rolled into Fuchsia.
2019-12-09 15:13:49 -08:00
Marco Vanotti
607350e438 syz/targets: add SyzExecutorCmd flag
This commit adds a new attribute to syzkaller targets that tells
syzkaller how to invoke the syz-executor command.

Some systems, like Fuchsia, are now building syz-executor as part of the
build, and there is no need to copy it over, or to run it from `/tmp`.
In fact, that might stop working at some time in the future in Fuchsia.

All places that used to copy syz-executor into the target machine will
now check for the SyzExecutorCmd flag, and won't copy it if the flag is
set.
2019-12-09 15:13:49 -08:00
Anton Lindqvist
b31eda3df8 pkg/report: normalize yet another free list modified report on OpenBSD 2019-12-09 11:09:14 +01:00
Siddharth M
12c3b6cd9a pkg/build: add support to build the NetBSD kernel with KMSan
* Initial KMSan commit
* pkg/buil: kmsan cleanup
* pkg/build: Modify the logic slightly
2019-12-06 11:28:19 +01:00
Dmitry Vyukov
4fb74474cf pkg/report: fix guilty file extraction in presence of rcu stalls
The the added test for exception from exception corner case.

"BUG: spinlock lockup" fails to respect panic_on_warn and panic
after printing report (though, it's a BUG already, so it should
have been paniced even without panic_on_warn).
As the result we got "spinlock lockup" followed by "rcu stall" report.
And we have that special exception for rcu stalls b/c for them
the most of the report is irrelevant up to apic_timer_interrupt frame.
The code did not expect this weird double-report case and skipped
everything up to apic_timer_interrupt, though it's actually
a lockup in netfilter code.
2019-12-05 12:14:58 +01:00
Andrey Konovalov
036f0b1e8d pkg/report: improve reports titles
Ignore kobject_put in stack frames.
2019-12-05 12:03:11 +01:00
Dmitry Vyukov
a2d178996b vm: add workdir_template functionality
The new manager config argument workdir_template refers to a directory. Optional.
Each VM will get a recursive copy of the files that are present in workdir_template.
VM config can then use these private copies as needed. The copy directory
can be referenced with "{{TEMPLATE}}" string. This is different from using
the files directly in that each instance will get own clean, private,
scratch copy of the files. Currently supported only for qemu_args argument
of qemu VM type. Use example:
Create a template dir with necessary files:
$ mkdir /mytemplatedir
$ truncate -s 64K /mytemplatedir/fd
Then specify the dir in the manager config:
	"workdir_template": "/mytemplatedir"
Then use these files in VM config:
	"qemu_args": "-fda {{TEMPLATE}}/fd"
2019-12-03 18:48:14 +01:00
Andrey Konovalov
659d8b8568 pkg/report: improve report titles 2019-11-29 13:13:04 +01:00
Dmitry Vyukov
736169d38b pkg/report: add few more UBSAN reports
Update #1523
2019-11-29 10:45:55 +01:00
Dmitry Vyukov
76357d6f89 pkg/report: update UBSAN report parsing
Update #1523
2019-11-28 14:07:19 +01:00
Dmitry Vyukov
46869e3ee2 pkg/csource: detect common mistakes in the common executor header 2019-11-28 10:30:27 +01:00
Jiri Pirko
97264cb1f3 executor: Add debug message in case devlink namespace move fails
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2019-11-28 10:10:57 +01:00
Jiri Pirko
e8c04ab052 executor: Fix value of DEVLINK_ATTR_NETNS_FD
During kernel -net and -next-next trees merge, the value got moved.
Fix it.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2019-11-28 10:10:57 +01:00
Dmitry Vyukov
6f7be11fa1 dashboard/app: don't report bisections pointing to release commits
They should have been detected by "same binary" logic.
But the problem is that we may use different compilers
for different commits and they switch exactly at release commits.
So we can build the release with a differnet compiler than the
rest of commits and then obviously it won't be "same binary".
Detect release commits separately.

Update #1271
2019-11-27 14:05:14 +01:00
Dmitry Vyukov
9f5fd6fe1a pkg/bisect: fix some off-by-ones
3/4 added tests currently fail.
The problem is that we don't collect results
from initial bisection range detection.
As the result we won't detect "same binary"
for release and first commit in a release.

Update #1271
2019-11-27 12:37:52 +01:00
Dmitry Vyukov
dfb91eacc4 pkg/ipc: fix potential nil deref
We've got the following crash:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x7d30ba]
goroutine 75 [running]:
github.com/google/syzkaller/pkg/ipc.(*command).exec(0xc000c68cb0, 0xc0001a4d20, 0xc00147a000, 0x1f28, 0x200000, 0x0, 0x0, 0xc00170a000, 0x1000000, 0x1000000, ...)
        /syzkaller/gopath/src/github.com/google/syzkaller/pkg/ipc/ipc.go:783 +0x7ca
github.com/google/syzkaller/pkg/ipc.(*Env).Exec(0xc0002de240, 0xc0001a4d20, 0xc016c2f440, 0x11, 0xc00019c7e0, 0x40, 0x1, 0xc016b6f590, 0x30, 0xc01615cc40)
        /syzkaller/gopath/src/github.com/google/syzkaller/pkg/ipc/ipc.go:280 +0x104
main.(*Proc).executeRaw(0xc0012a45c0, 0xc0001a4d20, 0xc016c2f440, 0x1, 0x0)
        /syzkaller/gopath/src/github.com/google/syzkaller/syz-fuzzer/proc.go:292 +0x1f3
main.(*Proc).execute(0xc0012a45c0, 0xc0001a4d20, 0xc016c2f440, 0x0, 0x1, 0x1)
        /syzkaller/gopath/src/github.com/google/syzkaller/syz-fuzzer/proc.go:255 +0x6a
main.(*Proc).loop(0xc0012a45c0)
        /syzkaller/gopath/src/github.com/google/syzkaller/syz-fuzzer/proc.go:101 +0x4df
created by main.main
        /syzkaller/gopath/src/github.com/google/syzkaller/syz-fuzzer/fuzzer.go:259 +0x1153

err can be nil even if hang=true in case of a narrow race:
we decided to kill the process, but it finished successfully meanwhile.
2019-11-26 14:16:57 +01:00
Andrei Vagin
2649e7ccc4 Call initialize_devlink_ports only when a device has been created
gVisor doesn't support netdevsim and NETLINK_GENERIC and
without this fix, sys-executor always fails:

E openat(AT_FDCWD, /sys/bus/netdevsim/new_device, ...)
X openat(AT_FDCWD, /sys/bus/netdevsim/new_device, ...) = 0x0 errno=2
E socket(AF_NETLINK, SOCK_RAW|0x0, NETLINK_GENERIC)
X socket(AF_NETLINK, SOCK_RAW|0x0, NETLINK_GENERIC) = 0x0 errno=93
E write(0x2 host:[3], "socket(AF_NETLINK) failed\n", 0x1a)
X write(0x2 host:[3], ..., 0x1a) = 0x1a (2.767µs)
E write(0x2 host:[3], " (errno 93)\n", 0xc)
X write(0x2 host:[3], ..., 0xc) = 0xc (2.729µs)
E exit_group(0x43)
X exit_group(0x43) = 0x0 (900ns)

Cc: Jiri Pirko <jiri@mellanox.com>
Fixes: f350e2dc1f59 ("executor: rename devlink port netdevices to defined names")
Signed-off-by: Andrei Vagin <avagin@google.com>
2019-11-26 10:07:31 +01:00