Commit Graph

5492 Commits

Author SHA1 Message Date
Dmitry Vyukov
9c6fc8db23
docs: add reference to "Exploiting the Linux kernel via packet sockets" 2020-08-16 10:12:39 +02:00
Dmitry Vyukov
4a68e16fb4
docs: add reference to "Industry Practice of Coverage-Guided Enterprise Linux Kernel Fuzzing" 2020-08-16 10:11:14 +02:00
Dmitry Vyukov
c71bff662d
docs: add reference to "HFL: Hybrid Fuzzing on the Linux Kernel" 2020-08-16 10:06:58 +02:00
Dmitry Vyukov
c2707aa5fe
docs: add reference to "Fuzzing the OpenBSD Kernel" 2020-08-14 19:05:57 +02:00
Stefano Duo
7c06bb218a sys/linux/test: add test performing getdents64() on FUSE dir
Add syzkaller program which correctly handles a getdents64() syscall
on a FUSE directory. Here the related comment/discussion
https://github.com/google/syzkaller/pull/2001#issuecomment-671185292.
2020-08-14 18:55:11 +02:00
Stefano Duo
a1481759c3 executor/common_linux.h: open target dir inside syz_mount_image()
Refactor syz_mount_image() to support filesystems not requiring a
backing device and filesystem image (e.g. FUSE). To do that, we check for
the presence of the pointer to the array of struct fs_image_segment: if
missingi, there is no need to setup the loop device and we can proceed
directly with the mount() syscall.
Add syz_mount_image$fuse() (specialization for FUSE) inside
sys/linux/fs_fuse.txt.
2020-08-14 18:55:11 +02:00
Stefano Duo
aa6107e60d sys/linux/fs_fuse.txt: use bytelen instead of len
Use the type bytelen instead of len to express the length of the data
structure being pointed by the pointer passed to read$FUSE().
2020-08-14 18:55:11 +02:00
Stefano Duo
19b6584f71 executor/common_linux.h: add syz_fuse_handle_req()
At the moment syzkaller is able to respond to FUSE with a syntactically
correct response using the specific write$FUSE_*() syscalls, but most of
the times these responses are not related to the type of request that
was received.
With this pseudo-syscall we are able to provide the correct response
type while still allowing the fuzzer to fuzz its content. This is done
by requiring each type of response as an input parameter and then
choosing the correct one based on the request opcode.
Notice that the fuzzer is still free to mix write$FUSE_*() and
syz_fuse_handle_req() syscalls, so it is not losing any degree of
freedom.

syz_fuse_handle_req() retrieves the FUSE request and resource
fuse_unique internally (by performing a read() on the /dev/fuse file
descriptor provided as input). For this reason, a new template argument has
been added to fuse_out (renamed to _fuse_out) so that the unique field
can be both an int64 (used by syz_fuse_handle_req()) and a fuse_unique
resource (used by the write$FUSE_*() syscalls) without any code
duplication.
2020-08-14 18:55:11 +02:00
Stefano Duo
3d9b8afae8 sys/linux/fs_fuse.txt: use expected flags for fuse_attr.mode
Instead of using a generic int32 for fuse_attr.mode, use the expected
file mode flags.
2020-08-14 18:55:11 +02:00
Stefano Duo
191c0565a1 sys/linux/fs_fuse.txt: define FUSE request id as a resource
Currently fuse_in.unique and fuse_out.unique are not linked by any
dependency chain. This causes the majority of the replies to the kernel
to be dropped because not referring to a previously sent request.
By defining them as a resource, we push the fuzzer in the right
direction (i.e., try to respond using a previously issued unique value).
The read syscall has been updated accordingly, it now expects and parses
a fuse_in header and some additional data.
2020-08-14 18:55:11 +02:00
Dmitry Vyukov
991110ce9d pkg/csource: add comment re ignoring cpp errors
Clarify why we ignore cpp errors.
2020-08-14 14:45:37 +02:00
Dmitry Vyukov
bdf3cf7267 executor: fix use of SYZ_SANDBOX_ANDROID define
"#if not" does not seem to be a thing in C:

$ cpp -undef -fdirectives-only -dDI -E -P -DSYZ_REPEAT -DSYZ_USE_TMP_DIR executor/common_linux.h 1>/dev/null
executor/common_linux.h:3776:9: error: missing binary operator before token "SYZ_SANDBOX_ANDROID"
 3776 | #if not SYZ_SANDBOX_ANDROID
      |         ^~~~~~~~~~~~~~~~~~~
