Commit Graph

194 Commits

Author SHA1 Message Date
Tobias Klauser
d88894e677 Makefile: set GO111MODULE=off for go get in install_prerequisites
Otherwise the versions in go.mod are updated on running `make
install_prerequisites` leading to inconsistent vendoring errors:

go: inconsistent vendoring in /go/src/github.com/google/syzkaller:
	golang.org/x/net@v0.0.0-20200625001655-4c5254603344: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
	golang.org/x/tools@v0.0.0-20200717024301-6ddee64345a6: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
	golang.org/x/net@v0.0.0-20200520182314-0ba52f642ac2: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
	golang.org/x/tools@v0.0.0-20200626171337-aa94e735be7f: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2020-07-20 17:03:33 +02:00
Dmitry Vyukov
54b3c45e28 Makefile: test executor build with clang
To get more compiler coverage and to not let it rot.
clang get detect more bugs statically.
2020-07-16 17:56:13 +02:00
Dmitry Vyukov
5369f4cbc6 Makefile: simplify arch build tests
There is not much value in the current 2 levels of indirections.
2020-07-16 17:56:13 +02:00
Greg Steuck
4272335555 Makefile: avoid non-portable realpath
pwd -P works great and is portable.
This fixes OpenBSD ci.
2020-07-07 07:28:07 +02:00
Dmitry Vyukov
c992206a1d tools/syz-linter: add custom linter
For now we have 2 simple checks:

1. for multiline comments:
/* */ -> //

2. for string len comparison with 0:
len(str) != 0 -> str != ""

Update #1876
2020-07-04 15:05:30 +02:00
Dmitry Vyukov
74cb4e09a5 go.mod: add go-fuzz-build
Otherwise go-fuzz-build now fails with:

+ go-fuzz-build -libfuzzer -func FuzzDeserialize -o fuzzer.a ./prog/test
-: cannot find package "." in:
	/syzkaller/gopath/src/github.com/google/syzkaller/vendor/github.com/dvyukov/go-fuzz/go-fuzz-dep
2020-07-04 15:05:30 +02:00
Dmitry Vyukov
c7d7f10bdf go.mod: vendor golangci-lint 2020-07-04 15:05:30 +02:00
Tobias Klauser
6050b932e6 Makefile: add support for linux/riscv64
Install g++-riscv64-linux-gnu in install_prerequisites target and hook
up arch_linux_riscv64_target.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2020-06-26 16:41:30 +02:00
Alexander Egorenkov
aea82c003a sys/linux: first 64bit big-endian architecture s390x
* mmap syscall is special on Linux s390x because
  the parameters for this syscall are passed as a struct
  on user stack instead of registers.
* Introduce the SyscallTrampolines table into targets.Target
  to address the above problem.
* There is a bug in Linux kernel s390x which causes QEMU TCG
  to hang when KASAN is enabled. The bug has been fixed
  in the forthcoming Linux 5.8 version. Until then do not enable
  KASAN when using QEMU TCG, QEMU KVM shall have no problems with
  KASAN.

Signed-off-by: Alexander Egorenkov <Alexander.Egorenkov@ibm.com>
2020-06-25 23:08:45 +02:00
Jukka Kaartinen
1afe15356a tools/syz-reporter: Tool to share/visualize crashes
Goes through crash folder that is stated in the workdir.
Collects the crashes, counts and tags.

usage:
 ./bin/syz-reporter -config manager.cfg

Signed-off-by: Jukka Kaartinen <jukka.kaartinen@unikie.com>
2020-06-22 15:10:31 +02:00
Dmitry Vyukov
9d10abe406 Makefile: don't reset jobserver
Re-exporting -j resets make jobserver. Don't do that.
Only export -j in top level make invocation.
2020-06-19 11:56:47 +02:00
Dmitry Vyukov
f7a1d89892 Makefile: cosmetic fixes
1. Use --no-print-directory.
These "Entering directory"/"Leaving directory" messages are completely useless.

