Commit Graph

1519 Commits

Author SHA1 Message Date
mspectorgoogle
e103bc9e1b
executor: add seccomp support for Android
This adds support for the seccomp filters that are part of Android into
the sandbox.  A process running as untrusted_app in Android has a
restricted set of syscalls that it is allow to run.  This is
accomplished by setting seccomp filters in the zygote process prior to
forking into the application process.  The seccomp filter list comes
directly from the Android source, it cannot be dynamically loaded from
an Android phone because libseccomp_policy.so does not exist as a
library on the system partition.
2020-03-11 11:21:36 +01:00
Andrey Konovalov
35f53e4574 pkg/report: improve report titles 2020-03-09 14:46:52 +01:00
Dmitry Vyukov
fd2a5f28eb executor: prevent "NMI handler took too long" messages
nmi_check_duration() prints "INFO: NMI handler took too long" on slow debug kernels.
It happens a lot in qemu, and the messages are frequently corrupted
(intermixed with other kernel output as they are printed from NMI)
and are not matched against the suppression in pkg/report.
This write prevents these messages from being printed.
2020-03-06 13:38:53 +01:00
Anton Lindqvist
c88c7b75a4 pkg/report: normalize soreceive report on OpenBSD
At last!
2020-02-27 20:12:33 +01:00
Andrei Vagin
40bcfdd59e executor: don't exit if NETLINK_GENERIC isnt' supported
NETLINK_GENERIC isn't supported in gVisor.

Fixes: c5ed587f4a ("wireguard: setup some initial devices in a triangle")
Signed-off-by: Andrei Vagin <avagin@google.com>
2020-02-27 09:31:19 +01:00
Andrey Konovalov
251aabb77e dashboard/config: switch to ORC unwinder
Jann pointed out that the frame pointer unwinder fails to unwind double
fault stacks. Switch to using the ORC unwinder instead.

https://www.kernel.org/doc/html/latest/x86/orc-unwinder.html

Suggested-by: Jann Horn <jannh@google.com>
2020-02-26 13:28:48 +01:00
Dmitry Vyukov
5e0e1d1450 executor: uncomment accidentially commented code
unshare(CLONE_NEWPID) was commented out in 4428511d10 accidentially.
Uncomment it.
Spotted by @xairy:
4428511d10 (r37456572)
2020-02-24 16:05:43 +01:00
Kamil Rytarowski
2c36e7a75f pkg/report: Improve parsing of the UBSan reports 2020-02-22 10:06:14 +01:00
Kamil Rytarowski
775a8882a6 pkg/build: Raise the timeout limit to 30min for building LLVM (tools) 2020-02-22 10:02:01 +01:00
Dmitry Vyukov
4428511d10 sys/linux: add NETLINK_RDMA descriptions 2020-02-21 17:38:10 +01:00
Dmitry Vyukov
135c18aadb tools: add script that checks copyright headers
Fixes #1604
2020-02-18 16:05:10 +01:00
Dmitry Vyukov
39cd0f85a1 executor: disable IFF_NAPI_FRAGS
Update #1594
2020-02-18 10:31:02 +01:00
Jason A. Donenfeld
c5ed587f4a
wireguard: setup some initial devices in a triangle
* wireguard: setup some initial devices in a triangle

The fuzzer will wind up undoing some of this, which is fine, but at
least it now has the chance of hitting some other paths it wasn't
before.

Closes: #1599

* wireguard: make code ugly after `make generate` pass

* wireguard: get rid of unused structs that are still interesting

* wireguard: compile in C++ mode with gcc 7

Complex designated initializers are only supported in C++ mode from gcc
8, and for whatever reason syzkaller wants to be compiled in C++ mode.

* wireguard: add braces around debug statements for checker

* wireguard: regenerate go source
2020-02-13 15:28:57 +01:00
Dmitry Vyukov
e624765350 pkg/csource: don't print too much error output
We print whole reproducer programs on failure,
if lots of programs fail, this results in thousands
of lines of output, which is esp bad on travis.
Limit amount of output.
2020-02-13 13:26:26 +01:00
Dmitry Vyukov
18847f55bb pkg/ast: introduce hex-encoded string literals
The stringnozescapes does not make sense with filename,
also we may need similar escaping for string flags.
Handle escaped strings on ast level instead.
This avoids introducing new type and works seamleassly with flags.

As alternative I've also tried using strconv.Quote/Unquote
but it leads to ugly half-escaped strings:
"\xb0\x80s\xe8\xd4N\x91\xe3ڒ,\"C\x82D\xbb\x88\\i\xe2i\xc8\xe9\xd85\xb1\x14):M\xdcn"

