Commit Graph

1290 Commits

Author SHA1 Message Date
Zubin Mithra
a02b5bcae2 dashboard/app: allow main UI to show bisect results
* Modify uiBug type. Rename BisectCause to BisectCauseDone. Introduce
BisectFixDone.
* Modify createUIBug() and MergeUIBug() to set the above fields
appropriately.
* Modify bug_list to display the bisection status; remove yesSort() as
it is not used anymore. Adjust ".list_table .stat" to appropriate width.
* Add TestBugBisectionStatus() to check bisection status on main page.
* Add file from running "make generate": pkg/html/generated.go
2019-08-08 15:58:57 +02:00
Andrey Konovalov
657092bddf pkg/report: add KMSAN kernel-usb-infoleak tests 2019-08-08 15:57:02 +02:00
R3x
bcc419e941 executer/common_bsd.h: increase the number of tap/tun devices for NetBSD 2019-08-08 15:23:39 +02:00
Andrey Konovalov
8f0516c5fa pkg/report: ignore flush_work related frames 2019-08-08 15:19:28 +02:00
Andrey Konovalov
e6ebef88ac
executor: add some USB realted TODOs (#1319)
Also simplify timeout related code a bit.
2019-08-07 18:11:33 +02:00
Mark Johnston
6affd8e838 pkg/build: Enable additional invariants-checking in FreeBSD kernels 2019-08-02 14:38:31 -04:00
Dmitry Vyukov
7c7ded697e prog: fix out-of-bounds access
ParseLog can access data out-of-bounds.
Fix that and fix regression fuzz tests to catch this.
2019-07-30 19:33:02 +02:00
Dmitry Vyukov
3b37734422 pkg/ast: fix out-of-bounds access
Scanner can access data out of bounds on bad input.
Also fix regression fuzz test to be able to detect the bug.
2019-07-30 18:43:14 +02:00
Dmitry Vyukov
314ea0c952 pkg/compiler: refactor regression fuzz test
Reuse most of the existing Fuzz function
rather than duplicate the logic.
2019-07-30 18:38:35 +02:00
Dmitry Vyukov
c85e1c5be9 pkg/cover: hierarchical coverage reports
Better coverage reports with hierarchical coverage information,
number of programs covering each line,
handling of partially covered lines,
links to programs covering lines.

Fixes #682
2019-07-26 19:32:14 +02:00
Dmitry Vyukov
de453f342b pkg/csource: skip cross-builds that are doomed to fail
OpenBSD instance failed with:

--- FAIL: TestSysTests (12.50s)
    --- FAIL: TestSysTests/linux/386 (0.16s)
        csource_test.go:145: failed to generate C source for ../../sys/linux/test/binder: cpp failed: exec: "cant-build-linux-on-openbsd": executable file not found in $PATH
...

Skip unsupported cross-builds in TestSysTests.
2019-07-23 10:01:44 +02:00
Dmitry Vyukov
78f30a5156 pkg/report: fix linux path prefix trimming
After f613a7c4 ("pkg/cover: fix prefix computation") we stopped trimming
starting "/" from linux path names. This broke get_maintainers.pl script
which is now given non-existent absolute paths (e.g. "/mm/mmap.c"),
as the result syzbot can't find any maintainers for bug reports
and mails them into lkml limbo.

Trim starting slashes and dots. Extend tests for catch this.
2019-07-23 09:24:09 +02:00
Dmitry Vyukov
d9ec038e02 pkg/report: refactor argument passing
We now pass 5 arguments through a bunch of functions,
this is quite inconvinient when the set of arguments changes.
Incapsulate all arguments in a struct and pass/store it as a whole.
2019-07-23 09:15:43 +02:00
Marco Vanotti
f171a40c6b pkg/build: change gcc for clang in fuchsia
Recently fuchsia changed the default compiler from GCC to clang. This
change updates the paths in the build package.
2019-07-23 08:44:20 +02:00
Marco Vanotti
5aec592bda pkg/build: Add ssh keys for fuchsia
This change modifies the way fuchsia is built to add the ssh keys to the
zbi image after building it. Previously that was done via the
"extra_ssh_keys" argument to the build system, but that was removed
recently.
2019-07-23 08:44:20 +02:00
Dmitry Vyukov
f3ad684464 executor: drop CAP_SYS_NICE
A process with CAP_SYS_NICE can bring kernel down by asking for too high SCHED_DEADLINE priority,
as the result rcu and other system services that use kernel threads will stop functioning.
Some parameters for SCHED_DEADLINE should be OK, but we don't have means to enforce
values of indirect syscall arguments. Peter Zijlstra proposed sysctl_deadline_period_{min,max}
which could be used to enfore safe limits without droppping CAP_SYS_NICE, but we don't have it yet.
See the following bug for details:
https://groups.google.com/forum/#!topic/syzkaller-bugs/G6Wl_PKPIWI
2019-07-22 11:59:00 +02:00
Dmitry Vyukov
5181b54d45 executor: drop CAP_SYS_PTRACE with sandbox=none
We only drop CAP_SYS_PTRACE for sandbox=namespace,
but it can equally affect testing with sandbox=none.
Drop it for sandbox=none, add a test.
2019-07-22 11:51:53 +02:00
Dmitry Vyukov
e530ec1bef pkg/csource: test sys/*/test programs
Running sys/*/test programs requires real machines and kernels for each OS.
We can't do that in unit tests, but at least try to deserialize these programs
so that they don't get rotten.
2019-07-22 10:20:51 +02:00
Dmitry Vyukov
d8b4c311be pkg/mgrconfig: add example for "enable_syscalls" 2019-07-22 09:27:11 +02:00
Dmitry Vyukov
18678d6989 pkg/report: support older format of "bad usercopy" 2019-07-22 09:07:23 +02:00
Dmitry Vyukov
8304907db0 tools/syz-env: restrict Makefile parallelism based on RAM
Ensure that we have at least 1GB per Makefile job.
Go compiler/linker can consume significant amount of memory
(observed to consume at least 600MB). See #1276 for context.
Update #1276
2019-07-19 09:51:07 +02:00
Dmitry Vyukov
f53c0235fa pkg/cover: fix objdump process hang
One instance we observed that objdump hanged due to stdout
pipe overflow due to panic in archCallInsn.
The reason for the original panic is still unclear,
but fix the objdump hang. We need to terminate objdump
and propagate the panic.
Also extend the panic messages.
2019-07-18 09:37:07 +02:00
Siddharth M
f613a7c41d pkg/cover: fix prefix computation
* pkg/cover: Modify parsing logic
1. Remove prefix computation
2. Add a mgrconfig for kernel build directory

* pkg/report: shorten reports with kernelBuildSrc instead of kernelSrc

* pkg/report: Fix failing tests

* pkg/report: fix formating issues

* tools/syz-cover: Fix unintended redefinition

* make changes to fix failing ci build

* pkg/report: fix issues
2019-07-17 11:58:23 +02:00
Marco Vanotti
0d10349cf0
sys/fuchsia: update zx_clock_get syscall (#1292)
* sys/fuchsia: update zx_clock_get.

zx_clock_get was deprecated and replaced by zx_clock_get_new. In a
recent CL[0], they replaced the zx_clock_get by zx_clock_get_new and
moved all client. This commit updates syzkaller to use the new function.

[0]: https://fuchsia-review.googlesource.com/c/fuchsia/+/298575

* run make extract && make generate
2019-07-16 17:09:43 -07:00
Dmitry Vyukov
4ec4ea4890 pkg/report: support new format of "held lock freed" linux bugs 2019-07-16 16:37:33 +02:00
Andrey Konovalov
6bc0be8b21
sys/linux, executor: improve USB descriptions
1. Change HID descriptions to allow devices to have two interrupt endpoints.
2. Remove unneeded responses to OUT control requests from descriptions.
3. Add some debugging code to detect and report missing descriptions.
2019-07-16 13:07:56 +02:00
Dmitry Vyukov
a963689197 pkg/log: rename -v to -vv
To avoid conflicts with programs that import both syzkaller packages
and github.com/golang/glog which also defines -v flag.
2019-07-16 11:18:12 +02:00
Siddharth M
0b48f538f1 pkg/report: enable feature comparisons for NetBSD 2019-07-15 18:10:08 +03:00
R3x
a827bf70d7 pkg/report: Fix corrupted reports 2019-07-14 19:22:39 +03:00
Siddharth M
2bbe2f0558 executor: add network packet injection for NetBSD
* Initial Commit

* working build of network packet fuzzing

* Add missed csource file

* pkg/csource: fix build

* executor/common_bsd.h: Add comment stating reason for ifconfig create
2019-07-14 17:59:29 +03:00
Andrey Konovalov
baa5258a5e executor: fix out-of-bounds in USB fuzzing code
We might not have any string descriptors provided at all, use a hardcoded
string in this case.
2019-07-11 15:44:30 +02:00
Andrey Konovalov
186a30b993 executor: update USB fuzzing code to use new kernel API
The kernel API has changed and now differentiates between IN and OUT
control requests.
2019-07-11 15:03:48 +02:00
Anton Lindqvist
429efa16d6 executor: make errors during thread creation exit zero
On OpenBSD, the executor sometimes manages to set the memory resource
limit 0 causing any following memory allocation to fail. Since threads
are potentially created from such a thread which cannot allocate any
memory, the executor will exit non-zero which in turn will cause
false-positive panics to be reported. For more info see the
discussion[1] in PR #1243.

Instead, if hitting a fatal error during thread creation exit zero.

[1] https://github.com/google/syzkaller/pull/1243
2019-07-04 20:26:46 +02:00
Dmitry Vyukov
5f175e9c09 pkg/report: ignore __wake_up function on linux
They are very generic and a bug is almost always in the parent frame.
2019-07-02 09:03:49 +02:00
Andrey Konovalov
cccc4302d7 sys/linux, executor: run make extract and generate 2019-07-01 17:26:35 +02:00
Andrey Konovalov
13c3a99962 sys/linux, executor: add syz_usb_ep_read syzkall
syz_usb_ep_read reads data from USB endpoints other than #0.
2019-07-01 17:26:35 +02:00
R3x
df9270ba7f pkg/report: fix ASan report parsing bug 2019-07-01 16:28:15 +02:00
R3x
4d3422405e pkg/report: fix error in report symbolization 2019-06-26 11:19:18 +02:00
Andrey Konovalov
82c13b6b49 sys/linux, executor: run make extract and generate 2019-06-24 17:24:44 +02:00
Andrey Konovalov
fa26c3cf35 sys/linux, executor: add basic USB HID fuzzing support
This commit adds the necessary descriptions and executor adjustments to
enable targeted fuzzing of the enumeration process of USB HID devices.
2019-06-24 17:24:44 +02:00
R3x
35a4434115 pkg/build: add DEBUG also 2019-06-24 16:24:48 +02:00
R3x
3a7e9179b1 pkg/build: add LOCKDEBUG and KASAN_PANIC 2019-06-24 16:24:48 +02:00
Andrey Konovalov
2873954bda pkg/report: add KMSAN kernel-usb-infoleak title regex 2019-06-24 12:58:49 +02:00
Dmitry Vyukov
472f0082fd pkg/ifuzz: update to latest intelxed
Update all-enc-instructions.txt to b7231de4c808db821d64f4018d15412640c34113
and regenerate instruction info.
2019-06-23 15:10:27 +02:00
Dmitry Vyukov
da9246f6d7 pkg/report: fix up parsing of lockdep stacks 2019-06-23 14:48:05 +02:00
Siddharth M
a139f92fef pkg/report: Add initial support for report symbolisation
* pkg/report: initial netbsd commit

* pkg/report: fix netbsd errors and add comments to help

* fix spelling error
2019-06-13 18:39:32 +02:00
mspecter
d2f63c9b49 pkg/host: improve openat check
* Add support for non-obvious open commands

* Adding Michael Specter to CONTRIBUTORS

* update

* /pkg/host/host_linux.go: leverage .txt for OpenAt

Allows users to specify OpenAt flags. Currently, Syzkaller will
automatically attempt to open device nodes at startup, and ignore
descriptions that do not exist. Unfortunately, Syzkaller only opens with
read-only permissions, and some device drivers will
return -EINVAL or likewise if the correct flags are not specified.
2019-06-11 12:06:50 +02:00
R3x
5b5826d065 pkg/build: fix the failing build
1. Add MKCTF option
2. Remove the command to make the kcov node. Since do it in the script.
2019-06-11 11:49:04 +02:00
Dmitry Vyukov
f5dd5568d2 pkg/report: improve should_fail regexp
Some kernels print hex PC value before frames.
Account for that in should_fail-matching regexp.
2019-06-06 09:26:26 +02:00
Andrey Konovalov
f41f5458bb pkg/host: enable evdev, hidraw and hiddev when USB fuzzing is on 2019-06-06 09:26:18 +02:00
Dmitry Vyukov
ad87cdf3c7 pkg/runtest: detect and ignore flakes
Add retry logic that detects and ignores episodic flakes.
This test episodically flakes on syzbot.
We run with the default timeout, but require a test
to pass in 50+% of cases.
Running 72 test binaries in parallel I am getting 35-44 failures out of 72
with 1 retry. With 3 retries it drops to ~7. With 5 it is close to 0.
Use 7 retries for now. Let's see if it still flakes.
2019-06-04 14:57:43 +02:00
Dmitry Vyukov
61f5c63922 pkg/report: skip refcount_* functions
These are too generic and don't point to any subsystem. Skip them.
2019-06-04 08:53:37 +02:00
Aditya Basu
4a4d36b4af pkg/build: update env variables for akaros
* Remove the environment variable: AKAROS_XCC_ROOT
(refer to commit: brho/akaros bdab8c3a)
* Add environment variable AKAROS_TOOLCHAINS which
points to the parent directory of the old AKAROS_XCC_ROOT.
(refer to commit: brho/akaro 62ec5c3c)
* Add "$AKAROS_TOOLCHAINS/x86_64-ucb-akaros-gcc/bin" to PATH.

Signed-off-by: Aditya Basu <mitthu@google.com>
2019-06-03 18:58:22 +02:00
Andrey Konovalov
63bf051fc1 pkg/report: add del_timer_sync to skip patterns 2019-06-03 13:14:08 +02:00
Dmitry Vyukov
5368a448e4 pkg/host: disable syz_execute_func
See the added comment for explanation.
2019-06-03 13:13:56 +02:00
Andrey Konovalov
142ce68175 pkg/runtest: add simple USB runtest 2019-05-31 13:35:25 +02:00
Andrey Konovalov
c054a92dde pkg/csource: generate timeouts for USB syzcalls
This patch only covers per call timeouts, per prog one is not adjusted yet.
2019-05-31 13:35:25 +02:00
Andrey Konovalov
2673c53079 pkg/report: ignore more frames for warnings in usb_submit_urb 2019-05-29 16:16:46 +02:00
Dmitry Vyukov
f5a25d38ac pkg/cover: factor out common code into combinePrefix
Combining of prefixes is now repeated in 2 places.
Factor it out into a common function.
2019-05-29 14:58:40 +02:00
Michael Tuexen
59a32682c0 pkg/cover: further improve prefix computation
When computing the prefix, take the covered and uncovered PCs into
account.
2019-05-29 14:58:36 +02:00
Michael Tuexen
17c2df6f20 pkg/cover: improve prefix computation
When the prefix becomes the empty string during the computation,
stop computing it, since the empty string is the result.
2019-05-29 14:58:31 +02:00
Andrey Konovalov
6bd615015d pkg/repro: don't double-reverse log entries
For extractProgSingle() lastEntries are already reversed, so no need to
call reverseEntries().

Also for extractProgBisect() there's no point in reversing the entries,
as the idea is to try connecting multiple programs in chronological order.
2019-05-27 20:03:37 +02:00
Andrey Konovalov
d53d0cd242 pkg/report: improve usb_submit_urb report titles 2019-05-27 13:52:30 +02:00
Anton Lindqvist
85c573157d pkg/csource: add ability to annotate syscalls using comments in C reproducers
Providing additional info, especially regarding syscall arguments, in reproducers
can be helpful. An example is device numbers passed to mknod(2).

This commit introduces an optional annotate function on a per target basis.

Example for the OpenBSD target:

  $ cat prog.in
  mknod(0x0, 0x0, 0x4503)
  getpid()
  $ syz-prog2c -prog prog.in
  int main(void)
  {
    syscall(SYS_mmap, 0x20000000, 0x1000000, 3, 0x1012, -1, 0, 0);
    syscall(SYS_mknod, 0, 0, 0x4503); /* major = 69, minor = 3 */
    syscall(SYS_getpid);
    return 0;
  }
2019-05-24 22:33:56 +02:00
R3x
0dadcd9d91 pkg/build: Add the KCOV build commands 2019-05-23 08:48:16 +02:00
Dmitry Vyukov
13427bd9a9 pkg/vcs: disable CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER before v5.2
See https://groups.google.com/d/msg/syzkaller/mODXmnauUZM/HLZiO2UDBAAJ for context.
2019-05-21 16:50:29 +02:00
R3x
9809825e48 make changes to prevent failing build 2019-05-21 13:56:38 +02:00
Dmitry Vyukov
712bfcbdd8 pkg/runtest: test host.Setup
This would catch binfmt_misc breakage on non-linux.
2019-05-21 12:35:51 +02:00
Dmitry Vyukov
f35ffcc16f pkg/host: don't enable binfmt_misc on non-linux
The csource options lack any relation to the tested OS,
while they do depend on the tested OS (most are linux-specific).
As the result we enable binfmt_misc, but its setup fails on anything
other than linux. As a work-around don't enable binfmt_misc on non-linux.
2019-05-21 12:23:44 +02:00
Dmitry Vyukov
40957b8193 executor: exit after first detected leak in C repros
Otherwise C repros print infinite stream of the same leaks again and again.
2019-05-21 12:00:02 +02:00
Dmitry Vyukov
e503f048b0 docs: don't duplicate manager config parameters
Currently we have them duplicated in docs/configuration.md
and the actual source in pkg/mgrconfig/config.go.
Documentation is missing in one place or another,
some is outdated, some is phrased slightly differently.
Move all docs to pkg/mgrconfig/config.go and reference it
from docs/configuration.md instead.
2019-05-21 11:47:51 +02:00
Dmitry Vyukov
8285069f89 executor: implement support for leak checking
Leak checking support was half done and did not really work.
This is heavy-lifting to make it work.

1. Move leak/fault setup into executor.
pkg/host was a wrong place for them because we need then in C repros too.
The pkg/host periodic callback functionality did not work too,
we need it in executor so that we can reuse it in C repros too.
Remove setup/callback functions in pkg/host entirely.

2. Do leak setup/checking in C repros.
The way leak checking is invoked is slightly different from fuzzer,
but much better then no support at all.
At least the checking code is shared.

3. Add Leak option to pkg/csource and -leak flag to syz-prog2c.

4. Don't enalbe leak checking in fuzzer while we are triaging initial corpus.
It's toooo slow.

5. Fix pkg/repro to do something more sane for leak bugs.

Few other minor fixes here and there.
2019-05-20 19:40:20 +02:00
Dmitry Vyukov
32ebe81cf3 pkg/repro: fix no output timeout
We duplicated the no output timeout in the repro package,
and it got out of sync. It's not 3 mins now, but 5 mins.
Remove the duplication and fix this.
2019-05-20 19:40:20 +02:00
Dmitry Vyukov
2c9280d432 pkg/rpctype: use string type for leak frames
We need them as string everywhere.
Not sure why they were []byte to begin with.
2019-05-20 19:40:20 +02:00
Dmitry Vyukov
4d4a4420e7 pkg/report: add Type/Frame to Report
In several places we do special handling for some crash types.
Currently we compare report title with magic strings,
which is error-prone. Add explicit Type to reports.
2019-05-20 19:40:20 +02:00
Dmitry Vyukov
5a4461b07f pkg/instance: fix types in OverrideVMCount
vmConfig value is interface{}, not string.
So compare with nil and assign int.
2019-05-18 08:41:48 +02:00
Andrew Donnellan
2755003a34 pkg/report: Label powerpc unreliable stack frames as questionable
Add a second "questionable" regex to match the powerpc "(unreliable)"
format.

Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
2019-05-17 07:15:52 +02:00
Andrew Donnellan
2233782fc1 pkg/report: Add powerpc's __switch_to to function skip list
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
2019-05-17 07:15:52 +02:00
Dmitry Vyukov
76fc461b55 pkg/compiler: add offsetof type
Similar to C offsetof gives offset of a field
from the beginning of the parent struct.
We have several TODOs in descriptions asking for this.
2019-05-16 18:05:05 +02:00
Dmitry Vyukov
491919b14f pkg/compiler: work around 0-array-size errors due to missing consts
A const can be used as array size. Then if the const is not present
on all arches, compiler will produce an error about 0-sized-array.
There is no easy way to work around this for a user.
Use value of 1 for missing consts. It's just a bit safer.
2019-05-15 13:48:59 +02:00
Dmitry Vyukov
01d1494471 .golangci.yml: add codeanalysis build tag
Using a build tag to exclude files for golangci-lint
reduces memory consumption (it does not parse them).
The naive attempt with skip-dirs did not work.
So add codeanalysis build tag and use it in auto-generated files.

Update #977
2019-05-15 11:39:31 +02:00
Dmitry Vyukov
2376f0f937 pkg/compiler: allow to refer to syscall arguments in len paths
This allows to use len[syscall:arg] expressions.
2019-05-14 19:28:01 +02:00
Dmitry Vyukov
9a4969814e pkg/compiler: refactor len target checking
Create named const for "parent" and move some code into a helper function.
2019-05-14 19:28:01 +02:00
Dmitry Vyukov
16c881ad85 pkg/compiler: generate complex len targets
Change the generated format for len type to support multiple path elements.
2019-05-14 19:28:01 +02:00
Dmitry Vyukov
eea28fee30 pkg/compiler: support complex len targets
This change adds compiler support for complex path
expressions in len targets. E.g. it allows to refer
to a sibling field as len[parent_struct:field:another_field].
See the docs change for details.

This is just a compiler change.
The feature is not yet supported by the prog package.
2019-05-14 19:28:01 +02:00
Dmitry Vyukov
1886b2a481 pkg/ast: refactor COLON handling
This prepared for handling of bytesize[parent:foo:bar] expressions
by allowing multiple identifiers after colon.
No functional changes for now, just preparation for storing more
than one identifier after colon.
2019-05-14 19:28:01 +02:00
Dmitry Vyukov
69423a1d41 pkg/email: allow commands in subject
Several users attempted this and there does not seem
to be any reason to not allow this.
So parse out command from subject as well.
2019-05-13 14:15:14 +02:00
Greg Steuck
ddba9a616e
pkg/instance: break the line to appease linter (#1173)
* pkg/instance: break the line to appease linter

* fix up format
2019-05-12 23:38:17 -07:00
Dmitry Vyukov
39449875b6 syz-ci: don't assume kernel config is called .config
.config is linux-ism. We have a convention that kernel config
is copied to kernel.config file. Use it.
2019-05-12 11:38:18 +02:00
Dmitry Vyukov
8f24b7d63e syz-ci: always use 10 VMs for bisection
If a manager has less then 10 VMs override it to 10 for bisection.
If a manager has only 1 VM, bisection won't end well.
2019-05-10 11:06:17 +02:00
Dmitry Vyukov
4e7ecf0713 pkg/report: preserve trackback from other CPUs
For some bug types kernel produces traceback of all CPUs
(which is presumably useful for these crashes).
However, we currently throw it away because it has context
different from the oops context.
Detect such traceback and preserve output.
2019-05-10 10:31:07 +02:00
Dmitry Vyukov
e551e0ce0d pkg/report: remove debugging leftover 2019-05-10 10:31:07 +02:00
Dmitry Vyukov
214bf476d3 pkg/report: improve format of "locking bug" reports 2019-05-09 15:04:17 +02:00
Dmitry Vyukov
6fc130d361 pkg/report: add new format of kernel page faults 2019-05-09 14:33:39 +02:00
Andrew Donnellan
98ec0fac71 pkg/host: Add test for kallsymsRenameMap
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
2019-05-08 16:52:55 +02:00
Andrew Donnellan
2697cc88bb pkg/host: Add stat to kallsyms rename map
On powerpc, the "stat" syscall is implemented by "sys_newstat" entry point.
This causes a test failure as we can't find "sys_stat" in kallsyms.

Add "stat" -> "newstat" to the kallsyms rename map to work around this.

Closes: #1083 ("pkg/host: TestSupportedSyscalls fails on ppc64le")
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
2019-05-08 16:52:55 +02:00
Andrey Konovalov
f8f0147ff7 pkg/report: don't mark unknown oopses as corrupted 2019-05-08 16:50:27 +02:00
Dmitry Vyukov
b12c1ab14c dashboard/app: restore printing of email commands
After commit 9ad9ef29ca
we started saying "your command '3' is accepted"
because we use numbers now. Keep string representation
of the command when parsing and use it in reply emails.
2019-05-08 16:29:04 +02:00
Dmitry Vyukov
a7383bfac1 Makefile: enable 386 executor build in presubmit
This hacky way to install 386 packages seems to unbreak executor build.
2019-05-07 18:01:24 +02:00
Dmitry Vyukov
04165d8f66 Makefile: enable arm executor build in presubmit
arm build seems to work now on Travis since we switched to xenial.
2019-05-07 18:01:24 +02:00
Dmitry Vyukov
6a9fb250a6 pkg/report: fix WARNING parsing for powerpc
2 recent commits conflict and cause test 380 to fail:

pkg/report: improve warning titles
pkg/report: Handle powerpc stack traces correctly

Currently 380 is detected as "WARNING in program_check_exception"
rather than the expected "WARNING in assert_slb_presence".
The reason is that we started parsing WARNING stack trace and applying
proper skip patterns to frames.

Adjust WARNING matching and skip common powerpc WARNING frames.
2019-05-07 09:50:41 +02:00
Siddharth M
27544d0fc8 pkg/report: fix other NetBSD corrupted reports
* Fix Superviser mode and lock error

* Fix smaller issues
2019-05-07 09:03:05 +02:00
Andrey Konovalov
024f6c4b7f pkg/report: improve warning titles
This change makes the reporting code account for the skip patterns when
selecting the frame that is used in a title of a generic warning report.
2019-05-07 08:53:52 +02:00
munjinoo
001e36bc78 executor: change syscall argument type to intptr_t
The type size of long depends on compiler.
Therefore, changing to intptr_t makes it depends on architecture.
2019-05-07 08:48:35 +02:00
Andrew Donnellan
04e9d8cedd pkg/report: Handle powerpc stack traces correctly
powerpc stack traces are printed a bit differently from x86 stack traces.
Adjust the regexes accordingly to cope with this format.

Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
2019-05-07 08:41:33 +02:00
Andrey Konovalov
148296f478 pkg/report: improve titles of 'sleeping function called from invalid context' 2019-05-06 18:39:08 +02:00
Dmitry Vyukov
c73da24c18 pkg/report: add __ia32_sys_ syscall prefix 2019-05-03 12:40:49 +02:00
Andrew Donnellan
90c8f82ae8 pkg/build: Add ppc64le Linux as a supported configuration
Enable the Linux builder for ppc64le.

For ppc64le, we use zImage rather than bzImage as our kernel target. Pass
through the target architecture to buildKernel() so we can pick the right
target based on arch.

Closes: #1084 ("pkg/build: Support building Linux on ppc64le")
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
2019-05-03 10:00:16 +02:00
Andrew Donnellan
0642ca0c5c pkg/build: Call Linux image creation script with target arch argument
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
2019-05-03 10:00:16 +02:00
Andrew Donnellan
bfc19a4b19 tools/create-gce-image.sh: Generate ppc64le pseries disk images
Add support for generating ppc64le pseries disk images. This will create a
disk image with a PowerPC PReP boot partition at the start, and install
the IEEE1275/OpenFirmware version of GRUB.

If we ever support the powernv platform in the future we're going to have
to do something different here.

Add a command line argument to specify architecture, defaulting to amd64.

Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
2019-05-03 10:00:16 +02:00
Andrey Konovalov
8e54d550ca repro: speedup bisection for flaky crashes
Limit the amount of bisection chunks to 8. Going over this value probably
means that we are bisection a flaky crash, and continuing bisection would
just take a lot of time and likely produce no result.
2019-05-03 08:30:36 +02:00
Andrey Konovalov
1bfa09b967 pkg/report: skip printk and other printing functions 2019-05-03 08:10:28 +02:00
Anton Lindqvist
e9039493d7 executor: unbreak on OpenBSD at runtime
Not using `elif GOOS_freebsd' since it could cause breakage on other *BSDs
due to unused variables.

Regression introduced in commit c7c3f772 (executor: improve setup for packet
handling on *BSD).
2019-05-02 19:21:37 +02:00
Anton Lindqvist
1852eb1814 sys/openbsd: add vmm descriptions (#1152)
Most probably limited to input validation for now. In the future, it
could be extended to provide a bootable kernel during vm create (/bsd)
and turn vmid into a proper resource.

The OpenBSD VMs on GCE does support vmm(4).
2019-05-01 19:30:36 -07:00
Michael Tüxen
c7c3f772ca
executor: improve setup for packet handling on *BSD (#1153)
Improve the handling of packets by:
* setting the local MAC address.
* configuring the local IPv4 address with prefix /24.
* adding an entry in the arp cache for the remote IPv4 address.
* adding an entry in the IPv6 neighbour cache for the remote
  IPv6 address.
2019-05-01 22:45:36 +02:00
Andrey Konovalov
f46aabc8c6 executor: fix another compiler warning 2019-04-25 16:06:29 +02:00
Andrey Konovalov
8e3c52b11d executor: fix compiler warning 2019-04-24 11:00:51 +02:00
Dmitry Vyukov
0766ce61fd pkg/report: fix stalls in RIP frame
Even though we extract an anchor frame which usually higher up the stack,
the anchor frame can be on RIP: line too. Account for that.
2019-04-24 00:02:57 +03:00
Andrey Konovalov
e99d004deb executor: use NONFAILING in common_usb.h
Also move some code to helper functions.
2019-04-23 23:42:31 +03:00
Andrey Konovalov
4d3d6a5007 executor: adjust waiting time for all usb syzcalls
Allow 2000 ms of waiting time for syz_usb_connect and and the same time for
the whole program is this syzkall is present. Allow 200 ms of waiting time
for syz_usb_disconnect. Remove sleep from syz_usb_control_io.
2019-04-23 23:37:02 +03:00
Dmitry Vyukov
deda7c38f9 pkg/report: skip osq_lock on linux
Another new helper for locking.
2019-04-23 19:18:39 +03:00
Andrey Konovalov
18c131578d pkg/email: support quilt patch format
Quilt uses a slightly different patch format to traditional git
diff/format-patch. Support it.
2019-04-23 19:04:22 +03:00
Dmitry Vyukov
8095117313 all: fix some static analysis warnings
Fix warnings produced by golangci-lint.

Update #977
2019-04-23 17:58:54 +03:00
Kristof Provost
2398edeacc sys/freebsd: Add pf ioctl()s
Tweak the building of the FreeBSD vm image to ensure pf is loaded at
startup, so that we can test it.
2019-04-23 15:55:07 +02:00
Marco Vanotti
4d3be36006 pkg/build: update zircon build directory. (#1132)
Recently, fuchsia changed the build directory for zircon, now instead of
build-zircon, we have arch.zircon, where arch is x64 or arm64.
2019-04-22 10:51:48 -07:00
Andrey Konovalov
05dbaf1bf4 report: skip strscpy and read_word_at_a_time frames 2019-04-22 12:02:56 +03:00
Andrey Konovalov
c6165716a5 pkg/report: ignore 'down' frame in the call stack 2019-04-11 18:54:45 +02:00
Andrey Konovalov
44841b9f9c all: run make generate 2019-04-11 16:24:45 +02:00
Andrey Konovalov
f4a3dc9128 all: add basic USB fuzzing support
This commits implements 4 syzcalls: syz_usb_connect, syz_usb_io_control,
syz_usb_ep_write and syz_usb_disconnect. Those syzcalls are used to emit USB
packets through a custom GadgetFS-like interface (currently exposed at
/sys/kernel/debug/usb-fuzzer), which requires special kernel patches.

USB fuzzing support is quite basic, as it mostly covers only the USB device
enumeration process. Even though the syz_usb_ep_write syzcall does allow to
communicate with USB endpoints after the device has been enumerated, no
coverage is collected from that code yet.
2019-04-11 16:24:45 +02:00
Dmitry Vyukov
a2fe7eca30 pkg/report: fix test 2019-04-09 18:47:30 +02:00
Dmitry Vyukov
95f24af5d3 pkg/report: add another interesting linux test case 2019-04-09 18:38:04 +02:00
Dmitry Vyukov
b8dec324f2 pkg/report: refine stalls in compat ioctl's 2019-04-09 18:38:04 +02:00
Dmitry Vyukov
4398bd5e97 pkg/build: detect "Permission denied" as build error
This happens when compiler has bad permissions.
2019-04-09 18:38:04 +02:00
Andrey Konovalov
5c51045d28 all: add optional close_fds feature to reproducers
Instead of always closing open fds (number 3 to 30) after each program,
add an options called EnableCloseFds. It can be passed to syz-execprog,
syz-prog2c and syz-stress via the -enable and -disable flags. Set the
default value to true. Also minimize C repros over it, except for when
repeat is enabled.
2019-04-09 10:53:11 +02:00
Andrey Konovalov
e619f52452 csource: use /*FOO*/ instead of [[FOO]]
The latter differently confuses different versions of clang-format.
2019-04-09 10:53:11 +02:00
Dmitry Vyukov
798a29ec91 pkg/html: regenerate 2019-04-08 15:08:24 +02:00
Dmitry Vyukov
3ef496b7ba dashboard/app: split dashboard per-namespace
We now have too many namespaces and bugs.
Main page takes infinity to load.
Also almost nobody is interested in more than 1 namespace.
So split main page per-namespaces.
2019-04-08 14:32:32 +02:00
Andrey Konovalov
ecbfbf0bcf pkg/host: move kallsyms parsing test to host_linux_test.go 2019-04-05 14:24:58 +02:00
Cody Holliday
40f2363e80 pkg/host: enable kallsyms parsing on arm
pkg/host/host_linux.go: Add "arm" to kallsyms support test.
pkg/host/host_test.go: TestKallsymsParse(): Add entry to test arm kallsyms parsing support.
2019-04-05 11:15:48 +02:00
Dmitry Vyukov
3635d6e678 pkg/report: refine hung task processing for v4.15 2019-04-05 08:52:19 +02:00
Dmitry Vyukov
ba27bbab87 pkg/report: add a test for .PID removal 2019-04-05 08:47:46 +02:00
Dmitry Vyukov
c3d7012379 pkg/report: remove .PID from syz-executor
pkg/ipc changed format of binaries, but pkg/report wasn't updated.
Update pkg/report for the new format.
2019-04-05 08:45:44 +02:00
Dmitry Vyukov
dae7a62f02 pkg/build: extract first build error instead of last
The first error is usually more informative and significant.
Extract first error instead of last.
2019-04-05 08:40:36 +02:00
Andrey Konovalov
1ee782d53c host: add kallsyms parsing tests
Start with a few simple tests that can be extended when needed.
2019-04-04 14:56:48 +02:00
Marco Vanotti
6a475fffec executor: move syz_execute_func after os imports. (#1107)
This commit moves the definition of the `syz_execute_func` after the
block of code that imports all the OS specific common headers.

This is required because after commit
dfd3394d42 `syz_execute_func` started
using the `NONFAILING` macro, which is defined in those header files for
each OS.

I also ran `make generate`.

TEST=I only tested that the executor works for Fuchsia with:

```shell
$ make executor TARGETOS=fuchsia TARGETARCH=amd64 SOURCEDIR=~/fuchsia
```
2019-04-03 16:46:38 -07:00
Marco Vanotti
8658c25622 executor: don't fallthrough in switches in fuchsia (#1103)
This commit modifies the common_fuchsia.h file changing the behavior of
the `syz_future_time function`. Before, the function used to have a switch
case that would fallthrough, making it always set the delta_ms to 10000.
The fix is to add a `break;` statement after each switch case.
2019-04-03 15:48:43 -07:00
Marco Vanotti
26cbbd042a pkg/ipc: use /data/ for storage in fuchsia. (#1101)
We cannot create folders in other directories anymore, for now, we only
have access to create directories in /data/. This change is temporary as
we move to a component-based world.
2019-04-03 15:44:27 -07:00
Dmitry Vyukov
dfd3394d42 executor: try to prevent machine outbreak
The fuzzer gained control over host machines again with something like:

syz_execute_func(&(0x7f00000000c0)="c4827d5a6e0d5e57c3c3b7d95a91914e424a2664f0ff065b460f343030062e67660f50e900004681e400000100440fe531feabc4aba39d6c450754ddea420fae9972b571112d02")

Let's see if perturbing syz_execute_func a bit and wiping registers
will stop the outbreak.
2019-04-02 13:43:46 +02:00
Dmitry Vyukov
a9ca43d41c pkg/report: add another linux test 2019-04-01 14:49:28 +02:00
Dmitry Vyukov
ca14bc89c0 pkg/build: increase gvosir build timeout
The 1 hour timeout is quite high. But we've seen false positives with 20 mins
on the first build after bazel/deps update. Also other gvisor instances running
on the same machine contribute to longer build times.
2019-04-01 14:23:09 +02:00
Dmitry Vyukov
9e381a42d3 pkg/gce: poll for operation completion less frequently
We are hitting quotas for operation completion polling.
Not surprising since we create/delete instances all the time.
Slightly decrease rate of polling.
2019-04-01 14:16:54 +02:00
Dmitry Vyukov
162bd26be4 pkg/compiler: make buffer alias to ptr[array[int8]]
Ptr type has special handling of direction (pointers are always input).
But buffer type missed this special case all the time.
Make buffer less special by aliasing to the ptr[array[int8]] type.
As the result buffer type can't have optional trailing "opt" attribute
because we don't have such support for templates yet.
Change such cases to use ptr type directly.

Fixes #1097
2019-04-01 12:46:10 +02:00
Dmitry Vyukov
c35ee0ea6d prog, pkg/compiler: fix warnings
gometalinter says:

pkg/compiler/consts.go:192:⚠️ internal error: no range for "n" (vetshadow)
pkg/compiler/consts.go:197:⚠️ internal error: no range for "n" (vetshadow)
prog/encoding.go:862:⚠️ declaration of "v" shadows declaration at prog/encoding.go:852 (vetshadow)

This somehow happens only with Go1.11 but not 1.12 so wasn't detected locally.
The prog warnings looks legit.
The pkg/compiler warning was amusingly introduced to please golangci-lint checker,
revert that fix for now.
2019-03-29 19:04:30 +01:00
Alexander Popov
babbf71b14 syz-repro: print detailed listings
Final reproducers are crafty. Sometimes they just stop working.
In that case the detailed listings of the programs executed by syz-repro
are very helpful. Let's print them at the loglevel 3.
2019-03-29 18:18:41 +01:00
Dmitry Vyukov
faba132374 pkg/build: shutdown bazel in case of errors too 2019-03-29 11:05:35 +01:00
Dmitry Vyukov
9633c5c8a1 pkg/build: extract bazel build errors
We currently manually call extractRootCause in few selected places
to denote kernel build errors that we want to report to developers.
The rest are considered infra errors that we don't report.
This does not work well. We are missing fuchsia and gvisor build errors.
Treat all external command exection failures as kernel build errors instead.
Let's see how this works in practice.
Also add bazel-specfic error patterns and tests.
2019-03-29 11:00:34 +01:00
Dmitry Vyukov
6b138f0f3c pkg/report: work around GCE console bugs 2019-03-29 09:40:31 +01:00
Marco Vanotti
e825006ce0 pkg/build: Add ssh tools for fuchsia.
This commit adds the "//bundles:tools" packages to the fuchsia build
used for syzkaller. This includes ssh tools, which includes scp.

TEST=I have tested this on syz-ci. Fuchsia is now able to pass the image
test.
2019-03-29 07:41:51 +01:00
Dmitry Vyukov
4a9fce1952 all: fix warnings pointed to by golangci-lint
Update #977
2019-03-28 15:30:18 +01:00
Dmitry Vyukov
742f448304 vm/gce: allow non-preemptible VMs
We are seeing some flakes during bisection and image testing.
Hard to tell what's the root cause because they are episodic.
But using non-preemptible VMs for bisection and image testing
looks good on all fronts.

Update #501
2019-03-28 13:22:37 +01:00
Marco Vanotti
69e1a4f7d5 pkg/build: update fuchsia build commands.
This CL changes the invocation of the `fx set` command to match the new
format[0].

This change involves removing "board" and "product" flags. Instead, now one has to use
`fx set product.board` to get the same result. In the case of syzkaller,
this would be "core.${ARCH}" where arch could be x64 or arm64.

Also, the default build directory now is `out/default`, and for now, it
is still not possible to have multiple archs built altogether. I set the
build directory manually to `out/${ARCH}` (as was before). This would
allow syzkaller to also build the kernel for arm if required.

[0]: https://fuchsia.googlesource.com/fuchsia/+/b814211ab33eeb4e8f02962d5c81d042b2464ac7

TEST=Tested this in syz-ci. It worked.
2019-03-27 09:07:06 +01:00
Dmitry Vyukov
55684ce16b pkg/html: update generated file 2019-03-25 17:20:35 +01:00
Dmitry Vyukov
52a20ba400 dashboard/app: properly handle build failures
Separate kernel and syzkaller build failures.
Fix logic to understand when a build is fixed:
look if kernel/syzkaller commit changes to understand
if it's a new good build or re-upload of an old build.

Fixes #1014
2019-03-25 17:00:25 +01:00
Dmitry Vyukov
2c86e0a54a pkg/report: skip memmove on linux 2019-03-24 16:59:26 +01:00
Dmitry Vyukov
028c09511b pkg/bisect: detect when too many instances errored
We currently skip a commit iff all 10 instances errored.
But if, say, only 9 errored we consider it as OK,
but this significnalty reduces chances of detecting flaky crashes.
So skip if more than 2/3 errored.

Update #501
2019-03-22 12:56:42 +01:00
Dmitry Vyukov
9ad9ef29ca dashboard/app: slightly relax command parsing
Users have misspelled test: multiple times.
Accept commands without the colon.
2019-03-22 12:00:50 +01:00
Dmitry Vyukov
8f92118cb6 pkg/vcs: disable CONFIG_CAN for bisection before v4.13
Update #501
2019-03-22 12:00:50 +01:00
Dmitry Vyukov
ca3ffbc9f3 dashboard/app: add uncc command
Add "#syz uncc" command as a safety handle.
The command allows sender to unsubscribe from all future communication on the bug.

Linus mentioned possibility of saying "I'm not the right person for this report"
in the context of bug reminders:
https://groups.google.com/d/msg/syzkaller/zYlQ-b-QPHQ/AJzpeObcBAAJ
2019-03-22 12:00:50 +01:00
Dmitry Vyukov
7c9c9fd24f pkg/build: add a test for build failure root causing
Such error popped up during bisection on older kernels.
It's already detected properly, yet build failed with just "make failed"...
Unclear why that happened, but the test won't harm.

Update #501
2019-03-21 14:25:08 +01:00
Dmitry Vyukov
a9007a8ccb pkg/html: add reference for 12-char hashes in tags 2019-03-21 14:24:10 +01:00
Dmitry Vyukov
e6d1a816d8 pkg/csource: allow to ignore warnings during build
Running bisection using an older repro failed with:

    <stdin>: In function ‘syz_mount_image.constprop’:
    <stdin>:298:3: error: argument 1 null where non-null expected [-Werror=nonnull]
    In file included from <stdin>:26:0:
    /usr/include/x86_64-linux-gnu/sys/stat.h:320:12: note: in a call to function ‘mkdir’ declared here
     extern int mkdir (const char *__path, __mode_t __mode)

Let's be safe and ignore warnings during repro/bisect.
Everything that runs during tests still has all warnings.

Update #501
2019-03-21 13:30:12 +01:00
Dmitry Vyukov
44270612b4 executor: prevent non-null expected warnings
The added test triggers warnings like these:

<stdin>: In function ‘syz_mount_image.constprop’:
<stdin>:298:3: error: argument 1 null where non-null expected [-Werror=nonnull]
In file included from <stdin>:26:0:
/usr/include/x86_64-linux-gnu/sys/stat.h:320:12: note: in a call to function ‘mkdir’ declared here
 extern int mkdir (const char *__path, __mode_t __mode)
            ^~~~~
cc1: all warnings being treated as errors

<stdin>: In function ‘syz_open_procfs.constprop’:
<stdin>:530:41: error: ‘%s’ directive argument is null [-Werror=format-truncation=]
<stdin>:85:110: note: in definition of macro ‘NONFAILING’
<stdin>:532:41: error: ‘%s’ directive argument is null [-Werror=format-truncation=]
<stdin>:85:110: note: in definition of macro ‘NONFAILING’
<stdin>:534:41: error: ‘%s’ directive argument is null [-Werror=format-truncation=]
<stdin>:85:110: note: in definition of macro ‘NONFAILING’

Use volatile for all arguments of syz_ functions to prevent
compiler from treating the arguments as constants in reproducers.

Popped up during bisection that used a repro that previously worked.
Update #501
2019-03-21 13:27:41 +01:00
Dmitry Vyukov
f6094a8c64 dashboard/app: use 12-char hash in Fixes tags
@ebiggers pointed out that Fixes tags should use 12-char hash:
https://groups.google.com/d/msg/syzkaller-bugs/yUhRrLD6T6A/3TMwOWvWAgAJ
I can't find any documentation on this, but it looks like most
existing tags follow this convention so use 12-char hashes.
2019-03-21 09:32:46 +01:00
Marco Vanotti
2cc9698b58 pkg/vcs: fix fuchsia's git repo directory.
This commit changes the fuchsia git repo to make it point to the main
repo instead of just "zircon".

Previously, zircon had its own git repo, so syzkaller had a wrapper that
would issue jiri commands for the whole fuchsia repo, but would just
report commits in the zircon repo.

Recently, fuchsia merged most of its repositories in just one big git
repo. So now, zircon is part of the fuchsia git repo. I think the code
continued working because the old zircon repo is still part of a git
repository, so git commands worked there.

The new code now doesn't have any special casing for Zircon, and now
(almost) everything is part of the fuchsia repo. The other repos are now
git submodules.
2019-03-21 09:10:48 +01:00
Mark Johnston
427ea48700 pkg/report: deduplicate sctp "no chunks on the queues" reports 2019-03-20 17:46:29 +01:00
Dmitry Vyukov
a469d047d1 pkg/vcs: fix git tag --points-at invocation
Turns out older versions of git don't imply --list for --points-at and fail.
So add --list explicitly.

Update #501
2019-03-20 13:55:48 +01:00
Dmitry Vyukov
042e4d5419 pkg/bisect: use CheckoutCommit instead of SwitchCommit
Use CheckoutCommit instead of SwitchCommitto get the crashing commit.
The problem is with trees like linux-next. They require at least fetching tags
and maybe even different tree (-history).
Use CheckoutCommit which at least fetches tags which is enough
for recent commits.

Update #501
2019-03-20 11:01:12 +01:00
Dmitry Vyukov
5f5191b43f pkg/vcs: wrap git invocations in a helper method
There is a bunch of repetition to invoke git.
Wrap it into a helper method.
2019-03-20 11:01:00 +01:00
Dmitry Vyukov
d4aacfdb59 pkg/vcs: remove unused functions
Bisect is not needed after introduction of Bisecter interface.
2019-03-20 10:34:16 +01:00
Marco Vanotti
b97faf8e7a executor: update fdio import path
The Fuchsia team is going to remove the `lib/fdio/util.h` library. They
have already moved all the functions to new header files.

I have seen that fuchsia uses `fdio_service_connect`, which has been
moved to the `lib/fdio/directory.h` header file.

This commit just changes the import path in the fuchsia executor, and in
the corresponding generated go file (I made that change by running `make
generate`).
2019-03-20 07:52:40 +01:00
Marco Vanotti
14799fb2ef docs, pkg/vcs, sys/fuchsia: update fuchsia urls
Recently the fuchsia team decided to merge all their subrepos into one
big git repo. This meant that the "zircon" repo doesn't exist anymore.
Instead almost everything is under the fuchsia repo.

This change updates all the reference I could find in the code that
point to the zircon and docs repo to make them point to the new fuchsia
repo.
2019-03-20 07:50:58 +01:00
Mark Johnston
2458c1c6c2 pkg/report: fix matching for traps in kernel mode
We already have a pattern to match "Fatal trap N: ..." panics, but the
format of our backtraces has changed since it was added.  Add another
pattern which correctly matches a few instances generated by syzbot.
2019-03-19 18:45:18 +01:00
Mark Johnston
e454923488 pkg/build: copy kernel.full to the objdir after a build
This helps ensure that we can create coverage reports on FreeBSD.
2019-03-19 10:26:46 +01:00
Dmitry Vyukov
bdb7b93f25 pkg/osutil: kill subprocesses more reliably
In some cases we start scp, which starts ssh,
then kill scp but the ssh subprocess is not killed.
As the result cmd.Wait hangs waiting for EOF on the stdout/stderr,
which are still kept alive by ssh subprocess. But ssh just hangs forever.

Create a process group for each command and kill whole process group.
Hopefully this will help.
2019-03-18 10:52:18 +01:00
Dmitry Vyukov
f875704448 pkg/vcs: fix too long line
Also restructure because we point to this file from syzbot docs.
2019-03-17 18:57:38 +01:00
Dmitry Vyukov
bcbe71c80a dashboard/app, syz-ci: bisection support
This adds bulk of support for bisection to dashboard/app and syz-ci:
- APIs to send bisection jobs and accept results
- syz-ci logic to execute bisection jobs
- formatting of emails with results
- showing of results on dashboard

Some difficulties we have to overcome:
- since linux is frequently build/boot broken, lots of bisections are inconclusive,
  need to present such results too
- git bisect is poorly suitable for automation, have to resort to output parsing (is output stable?)
- git bisect turns out to fail (exit with non-0 status) when bisection is inconclusive
  (multiple potential cause commits)
- older syzkaller revisions can't be built with newer (broken) kernel header, e.g.:
  ebtables.h:197:19: error: invalid conversion from ‘void*’ to ‘ebt_entry_target*’
- newer compilers produce more warnings and break old syzkaller builds, e.g.:
  kvm.S.h:6:12: error: ‘kvm_asm64_vm86’ defined but not used [-Werror=unused-const-variable=]
- figuring relevant emails to CC from a commit is non-trivial:
  besides commit author, there can be some emails in commit tags, or not,
  which tags to use is an interesting question (some may include irrelevant emails)
  we can also run get_maintainers.pl on the commit, but this can produce too wide
  list if commit touches lots of files, it can also produce too small list,
  and then we need to resort to blame
- for inconclusive bisection we probably don't need to include emails referenced
  in the commits (there can be too many of these commits)
- need to be careful to exclude own syzbot email from commit CC list,
  now syzbot emails are referenced in some commits (Reported-by/Tested-by/etc)
  (can cause some kind of infinite recursion)
- lots of commits reference stable mailing list,
  we should not include it in CC because it's referenced for backports rather then bug reports
- since we add new Bug entity fields which we use in queries,
  whole datastore need to be upgrades to add the new field to index
- we must not discard the crash that was used for bisection
  (treat it as a reported crash)
- bisection results need 2 forms of reports:
  one when we add bisection results to already reported bug
  another when we report a bug first time with bisection results
- when reporting a bug with bisection results we need to use the crash
  that was used for bisection
- some fraction of bisections will probably fail with various errors
  and we will need some mechanism to retry bisection after the root cause is resolved
  this is not implemented yet
- linux-next is problematic for 2 reasons:
  fix bisection can't possibly run on linux-next as commits are not reachable from HEAD
  lots of commits are missing in linux-next (even in linux-next-history)
  e.g. we have some c63e9e91a254a52 which is now missing in linux-next/linux-next-history
- older kernels can't be build with fresh gcc/binutils/perl/make/glibc
  for now we have to stop at v3.9 (this only requires switching gcc several times along the way)
- kernels past v4.11 do not build with gcc 7 and 8 (undefined reference to `____ilog2_NaN')
- v4.1 and back have only compiler-gcc5.h
- v3.17 and back have only compiler-gcc4.h
- v3.6 and back do not have make olddefconfig
- compat socket calls can't be bisected past "x86/entry/syscalls: Wire up 32-bit
  direct socket calls" (v4.10) because of
  https://syzkaller.appspot.com/bug?id=b5b150e322d5f48c869bcf1528cdbee08d1421cb
- v2.6.28 and below does not work with modern make:
  *** mixed implicit and normal rules: deprecated syntax
- v3.8 build fails:
  Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at kernel/timeconst.pl line 373.
  kernel/Makefile:134: recipe for target 'kernel/timeconst.h' failed
- make 3.81 works for v2.6.28.
  3.81 almost works with current HEAD, you need to run make twice because first run spuriously fails with:
- v2.6.28 with gcc-4.9.4 broken with:
  include/linux/kvm.h:240:9: error: duplicate member ‘padding’
- but even defconfig fails:
  VDSO    arch/x86/vdso/vdso.so.dbg
  gcc: error: elf_x86_64: No such file or directory
  gcc: error: unrecognized command line option ‘-m’
  It seems that we also need old binutils.
- for v3.8 and below we need perl-5.14.4.
  Unfortunately this or any manually built perl doesn't work for later kernels:
  Can't locate strict.pm in @INC
- kernels starting from 4.14 and older are boot broken:
  https://lkml.org/lkml/2018/9/7/648
- kernels older than 4.12 are broken during netdev setup
  (fixed by commit 675c8da049fd6556eb2d6cdd745fe812752f07a8)

Update #501
2019-03-17 18:06:44 +01:00
Dmitry Vyukov
dc89691385 pkg/instance: fix boot error detection
Currently we truncate output up to rep.EndPos after unexpected reboot.
But report sets EndPos to the _last_ report in output,
so if there are any other errors they are all skipped after
truncation to EndPos. Truncate just one line instead.
2019-03-17 18:06:44 +01:00
Dmitry Vyukov
699923ce73 pkg/instance: clean up temp file 2019-03-17 18:06:44 +01:00
Dmitry Vyukov
1f6fc9f188 pkg/vcs: reset repo more
If we cherry-pick some fixes during bisection
we need to "git reset" repo before "git bisect reset".
Otherwise it will fail. Reset repo in more points.

Update #501
2019-03-17 18:06:44 +01:00
Dmitry Vyukov
8bfa7f8698 pkg/vcs: try to work around massive linux kernel build/boot breakages
Linux kernel is frequently build/boot broken. Even on release tags.
Everything past 4.15 is broken with our config for multiple reasons.
This makes bisection process almost infeasible.
Try to work around some breakages by disabling configs are we go back in time.

Update #501
2019-03-17 18:06:44 +01:00
Dmitry Vyukov
b3ed01507f pkg/bisect: various improvements
A bunch of improvements after more wide bisection testing.
Improve logging.
Support returning several commits for inconclusive bisection.
Return Report with the final crash.
Remove code that was moved to pkg/vcs.

Update #501
2019-03-17 18:06:44 +01:00
Dmitry Vyukov
5ed211ca96 pkg/vcs: refactor bisection support
In preparation for syz-ci bisection:
- move bisection function into a separate interface
  they look out of place in vcs.Repo because most OSes
  don't implement it and most users don't case
- extract author name and more CC emails for commits
- move linux-specific PreviousReleaseTags into linux.go
- fix inconclusive bisection (more than 1 potential commits)
- add tests fr bisection
- add maintainers returned from get_maintainers.pl for commits
  that don't have enough emails (e.g. only author email)

Update #501
2019-03-17 18:06:44 +01:00
Dmitry Vyukov
e5207950ca pkg/log: add VerboseWriter
Helper io.Writer that logs on the specified verbosity level.
Will be useful for bisection logging in syz-ci.

Update #501
2019-03-17 18:06:44 +01:00
Dmitry Vyukov
c693e273b3 pkg/instance: use -fpermissive -w when building old syzkaller
Since we can be building very old revisions for bisection here,
make the build as permissive as possible.
Newer compilers tend to produce more warnings also kernel headers may be broken, e.g.:
ebtables.h:197:19: error: invalid conversion from ‘void*’ to ‘ebt_entry_target*’

Update #501
2019-03-17 18:06:44 +01:00
Dmitry Vyukov
03df839448 pkg/osutil: return output with errors from Run
Turns out git bisect fails to communicate some outcomes (multiple potential commits),
and the only way to understand what happened is parsing plain English output.
Extracting the output from the error is quite unhandy.
So return it with the error.

Update #501
2019-03-17 18:06:44 +01:00
Dmitry Vyukov
64745f640c pkg/osutil: fix disabling of sandbox
If sandboxing is disabled don't unshare net namespace too.

Update #501
2019-03-17 18:06:44 +01:00
Dmitry Vyukov
be40654906 pkg/html: add more helper function
Add optlink, formatKernelTime, formatCommitTableTitle.
Will be useful to format bisection emails.

Update #501
2019-03-17 18:06:44 +01:00
Anton Lindqvist
bab43553a9 pkg/report: improve page fault detection on OpenBSD
Fixes #1059
2019-03-15 09:08:49 +01:00
Dmitry Vyukov
d23e90a7b4 all: switch to Go 1.12
Differences in code formatting between Go versions cause constant
problems for us (https://github.com/golang/go/issues/25161).
Currently we support 1.9 and 1.10. Switch to newer 1.11 and 1.12.

Fixes #1013
2019-03-14 14:55:59 +01:00
Mark Johnston
375815261d pkg/build: avoid hard-coding partition numbers in the freebsd build
Be marginally more general and mount the first UFS partition, whose
index may vary depending on whether a swap partition exists.
2019-03-14 07:32:15 +01:00
Mark Johnston
ac5e611fde pkg/build: use incremental builds for the FreeBSD kernel toolchain
LLVM takes a long time to compile, so let's avoid rebuilds when they're
unnecessary (which is most of the time).
2019-03-14 07:32:15 +01:00
Marco Vanotti
4bb30071df pkg/build: update fuchsia build commands.
This CL splits the fx commands into two: one that runs `fx set` setting
the same arguments as before, and another one right after, running `fx
clean-build` to build fuchsia.

Recently[0], fuchsia made it impossible to run `fx clean-build`
specifying the arguments. Instead, one should run `fx set` before.

The benefit is that `clean-build` now preserves the build arguments
across runs. For syzkaller, it doesn't change anything though.

[0]: https://fuchsia-review.googlesource.com/c/fuchsia/+/262674
2019-03-14 07:30:33 +01:00
Marco Vanotti
d09a902e9d pkg/build: fix getBuilder for fuchsia.
This CL changes the supported vmType for fuchsia to be QEMU, instead of
GCE.

This was broken by commit b4e5a74e4, which changed the behavior of
getBuilder. It was part of a 6-commit PR trying to add support for
FreeBSD.

That commit has caused syzkaller to stop being able to build the fuchsia
image, getting the following error:

`kernel build failed: unsupported image type fuchsia/amd64/qemu`
2019-03-14 07:13:58 +01:00
Dmitry Vyukov
a71bfb62b4 pkg/report: skip memchr in linux reports 2019-03-12 14:31:24 +01:00
Mark Johnston
f7f70d5a7e pkg/report: match panics from locking a destroyed lock
The plain panic message includes an absolute path to the source file
where we panicked, which may be too long for a report title.
2019-03-12 14:30:21 +01:00
Mark Johnston
b8de2a60a0 pkg/build: add freebsd
For now we must assume that we're building on FreeBSD; cross-compilation
support isn't quite there yet.

During a build, we first build an updated kernel toolchain if required,
generate a custom kernel configuration file with KCOV enabled, and build
a new kernel.  (When running on the custom kernel, "uname -i" will print
"SYZKALLER" rather than "GENERIC".)  Then, the image is mounted under a
tmpdir and we install the custom kernel to /boot/kernel.
2019-03-12 14:30:21 +01:00
Mark Johnston
2806a9214b pkg/vcs: add freebsd
This is currently identical to support for OpenBSD and NetBSD.  A
FreeBSD git repo is available at github.com/freebsd/freebsd.
2019-03-12 14:30:21 +01:00
Mark Johnston
b4e5a74e4c pkg/build: reduce cyclomatic complexity of getBuilder() 2019-03-12 14:30:21 +01:00
Mark Johnston
b489e4987d pkg/build: don't export OS-specific functions 2019-03-12 14:30:21 +01:00
Siddharth M
13faf88fdf pkg/report: fix the error corrupting reports
* fix error with reports

* add additional testdata
2019-03-08 07:55:08 +01:00
Dmitry Vyukov
4b69c3cbac pkg/runtest: make tests pass on freebsd
The problem is stupid: <endian.h> should be included as <sys/endian.h> on freebsd.
Pass actual host OS to executor build as HOSTGOOS and use it to figure out
how we should include this header.
2019-03-07 20:37:43 +01:00
Mark Johnston
c08c1cd05c pkg/csource: sort sys/types.h to the top on FreeBSD
sys/types.h is a special header that is required by many other system
headers on FreeBSD.
2019-03-07 19:46:55 +01:00
Dmitry Vyukov
2eb2cd93e0 pkg/report: skip retpolines in reports
These __x86_indirect_thunk_rax broke reports for bad indirect calls.
2019-03-07 19:35:39 +01:00
Dmitry Vyukov
967dc02d70 pkg/compiler: fix potential nil deref
One one found on fuzzbuzz.io.
2019-03-06 16:54:38 +01:00
Greg Steuck
16559f86f5
ci-openbsd-multicore: enable PF (#1033)
* pkg/build/openbsd: copy overlay files from userspaceDir into image

Fixes #1030
2019-03-05 09:08:17 -08:00
Dmitry Vyukov
78b7ec0fbe pkg/compiler: fix infinite recursion on unions
Found by go-fuzz on fuzzbuzz.
2019-03-05 16:14:27 +01:00
Dmitry Vyukov
5677e61bfa fuzz.yaml: add pkg/compiler and trace2syz fuzzers 2019-03-05 15:57:06 +01:00
Siddharth M
2a477d7713 pkg/report: add better ASan bug parsing for NetBSD
* Add basic ASan parser

* Fix the test data

* Removed Read|Write parameter
2019-03-05 14:36:59 +01:00
Andrey Konovalov
dfd609eca1 execprog, stress, prog2c: unify flags to enable additional features
This change makes all syz-execprog, syz-prog2c and syz-stress accept
-enable and -disable flags to enable or disable additional features
(tun, net_dev, net_reset, cgroups and binfmt_misc) instead of having
a separate flag for each of them.

The default (without any flags) behavior isn't changed: syz-execprog
and syz-stress enabled all the features (provided the runtime supports
them) and syz-prog2c disables all of them.
2019-03-05 14:30:10 +01:00
Julia Hansbrough
8845b00e1e pkg/build: update fuchsia fx arguments
We've once again changed the way you define a build via fx; update it in
Syzkaller too.
2019-03-01 06:20:22 +01:00
Julia Hansbrough
09aeeba49f fuchsia: Update Syzkaller to pull from Fuchsia monorepo (#1021)
Fuchsia and its repos now live in a new spot!
2019-02-27 21:44:58 -08:00
Dmitry Vyukov
34ec456bcf pkg/report: ignore postfix error on netbsd 2019-02-27 19:35:36 +01:00
Dmitry Vyukov
4c8feb4e71 executor: add newline in debug call
debug does not add newlines.
2019-02-27 11:39:47 +01:00
Julia Hansbrough
083cfd0e4a executor: update syntax for making W+X fuchsia memory
Fuchsia recently changed such that zx_vmar_map can't be declared
executable and writeable at the same time; use a new syscall for this
purpose.

Also made a few errors more informative.
2019-02-27 08:57:48 +01:00
Ed Maste
f2468c12ea pkg/instance: use gmake on FreeBSD as on OpenBSD 2019-02-26 17:25:22 +01:00
Dmitry Vyukov
4d7696cb31 pkg/repro: fix goroutine/instance leaks
On early return paths we fail to close instances and shutdown goroutines.
Fix that.
2019-02-25 11:21:48 +01:00
Dmitry Vyukov
9737e71ed1 pkg/build: fix netbsd ifconfig
! escaping seems not be required.
The current code writes / as well, which is wrong.
2019-02-23 19:18:12 +01:00
Dmitry Vyukov
30a3bd9f94 pkg/build: setup network interface on GCE for netbsd 2019-02-23 18:53:37 +01:00
Dmitry Vyukov
40311807ad pkg/build: netbsd build improvements
1. Implement clean since we do incremental build we actually need no-op clean.
2. Don't copy netbsd to output dir, we don't need it there (we create full-fledged image).
3. Copy netbsd.gdb to obj/ dir, that's where it is expected.
4. Fix boot disk name for gce (it's sd0 instead of wd0).
2019-02-23 17:01:44 +01:00
Dmitry Vyukov
0c7ffbeafc pkg/report: update UBSAN netbsd report format 2019-02-23 11:58:06 +01:00
Dmitry Vyukov
c28db61f53 pkg/report: add KUBSan netbsd reports
Just to detect them at all and have some test base.
Will need better bug identification later.
2019-02-23 11:41:44 +01:00
Dmitry Vyukov
baad4d3621 pkg/build: minor assorted improvements for netbsd
Create /fastboot and /var/db/entropy-file files.
Check that we copy kernel into the right location.
Fix code style.
2019-02-22 19:01:22 +01:00
Dmitry Vyukov
1c2f03dc0d pkg/report: add few netbsd KASAN reports 2019-02-22 18:39:15 +01:00
Siddharth M
7fa29a5895 pkg/build: added feature to copy kernel image for netbsd
* Modified pkg/build/netbsd.go
1. Made kernel build incremental
2. Added code to copy kernel to disk image

* Fix formating issues

* Fixed basic issues

* Fixed copy kernel to disk
1. Added CPU option to default
2. Added snapshot option to vm/qemu/qemu.go
3. Hacky solution to get the build working

* Fixed issues and added vm.MonitorExecution

* Added sync instead of poweroff
2019-02-22 13:18:44 +01:00
Dmitry Vyukov
647e8b6e47 executor: fix format strings
clang complains that we pass an int to %hx. Fix it.
2019-02-19 15:23:15 +01:00
Dmitry Vyukov
23f4bab451 pkg/ifuzz/generated: change package name to match path
Some tools blow up due to the mismatch...
Let's use the canonical convention.
2019-02-19 15:23:15 +01:00
Dmitry Vyukov
3636a62c11 pkg/vcs: implement few missing methods for akaros
CheckoutBranch is now needed for commit polling.
2019-02-17 15:20:01 +01:00
Dmitry Vyukov
3e98cc3080 dashboard/app: poll commits info
This implements 2 features:
 - syz-ci polls a set of additional repos to discover fixing commits sooner
   (e.g. it can now discover a fixing commit in netfilter tree before
   it reaches any of the tested trees).
 - syz-ci uploads info about commits to dashboard.
   For example, a user marks a bug as fixed by commit "foo: bar".
   syz-ci will find this commit in the main namespace repo
   and upload commmit hash/date/author to dashboard. This in turn
   allows to show links to fixing commits.

Fixes #691
Fixes #610
2019-02-17 15:08:45 +01:00
Anton Lindqvist
f42dee6d5e pkg/report: normalize timeout_add panic on OpenBSD 2019-02-15 17:39:25 +01:00
Dmitry Vyukov
0a49c954ff pkg/instance: test coverage during instance testing
Currently we always pass cover=false during instance testing
and as the result covereage is not tested. This can result in
broken images. Pass the actual value of coverage for testing.
2019-02-13 15:58:42 +01:00
Dmitry Vyukov
6193630786 pkg/runtest: don't print skipped/broken tests by default
SKIP/BROKEN distract too much attention from FAIL tests
and are not usually interesting. Add Verbose flag that
controls printing of SKIP/BROKEN tests. Enable it in
pkf/runtest/run_test.go by default and disable in tools/syz-runtest.
2019-02-13 15:58:42 +01:00
Dmitry Vyukov
65a0d61939 pkg/host: don't fail if CONFIG_FAIL_FUTEX is not enabled
See #991 and added comments.

Fixes #991
2019-02-11 18:35:46 +01:00
Dmitry Vyukov
a39e52b1cd all: reformat with Go 1.10 2019-02-11 18:13:34 +01:00
Dan Robertson
13f1d0047a sys/linux: add NDISC packet formats to vnet.txt
Add the basic NDISC (RFC 4861) packet formats to sys/linux/vnet.txt.
2019-02-11 18:10:35 +01:00
Greg Steuck
73f5f45267 pkb/build: extractRootCause for NetBSD too
* pkg/build: share extractRootCause with openbsd

This should get kernel build errors reported in syz-ci console.

* Add a test

* lint

* pkb/build: extractRootCause for NetBSD too
2019-02-11 11:10:05 +01:00
Greg Steuck
5e5bb28ebf pkg/build: share extractRootCause with openbsd
* pkg/build: share extractRootCause with openbsd

This should get kernel build errors reported in syz-ci console.

* Add a test

* lint
2019-02-11 11:09:05 +01:00
Anton Lindqvist
c69659e352 openbsd: remove shorten report logic (#986)
A line length of 79 in the ddb output does not necessarily imply that the
following line is a continuation of the current line. Since there's no way
to distinguish between ordinary and continuation lines, it could end up
corrupting the report by joining two lines that are disjoint[1].

Instead, disable line wrapping in ddb. If we want some kind of wrapping in
the future it's easier done by pkg/report.

[1] https://syzkaller.appspot.com/bug?extid=03f7377a9848d7d008c9
2019-02-09 08:23:53 -08:00
Dmitry Vyukov
381ccbf2f8 pkg/ipc: generate better temp name for executor
Just appending the pid number can produce conflicting names
if the name itself ends with digits (standard temp file naming convention).
So append ".PID".
Also remove beginning from too long names instead of ending.
Temp files in tests has unique numbers at the end, we need to preserve them
to avoid file name conflicts.
2019-02-08 16:27:53 +01:00
Dmitry Vyukov
78a290863d pkg/runtest: run syz tests in non-repeat mode
Turns out it can affect some tests,
e.g. some things manifest only after executor restart
(executor binary marked as non-executable by the test).
2019-02-08 16:27:53 +01:00
Dmitry Vyukov
564f9a4f57 pkg/report: add simple version of netbsd crash parser
Just something to start with. Plus some test cases.
2019-02-01 19:52:56 +01:00