376 Commits

Author SHA1 Message Date
Marco Vanotti
1b0aeaa4e8 Makefile: build fuchsia go binaries using the sdk
This commit removes a dependency on fuchsia's tools/devshell/contrib/go,
which was removed recently[0].

Now to build go binaries for fuchsia we are not relying on the
fuchsia.git repo at all. The code just needs a copy of the fuchsia
//third_party/go repository, the fuchsia sdk and a copy of clang.

Users should download the sdk and clang beforehand (see documentation
for links), and then run (with the correct environment variables):

```
$ make TARGETOS=fuchsia TARGETARCH=amd64 \
    SOURCEDIR=$HOME/fuchsia \
    FX_SDK_PATH=${HOME}/sdk/fuchsia-sdk \
    CLANG_PATH=${HOME}/sdk/clang \
    fuchsia_go
```

After that, they will be able to build the syzkaller go binaries by
doing:

```
$ make TARGETOS=fuchsia TARGETARCH=amd64 \
    SOURCEDIR=$HOME/fuchsia \
    FX_SDK_PATH=${HOME}/sdk/fuchsia-sdk \
    CLANG_PATH=${HOME}/sdk/clang
```

This commits adds two scripts to tools/fuchsia, one for building go in
fuchsia (just calls the ./make.all script in fuchsia's go repo), and one
that replaces the devshell/contrib/go script.

Given that go is unsupported in fuchsia, this change might break at any
point.

[0]: https://fuchsia-review.googlesource.com/c/fuchsia/+/291631
2019-07-23 08:44:20 +02:00
Andrey Konovalov
55e0c07757
sys/linux: extract USB HID ids (#1294)
* sys/linux: extract USB HID ids

As it turns out the HID kernel subsystem registers only one USB driver that
checks that the interface of the connected device has HID class and then looks
up its own list of vendor/device ids to find a matching driver. This means
that we currently don't generate proper vendor/device ids for USB HID devices.

This patch updates the syz-usbgen tool to also extract USB HID vendor/device
ids from a running kernel and makes the generated descriptions for HID devices
to be patched using the extracted ids.

This patch also contains some minor improvements to USB descriptions
(better HID descriptions and more replies for some USB classes/drivers).

* sys/linux: run make generate
2019-07-22 19:25:54 +02:00
Greg Steuck
b3c615f51b tools/syz-execprog: remove unused parameter 2019-07-22 07:37:09 +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
06616a2715 tools/syz-cover: skip empty lines in coverage file
If it's constructed manually, it's easy to add an empty line at the end.
2019-07-18 09:36:03 +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
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
Dmitry Vyukov
1dcdf7ef37 tools/syz-stress: fix syscall list parsing
If -syscalls flag is empty (default),
strings.Split produces an empty string which
is then not parsed as valid syscall name.
2019-06-14 12:19:25 +02:00
Andrew Turner
ea2f400664 tools/kcovtrace: Fix the format of kcovtrace.c 2019-06-11 15:25:32 +02:00
Andrew Turner
28a6eb7203 tools/kcovtrace: Fix cover type on FreeBSD and NetBSD
It should be uint64_t as a 32 bit tool may be tracing a 64 bit kernel.
2019-06-11 12:31:30 +02:00
Andrey Konovalov
142ce68175 pkg/runtest: add simple USB runtest 2019-05-31 13:35:25 +02:00
R3x
9809825e48 make changes to prevent failing build 2019-05-21 13:56:38 +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
Greg Steuck
051c49fe0d
tools/create-openbsd: valid URIs must use a single slash (#1184)
Triggered by OpenBSD ftp upgrade which isn't looking kindly
at double slahses: https://marc.info/?t=155794126200001&r=1&w=2
2019-05-15 12:08:03 -07: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
92d5fb8ed3 tools/syz-bisect: add usage docs 2019-05-13 13:04:01 +02: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
Greg Steuck
018207ef2f
tools/create-openbsd-vmm-worker.sh: set location to cd0 for consistency (and speed) (#1168) 2019-05-09 12:46:24 -07:00
Greg Steuck
a7aeccd44b
tools/create-openbsd-gce-ci.sh: explicitly specify sets location (#1167)
The previous default must have changed resulting in apparent failure
to install siteXX.tgz. The observable symptom was:
`Package installation failed. Inspect install_log.`
2019-05-09 10:40:00 -07: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
10e721ba92 sys: add USB descriptions
This commit adds syzkaller descriptions for USB fuzzing. The descriptions in
vusb.txt are written manually and cover different kinds of USB descriptors.
The descriptions in init_vusb_ids.go are generated automanitally by the
syz-usbgen tool and contain the vendor, device and some other IDs that
map to different USB drivers.
2019-04-11 16:24:45 +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
Dmitry Vyukov
0dfb045226 tools/syz-benchcmp: update name of coverage stat 2019-04-08 15:10:07 +02:00
Shankara Pailoor
acbc5b7d05 sys/linux: move openat to dev_rtc.txt
move openat$rtc to rtc_dev and change return type to fd_rtc
2019-03-24 09:28:43 +01:00
Dongliang Mu
a2cef203ff tools/syz-execprog: remove dead code 2019-03-23 09:54:12 +01:00
Dmitry Vyukov
93e723abbc tools/syz-testbuild: add utility for kernel build testing
syz-testbuild tests kernel build/boot on releases as it will be done by pkg/bisect.
This allows to ensure that, for example, a change to kernel config won't break
build/boot on older releases and consequently won't break bisection process.
The binary needs to run under root because it creates images.
The kernel checkout given to the tool will be cleaned and used for in-tree builds.
Example invocation:

sudo syz-testbuild -kernel_src $LINUX_CHECKOUT \
	-config dashboard/config/upstream-kasan.config \
	-sysctl dashboard/config/upstream.sysctl \
	-cmdline dashboard/config/upstream-apparmor.cmdline \
	-userspace $WHEEZY_USERSPACE \
	-bisect_bin $BISECT_BIN

A suitable wheezy userspace can be downloaded from:
https://storage.googleapis.com/syzkaller/wheezy.tar.gz
A set of binaries required for bisection (older compilers) can be downloaded from:
https://storage.googleapis.com/syzkaller/bisect_bin.tar.gz
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
Dongliang Mu
2881fc25a8 tools/create-image.sh: fix two issues
allow user to provide ADD_PACKAGE and double check if KERNEL is set when perf is enabled
2019-03-12 18:33:29 +01:00
Kees Cook
18215b8d64 create-image.sh: Fix "full" package list
The list of packages to install is comma-separated, not space. This
fixes the "-f full" argument to actually install the expected packages.
2019-03-06 18:44:30 +01:00
Andrey Konovalov
eb9e33b10f execprog: fix executing with fault injection
If the fault injection flags are not provided, but the log contains a
fault injection like this:

2017/08/12 17:16:04 executing program 5 (fault-call:4 fault-nth:5):

we fail to enable fault injection in ipc.Config. Fix it.
2019-03-05 16:05:02 +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
Greg Steuck
1c0e457aaa tools/*openbsd*: switch to 6.5 now that it's in -beta 2019-03-01 19:09:16 +01:00
Andrey Konovalov
68d9e495c3 check_links: ignore mailto:* links 2019-03-01 13:19:42 +01:00
Dongliang Mu
8a4b3a6b65 tweak create-image.sh script and modify document about its deployment (#1022) 2019-03-01 06:29:44 +01:00
Dongliang Mu
f6f233c07e tools/create-image.sh: make more flexible
The usage of current create-image.sh:

```
./create-image.sh -d=stretch -f=minimal --add-perf

The options are in the following:

-d, --distribution         Set on which debian distribution to create
-f, --feature              Check what packages to install in the image, options are minimal, full
-p, --add-perf             Add perf support with this option enabled

The default image is stretch with minimal feature, without perf.
2019-02-15 10:54:18 +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
be0e89ec44 tools/syz-stress: add flag to select subset of syscalls
Add -enable flag similar to syz-mutate flag.
The flag allows to select a subset of syscalls that will be tested
(e.g. -enable=open,read,write,close).
2019-02-12 18:34:25 +01:00
Greg Steuck
b4f792e401
tools/openbsd: use fully resolved gcc package name (#988) 2019-02-09 10:11:37 -08: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
25e10a0434 executor: remove ability to detect kernel bugs
This ability was never used but we maintain a bunch of code for it.
syzkaller also recently learned to spoof this error code
with some ptrace magic (probably intercepted control flow again
and exploited executor binary).
Drop all of it.
2019-01-31 11:35:53 +01:00
Dmitry Vyukov
fa3d6b0b21 Makefile: don't cross-compile executor if cross-compiler is missing
We started building netbsd executor on linux.
This fails on CI since cross-compiler is missing.
But we don't want to exclude netbsd from presubmit entirely.
So check if cross-compiler is missing and just produce a warning.
This should unbreak CI and humans will see the warning.
2019-01-24 11:28:55 +01:00
Shankara Pailoor
769e75ed8e tools/syz-trace2syz/proggen: add support to generate structs like sockaddr_storage_in6
trace2syz has trouble generating structs like sockaddr_storage_in6 which are
wrappers around other structs like sockaddr_in6 because strace just decodes the
wrapped struct (sockaddr_in6). This causes trace2syz to generate the addr field
of sockaddr_storage_in6 from the af_family field of sockaddr_in6 which triggers
an error. We now try and detect these cases and recursively generate the struct.
2019-01-17 13:44:43 +01:00
Andrey Konovalov
c2faf9b2d5 all: detect extra coverage support
Based on whether the kernel supports KCOV_REMOTE_ENABLE ioctl.
2019-01-16 19:19:53 +01:00
Andrey Konovalov
b5df78dc5d all: support extra coverage
Right now syzkaller only supports coverage collected from the threads that
execute syscalls. However some useful things happen in background threads,
and it would be nice to collect coverage from those threads as well.

This change adds extra coverage support to syzkaller. This coverage is not
associated with a particular syscall, but rather with the whole program.
Executor passes extra coverage over the same ipc mechanism to syz-fuzzer
with syscall number set to -1. syz-fuzzer then passes this coverage to
syz-manager with the call name "extra".

This change requires the following kcov patch:
https://github.com/xairy/linux/pull/2
2019-01-16 19:19:53 +01:00
Shankara Pailoor
505b1767d0 tools/syz-trace2syz/proggen: add support for open, openat, syz_open_dev variants
Add support to accurately select variants for open and openat system calls.
This is needed because in order to accurately select ioctl variants we need
to use device resource types. The device resource types can only be created
by syz_open_dev and openat variants.
2019-01-16 16:34:17 +01:00
Shankara Pailoor
31648909f9 tools/syz-trace2syz/proggen: deleting unnecessary code in genSockaddrStorage()
genSockaddrStorage() determines the correct sockaddr_storage union option when we
cannot identify the system call variant. We used to have custom logic per system
call which was not tested and is actually unnecessary. This patch deletes that
code and adds a test to make sure there are no regressions.
2019-01-14 17:47:18 +01:00
Michael Tuexen
95f1d718cf tools/kcovtrace: add FreeBSD support
KCOV support has been committed to FreeBSD in r342962. Therefore,
allow this program to be run on FreeBSD.
2019-01-14 09:50:07 +01:00
Shankara Pailoor
80dde1721e tools/syz-trace2syz/proggen.go: delete reorderStructFields()
strace incorrectly printed sin6_addr before sin6_flowinfo. To fix this,
trace2syz added reorderStructFields() which swapped back the order. Incorrect
orderings of structs is a bug in strace or in our descriptions so we should
fix the source rather than work around. We have submitted a patch to fix the
sockaddr_in6 decoding in strace so we can safely delete this function.
2019-01-10 17:24:09 +01:00
Shankara Pailoor
db9b657915 tools/syz-trace2syz/proggen/proggen_test.go: test ipv6 address conversion 2019-01-10 12:34:28 +01:00
Shankara Pailoor
f9ccea26eb tools/syz-trace2syz/proggen: convert strace byte arrays to int args
strace decodes certain arguments like sockaddr_in.sin_port or sin_addr
as hex strings under -Xraw. This is because the arguments are in network byte
order. This patch supports converting those hex strings to int args if the size
of the string is 1, 2, 4, or 8.
2019-01-10 12:34:28 +01:00