executor/common_linux.h:3801:9: error: missing binary operator before token "SYZ_SANDBOX_ANDROID"
 3801 | #if not SYZ_SANDBOX_ANDROID
      |         ^~~~~~~~~~~~~~~~~~~
executor/common_linux.h:3837:9: error: missing binary operator before token "SYZ_SANDBOX_ANDROID"
 3837 | #if not SYZ_SANDBOX_ANDROID
      |         ^~~~~~~~~~~~~~~~~~~
executor/common_linux.h:3868:9: error: missing binary operator before token "SYZ_SANDBOX_ANDROID"
 3868 | #if not SYZ_SANDBOX_ANDROID
      |         ^~~~~~~~~~~~~~~~~~~

Currently parts under "#if not SYZ_SANDBOX_ANDROID" are always stripped from
reproducers under all sandboxes. Use the standard !SYZ_SANDBOX_ANDROID.

We also need SYZ_EXECUTOR part because sandbox is not statically known
when we are building syz-executor.

And we also need to remove the use of flag_sandbox_android for C reproducers
because for these sandbox is statically known and we don't have flag_sandbox_*.
2020-08-14 14:04:41 +02:00
Anton Lindqvist
872ebc286c sys/openbsd: neutralize sysctl kern.maxthread
Yet another root only knob that can cause the syz-execprog process to
panic[1]. Greg is currently working on sanitizing sysctl integer knobs
in the OpenBSD kernel. This will improve the situation but preventing
fiddling with this knob is a good call anyway.

While here, restructure the code a bit making it easier to add sysctl
neutralizers.

[1] https://syzkaller.appspot.com/bug?id=40bcbbeb244998dfc4eeec90b8f8bce372882211
2020-08-14 13:46:14 +02:00
Necip Fazil Yildiran
5ce135324a prog: fix UnionType mutation for when per-field dir is specified
prog/TestMutateRandom used to fail due to this.
2020-08-14 11:02:10 +02:00
Dmitry Vyukov
424dd8e7b5 executor: warn about C89-style var declarations
We generally use the newer C99 var declarations combined with initialization because:
 - declarations are more local, reduced scope
 - fewer lines of code
 - less potential for using uninit vars and other bugs
However, we have some relic code from times when we did not understand
if we need to stick with C89 or not. Also some external contributions
that don't follow style around.

Add a static check for C89-style declarations and fix existing precedents.

Akaros toolchain uses -std=gnu89 (or something) and does not allow
variable declarations inside of for init statement. And we can't switch
it to -std=c99 because Akaros headers are C89 themselves.
So in common.h we need to declare loop counters outside of for.
2020-08-14 09:40:08 +02:00
Dmitry Vyukov
54ce1ed6b9 sys/linux: switch to the new .const format
This reduces number of const files/lines from 1288/96599 to 158/11603.
Const files are generated on next-20200813.

Update #1983
2020-08-13 17:22:16 +02:00
Dmitry Vyukov
b6de93e603 pkg/compiler: merge const files into a single file
We now have 8 arches for Linux and .const files
produce lots of noise in PRs and lots of diffs.
If 3 .txt files are touched, the PR will have 24 .const files,
which will be intermixed with .txt files.
Frequently const values are equal across arches,
and even if they don't spreading a single value
across 8 files is inconvinient.

Merge all 8 *_arch.const files into a single .const file.
See the test for details of the new format.
The old format is still parsed for now,
we can't update all OSes at once.

For Linux this reduces number of const files/lines
from 1288/96599 to 158/11603.