2. Use go build instead of go install.
This is just to test build and we don't install anything otherwise.
Don't mess with GOAPTH/bin unnecessarily.

3. Don't export MAKEFLAGS.
It is exported by default.

4. Suppress descriptions up-to-date check output.
It's cryptic and is not particularly useful.
2020-06-19 11:56:47 +02:00
Jukka Kaartinen
f56b572638 tools/syz-crush: Add feature to run C-program
usage:
  syz-crush -config=config.json creprog.c

Produced output is same as syz-manager produces.
New directory called reproduced_with is added that lists all the
reproducers that triggered the crash.

Example:

~/workdir/crashes  $ tree
.
├── 2a8fff76c6267ecfeaf3530a602ed48afbc4a151
│   ├── description
│   ├── log0
│   ├── log1
│   ├── log2
│   ├── report0
│   ├── report1
│   ├── report2
│   └── reproduced_with
│       └── 17a6ed226769660f3e5dad7b22b13466b938e290.c
├── 2b6b921457afe8cebd0a96ca40f8569e6ee95174
│   ├── description
│   ├── log0
│   ├── log1
│   ├── log2
│   ├── log3
│   ├── log4
│   ├── log5
│   ├── report0
│   ├── report1
│   ├── report2
│   ├── report3
│   ├── report4
│   ├── report5
│   └── reproduced_with
│       ├── 9fb2f5b37bf4428382334e336bbbb201634c7c4c.c
│       └── ab27002b46d19cafb1ebb8b040f0a3b0f8f88974.c

Signed-off-by: Jukka Kaartinen <jukka.kaartinen@unikie.com>
2020-06-15 18:41:13 +02:00
Dmitry Vyukov
588020678f all: use more respective language
Some terms are normalised on the technical level
but may be oppressive on a societal level.
Replace them with more technically neutral terms.
See the following doc for a longer version:
https://tools.ietf.org/id/draft-knodel-terminology-00.html
2020-06-11 23:19:34 +02:00
Dmitry Vyukov
52fd7b7d77 tools: add syz-big-env
On top of syz-env it provides akaros/fuchsia/netbsd toolchains and gcloud sdk.
With this it's possible to run dashboard/app tests on CI and locally
and test executor build and pkg/{csource,cover} for these OSes.

Update #1765
2020-06-02 13:39:30 +02:00
Dmitry Vyukov
24d9114275 .github/workflows: add CI workflow
Switch from Travis to Github Actions for testing.
This is faster and is better integrated with github.

Update #1699
2020-05-18 11:34:42 +02:00
Dmitry Vyukov
37137150cb tools: add syz-env
syz-env provides a canned dev environment with all tools necessary
(Go, gcc, clang-format, etc) for development/testing in a form
of a Docker image. Example use:

$ syz-env make presubmit
$ syz-env make extract SOURCEDIR=~/linux

Update #1699
2020-05-18 11:34:42 +02:00
Dmitry Vyukov
70100a5440 Makefile: fix generate target
descriptions target needs to be executed before generate_go,
because the latter builds Go code which won't build without descriptions.
2020-05-18 11:34:42 +02:00
Dmitry Vyukov
4836c13c61 tools/syz-make: rename from syz-env
syz-env will be a good, short name for the planned
docker-ized build environment. So rename syz-env to syz-make.
Maybe not the best name, but it's not visible basically anywhere.
2020-05-18 11:34:42 +02:00
Dmitry Vyukov
2d4efabd02 Makefile: print errors in standard format
Use the standard "file:line:col: error message" format.

Update #1699
2020-05-18 11:34:42 +02:00
Alexander Potapenko
d7f9fffab3 targets: syz-extract: add Clang support for Linux builds
Allow targets.go use Clang instead of the default Linux compiler by
setting the SYZ_CLANG=1 env var. Doing so changes the compiler to
"clang" and the linker to "ld.ldd", assuming they are in $PATH, and adds
the --target and -ferror-limit CFLAGS.