Make hex-encoded strings a separate string format instead.
2020-02-10 14:45:20 +01:00
Jason A. Donenfeld
b97dee873b pkg/compiler: allow for escaped strings
This adds stringnozescapes to allow parsing of escape sequences in
strings.
2020-02-10 10:51:16 +01:00
Jason A. Donenfeld
4f86d32773 wireguard: use wg0, wg1, wg2
This matches more closely what people are used to dealing with. We also
add one additional device for interesting multi-interface effects.
2020-02-10 10:51:16 +01:00
Dmitry Vyukov
553630e1a9 pkg/ipc: remove use of unsafe
Unsafe is, well, unsafe.
Plus it fails under the new checkptr mode in go1.14.
Remove some uses of unsafe.
2020-02-09 14:09:19 +02:00
Dmitry Vyukov
93e5e33559 pkg/report: update parsing of rcu stalls in ioctls
vfs_ioctl is now inlined somethimes...
2020-02-02 12:56:15 +01:00
Dmitry Vyukov
c30117b2ac pkg/report: don't attribute deadlocks to workqueue functions
In all cases we seen deadlocks in workqueue functions are related
to the subsystem that submits work items.
2020-01-31 19:14:47 +01:00
Dmitry Vyukov
96ce537b15 sys/linux: add some wireguard descriptions
Update #806
2020-01-31 19:12:16 +01:00
Dmitry Vyukov
b190f06061 dashboard/app: fix testing for go1.11 runtime
0. Remove aetest build tag. We don't need it anymore, go test should work.
1. IsDevAppServer does not return true in tests anymore, so don't use it
2. Use a different mechanism to register test/prod config.
We don't have aetest tag anymore, so we need something even more dynamic.
3. Fix new golangci-lint warnings: all test files are checked now.

Update #1461
2020-01-29 16:01:06 +01:00
Dmitry Vyukov
0692a5861f pkg/report: add a note about an existing suppression 2020-01-28 13:38:53 +01:00
Dmitry Vyukov
dd56146d26 prog: remove unused ResourceDesc.Type 2020-01-26 11:30:18 +01:00
Dmitry Vyukov
55da6462ff pkg/serializer: do not write field names if it won't save space
If we are going to write all values, don't write field names.
This only increases size of generated files.
The change reduces size of generated files by 5.8%
(62870496-59410354=3460142 bytes saved).
2020-01-26 11:07:18 +01:00
Dmitry Vyukov
2e95ab3357 pkg/build: switch to sha256
SHA-1 is insecure. See a representative summary of known attacks here:
https://en.wikipedia.org/wiki/Hash_function_security_summary
Some external build systems warn about sha1 uses and reject to build.
Whitelisting is pain. Switch to sha256.
2020-01-23 16:11:47 +01:00
Dmitry Vyukov
02754a8f9a tools/syz-check: check netlink policy descriptions
Overall idea of netlink checking.
Currnetly we check netlink policies for common detectable mistakes.
First, we detect what looks like a netlink policy in our descriptions
(these are structs/unions only with nlattr/nlnext/nlnetw fields).
Then we find corresponding symbols (offset/size) in vmlinux using nm.
Then we read elf headers and locate where these symbols are in the rodata section.
Then read in the symbol data, which is an array of nla_policy structs.
These structs allow to easily figure out type/size of attributes.
Finally we compare our descriptions with the kernel policy description.

