Commit Graph

410 Commits

Author SHA1 Message Date
Dmitry Vyukov
fa1f41078a tools/syz-trace2syz/proggen: comment blank import
golint suggests to comment all blank imports.
But actually we don't need whole sys, we can import only sys/linux.

Also rename target var to prevent name shadowing.
2018-12-08 08:59:52 +01:00
Dmitry Vyukov
b80cc86486 prog: rename ProgGen to Builder
golint suggests that "prog.Prog" is a bad naming
because everything in prog package is ProgSomething.
Rename to Builder, "prog.Builder" sounds right.
2018-12-08 08:40:03 +01:00
Dmitry Vyukov
65ed24721e tools/syz-trace2syz/proggen: reduce nesting depth in context.genResult 2018-12-07 14:32:44 +01:00
Dmitry Vyukov
c138f09215 tools/syz-trace2syz/proggen: remove currentStraceArg
It's used only by 2 functions: genSockaddrNetlink and genIfrIfru.
Majority of functions just accept the straceType as argument,
which looks like a much more appropriate way to pass an argument to a function.
Amusingly, both functions already accept and use the straceType as argument.
2018-12-07 14:28:12 +01:00
Dmitry Vyukov
276faf74b2 tools/syz-trace2syz/proggen: unexport and refactor Context
1. Unexport Context, it's not meant for callers.
2. Unexport all Context fields.
3. Make all function Context methods.
2018-12-07 14:23:58 +01:00
Dmitry Vyukov
c9f43ce698 tools/syz-trace2syz/proggen: tidy up shouldSkip 2018-12-07 14:08:56 +01:00
Dmitry Vyukov
4f39cef6c2 tools/syz-trace2syz/proggen: convert tests to table format
This has number of advantages:
1. Tests are readable and writable.
   The current checks [1] are neither.
2. Tests are much more compact.
3. Tests verify all aspects rather than just
   1 aspect of the resulting program.
4. Tests are much less fragile.
5. Any diffs in the results will be more clearly visible.