Target also exports KernelCompiler and KernelLinker fields now, which allows
overriding the compiler and linker in the kernel make invocation.

Signed-off-by: Alexander Potapenko <glider@google.com>
2020-05-15 14:08:01 +02:00
Dmitry Vyukov
1e61c8bc14 Makefile: add target for syz-symbolize 2020-05-13 20:48:47 +02:00
Dmitry Vyukov
9a6d42fb40 Makefile: fix check_links
1. Disable pager.
2. Actually fail.
2020-05-13 11:42:59 +02:00
Dmitry Vyukov
6c70a1c220 all: replace TRAVIS env var with CI
In preparation to running some tests as github actions.
Both Travis and Github define CI env var, while TRAVIS is, well,
too Travis-specific.

Update #1699
2020-05-07 15:41:50 +02:00
Dmitry Vyukov
5395017f67 Makefile: print what files are not formatted
Move this part from .travis.yml to Makefile.
It's useful to see it always and we generally
don't have lots of logic in the travis file.
Also move list of changed files to the bottom
(that's what one generally sees at console
and at the end of the log).
2020-05-06 14:17:35 +02:00
Dmitry Vyukov
5457883a51 tools/codecov.yml: add
Add configuratio file for codecov.io
2020-05-02 14:12:25 +02:00
Dmitry Vyukov
43dc635b4f Makefile: reduce presubmit size
Run fewer builds in presubmit. Also run them sequentially instead of parallel.
The current presubmit OOMs on CI every other time, this is not useful.

Update #1699
2020-05-01 13:31:17 +02:00
Dmitry Vyukov
a73c1fd952 Makefile: fix use of PWD
PWD in Makefile points to the dir from where make is invoked,
not the Makefile dir. Moreover, PWD may be overriden in shell.
Use "realpath ." instead.
2020-05-01 07:08:01 +02:00
Dmitry Vyukov
ec42220e77 Makefile: generate descriptions on-the-fly
Checking in the generated descriptions files makes few things simpler,
but causes pain for pull requests: (1) PRs that touch descriptions
_always_ conflict, (2) PRs are large and harder to review,
(3) people sometimes forget to add auto-generated files.

The proposed way does not require us to hardcode lots of dependencies
in the Makefile (which is nice) and seem to work.
Let's see how it works.

The main contributor-visible consequence is that the auto-generated
files do not need to be checked-in now.

Credit for figuring the Makefile magic goes to @melver.