Fixes #1983
2020-08-13 17:22:16 +02:00
Tetsuo Handa
598f4936eb executor/linux: dump more information when failed to open kcov file
With commit 50e21c6be6188f42 ("executor/linux: dump mount information when
failed to open kcov file"), we got an unexpected result.

  /sys/kernel/ does not exist despite /sys/ exists.
  /proc/mounts cannot be opened despite /proc/ exists.

If sysfs is not mounted on /sys/ and proc is not mounted on /proc/ ,
maybe other filesystems (e.g. devtmpfs, cgroup) are not mounted as well.
Let's dump "/", "/proc/" and "/sys/", and then mount /proc/ and dump /proc/mounts .
2020-08-13 15:56:42 +02:00
Dmitry Vyukov
60d836d372 executor: fix style checking test
The regexp for empty suppressions matches _everything_...
Don't match suppression if it's empty.
2020-08-13 15:37:26 +02:00
Necip Fazil Yildiran
cc59e7e4ad sys/linux: use per-field directions in descriptions 2020-08-13 13:50:25 +02:00
Necip Fazil Yildiran
f5442bde55 pkg, prog: add per-field direction attribute 2020-08-13 13:50:25 +02:00
Tetsuo Handa
ee7cb8b695 Makefile: try to install clang-tidy package explicitly
Commit 43f1389ddc ("Makefile: enable clang-tidy in presubmit tests")
added clang-tidy to only tools/docker/env/Dockerfile file. We should try to
explicitly install clang-tidy in Makefile for those who don't use docker.

  /bin/sh: 1: clang-tidy: not found
  (...snipped...)
  Makefile:250: recipe for target 'tidy' failed
  make[2]: *** [tidy] Error 127
  make[2]: *** Waiting for unfinished jobs....
  (...snipped...)
  Makefile:269: recipe for target 'presubmit_smoke' failed
  make[1]: *** [presubmit_smoke] Error 2
  Makefile:264: recipe for target 'presubmit' failed
  make: *** [presubmit] Error 2
2020-08-13 13:26:55 +02:00
Tetsuo Handa
bc15f7dbbc executor/linux: dump mount information when failed to open kcov file
There are many "lost connection to test machine (5)" reports where the
testing terminated due to ENOENT upon open("/sys/kernel/debug/kcov").

Since some testcase might be unintendedly modifying mount information,
let's start from checking whether/how mount is broken.
This commit might be reverted after the cause is identified and fixed.
2020-08-12 18:19:04 +02:00
Mark Johnston
1bf9153625 pkg/runtest: re-enable 32-bit test target tests on FreeBSD
They now pass since we set DataOffset correctly for those targets.
This reverts 594e57536f.
2020-08-12 18:09:10 +02:00
Mark Johnston
b38f46a018 sys/targets: override DataOffset for 32-bit test targets on FreeBSD
freebsd/386 requires a non-default DataOffset value.  Since it is
currently the only platform with this constraint, just add a special
case for that when initializing target parameters.
2020-08-12 18:09:10 +02:00
Dmitry Vyukov
0d7bd2e052 executor: initialize vhci early
We added initialize_vhci to all sandboxes so that we don't have
unused function warnings. We assumed it will fail silently,
but it fails loudly and crashes the whole machine on init,
so no fuzzing can happen with sandboxes other than none.
Initialize vhci earlier while we still have CAP_ADMIN.
As a nice side effect we now don't need to use syz_init_net_socket.
2020-08-12 11:03:32 +02:00
Mark Johnston
bb3e5fe608 docs/freebsd: clarify that the dataset name is an example 2020-08-11 11:42:07 -04:00
Mark Johnston
4ad44804fb docs/freebsd: update the "missing things" list
Some items have already been implemented.  Add some new items to work
towards.
2020-08-11 11:42:07 -04:00
Anton Lindqvist
5d3ebca921 executor: enable extra coverage on OpenBSD
This reverts commit 63a7334112.
2020-08-11 10:56:29 +02:00
Dmitry Vyukov
bacaf5fa2c pkg/report: fix parsing of kernel-usb-infoleak
It used to use warningStackFmt, it is wrong, this is not a WARNING.
As the result it previously parsed as:
KMSAN: kernel-usb-infoleak in __kmalloc
2020-08-11 09:58:05 +02:00
Ioana-Ruxandra Stăncioi
d3694ffbb1 sys/linux: add tca_flower_key_mpls_opts descritpion
mpls_opts:
https://elixir.bootlin.com/linux/v5.8-rc4/source/net/sched/cls_flower.c#L670
mpls_opts_lse:
https://elixir.bootlin.com/linux/v5.8-rc4/source/net/sched/cls_flower.c#L731
2020-08-10 17:55:15 +02:00
Dmitry Vyukov
83223b4c46 pkg/csource: add description of the generation process 2020-08-10 15:32:40 +02:00
zizizi
7adc7b652a sys/linux: fix make extract on latest linux-next
VIRTIO_F_IOMMU_PLATFORM was renamed to VIRTIO_F_ACCESS_PLATFORM
2020-08-10 12:06:25 +02:00
zizizi
140970f4be CONTRIBUTORS: add Matthew Halchyshak 2020-08-10 12:06:25 +02:00
Alexander Egorenkov
70301872e1 syz-manager/cover: support compiler triple for readelf 2020-08-09 14:58:49 +02:00
Albert van der Linde
f721e4a097 sys/linux: add missing flags to rtnexthop 2020-08-08 14:12:06 +02:00
Albert van der Linde
cb9c120a74 sys/linux: add descriptions for RTM_(NEW|DEL|GET)NEXTHOP
https://elixir.bootlin.com/linux/v5.8-rc4/source/net/ipv4/nexthop.c#L1961
2020-08-08 14:12:06 +02:00
Mark Johnston
01975a06cb executor: always ignore SIGBUS on FreeBSD
syz-executor uses a heuristic to help fail closed if an invalid access
might corrupt the output region.  This heuristic fails on FreeBSD, where
SIGBUS is delievered with si_addr equal to address of the faulting
instruction, rather than 0 when the fault address cannot be determined
(e.g., an amd64 protection fault).  Always handle SIGBUS quietly on
FreeBSD.

This fixes pkg/runtest tests for sys/test/test/nonfailing.
2020-08-08 11:09:48 +02:00
Mark Johnston
594e57536f pkg/runtest: disable 32-bit tests on FreeBSD for now
FreeBSD requires a non-default SYZ_DATA_OFFSET on 32-bit targets.
2020-08-08 11:09:48 +02:00
Mark Johnston
6ba54cf64e executor: use MAP_EXCL to map the data region on FreeBSD
We've had some problems where the default SYZ_DATA_OFFSET collides with
a mapping created by the C runtime.  MAP_EXCL ensures that mmap() will
fail in this case, so such problems become a bit easier to diagnose.
2020-08-08 11:09:48 +02:00
Dmitry Vyukov
ff51e5229e tools/syz-hubtool: fix up drain mode
We may want to drain hub without uploading any repros/corpus.
2020-08-07 18:39:45 +02:00
Dmitry Vyukov
bb468f3218 tools/syz-hubtool: add initial version
syz-hubtool uploads local reproducers to syz-hub.
2020-08-07 17:27:03 +02:00
Cheng-Min Chiang
28ac5c9e93 sys/linux/test: fix io_uring test
Fix the io_uring test by adding some blank lines after comments. This
commit changes nothing beside that.
2020-08-07 09:44:43 +02:00
Dmitry Vyukov
8115b1e225 dashboard/config: enable BPF LSM 2020-08-07 09:28:35 +02:00
Cheng-Min Chiang
20a3465b97 sys/linux: add descriptions for BPF LSM
This commit includes the following changes:
* executor: add a new syz_btf_id_by_name psuedo-syscall
* sys/linux: add descriptions for BPF LSM subsystem
* sys/linux: add instructions on how to dump vmlinux and install
  bpftool
* sys/linux/test: add tests for the new psuedo-syscall
* pkg/host: add support detection for the new psuedo-syscall
* pkg/runtest: skip the coverage test when invoking the new
  psuedo-syscall

Update #533.
2020-08-07 09:28:26 +02:00
Dmitry Vyukov
cb436c69d9 executor: add some code style checks
Move the test from pkg/csource to executor/
in order to be able to (1) run it on *.cc files,
(2) run on unprocessed *.h files, (3) produce line numbers.
Add a check for missed space after //.
2020-08-06 15:27:41 +02:00
Dmitry Vyukov
56fe566546 dashboard/config: enable rcupdate.rcu_expedited
See https://bugzilla.kernel.org/show_bug.cgi?id=208299
and https://groups.google.com/forum/#!topic/kasan-dev/si9jMcgTr74
for context.
2020-08-06 15:23:05 +02:00
Anton Lindqvist
1f122f880f pkg/report: fix uvm_fault report detection on OpenBSD
Regression introduced in commit cb93dc6a ("pkg/report: flag short
uvm_fault reports as corrupted") causing some valid reports to be
flagged as corrupted.
2020-08-06 12:02:42 +02:00
Dmitry Vyukov
4ca1c0ea44 tools/check-commits.sh: use PR head instead of base
Base points to already commetted changes,
we really want to cheack head of the PR.
2020-08-06 11:49:45 +02:00
Marco Elver
f94b533a4b tools/check-commits: allow canonical 'git revert' format
Allow the canonical 'git revert' format.
2020-08-06 11:49:26 +02:00