[1]
switch a := p.Calls[1].Args[0].(type) {
case *prog.ResultArg:
	if a.Res != p.Calls[0].Ret {

switch a := p.Calls[1].Args[0].(type) {
case *prog.ResultArg:
	pipeSecondFd := p.Calls[0].Args[0].(*prog.PointerArg).Res.(*prog.GroupArg).Inner[1]
	if a.Res != pipeSecondFd {

write := p.Calls[len(p.Calls)-2]
inotifyRmWatch := p.Calls[len(p.Calls)-1]
switch a := write.Args[0].Type().(type) {
case *prog.ResourceType:
	if a.TypeName != "fd" {
		t.Fatalf("expected first argument of write to have type fd, got: %s", a.TypeName)
	}
default:
	t.Fatalf("first argument of write is not resource type: %s", a.Name())
}
switch a := inotifyRmWatch.Args[1].(type) {
case *prog.ResultArg:
	b := a.Type().(*prog.ResourceType)
	if b.TypeName != "inotifydesc" {
		t.Fatalf("expected second argument of inotify_rm_watch to have type inoitfydesc, got: %s", b.TypeName)
	}
	if a.Res != p.Calls[2].Ret {
		t.Fatalf("inotify_rm_watch's second argument should match the result of inotify_add_watch.")
	}
}

sockaddr, ok := a.(*prog.PointerArg).Res.(*prog.GroupArg)
if !ok {
	t.Fatalf("%s", a.Type().Name())
}
ipv4Addr, ok := sockaddr.Inner[2].(*prog.UnionArg)
if !ok {
	t.Fatalf("expected 3rd argument to be unionArg, got %s", sockaddr.Inner[2].Type().Name())
}
optName := ipv4Addr.Option.Type().FieldName()
if !strings.Contains(optName, "rand") {
	t.Fatalf("expected ip option to be random opt, got: %s", optName)
}
ip, ok := ipv4Addr.Option.(*prog.ConstArg)
if !ok {
	t.Fatalf("ipv4Addr option is not IntType")
}
if ip.Val != expectedIp {
	t.Fatalf("parsed != expected, %d != %d", ip.Val, expectedIp)
}
2018-12-07 14:01:26 +01:00
Dmitry Vyukov
eada53b810 tools/syz-trace2syz/proggen: fix vma allocation
There are 2 bugs:
1. We always allocate 1 page, even if use more.
2. VMA addresses are not aligned, so most mmap-like functions fail with EINVAL.
The added test currently panics with "unaligned vma address".
2018-12-07 12:56:38 +01:00
Dmitry Vyukov
9e8a45fe27 tools/syz-trace2syz/proggen: replace memoryTracker with prog.memAlloc 2018-12-07 12:44:45 +01:00
Dmitry Vyukov
413e414738 tools/syz-trace2syz: add go-fuzz fuzzer
Inputs like "2__R" or "3_F	T.3.3l" make
traze2syz hang infinitely consuming all machine memory.
Need to fix all crashes over time.
2018-12-07 12:12:27 +01:00
Dmitry Vyukov
742f85bb22 tools/syz-trace2syz: start adding proper error handling
log.Fatal is not the proper way to handle errors.
It does not allow to write good tests, fuzzers
and utilities that crash all the time.
2018-12-07 12:05:43 +01:00
Dmitry Vyukov
8056889866 tools/syz-trace2syz/proggen: add ParseFile function
Current code structuring has 2 problems:

1. parsing anything with proggen requires complex multistep dance including
 - parsing data with parser
 - walking the resulting tree manually and calling proggen on each
 - then for each context
   - calling FillOutMemory (unclear why it's not part of parsing)
   - calling prog.Finalize
   - checking is the program is not too large
All of this duplicated across trace2syz and tests.
And any new tests or fuzzers we will write will need to duplicate
all of this logic too.

2. As the result of this structuring, lots of proggen guts
and implementation details are exposed.
While none of the callers are actually intersted in Context details,
they are not interested in Context itself whatsoever.

What every caller wants is "here is data to parse, give me programs".
Add such function.
2018-12-07 11:30:13 +01:00
Dmitry Vyukov
840b5cc058 tools/syz-trace2syz/parser: remove Filename from TraceTree
We already printed file name of the trace in parseTraces,
no need to print it again and again.
Consequently we don't need Filename in TraceTree.
If needed, caller can always log it before parsing,
or pass along with the TraceTree.
2018-12-07 10:43:27 +01:00
Dmitry Vyukov
5cdc1f5f6d tools/syz-trace2syz: use short variable declaration syntax
Use short variable declaration syntax where possible.
Move declarations closer to usages.
2018-12-07 10:35:42 +01:00
Dmitry Vyukov
ae17c862c9 tools/syz-trace2syz/parser: use []byte instead of string for file contents
If we are handling whole files, it's more efficient to use []byte.
string is not really meant to hold large amounts of data.
2018-12-07 10:24:24 +01:00
Shankara Pailoor
1eb6a7e433 tools/syz-trace2syz: adding missing copyright headers
Adding missing copyright headers to return_cache.go and context.go
2018-12-07 09:50:45 +01:00
Greg Steuck
dcf836b12d tools/syz-trace2syz/proggen/return_cache.go: format string mismatch 2018-12-06 20:33:02 +01:00
Dmitry Vyukov
ab4b148b34 prog: add Prog.Finalize
Prog.Finalize combines assignSizesCall, SanitizeCall and validate.
Intended for users who build own programs,
so that we don't need to expose all individual methods.
2018-12-06 18:56:08 +01:00
Dmitry Vyukov
ceaec61a83 prog: export Type.DefaultArg
It's effectively exported anyway.
So export it the proper way.
2018-12-06 18:55:46 +01:00
Dmitry Vyukov
f40330afce tools/syz-trace2syz: skip 2 more syscalls
These set_robust_list and set_tid_address are issued by glibc
for every process/thread start.
Normal programs don't use them and it's unlikely we build
something interesting with them (e.g. we won't get real robust list in memory).
Skip them.
2018-12-06 17:33:05 +01:00
Dmitry Vyukov
df8657a90f tools/syz-trace2syz: tidy up code
Lots of assorted changes mainly converting code to idiomatic Go
and replacing code with equivalent, but shorter code.
2018-12-06 17:28:09 +01:00
Dmitry Vyukov
c1641491e4 pkg/db: provide helper function for database creation
This is needed for both tools/syz-db and tools/syz-trace2syz.
Also, remove code to resolve SHA1 collisions.
Also, don't set db version as we actually want to minimize
and smash these programs like anything else
(not minimizing nor smashing them is only useful during tool testing).
2018-12-06 16:49:37 +01:00
Dmitry Vyukov
d68400a8d1 tools/syz-trace2syz: merge config package into proggen
Since we now have only single variable there,
it does not seem to deserve a separate package.
2018-12-06 16:30:14 +01:00
shankarapailoor
6a60a19530 tools/syz-trace2syz: add tool to convert strace output to programs
* fixing weird merge error

* fixing presubmit

* fixing presubmit

* removing parsing code because of -Xraw option

* fix presubmit

* update

* deleting vma_call_handlers as we are currently skipping most vma calls. This simplifies memory_tracker as we don't need to keep track of vma allocations

* removing custom handling of bpf_instruction union

* removing ifconf parsing

* update

* removed all expression types and replaced them with constant types. removing ipv6_addr parsing while -Xraw is getting fixed. Removing constants.go

* removing ipv6 parsing

* presubmit

* moving direction check from ipv4_addr out to genUnion

* removing code that parses kcov

* removing redundant test

* removing custom code in generate unions to fill ipv4_addr

* proggen: changing order of imports to make external packages import first

fixing presubmit

* changing log messages to lower case to be consistent with other packages.

* removing pointer type and simplifying memory_tracker

removing comment

* moving context and return_cache to seaparate files

* deleting default argument generation when we should probably throw an error
2018-12-06 16:25:37 +01:00
Greg Steuck
49e1764c75 tools/create-openbsd-vmm-worker.sh: shut off pagination in ddb 2018-12-04 08:55:04 +00:00
Greg Steuck
e0d8c853f6 tools: set openbsd hostname to instance name for serviceability
* openbsd images: set hostname to instance name for serviceability

* openbsd startup scripts insist on EOL characters
2018-12-02 09:53:06 +00:00
Greg Steuck
4b6d14f266 tools/create-openbsd-gce-ci.sh: simplification due to workers on GCE 2018-11-27 13:16:46 +01:00
Greg Steuck
6419afbb77 openbsd: run on gce
* build/openbsd: minor cleanup (use tuples instead of maps)

* Grammar nits in comments.

* Simplify openbsd.Create, will defer when there's more than one error exit.

* pkg/build: Support copying kernel into GCE image

* Simple test for openbsd image copy build.

* Cleanup in case something failed before.

* Support multi-processor VMs on GCE.

* More debug

* Reformat

* OpenBSD gce image needs to be raw.

* GC

* Force format to GNU directly on Go 1.10 or newer.

* Use vmType passed as a parameter inside openbsd.go

* gofmt

* more fmt

* Can't use GENERIC.mp just yet.

* capitalize

* Copyright
2018-11-27 13:14:06 +01:00
Andrey Konovalov
2b0dc848a0 ipc: fix ProgInfo usage better
Fix a bad fix for ProgInfo usage.
2018-11-23 07:17:29 +01:00
Andrey Konovalov
87815d9d32 ipc: fix ProgInfo usage
We used to use len([]CallInfo) to check both, whether the slice is nil or
whether its length is zero. Since ProgInfo is not a slice, we need a
separate check for nil.
2018-11-22 19:30:04 +01:00
Andrey Konovalov
582e1f0d1d ipc: add ProgInfo struct
This patch add a new struct ProgInfo that for now holds info about each
call in a program []CallInfo, but in the future will be expanded with remote
coverage info. Update all the callers to use the new interface as well.
2018-11-22 13:49:50 +01:00
Greg Steuck
16ba540df4 Review 2018-11-21 07:27:04 +01:00
Greg Steuck
5cdd8fe0e0 syz-repro: minor UX improvements. 2018-11-21 07:27:04 +01:00
Dmitry Vyukov
adf636a83b tools/syz-fmt: allow to reformat all OSes at once
We forgot trusty in Makefile.
Fix this once and for all by formatting all known targets.
2018-11-17 11:46:48 -08:00
Dmitry Vyukov
d1a8851085 sys/targest: introduce target.BuildOS
We can't cross-compile native binaries from just any OS to any other.
For most OSes we can do only native compilation.
Some can only be compiled from linux.
To date we avoided this problem completely (mostly assumed linux build OS).
Make this notion of what can build what explicit.
2018-11-17 11:42:22 -08:00
Anton Lindqvist
1508cc9c44 pkg/csource: add support for creating reproducers on OpenBSD 2018-11-17 10:32:19 -08:00
Dmitry Vyukov
4744d8ccac pkg/report: fix guilty file extraction
reportPrefixLen can become wrong after symbolization
if we symbolize any lines in the prefix.
Adjust reportPrefixLen during symbolization.

Automatic testing of this is problematic
because we would need to symbolize which requires
the object file with debug info.
Tested manually with syz-symbolize.
2018-10-28 19:07:22 +01:00
Greg Steuck
24808096ca tools/create-openbsd*sh: use cdn.openbsd.org not cloudflare, install vmm-firmware
* Use cdn.openbsd.org not cloudflare. Install vmm-firmware explicitly.

* Use cdn.openbsd.org not cloudflare. Install vmm-firmware explicitly.

* set hw.smt=1: the underlying hw on VM is unknown so don't waste SMT.
2018-10-28 10:18:59 +01:00
Dmitry Vyukov
8cd30605ce tools/create-gce-image.sh: create ext4 image without journalling
We don't need consistent image after reboot since we always reimage.
We know of some use cases that don't use journalling, but don't know
of any that use journalling.
2018-10-15 18:56:55 +02:00
Zach Riggle
caf1290068 Android: Add simple test harness for Sandbox 2018-10-12 16:39:26 +02:00
Greg Steuck
42c78641f5 tools/create-openbsd*: Support post-version flip snapshots.
* Fixed pkg_add status checking
  * Switched to qcow2 test image
  * Minor GC
2018-10-11 19:44:34 +02:00
Dmitry Vyukov
fefd83bf0b tools/syz-execprog: show host features
syz-execprog -output is handy way to check what features host.Check detects.
2018-10-10 15:36:57 +02:00
Greg Steuck
0b624c8069 tools/create-openbsd-*: fully functional images from scratch
* tools/create-openbsd-gce-ci: use config from /syzkaller

* Use syzkaller copy of src instead of a separate one.

* Using /dev/null disk in vm.conf

* Use KVM, enable doas, no longer symlink.

* Use a dummmy.img

* Revert "Use a dummmy.img"

This reverts commit 656b24d5e4573dde5e95c6158852001c7241e65a.
2018-09-28 11:13:51 +02:00
Dmitry Vyukov
8899d58437 tools/create-gce-image.sh: mount securityfs and configfs 2018-09-26 14:06:11 +02:00
Greg Steuck
455b6354e8 tools/create-openbsd-gce-ci auto-start syz-ci, redirect 8080 to 80 2018-09-26 09:41:21 +02:00
Greg Steuck
370797126e tools/create-openbsd-gce-ci.sh mount 10G ramdisk for worker images 2018-09-20 20:46:45 +02:00
Greg Steuck
b117b6ed3d tools/*openbsd*: smaller VMM images and tweaks. 2018-09-20 11:03:43 +02:00
Greg Steuck
7f125108ae More packages and fewer daemons. 2018-09-17 09:44:01 +02:00
Greg Steuck
68def56dce tools/create-openbsd-gce-ci.sh: Add VMM configuration.
Added verification of successful package install.
2018-09-17 09:44:01 +02:00
Greg Steuck
8c88323f94 tools/create-openbsd-gce-ci.sh: image for build machine
Mostly derived from Go buildlet generator with blessing from bradfitz@.

Update #712
2018-09-10 18:28:00 +02:00
Dmitry Vyukov
58f18e3f60 tools/create-gce-image.sh: disable ftrace_dump_on_oops
We don't have anything useful there.
But sometimes fuzzer somehow poppulates it with some nonsense,
and then it all dumped in crashes.
Disable it.
2018-09-10 16:19:40 +02:00
Dmitry Vyukov
6b5120a464 tools/create-gce-image.sh: auto-detect block device type
Currently we choose block device to use (nbd/loop) based on SYZ_VM_TYPE.
Strictly saying these things are orthogonal.
losetup is broken on Ubuntu. qemu-nbd is broken on Debian.
Try to auto-detect what will work based on uname.
2018-09-07 19:04:47 +02:00
Kees Cook
873745f2ff tools: update to Debian stretch
This updates the image creation tool to use Debian stretch (current stable)
instead of wheezy, which is very out of date. The only change needed here
was a hint to systemd to make the root filesystem read-write after booting.
Documentation has also been updated.
2018-09-05 19:26:06 +02:00
Dmitry Vyukov
196410e4f5 dashboard/config: re-enable selinux
Upstream "selinux: fix mounting of cgroup2 under older policies"
commit fixes mounting of cgroup2 under wheezy selinux policy.
So don't disable selinux on start.
Create separate cmdline arguments that enable selinux and apparmor.
2018-09-05 12:50:53 +02:00
Dmitry Vyukov
98bfd6d34c tools/create-gce-image.sh: add default ext4 options
Set some realistic modern ext4 options when creating the image.
2018-09-03 16:42:59 +02:00
Dmitry Vyukov
3653592507 pkg/runtest: assorted improvements
Support checking "blocked"/"unfinished" flags for calls.
Support test constanints, e.g. "requires: threaded" or "requires: -sandbox=setuid".
Some improvements in tools/syz-runtest.

Update #603
2018-08-08 15:05:01 +02:00
Dmitry Vyukov
4207dbaa99 tools/syz-execprog: print blocked/unfinished/faulted flags for calls 2018-08-08 15:03:31 +02:00
Dmitry Vyukov
2763e04c22 tools/syz-runtest: add tool for program unit testing
The tool is run as:

$ syz-runtest -config manager.config

This runs all programs from sys/*/test/* in different modes
on actual VMs and checks results.

Fixes #603
2018-08-03 21:08:02 +02:00
Dmitry Vyukov
6bfd4f09db pkg/ipc: move flags into subpackage
Move all ipc flags into pkg/ipc/ipcconfig package
so that importing pkg/ipc does pull in the flags.
2018-08-03 18:12:24 +02:00
Dmitry Vyukov
fbedd425b5 pkg/mgrconfig: move from syz-manager/mgrconfig
mgrconfig was used only by syz-manager initially,
but now it's used by a dozen of packages and it's
weird to import from under a binary dir.
pkg/ is much more reasonable dir for a widely used
helper package.
2018-08-02 16:57:32 +02:00
Dmitry Vyukov
531d157044 tools/syz-execprog: refactor
Reduce cyclomatic complexity of the main function.
It's too huge.

Update #538
2018-07-31 16:05:03 +02:00
Dmitry Vyukov
f5d67fbd9c .gometalinter.json: enable gofmt
The part that we want from gofmt is simplify (-s).
Fix all code that needs fixing.

Update #538
2018-07-31 12:16:54 +02:00
Dmitry Vyukov
b25fc7b831 pkg/csource: add option to trace syscall results
This will be needed for testing of generated programs.
2018-07-27 10:22:23 +02:00
Dmitry Vyukov
c7725f52b1 syz-execprog: initialize net devices 2018-07-27 10:22:23 +02:00
Dmitry Vyukov
9fe4bdc5f1 executor: overhaul
Make as much code as possible shared between all OSes.
In particular main is now common across all OSes.
Make more code shared between executor and csource
(in particular, loop function and threaded execution logic).
Also make loop and threaded logic shared across all OSes.
Make more posix/unix code shared across OSes
(e.g. signal handling, pthread creation, etc).
Plus other changes along similar lines.
Also support test OS in executor (based on portable posix)
and add 4 arches that cover all execution modes
(fork server/no fork server, shmem/no shmem).

This change paves way for testing of executor code
and allows to preserve consistency across OSes and executor/csource.
2018-07-24 12:04:27 +02:00
Dmitry Vyukov
bad4246bf2 pkg/report: improve akaros reporter and implement symbolization 2018-07-16 17:03:14 +02:00
Dmitry Vyukov
92a4950507 pkg/host: add "network devices" feature
Linux executor sets up some network devices for testing,
detect when that's supported on the machine and don't
do it if it's not supported.
2018-07-13 12:46:32 +02:00
Dmitry Vyukov
0b95b8ec49 pkg/host: disable for akaros
akaros can't have own host version
because fuzzer does not run on akaros,
so just disable it all.
2018-07-06 20:18:05 +02:00
Dmitry Vyukov
04bd6c3d9e pkg/instance: pass -os to execprog/fuzzer only for akaros
Only akaros needs OS, because the rest assume host OS.
But speciying OS for all OSes breaks patch testing on syzbot
because old execprog does not have os flag.
2018-07-06 14:43:24 +02:00
Dmitry Vyukov
538df42ec7 pkg/repro: provide stats even for failed repro
Provide stats and logs for failed repro and save it in manager.
In particular log is useful for failed repros,
currently there is no visibility into why bugs
failed to reproduce.
2018-07-05 13:14:00 +02:00
Daniel Borkmann
3a35170a24 bpf: disable hardening in favor of unwinding
I had missed that once hardening is enabled, it automatically disables
any exposure of JITed addresses, therefore when crashes or warnings are
thrown we don't unwind beyond a helper function. For now disable hardening.

After merge window I'll see if it's possible to detangle the case where
kernel queries kallsyms internally to find function names whenever a WARN
or BUG is thrown. If that's not possible easily, we can potentially add a
harden mode 3 which does hardening but does not disable kallsyms exposure
and then set this here for tools like syzkaller.

Fixes: ac9b19d2e4 ("bpf: enable hardening mode 1 for jited images")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

[dvyukov: also updated dashboard/config/upstream.sysctl]
2018-07-05 10:48:20 +02:00
Dmitry Vyukov
bc1210b614 pkg/ipc: create default config based on target
Pass actual target to DefaultConfig, that's what we really want,
not the stray ipc flag.
2018-07-05 10:44:34 +02:00
Dmitry Vyukov
2c6c896b36 tools/syz-repro: add debug mode 2018-07-05 10:44:34 +02:00
Dmitry Vyukov
9dd8cf63e0 executor, pkg/ipc: support output over pipes 2018-06-29 16:33:07 +02:00
Dmitry Vyukov
a736f2e8e6 tools/syz-prog2c: allow to test build of the resulting program 2018-06-29 09:22:42 +02:00
Dmitry Vyukov
2a075d57ab pkg/report: allow to specify suppressions per OS
Currently all (linux-specific) suppressions are hardcoded in mgrconfig.
This is very wrong. Move them to pkg/report and allow to specify per OS.
Add gvisor-specific suppressions.
This required a bit of refactoring. Introduce mgrconfig.KernelObj finally.
Make report.NewReporter and vm.Create accept mgrconfig directly
instead of passing it as multiple scattered args.
Remove tools/syz-parse and it always did the same as tools/syz-symbolize.
Simplify global vars in syz-manager/cover.go.
Create reporter eagerly in manager. Use sort.Slice more.
Overall -90 lines removed.
2018-06-22 16:40:45 +02:00
Dmitry Vyukov
9a7d0a5412 pkg/report: pass vm type to NewReporter
For the case when VM type affects output.
Will be needed for gvisor. It is kinda linux, but kinda not.
2018-06-22 16:40:45 +02:00
Dmitry Vyukov
87bfb99cfe vm: pass instance to MonitorExecution
It may need it later to try to obtain additional
diagnostic from hanged instances.
2018-06-22 16:40:45 +02:00
Dmitry Vyukov
06ece2ca66 pkg/host: rework host feature detection/setup
Currently host feature detection/setup code is spread
across platform-independent fuzzer code, pkg/host, pkg/ipc
and executor.
Move this all into pkg/host and show readable info
about features on manager start.

Fixes #46
2018-06-12 14:53:22 +02:00
Daniel Borkmann
ac9b19d2e4 bpf: enable hardening mode 1 for jited images
This will harden non-root programs from kernel side, but not
root-only ones. Helps also to increase coverage a bit since
syzkaller generates programs for both cases.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2018-06-07 12:39:12 +03:00
Daniel Borkmann
b17ae9398c bpf: enable full unwind and kallsym export support for jited images
Helps syzkaller in particular for unwinding full stack in case
of warnings or crashes.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2018-06-07 12:39:12 +03:00
Dmitry Vyukov
6479ab2a75 Makefile, sys/targets: move all native compilation logic to sys/targets
We currently have native cross-compilation logic duplicated
in Makefile and in sys/targets. Some pieces are missed in one
place, some are in another. Only pkg/csource knows how to check
for -static support.

Move all CC/CFLAGS logic to sys/targets and pull results in Makefile.

This should make Makefile work on distros that have broken x86_64-linux-gnu-gcc,
now we will use just gcc. And this removes the need to define NOSTATIC,
as it's always auto-detected.

This also paves the way for making pkg/csource work on OSes other than Linux.
2018-06-06 10:02:03 +02:00
Dmitry Vyukov
f48c20b8f9
tools/create-image.sh: fix watchdog_thresh value
watchdog_thresh is capped at 60, so 120 causes EINVAL.
2018-05-19 10:48:34 +02:00
Dmitry Vyukov
70c84d118a tools/create-image.sh: add few useful sysctl's 2018-05-18 19:29:06 +02:00
Dmitry Vyukov
61ef28da7a tools/syz-execprog: restore the previous tun disabling logic
This probably can break some things.
I feel that tun setup can affect other things even if
syz_emit_ethernet/syz_extract_tcp_res are not used.
So it can make sense to setup tun even if they are not used.
But let's be more careful.
2018-05-18 10:01:22 +02:00
Dmitry Vyukov
738d58ade0 pkg/csource: minimize netdevices and net reset
Add separate options to minimize netdevices setup and net namespace reset.

Fixes #581
2018-05-17 19:57:54 +02:00
Dmitry Vyukov
9753d3be5e tools/syz-prog2c: add missing csource option 2018-05-17 19:07:33 +02:00
Dmitry Vyukov
4e1c0dbaea pkg/bisect: add bisection logic
Add first version of bisection package
(supports both bug and fix bisection).
And tools/syz-bisect wrapper for testing.

Update #501
2018-05-17 14:52:39 +02:00
Dmitry Vyukov
6595937c34 tools/create-gce-image.sh: support both nbd and loop
Pass target OS/arch and VM type to kernel.CreateImage.
Use nbd for gce and loop for qemu VM type.
2018-05-17 14:50:18 +02:00
Dmitry Vyukov
a367c1d7a8 tools/create-gce-image.sh: support MKE2FS_CONFIG 2018-05-16 17:21:29 +02:00
Dmitry Vyukov
86ea19e4c2 tools/create-gce-image.sh: revert loop to nbd
loop devices are nice, but unfortunately this creates images
that does not boot on GCE. Reason is unclear.
Revert back to nbd for now.
2018-05-14 19:32:39 +02:00
Dmitry Vyukov
d5dc4006db tools/kcovtrace: add missing include 2018-05-14 11:17:41 +02:00
Dmitry Vyukov
ea9496cdbd tools/create-gce-image.sh: use loop instead of nbd
loop is much more standard than nbd and does not require additional modules.
nbd broke on Debian rolling.
loop also allows parallel execution thanks to losetup -f.

Use loop instead of nbd.
Also improve cleanup logic and add one missing sudo.

Update #501
2018-05-14 11:16:36 +02:00
Dmitry Vyukov
9e0846e8a4 all: get rid of underscores in identifiers
Underscores are against Go coding style.

Update #538
2018-05-07 17:59:06 +02:00
Dmitry Vyukov
3f70522c7e tools/syz-execprog: split overly large function
Update #538
2018-05-07 16:23:18 +02:00
Dmitry Vyukov
78b251cbd7 all: fix too long lines
Not sure why I have not seen warnings about
these lines on another machine...
2018-05-05 16:00:01 +02:00
Dmitry Vyukov
9fe5658a1b gometalinter: check dot imports
Update #538
2018-05-03 14:41:34 +02:00
Hyeongchan Kim
d23fcf6cfb syz-upgrade: fix typo in usage message 2018-04-21 10:41:19 +02:00
Dmitry Vyukov
bc77795d90 tools/syz-execprog: reduce log level of some messages
Too much output by default.
2018-04-08 13:37:24 +02:00
Dmitry Vyukov
10a8987f80 tools: fix create-image.sh again 2018-04-07 12:42:50 +02:00
Dmitry Vyukov
54907ddb1e tools: improve demo_setup.sh
1. Account for the fact that go can be already in path.
2. Unset GOROOT in case it is set already.
3. export variables (not sure how it worked for me).
2018-04-07 12:33:23 +02:00
Dmitry Vyukov
2a9c3edcda pkg/prog: explain why syscalls are transitively disabled 2018-04-06 19:43:06 +02:00
Dmitry Vyukov
4daf8570eb pkg/host: explain why syscalls are disabled 2018-04-06 18:47:56 +02:00
Dmitry Vyukov
a932eae671 tools: add a script that setups everything 2018-04-05 19:52:54 +02:00
Dmitry Vyukov
ad7d294798 tools/syz-execprog: dump coverage in text format
There is no point in using sancov,
it does not do anything other than transforming
binary format to a useful text format.
Write out text format directly.
2018-04-05 12:02:16 +02:00
Dmitry Vyukov
676bd07e7e sys/linux: test various binfmt's in execve 2018-04-02 20:10:48 +02:00
Dmitry Vyukov
99e3b0a7e8 sys/linux: add support for reading partition tables 2018-04-01 18:29:56 +02:00
Dmitry Vyukov
7c923cf8d4 sys/linux: add support for mounting filesystem images 2018-03-30 19:51:27 +02:00
Dmitry Vyukov
d47f0ed685 tools: remove stray comments in create-image.sh
The comments were unintentionally committed in a previous commit.
2018-03-29 11:59:14 +02:00
Dmitry Vyukov
c7e0d50a76 tools/syz-db: allow to specify db version in pack 2018-03-27 09:39:02 +02:00
Dmitry Vyukov
2675f92065 sys/linux: add cgroup descriptions 2018-03-25 12:46:05 +02:00
Dmitry Vyukov
36d1c4540a all: fix gometalinter warnings
Fix typos, non-canonical code, remove dead code, etc.
2018-03-08 18:48:26 +01:00
Dmitry Vyukov
42467f5b7b sys/linux: add syz_init_net_socket syscall
The new pseudo syscall allows opening sockets that can only
be created in init net namespace (BLUETOOTH, NFC, LLC).
Use it to open these sockets.

Unfortunately this only works with sandbox none at the moment.
The problem is that setns of a network namespace requires CAP_SYS_ADMIN
in the target namespace, and we've lost all privs in the init namespace
during creation of a user namespace.
2018-03-05 12:10:27 +01:00
Dmitry Vyukov
1f693e0219 tools/syz-mutate: allow limiting set of syscalls 2018-02-17 19:02:12 +01:00
Dmitry Vyukov
d39a1fe856 tools/syz-execprog: fix parsing of multiple logs 2018-01-31 15:50:36 +01:00
Dmitry Vyukov
b88de8e0bf tools/syz-symbolize: allow to symbolize arbitrary kernel output 2018-01-09 21:24:29 +01:00
Dmitry Vyukov
1d3e907710 tools/syz-symbolize: assume that kernel is in the current dir 2017-12-27 15:02:46 +01:00
Dmitry Vyukov
0d231ceb73 syz-fuzzer: refactor
syz-fuzzer organically grew from a small nice main function
into a huge single-file monster with tons of global state.

Start refactoring it into something more managable.
This change separates 2 things:
1. Proc: a single fuzzing process (ipc.Env wrapper).
2. WorkQueue: holds global non-fuzzing work items.
More work needed, but this is good first step.
2017-12-18 09:50:17 +01:00
Dmitry Vyukov
c5826ff7aa pkg/ipc: make threaded/collide per-program options
Currently threaded/collide are global environment flags.
It can be useful to turn off collider during some executions
(minimization, triage, etc).
Make them per-program options.
2017-12-17 11:39:14 +01:00
Dmitry Vyukov
dcd99c6fd1 tools: fix create-image.sh
Uncomment unintentionally commented out lines from a previous commit.
2017-12-08 13:20:50 +01:00
Dmitry Vyukov
5c1e6a291b tools/syz-execprog: extend hints output
Print call number because one is usually interested
in a particular call only.
2017-12-08 10:25:41 +01:00
Dmitry Vyukov
c0e5b8c81f tools: include selinux packages when building images
These packages are required to actually activate selinux during boot.
2017-12-08 10:19:09 +01:00
Dmitry Vyukov
eddaedbb9c tools/syz-crush: fix for new multi-target world 2017-11-30 10:20:34 +01:00
Dmitry Vyukov
29b0fd90e6 pkg/report: include Maintainers into report
Currently getting a complete report requires a complex,
multi-step dance (including getting information that
external users are not interested in -- guilty file).

Simplify interface down to 2 functions: Parse and Symbolize.
Parse does what it did before, Symbolize symbolizes report
and fills in maintainers. This simplifies both implementations
of Reporter interface and all users of the interface.

Potentially we could get this down to 1 function Parse
that does everything. However, (1) Symbolize can fail,
while Parse cannot, (2) usually we want to ignore (log)
Symbolize errors, but otherwise proceed with the report,
(3) repro does not need symbolization for all but the
last report.
2017-11-29 18:24:30 +01:00
Dmitry Vyukov
34f2c2332b pkg/report: add Output to Report
Whole raw output is indivisble part of Report,
currently we always pass Output separately along with Report.
Make Output a Report field.

Then, put whole Report into manager Crash and repro context and Result.
There is little point in passing Report as aa bunch of separate fields.
2017-11-29 14:36:51 +01:00
Dmitry Vyukov
afba0b55e6 sys/linux: add binder descriptions 2017-11-27 15:09:30 +01:00
Andrey Konovalov
6834199b8c pkg/report: various corrupted report detection improvements 2017-11-23 16:17:40 +01:00
Dmitry Vyukov
ad0af9fff5 vm: return Report from MonitorExecution
This allows callers to get access to Report.Corrupted.
Better than adding 6-th return value and will allow
to pipe other report properties if necessary.
2017-11-21 19:02:35 +01:00
Dmitry Vyukov
4bd78cef05 pkg/report, pkg/repro, syz-manager: name crash attributes consistently
We currently have several names for crash attributes, which is disturbing.
E.g. crash title is called "Title" or "Desc". Name them consistently.

Title - single line bug identity.
Report - whole crash text.
Log - whole fuzzer/kernel output.
2017-11-14 10:04:22 +01:00
Dmitry Vyukov
10112655d7 vm: remove needOutput arg for MonitorExecution
Always wait 10 secs for output.
If anything this can only lead to missed crashes during repro.
Let's unify manager and repro behavior.
2017-11-14 09:45:34 +01:00
Dmitry Vyukov
7a53e7e35d pkg/report: combine report data into a struct
Parse returns 5 variables now. Later we may want to add crash "priority".
Introduce Report struct that holds all report data.
2017-11-14 09:41:55 +01:00
Andrey Konovalov
f9a8d567eb pkg/report: add corrupted report detection
This change makes pkg/report try to detect corrupted reports by
using some heuristics.
2017-11-13 17:18:16 +03:00
Andrey Konovalov
a2c64463a2 execprog: correctly handle fault injections
syz-execprog doesn't utilize info about fault injections from a prog log.
Since syz-execprog is used by the repro package to reproduce crashes,
crashes caused by fault injections might not reproduce.
2017-11-07 16:17:18 +01:00
Dmitry Vyukov
d5a1adcc06 tools/syz-execprog: allow to override target OS
This is currently useful for akaros, which is tested remotely.
2017-11-06 15:01:28 +01:00
Andrey Konovalov
26d265c811 docs, tools: add local link checker
This commit adds tools/check_links.py script, that checks that all local
links from documentation files are valid; fixes some of the invalid links
that we had; and makes travis buildbot check them as well.
2017-10-27 10:04:34 +02:00
Dmitry Vyukov
8fa0c867d4 syz-fuzzer: generates hints only for the call that gave new coverage
During smashing we know what call gave new coverage,
so we can concentrate just on it.
This helps to reduce amount of hints generated (we have too many of them).
2017-10-23 09:59:39 +02:00
Dmitry Vyukov
54ae9c6db3 tools/syz-execprog: print total number of comps/hints 2017-10-23 09:59:39 +02:00
Dmitry Vyukov
85c802e4cf pkg/report: support multiple OSes
Introduce report.Reporter interface.
Add an implementation per-OS.
Make users be explicit about OS they are testing.
2017-10-18 12:01:24 +02:00
Dmitry Vyukov
a8a0b01a8b tools/syz-mutate: allow to specify target 2017-10-17 10:54:19 +02:00
Dmitry Vyukov
aa2533b98d tools/syz-prog2c: allow to specify target OS 2017-10-16 14:21:54 +02:00
Dmitry Vyukov
9444f97045 tools/syz-stress: allow to specify target OS 2017-10-16 14:21:54 +02:00
Dmitry Vyukov
d49f04b345 tools/syz-prog2c: import targets
Currently syz-prog2c is broken as it does not import any targets.
Import sys package.
2017-10-02 13:57:04 +02:00
Dmitry Vyukov
64b6c0724d sys/windows: add more descriptions 2017-09-27 20:17:09 +02:00
Dmitry Vyukov
913d592f97 all: more assorted fuchsia support 2017-09-22 13:10:55 +02:00
Dmitry Vyukov
8cb7d3dcfc all: initial support for fuchsia
Nothing works, but builds.

Update #191
2017-09-20 21:19:29 +02:00
Dmitry Vyukov
52a33fd516 prog: remove default target and all global state
Now each prog function accepts the desired target explicitly.
No global, implicit state involved.
This is much cleaner and allows cross-OS/arch testing, etc.
2017-09-15 16:02:37 +02:00
Dmitry Vyukov
c0cabacda7 syz-fuzzer, syz-execprog: add -arch flag
arch flag specifies target arch, which can be different from GOARCH.
For example, 386 executor with amd64 fuzzer.
2017-09-15 16:02:37 +02:00
Dmitry Vyukov
f7b1163afb syz-manager/mgrconfig: explicitly specify target in config
Add target config parameter (e.g. linux/amd64) which controls target OS/arch.
No more explicit assumptions about target.
2017-09-15 16:02:37 +02:00
Dmitry Vyukov
ffe7e17368 prog, sys: move types to prog
Large overhaul moves syscalls and arg types from sys to prog.
Sys package now depends on prog and contains only generated
descriptions of syscalls.
Introduce prog.Target type that encapsulates all targer properties,
like syscall list, ptr/page size, etc. Also moves OS-dependent pieces
like mmap call generation from prog to sys.

Update #191
2017-09-05 15:52:42 +02:00
Dmitry Vyukov
5db39ab953 sys: rename Call to Syscall
In preparation for moving sys types to prog
to avoid confusion between sys.Call and prog.Call.
2017-09-05 10:38:22 +02:00