Fixes #1291
2020-04-30 17:18:29 +02:00
Dmitry Vyukov
3b93a8e003 sys/targets: better detection for missing/broken cross-compilers
1. Detect when compiler is present, but is not functioning
(can't build a simple program, common for Linux distros).

2. Be more strict with skipping tests due to missing/broken compilers on CI
(on CI they should work, so fail loudly if not).

3. Dedup this logic across syz-env and pkg/csource tests.

4. Add better error reporting for syz-env.

Fixes #1606
2020-04-29 16:32:33 +02:00
Greg Steuck
32c0bff1a8 Makefile: pin golangci-lint version
Used the recipe from https://github.com/golangci/golangci-lint
2020-04-26 04:42:23 +02:00
Dmitry Vyukov
9b95008878 Makefile: don't do go install
We did it for caching purposes, but now
(1) go command caches everything anyway,
(2) we use custom tags and flags, so result
    of go install is not reused anyway.
2020-04-18 14:36:05 +02:00
Dmitry Vyukov
e7caca8e1e executor: minor cleanup of android sandbox
Fix code formatting, clang-tidy warnings, minor style nits.
2020-03-11 12:09:17 +01:00
Dmitry Vyukov
b6ed147834 prog: dump orig prog if Deserialize panics
We are seeing some one-off panics during Deserialization
and it's unclear if it's machine memory corrpution or
an actual bug in prog. I leam towards machine memory corruption
but it's impossible to prove without seeing the orig program.

Move git revision to prog and it's more base package
(sys can import prog, prog can't import sys).
2020-02-21 10:22:07 +01:00
Dmitry Vyukov
135c18aadb tools: add script that checks copyright headers
Fixes #1604
2020-02-18 16:05:10 +01:00
Dmitry Vyukov
f83f92fd5e tools/syz-check: inject description compilation warnings
Currently we print them as part of `make genereate`,
but nobody reads them, too much output each time.
Don't print them in `make generate` and instead
print in syz-check, the warn files are a good mechanism
to handle "known warnings".
2019-12-20 16:45:34 +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
d20ee9bd98 tools: add fops_probe utility
fops_probe utility helps to understand what file_operations callbacks
are attached to a particular file. Requries KCOV and KALLSYMS.
Build with:
	g++ tools/fops_probe/fops_probe.cc -Wall -static -o fops_probe
Then copy the binary to target machine and run as:
	./fops_probe /dev/fb0
You should see output similar to:

	ffffffff81bcccb9 vfs_read
	................
	ffffffff83af85c3 fb_read
	ffffffff83b52af5 cirrusfb_sync

	ffffffff81bcd219 vfs_write
	................
	ffffffff83af7fe2 fb_write
	ffffffff83b52af5 cirrusfb_sync

	ffffffff81c1b745 do_vfs_ioctl
	ffffffff83af7ea9 fb_ioctl

	ffffffff81a4ea44 do_mmap
	................
	ffffffff83af716c fb_mmap

which allows to understand what callbacks are associated with /dev/fb0.
2019-12-03 18:48:14 +01:00
Matthew Dempsky
f4b7ed0781 tools/fuchsia: remove custom Go toolchain scripts
These used to be required to build Fuchsia's Go toolchain to build
syz-fuzzer to run on Fuchsia. However, Fuchsia now uses HostFuzzer
mode, so only syz-executor (written in C) needs to run on Fuchsia; all
Go code runs on the Host OS (currently Linux).
2019-11-19 17:20:14 -08:00
Dmitry Vyukov
426631ddb4 Makefile: support overriding CGO_ENABLED
We generally want CGO_ENABLED=0, but cgo is required for odroid.
This change makes the following work:

make manager CGO_ENABLED=1 GOTAGS=odroid
2019-10-11 17:28:37 +02:00
Andrey Konovalov
2b854f96b1 tools: add syz-expand
The syz-expand tools allows to parse a program and print it including all
the default values. This is mainly useful for debugging, like doing manual
program modifications while trying to come up with a reproducer for some
particular kernel behavior.
2019-09-23 17:13:23 +02: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
Dmitry Vyukov
efe659d763 travis: add fuzzit.dev support
Based on https://github.com/fuzzitdev/example-go
Let's see if it works...
2019-07-30 14:13:44 +02:00
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
Denis Efremov
0a8d1a965a travis: use cache
* travis: cache clang-format installation

* travis: indent

* travis: use user paths for caching

* travis: cache go build results

* travis: use system clang-format

* travis: remove custom libstdc++ installation

Fixes #1252
2019-06-25 13:55:46 +02:00
Andrew Turner
5457ef3463 sys/freebsd: Add support for fuzzing FreeBSD/i386
Add support to fuzz 32 bit FreeBSD system calls.
2019-05-29 14:28:59 +02:00
Dmitry Vyukov
22c391e195 Makefile: switch to golangci-lint
Finally!

Fixes #977
Fixes #1108
2019-05-15 11:39:31 +02:00
Dmitry Vyukov
a7383bfac1 Makefile: enable 386 executor build in presubmit
This hacky way to install 386 packages seems to unbreak executor build.
2019-05-07 18:01:24 +02:00
Dmitry Vyukov
04165d8f66 Makefile: enable arm executor build in presubmit
arm build seems to work now on Travis since we switched to xenial.
2019-05-07 18:01:24 +02:00
Dmitry Vyukov
51fc038380 .golangci.yml: update
Enable more linters.
Tune settings for existings.
Fix excludes.

Update #977
2019-04-23 17:58:54 +03:00