Update #590
2020-01-22 12:19:53 +01:00
Dmitry Vyukov
d2557fb5ca pkg/report: treat nfnetlink_rcv_msg as anchor frame
There is tremendous branching after that frame to all
existing netlink callbacks which are effectively completely
different syscalls.
2020-01-20 10:57:28 +01:00
Dmitry Vyukov
0342f8c7bc sys/linux: add more device descriptions (geneve, lowpan, ipoib, cfhsi) 2020-01-19 13:51:21 +01:00
Dmitry Vyukov
4668877967 sys/linux: add some batadv descriptions 2020-01-18 21:02:24 +01:00
Dmitry Vyukov
543c012b4e executor: create macvtap, macsec devices 2020-01-18 21:02:24 +01:00
Dmitry Vyukov
22535fecd5 pkg/compiler: don't mark flags with 0 as bitmask
They can't be a bitmask. This fixes important cases
of "0, 1" and "0, 1, 2" flags. Fix some descriptions
that added 0 to bitmasks explicitly (we should do it
automatically instead).
2020-01-18 21:02:24 +01:00
Dmitry Vyukov
d412ea5e8e pkg/compiler: sort flags values
Will simplify runtime analysis of flags.
Also just no reason to make it more deterministic
and avoid unnecessary diffs in future if values are reordered.
2020-01-18 21:02:24 +01:00
Dmitry Vyukov
132dcea0af pkg/compiler: generate const[0] for flags w/o values
Generate const[0] for flags without values and for flags
with a single value which is 0.
This is the intention in all existing cases (e.g. an enum with types
of something, but there is really only 1 type exists).
2020-01-18 21:02:24 +01:00
Dmitry Vyukov
3de7aabbb7 pkg/vcs: disable CONFIG_DEBUG_KOBJECT during bisection
We disabled it in configs, now also disable during bisection.
This config only adds debug output. It should not be enabled at all,
but it was accidentially enabled on some instances for some periods of time,
and kernel is boot-broken for prolonged ranges of commits with deadlock
which makes bisections take weeks.
2020-01-16 11:31:02 +01:00
Jann Horn
069a5a4486 pkg/report: add pattern for Linux #SS faults
On X86-64, dereferencing a non-canonical address normally causes a #GP, for
which syzkaller already has a pattern. However, if the base register of the
non-canonical address is RBP (which can happen in builds that use RBP as a
general-purpose register because they don't use frame pointer unwinding),
#SS is thrown instead, for which syzkaller did not yet have a pattern.

To see this kind of fault, you can insert the following code in
kernel_init() after the call to rcu_end_inkernel_boot():

	asm volatile(
		"movabs $0x8000000000000000, %rbp\n\t"
		"movq (%rbp), %rax\n\t"
		"ud2\n\t"
	);

Linux prints a different error message for #SS, so add that error message
to syzkaller's list of patterns.
2020-01-15 16:06:40 +01:00
Andrew Turner
fa12bd3c2e pkg/report: Add the calling function to sx reports
These can fail in many functions, include the calling function in
the report
2020-01-14 19:55:46 +01:00
Andrey Konovalov
23f3478a8c executor: provide explicit values for usb_raw_event_type
To match the kernel uapi headers.
2020-01-13 16:14:45 +01:00
Andrey Konovalov
a20859865e pkg/report: add more ignored frames 2020-01-07 16:02:48 +01:00
Dmitry Vyukov
7042566e4b pkg/email: accept #syz- prefix for commands
Some users spell the command as "#syz-dup:".
Support this and few more variations.
2020-01-07 14:32:50 +01:00
Dmitry Vyukov
7824163310 pkg/vcs: disable CONFIG_DEBUG_INFO_BTF during bisection
BTF fails lots of builds with:
pahole version v1.9 is too old, need at least v1.13
Failed to generate BTF for vmlinux. Try to disable CONFIG_DEBUG_INFO_BTF.
2020-01-07 11:31:59 +01:00
Dmitry Vyukov
d2bde102ff pkg/compiler: fix another bitfield layout bug
See the added test for details.
2020-01-07 10:02:09 +01:00
Andrey Konovalov
c43471c3ac pkg/repro: simplify C repros over DevlinkPCI 2020-01-07 10:02:02 +01:00
Andrey Konovalov
6738080fea executor: setns requires including sched.h on some setups 2020-01-07 10:02:02 +01:00
Anton Lindqvist
53430d9719 pkg/report: normalize kqueue_check report on OpenBSD 2020-01-06 20:37:03 +01:00
Dmitry Vyukov
438e122712 pkg/host: fix detection of enabled LSMs
securityfs may not be mounted, but it does not mean that no LSMs are enabled.
2020-01-05 17:48:19 +01:00
Dmitry Vyukov
b726d37627 pkg/host: detect unsupported LSMs 2020-01-05 11:46:32 +01:00
Dmitry Vyukov
682569741a executor: fix IPVLAN_F_VEPA definition again
Now other machines failed with redefinition IPVLAN_F_VEPA.
The #ifndef does not really work the way it should due
to the way pkg/csource preprocesses sources.
IPVLAN_F_VEPA is never defined during preprocessing.
Let's try this.
2020-01-03 21:47:45 +01:00
Dmitry Vyukov
0d1a814324 executor: define constants that are missing on some distros 2020-01-03 21:34:46 +01:00
Dmitry Vyukov
76d86b16e6 executor: setup vlan/macvlan/ipvlan devices 2020-01-03 19:01:39 +01:00
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: f350e2dc1f ("executor: rename devlink port netdevices to defined names")
Signed-off-by: Andrei Vagin <avagin@google.com>
2019-11-26 10:07:31 +01:00
Dmitry Vyukov
371caf7733 pkg/build: make linux implement binary signer
We were almost there...

Update #1271
2019-11-25 10:29:35 +01:00
Andrey Konovalov
b7a277d2ba executor: extend USB debug messages
When USB_DEBUG is enabled, syzkaller crashes on unknown USB requests.
This helps to find missing descriptions for particular USB classes.
2019-11-19 15:33:25 +01:00
Denis Efremov
e9c47538a4 executor: add missing includes
stdbool.h is required by initialize_devlink_ports(): true define.
fcntl.h is required by initialize_devlink_pci(): O_RDONLY define.

Signed-off-by: Denis Efremov <efremov@linux.com>
2019-11-19 11:38:19 +01:00
Jann Horn
432c7650d5 pkg/report: generalize general protection fault pattern
An upcoming patch for Linux will change the error reporting pattern for
general protection faults such that the colon doesn't necessarily come
immediately after the string "general protection fault" (see
https://lore.kernel.org/lkml/20191118142144.GC6363@zn.tnic/).
Change the pattern in syzkaller before that happens.

Note that this is not necessarily the final format; in particular, the
ordering of the KASAN note and the "general protection fault" line might
swap.
2019-11-19 08:07:30 +01:00
Dmitry Vyukov
5bc702124e pkg/bisect: add more logging for build signatures
It seems that some signatures that should be equal are not
(or something else is going on). Add some logging for transparency.
2019-11-18 18:23:01 +01:00
Dmitry Vyukov
b436ffb77d pkg/build: produce more deterministic linux binaries
There are few more dynamic variables related to kernel release tagging.
Set these to known deterministic values.
2019-11-18 17:39:09 +01:00
Dmitry Vyukov
d5696d5192 pkg/ipc: always chmod the work dir
There is little reason in not doing the chown for sandbox=none.
Simpler and can actually increase coverage if the test program
setuid's itself (since it's root under sandbox=none).
2019-11-16 09:58:54 +01:00
Dmitry Vyukov
8825ff8ff2 pkg/runtest: shrink if condition 2019-11-16 09:58:54 +01:00
Dmitry Vyukov
587cec15e2 pkg/host: add Features.Supported
To reduce diff in future changes. Currently no-op.
2019-11-16 09:58:54 +01:00
Dmitry Vyukov
a129861adb pkg/ipc: move target characteristics out of config flags
They don't belong there, executor does not know about them.
In preparation for future changes.
2019-11-16 09:58:54 +01:00
Dmitry Vyukov
aa27601f9e pkg/host: rename some features
Rename some features in preparation for subsequent changes
which will align names across the code base.
2019-11-16 09:58:54 +01:00
Dmitry Vyukov
157653cfe7 pkg/csource: rename some options
Rename some options in preparation for subsequent changes
which will align names across the code base.
2019-11-16 09:58:54 +01:00
Dmitry Vyukov
690740b4a4 executor: refactor sandbox flags
In preparation for future changes.
2019-11-16 09:58:54 +01:00
Dmitry Vyukov
a6e3054436 executor: rename some macros
Rename some macros in preparation for subsequent changes
which will align names across the code base.
2019-11-16 09:58:54 +01:00
Dmitry Vyukov
ca13dd2ab5 pkg/csoruce: test that executor does not mis-spell any of the SYZ_* macros 2019-11-16 09:58:54 +01:00
Dmitry Vyukov
2ac1d00f55 executor: rename some flags
Rename some flags in preparation for subsequent changes
which will align names across the code base.
2019-11-16 09:58:54 +01:00
Dmitry Vyukov
531b5368e2 executor: remove pointless macro checks
common_bsd.h is used for 3 OSes, so checking if it's
any of these 3 OSes is pointless. Remove these checks.
2019-11-16 09:58:54 +01:00
Dmitry Vyukov
8d85129b3c pkg/host: split files into syscalls/features
pkg/host does 2 things: detects supported syscalls and supported features.
There is enough code for each for a separate file.
2019-11-16 09:58:54 +01:00
Dmitry Vyukov
b5c36524a2 sys/targets: add HostFuzzer flag
Move HostFuzzer from vm/qemu.
It's needed in a number of other packages
and strictly saying is not specific to qemu
(it just happened that both fuchsia and akaros only support qemu).
2019-11-16 09:58:54 +01:00
Jiri Pirko
cdac920beb executor: consider NLMSG_DONE type in netlink_send_ext()
In case the dump is empty, NLMSG_DONE type message is received from
kernel right away. Count with this and return 0. Set the reply_len to 0.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Fixes: f350e2dc1f ("executor: rename devlink port netdevices to defined names")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2019-11-15 15:58:48 +01:00
Andrey Konovalov
90f3b019e4 executor, pkg/host: update usb raw-gadget interface
The patches are being upstreamed and the interface has changed.
2019-11-15 14:53:30 +01:00
David Pursell
79248ee88b sys/fuchsia: remove deprecated exception APIs
The port-based exception APIs have been deprecated on Fuchsia and will
be removed shortly. Delete them from the syscall definitions and
modify the Fuchsia executor to use the new channel-based APIs instead.
2019-11-14 16:21:01 -08:00
Kamil Rytarowski
a24fe792a6 Correct parsing of Kernel ASan reports
Handle __asan strings in backtraces.
2019-11-14 18:48:40 +01:00
Jiri Pirko
f350e2dc1f executor: rename devlink port netdevices to defined names
Devlink port netdevices stay in the form of eth%d. Rename then to
defined names so they could be used for system calls.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2019-11-14 09:21:37 +01:00
Jiri Pirko
7209952f67 executor: pass struct nlmsg to netlink_* helpers
Don't rely on global "nlmsg" struct and rather pass the structure to
netlink_* helpers. That allows to possibly work with multiple netlink
messages (sending while receiving for example) at the same time.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2019-11-14 09:21:37 +01:00
Jiri Pirko
2b6d94ac9b executor: extend netlink_device_change() to allow name changes
Extend existing helper netlink_device_change() in order to allow to
change netdevice names.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2019-11-14 09:21:37 +01:00
Jiri Pirko
966d14f910 executor: identify netdev by ifindex in netlink_device_change()
IFLA_NAME is going to be used to set the name of the netdevice, so
change the handle to be ifindex.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2019-11-14 09:21:37 +01:00
Jiri Pirko
d5f798b079 executor: push out devlink generic netlink id getter into a separate function
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2019-11-14 09:21:37 +01:00
Dmitry Vyukov
31b7aac462 pkg/report: ignore boot warning that always happens
Happens on every boot and prevents detection of other bugs.
The warning was already reported upstream:
https://groups.google.com/forum/#!msg/syzkaller-bugs/8HZdIbi8sdE/Niu4qijeAAAJ
https://syzkaller.appspot.com/bug?extid=4d497898effeb1936245
2019-11-08 13:38:31 +01:00
Mark Johnston
5e1ad02b17 pkg/csource: Force promotion of 64-bit constant values
Constant 64-bit arguments to the variadic syscall(2) must have their
width specified explicitly.  In practice this is not necessary most of
the time, but on amd64/freebsd with clang the compiler can and does
store the constant 32-bit value to the stack, leaving garbage in the
upper 32 bits.

This makes C reproducers somewhat uglier, but I see no other solution.
2019-11-08 10:51:32 +01:00
Dmitry Vyukov
1e35461e02 pkg/report: trim panic_on_warn set few lines earlier
The KCSAN reports can be quite short.
Now with task contexts we can hopefully reduce the threshold a bit.
2019-11-08 07:51:25 +01:00
Dmitry Vyukov
30cb7f98cd pkg/bisect: detect wrong bisections
Detect bisection to merge commits and to commits that don't affect
kernel binary (comments, other arches, whitespaces, etc).
Such bisections are not reported in emails (but shown on web).

Update #1271
2019-11-07 11:07:03 +01:00
Dmitry Vyukov
f158761183 pkg/csource: don't run tests if compiler is broken
Test presence of a working compiler before running any tests for a target.
This helps to make tests pass even if some cross-compilers are not installed properly.
2019-11-07 11:07:00 +01:00
Dmitry Vyukov
d797d2018f pkg/report: fix up panic handling
Obviously there is an exception to every exception in kernel output parsing...
2019-11-06 18:06:12 +01:00
Dmitry Vyukov
da505f84d3 pkg/report: detect syzkaller panics in lost connection bugs
Some syzkaller panics happen due to memory corruptions,
but it still would be useful at least to get some visibility into these crashes.
On some OSes we actualy already detect them as they have "panic:" oops pattern,
but not e.g. on linux.

Fixes #318
2019-11-06 11:41:05 +01:00
Dmitry Vyukov
424cf6e8a1 pkg/build: add build signatures
Add optional build signature for images, currently only implemented for linux.
This can be used in bisection process to detect changes that does not affect kernel.

Update #1271
2019-11-06 11:41:05 +01:00
Dmitry Vyukov
c487cd4633 pkg/build: refactor Image function arguments
Image takes too many arguments, so we need to do lots of forwarding,
adding new argumnets is painful and most OSes are not interested
in lots of arguments.
Combine all arguments into a params struct.
2019-11-06 11:41:05 +01:00
Andrey Konovalov
80aca15c2a executor: update the list of raw usb events
The number of reported event types changed.
2019-11-05 15:11:22 +01:00
Zubin Mithra
0a2d7d8293 pkg/bisect: modify Run() to return information about commit
* Modify Run() to return the commit object when a failure occurs on the
oldest tested release(for BisectCause) and latest tested
release(for BisectFix).
* Modify tests to check the returned commit object.
2019-11-05 09:15:56 +01:00
Andrey Konovalov
76630fc947 executor, pkg/host, dashboard/config: rename usb-fuzzer to usb raw-gadget
The interface is being upstreamed and the name has changed.
2019-11-04 15:43:43 +01:00
Zubin Mithra
1d0df175f3 pkg/bisect: add more tests for various possible bisection results
Add tests for the following cases(1 each for cause and fix):
- bisection returns the correct commit
- bisection failed due to crash not occuring on the original commit
- bisection failed as crash occurs on oldest/latest commit
- bisection is inconclusive
2019-11-04 14:40:37 +01:00
Dmitry Vyukov
e2d61622eb sys/linux: improve CAN descriptions 2019-11-04 12:39:39 +01:00
Jiri Pirko
b35fad31e9 pkg/csource: remove duplicate check
Remove a check that was mistakenly added with devlink_pci feature and is
duplicate of the existing check.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2019-11-03 16:42:57 +01:00
Dmitry Vyukov
99d946ccff executor: fix setup of vxcan
Adding vxcan1 also adds vxcan0. Setup and use both.
2019-11-03 15:00:15 +01:00
Dmitry Vyukov
2079602763 pkg/csource: fix lint warnings
CI failed:
https://travis-ci.org/google/syzkaller/jobs/606730911?utm_medium=notification&utm_source=github_status
2019-11-03 14:44:53 +01:00
Jiri Pirko
d40d75d2d7 executor: move fixed pci devlink handle into network namespace
In case there is a fixed pci devlink handle "pci/pci/0000:00:10.0"
on the system (initial network namespace), it is moved to a working
network namespace.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2019-11-03 14:20:59 +01:00
Paul Chaignon
997ccc675b pkg/compiler: define fileoff template
Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
2019-11-01 19:14:49 +01:00
Paul Chaignon
f922d4435a pkg/compiler: special BASE argument in templates
Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
2019-11-01 19:14:49 +01:00
Anton Lindqvist
25bb509e59 pkg/report: suppress fifo_badop reports on OpenBSD
This panic is not to interesting since the intended behavior is to panic and
it requires root due to usage of mknod(2).
2019-10-26 09:02:46 +02:00
Paul Chaignon
413926c563 pkg/compiler: check range is consistent with base type
For any intN, values in the range [-MAX_INTN:MAX_INTN] are accepted.

Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
2019-10-25 18:16:59 +02:00
Paul Chaignon
713f727d98 prog, pkg/compiler: alignment for integer ranges
Enables the syntax intN[start:end, alignment] for integer ranges.  For
instance, int32[0:10, 2] represents even 32-bit numbers between 0 and 10
included.  With this change, two NEED tags in syscall descriptions can be
addressed.

Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
2019-10-25 18:16:59 +02:00
Paul Chaignon
ced0f73a67 pkg/compiler: check first int arg is range
Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
2019-10-25 18:16:59 +02:00
Jiri Pirko
5b49e1f605 executor: create netdevsim device
Create testing netdevsim instance with 4 ports.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
2019-10-25 13:15:56 +02:00
Dmitry Vyukov
d894f260cc pkg/report: better diffirentiate task hung reports (2)
Add file missed in the previous commit.
2019-10-23 10:38:37 +02:00
Paul Chaignon
55afb04f04 pkg/ast: unexport Node.Walk()
Other packages should use ast.Recursive and ast.PostRecursive to ensure
the root node is visited as well.

Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
2019-10-23 10:22:35 +02:00
Paul Chaignon
d3cea9507f pkg/compiler: fix root node not visited in typedef checks
Without this fix, the compiler throws an error 'template argument BASE is
not used' for the following typedef.

  type templ1[BASE] BASE
  foo(a ptr[in, templ1[int64]])

Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
2019-10-23 10:22:35 +02:00
Dmitry Vyukov
bb6c338b9e pkg/report: better diffirentiate task hung reports
A number of hangs happen when trying to cancel tasks in different subsystems.
2019-10-23 10:13:30 +02:00
Anton Lindqvist
d0686497a9 pkg/report: normalize pool cpu free list modified reports on OpenBSD (#1474) 2019-10-22 15:06:11 -07:00
Marco Elver
5681358a2a syz-fuzzer, executor: Add support for blacklisting data race frames
This adds support to add frames that have already been in data races, to
the KCSAN report blacklist.
2019-10-22 17:48:18 +02:00
Dmitry Vyukov
788abb174f pkg/vcs: detect old git binary that can't do bisection 2019-10-22 15:57:26 +02:00
Dmitry Vyukov
084e388155 pkg/vcs: make EnvForCommit return full compiler path
All callers of EnvForCommit need the compiler path,
so move this logic into EnvForCommit to avoid duplication.
Also simplifies tests because test impl can now return
an empty compiler (which should be unused).
2019-10-22 15:41:03 +02:00
Zubin Mithra
a2bdbd8c37 pkg/bisect: add initial testing support for cause bisection
(note: incomplete change)

Refactor existing code as follows:
* Move reusable test utility functions from git_repo_test.go to
pkg/vcs/test_util.go and make them exported.
* Split Run() into Run()+runImpl().
* Change type of bisect.go:env.inst to `instance.BuilderTester`.
Change usage inside syz-testbuild/testbuild.go accordingly.
* Move most of linux.PreviousReleaseTags() into vcs/git.go as
git.previousReleaseTags().
* Allow build.CompilerIdentity to be mocked.

Introduce the following changes:
* instance.BuilderTester is an interface with methods
	BuildSyzkaller()
	BuildKernel()
	Test()
NewEnv() now returns this interface.
* type testEnv implements instance.BuilderTester.
* type testBuilder implements builder interface. Add a entry into table
inside pkg/build/build.go:getBuilder() to return testBuilder object.
2019-10-22 10:09:57 +02:00
Dmitry Vyukov
37dc03de04 pkg/report: improve parsing of task hung reports
The problem with task hung reports is that they manifest at random victim stacks,
rather at the root cause stack. E.g. if there is something wrong with RCU subsystem,
we are getting hangs all over the kernel on all synchronize_* calls.
So before resotring to the common logic of skipping some common frames,
we look for 2 common buckets: hangs on synchronize_rcu and hangs on rtnl_lock
and group these together.
2019-10-22 09:52:16 +02:00
Andrey Konovalov
6901a56e00 executor/usb: enable endpoints on SET_INTERFACE
This commit changes syz_usb_control_io to enable the relevant endpoints
for the interface being set via a SET_INTERFACE request.
2019-10-21 15:56:03 +02:00
Andrew Donnellan
a6aef847d9 pkg/report: Add ppc64le kernel paging request test case
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
2019-10-14 11:17:24 +02:00
Andrew Donnellan
d18522a287 pkg/report: Add regexes for kernel data access BUG on ppc64le
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
2019-10-14 11:17:24 +02:00
Andrew Donnellan
05c1b98356 pkg/report: Fix linuxRipFrame regex for ppc64le
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
2019-10-14 11:17:24 +02:00
Anton Lindqvist
2f661ec405 pkg/report: normalize malloc free list modified reports on OpenBSD 2019-10-13 10:31:52 +02:00
Dmitry Vyukov
a4efa8c091 pkg/compiler: fix infinite recursion in template instantiation
Currently we replace a template argument and then recurse
into the new type AST to see if there is more to replace.
If the description is buggy and the template argument
contains itself, then we will recurse infintiely trying
to replace it more and more.
Use post-order traversal when replacing template argument to fix this.
2019-10-10 11:57:33 +02:00
Kamil Rytarowski
c4b9981b5f Disable checkFeature[FeatureNetworkInjection] for NetBSD
There is a problem with the image. Until the problem will be resolved,
disable the feature as it causes premature death of the syzbot setup.
2019-10-09 19:16:07 +02:00
Dmitry Vyukov
b1ebbfef72 pkg/report: fix up test 2019-10-08 16:36:45 +02:00
Dmitry Vyukov
ec93713427 pkg/report: ignore mutex_slowlock in task hung reports 2019-10-08 16:06:25 +02:00
Marco Elver
137e37cac2 Change KCSAN info file to debugfs 2019-10-08 15:04:54 +02:00
Dmitry Vyukov
28ac6e6496 pkg/report: fix ODEBUG parsing for v4.4 2019-10-07 09:37:24 +02:00
Marco Elver
69b8b8fa36 pkg/report: Fix formatting 2019-10-04 16:46:37 +02:00
Marco Elver
c86336cf24 pkt/report: Shorten KCSAN report titles 2019-10-04 15:52:40 +02:00
Marco Elver
b2f369e56e executor, host, csource: Add support to enable KCSAN
By default, the current KCSAN .config does not enable KCSAN during boot,
since we encounter races during boot which would prevent syzkaller from
ever executing.

This adds support to detect if KCSAN is available, and enables it on the
fuzzer host.
2019-10-04 13:44:09 +02:00
Anton Lindqvist
eb6b9855e0 pkg/report: improve uvm_fault reports on OpenBSD
Some reports[1] does not include a symbol but rather an address in the
"Stopped at" line. There's unfortunately no useful context to add to the
title so make them generic instead.

[1] https://syzkaller.appspot.com/bug?id=3e44d0b128fd8d6826e4d0044baadcfc02ba7125
2019-09-28 12:05:58 +02:00
Anton Lindqvist
2f1548bc77 pkg/report: normalize attempt to execute user address reports on OpenBSD (#1431) 2019-09-26 12:52:00 -07:00
Andrey Konovalov
24d405a355 pkg/report: improve USB reports 2019-09-25 18:48:23 +02:00
Andrey Konovalov
a3355dba73 pkg/report: improve USB reports
tty_unregister_device looks generic enough, add to ignore list.
2019-09-25 14:55:31 +02:00
Andrey Konovalov
0942eab8c6 pkg/report: improve USB report titles 2019-09-24 15:15:04 +02:00
Andrey Konovalov
792da3da86 executor, csource: adjust syz_open_dev$hiddev timeout
Looks like opening hiddev can take up to ~100 ms.
2019-09-24 10:45:51 +02:00
Andrey Konovalov
5ff4e14cb1 pkg/runtest: allow empty signal 2019-09-24 10:45:51 +02:00
Anton Lindqvist
aac00cc3db pkg/vcs: handle git commits without a body
OpenBSD uses cvs and does not enforce the standard Git convention for
commit messages of putting a summary followed by a new line and body.
If such commit[1] contains a `Reported-by` header, it's currently not
detected. Instead, if the body is empty try to extract data from the
commit summary.

[1] bdbfbec5ce
2019-09-24 10:43:57 +02:00
Mark Johnston
83620b5b4e pkg/report: deduplicate some common FreeBSD panics 2019-09-24 10:42:43 +02:00
Veronica Radu
5a7028d005 pkg/db: moved ReadCorpus function to avoid duplicate code 2019-09-23 15:35:26 +02:00
Dmitry Vyukov
d96e88f320 pkg/report: add a test case which we mis-handle now 2019-09-20 09:37:36 +02:00
Andrey Konovalov
4d3ae0b784 executor: handle USB IN requests with wLength == 0 2019-09-19 19:31:56 +02:00
Andrey Konovalov
0c00210ff3 executor: always provide DEVICE_QUALIFIER USB descriptor 2019-09-19 19:31:56 +02:00
Siddharth M
7fa5d0a69b pkg/build: build netbsd using config files 2019-09-18 15:00:55 +02:00
Dmitry Vyukov
ad847b96aa pkg/report: ignore "INFO: recovery required on readonly filesystem"
This is not a kernel bug.
2019-09-17 16:14:31 +02:00
Andrey Konovalov
d62be7809c runtest: add a flag to specify tests to run 2019-09-17 15:58:29 +02:00
Andrey Konovalov
5883acb646 pkg/report: improve some USB reports 2019-09-17 15:09:43 +02:00
Andrey Konovalov
51ca0454d7 pkg/osutil: fix arm build
pkg/osutil/osutil_linux.go:44:13: cannot use info.Totalram (type uint32) as type uint64 in return argument
2019-09-16 14:15:38 +02:00
Marco Vanotti
40fa42bc27 executor/fuchsia: close vmo handle in syz_mmap.
This commit fixes a handle leak in syz_mmap. The bug was pointed out by
mdempsky during a code review.

The `syz_mmap` function creates a VMO and maps it to a VMAR in the address
specified by the `syz_mmap` parameters. Once a VMO is mapped to a vmar,
the handle to the vmo can be closed without problems.

The new code makes sure that `zx_handle_close(vmo_handle)` gets called before
the `syz_mmap` function returns.
2019-09-12 21:17:27 -03:00
Marco Vanotti
f4e53c1037 executor/fuchsia: don't crash on syz_mmap failure.
syz_mmap is a pseudo-syscall that can be used by syzkaller in fuzzing
programs, however, it is also used to setup the environment for
syz-executor. syz-executor already checks the return value[0] when it is
used for setting up the environment, so it doesn't make sense for the
function to crash (most probably, in a fuzzing program it will be called
with arguments that would make it fail).

The previous behavior was causing a bunch of "Lost connection to test
machine" syzkaller crashes which were meaningless. An example of a
program in which syz_mmap would crash would be any program in which the
handle to the root vmar is closed before calling syz_mmap.

[0]:
a60cb4cd84/executor/executor_fuchsia.h (L15)
2019-09-11 16:38:45 -03:00
Marco Vanotti
000d39a9b8 pkg/ipc: Send output from syz-executor for non-Forkserver oses.
This change reuses the logic for sending the output back from
syz-executor to syz-fuzzer that forkserver oses use: reading it
periodically. This will be useful for debugging issues in Fuchsia that
does not support forkserver yet.
2019-09-11 16:38:45 -03:00
Andrey Konovalov
a60cb4cd84 executor/usb: use UTF16 encoding for default string
Also respond with lang ID when string #0 is requested.
2019-09-06 20:11:54 +02:00
Andrey Konovalov
3fe4b3b1aa executor/usb: fix null-ptr-deref in syz_usb_control_io 2019-09-06 20:11:54 +02:00
Andrey Konovalov
1af11d9328 executor/usb: improve debugging messages 2019-09-06 20:11:54 +02:00
Andrey Konovalov
2d7c71133a executor/usb: allow syz_usb_control_io args to be 0 2019-09-06 20:11:54 +02:00
Andrey Konovalov
a38da1b89a sys/linux, executor: basic support for multiple USB interfaces 2019-09-06 17:19:55 +02:00
Andrey Konovalov
c16be727a6 executor: fix sigsegv for default USB string response 2019-09-05 19:03:35 +02:00
Andrey Konovalov
3977854c2a
pkg/compiler: remove fixed TODO (#1376) 2019-09-04 12:58:59 +02:00
Dmitry Vyukov
b0e5f924b5 pkg/report: update ODEBUG warning format
It seems something has changed in the kernel again...
2019-09-04 10:35:20 +02:00
Andrey Konovalov
a50398545a pkg/compiler: detect unused template params 2019-09-04 07:10:15 +02:00
Dmitry Vyukov
8d48456885 tools/syz-symbolize: fix kernel dir calculation
syz-symbolize did not use the common mgrconfig logic
to calculate kernel dirs. Thus KernelBuildSrc ended up empty,
+dirs were not extended to absolute paths.
Use the common mgrconfig logic to calculate kernel dirs.
2019-09-03 15:00:40 +02:00
Andrey Konovalov
7ca47f80a8
pkg/report: improve USB reports (#1372) 2019-09-03 14:09:51 +02:00
Dmitry Vyukov
14544a569e pkg/build: fix linux make invocation
-j flag is weird, make fails on -j=N.
2019-09-02 07:41:19 +02:00
Dmitry Vyukov
db7c31ca79 pkg/build: make linux builds more deterministic
Kbuild inserts build timestamp into every build.
This makes vmlinux change always even if no present.
Make the build more deterministic.
We plan to use it for detecting no-op changes during bisection.

Update #1271
2019-09-01 20:42:42 -07:00
Dmitry Vyukov
aaf9e5bb5e pkg/build: factor out linux make execution
Remove duplication when calling linux make.
2019-09-01 20:42:35 -07:00
Zubin Mithra
bad3cce26c dashboard/app: allow reporting of BisectFix results
* Modify mail_bisect_result.txt to allow for sending fix bisection
results.
* Modify BisectResult to have a Fix field; introduce selectBisect for
use within the template for choosing between BisectCause/BisectFix
fields.
* Modify bisectFromJob() to return BisectResult with Fix field set if
relevant.
* Modify the tests inside bisect_test.go to account for bisect fix
related reporting emails.
* Modify incomingMail() to ignore any emails from syzbot itself.
2019-08-30 19:50:12 -07:00
Anton Lindqvist
9adfa8760f pkg/report: improve witness extraction for OpenBSD
Reports from witness regarding returning to userspace with locks held is not
unique enough, causing all lock leaks to be grouped under the same bug.
Instead try to extract the name of syscall where the first held lock was
grabbed.

While here, shorten the title a bit.
2019-08-30 06:13:56 -07:00
Matthew Dempsky
fd37b39ea8 all: convert Fuchsia to use "host fuzzing" mode
Go support is not a priority for Fuchsia at the moment, so it's
preferable to use host fuzzing mode for Fuchsia like currently done
for Akaros.

This commit basically looks for all the places where there was special
logic for OS=="akaros" and extends the same logic for OS=="fuchsia".
2019-08-27 14:39:18 -07:00
Andrey Konovalov
78ded1969a
sys/linux, executor: minor USB fixes (#1361) 2019-08-23 14:50:37 +02:00
Michael Pratt
d003d6d021 Merge pull request #1338 from prattmic/patch-3
pkg/report: ignore exceeded race limits
2019-08-22 07:21:17 -07:00
Michael Pratt
b231f4c271 pkg/gvisor: suppress one more gvisor PID exhaustion 2019-08-22 07:21:09 -07:00
Andrey Konovalov
c6c81a0bd3
executor: fix procid not declared properly for netbsd (#1358) 2019-08-22 14:49:06 +02:00
Andrey Konovalov
0ab81da2cf
pkg/report: revert bucketing MAX_STACK_TRACE_ENTRIES reports (#1357)
MAX_STACK_TRACE_ENTRIES crash reports caused by a particular issues can come
from any part of the kernel, so bucketing them based on the stack trace is
pointless and only creates duplicate bug reports.
2019-08-22 14:42:17 +02:00
Siddharth M
8570f91c22 pkg/csource: fix failing syz-runtest for NetBSD
* pkg/csource: fix failing syz-runtest for NetBSD

* update common.go
2019-08-21 07:13:43 -07:00
Andrey Konovalov
5e0a9c712f pkg/report: improve netdev reports titles 2019-08-21 07:09:54 -07:00
Marco Vanotti
4ea67ff893 pkg/build: use sandbox to build fuchsia.
We have noticed that the build process was being invoked as root. This
change modifies the calls to use osutil.Sandbox before invoking cmds to
build fuchsia.

This is required for the process to use goma, as goma is running under
the syzkaller user.
2019-08-20 18:47:02 -07:00
Andrey Konovalov
ae348fb726 pkg/report: ignore finish_wait frame 2019-08-19 09:44:52 -07:00
Andrey Konovalov
8fd428a197 pkg/report: improve ODEBUG titles 2019-08-15 13:39:03 -07:00
Marco Vanotti
5576551bab pkg/build: increase timeout for building fuchsia 2019-08-14 09:34:25 +02:00
Andrey Konovalov
ef801a3eab
pkg/report: improve some titles (#1332)
* pkg/report: improve BUG: MAX_STACK_TRACE_ENTRIES titles

* pkg/report: improve refcount bug titles
2019-08-13 19:05:24 +02:00
Andrey Konovalov
acb5163814
sys/linux: add basic USB CDC Ethernet descriptions (#1328) 2019-08-09 19:46:27 +02:00
Dmitry Vyukov
c576290a35 pkg/host: fix linux netdevices detection
We don't use ip command for netdevices and tun setup.
2019-08-09 18:20:11 +02:00
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