Commit Graph

710 Commits

Author SHA1 Message Date
Dmitry Vyukov
94ef62054c pkg/build: move from pkg/kernel
Rename pkg/kernel to pkg/build and prepare for multi-OS support.
2018-06-22 16:40:45 +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
c31f96a8c6 executor: rework fallback coverage
We have fallback coverage implmentation for freebsd.
1. It's broken after some recent changes.
2. We need it for fuchsia, windows, akaros, linux too.
3. It's painful to work with C code.

Move fallback coverage to ipc package,
fix it and provide for all OSes.
2018-06-22 16:40:45 +02:00
Dmitry Vyukov
14e6c472f5 vm/gvisor: add package
gvisor package provides support for gVisor, user-space kernel, testing.
See https://github.com/google/gvisor
2018-06-22 16:40:45 +02:00
Dmitry Vyukov
c71647f2cc pkg/report: add gvisor support 2018-06-22 16:40:45 +02:00
Dmitry Vyukov
3cf0de82e9 pkg/report: move title sanitization from linux to common code
Stripping dynamic data (addresses, numbers) is required for all OSes.
Move this code from linux to common code.
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
ef9ddfbe36 executor: handle case when AF_INET is not enabled
No AF_INET is somewhat crazy, but why not.
2018-06-22 16:40:45 +02:00
Dmitry Vyukov
095ef80678 pkg/host: fix race in test 2018-06-19 14:33:56 +02:00
Dmitry Vyukov
ed73f9c3aa pkg/host: more precise detection for syz_mount_image support 2018-06-18 19:45:50 +02:00
Dmitry Vyukov
af9f337ea6 pkg/host: support trial supported syscall detection
Detect supported syscall by directly executing them
if kallsyms is not present. This is required for gvisor testing.
2018-06-18 19:45:45 +02:00
Dmitry Vyukov
7bd97c6ff6 pkg/host: better detection of supported sockets
Check socketpair.
Check non-constant socket types.
2018-06-18 19:45:45 +02:00
Dmitry Vyukov
b7d00d1e14 pkg/email: support quoted-printable emails
We did not handle quoted-printable because mime package handles it.
But we can have a non-mime email in quoted-printable.
Simply handle it always, it's not hard.
2018-06-18 19:45:44 +02:00
Dmitry Vyukov
27c5f59f50 all: fix gometalinter warnings 2018-06-12 20:10:58 +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
Dmitry Vyukov
62d1af2467 pkg/instance: more robust instance testing
Strictly saying, we may not get the connection when
the fuzzer process exits. The accepting goroutine
may have not been scheduled yet.
For the connection for up to 10 seconds.
2018-06-11 16:47:12 +02:00
Dmitry Vyukov
ae8bdb5058 syz-fuzzer: don't crash on commit mismatch
We now check for manager-fuzzer-executor commit mismatch (see Manager.Check).
But in some cases commit mismatch is not detected gracefully, and instead
leads to panics in fuzzer. Namely, when -enabled_syscalls fuzzer flag includes
large syscalls numbers, so large that they are no present at all in the an old
revision that fuzzer uses, in such case fuzzer panics.

Notify manager about invalid calls instead.

Fixes #464
2018-06-11 12:12:01 +03:00
Dmitry Vyukov
deb0e69e10 executor: always use errors=continue when mounting ext2/3/4
For ext2/3/4 we have to have errors=continue because the image
can contain errors=panic flag and can legally crash kernel.

Fixes #599
2018-06-11 12:12:01 +03:00
Dmitry Vyukov
6db75fefbe pkg/report: add another format for null RIP
Kernel keeps inventing new formats...
2018-06-08 09:34:02 +02:00
Dmitry Vyukov
645e75f803 executor: make syscall table and number constant
We see some crashes that suggest corruption of the syscall number:

invalid command number 1296 (errno 11)
invalid command number 107 (errno 110)

Make the table and the number constant to prevent corruption.
2018-06-07 15:32:30 +02:00
Dmitry Vyukov
7fb9023fd7 pkg/report: ignore down functions for task hung bugs 2018-06-07 14:01:22 +02:00
Dmitry Vyukov
d2ba33fac0 pkg/kernel: pass CC to oldconfig
Passing in compiler is important since 4.17
(at the very least it's noted in the config).
2018-06-07 10:18:14 +02:00
Dmitry Vyukov
a6bf43aeeb pkg/report: add simplistic fuchsia reporter 2018-06-06 16:29:59 +02:00
Dmitry Vyukov
606f9a96d8 pkg/csource: allow to build source fom memory
In most cases we have source in memory,
so provide a function to build right from memory
without creating temp files.
2018-06-06 10:30:54 +02: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
9820e1cae6 pkg/report: more "NMI handler took too long" ignores 2018-06-06 10:02:03 +02:00
Dmitry Vyukov
3f4f3d5ec9 pkg/report: ignore INFO messages about long interrupts 2018-06-04 12:07:28 +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
3717901c10 pkg/csource: serialize options into json
Current format is painful to parse after changes.
Switch to json.
2018-05-17 19:07:46 +02:00
Dmitry Vyukov
be47ebb0eb pkg/kernel: allow to split full make output
Currently kernel build failures are insanely verbose
(contain full kernel build output) and there is no
way to separate short descriptions from full output.
Make it possible.
Also try to extract failure root cause froom build log.
Use this in pkg/bisect to not pollute log on build failures.

Update #501
2018-05-17 17:18:24 +02:00
Dmitry Vyukov
28cbff8c7d pkg/bisect: stop at Linux v3.8
Update #501
2018-05-17 16:40:00 +02:00
Dmitry Vyukov
8dd3159f51 pkg/bisect: increase number of tries to 8
With 5 tries sometimes only 1 fails,
and sometimes we probably have false negatives.
Increase number of tries to 8 and compress
results if they all are the same.

Update #501
2018-05-17 16:30:20 +02:00
Dmitry Vyukov
edbe39a26d pkg/git: extract relevant email addresses from commits
Update #501
2018-05-17 15:58:58 +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
9c84f7c395 pkg/osutil: allow disabling sandboxing with env var
If SYZ_DISABLE_SANDBOXING=yes is set, don't do user sandboxing.
Will be usefule for bisection tool which runs locally,
but needs to build kernel.

Update #501
2018-05-17 14:03:46 +02:00
Dmitry Vyukov
031c7941d7 pkg/compiler: add optional builtin template
type optional[T] [
	val	T
	void	void
] [varlen]
2018-05-17 12:02:30 +02:00
Dmitry Vyukov
90c54c496b pkg/compiler: detect duplicate fields in template structs 2018-05-17 11:46:45 +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
d131f1b9fc pkg/instance: relax syzkaller path check
Only check that syzkaller path is in GOPATH if we are going to build it.
syz-ci image testing does not have syzkaller path in GOPATH,
but it also does not build syzkaller.
2018-05-14 13:47:44 +02:00
Dmitry Vyukov
2407e7407a pkg/instance: add package for testing of images/patches/bisection
Move helper image/patch testing code from syz-ci/testing.go
to a separate package so that it can be reused during bisection.

Update #501
2018-05-14 11:32:56 +02:00
Dmitry Vyukov
9fb3ae4dfd pkg/osutil: introduce TempFile helper
Introduce TempFile helper and use it in several packages.
2018-05-14 11:17:23 +02:00
Dmitry Vyukov
acfd774f46 pkg/git: add bisection functionality
Bisect bisects good..bad commit range against the provided predicate (wrapper around git bisect).
The predicate should return an error only if there is no way to proceed
(it will abort the process), if possible it should prefer to return BisectSkip.
Progress of the process is streamed to the provided trace.
Returns the first commit on which the predicate returns BisectBad.

Update #501
2018-05-14 11:17:23 +02:00
Dmitry Vyukov
b4df103f78 pkg/git: add PreviousReleaseTags
PreviousReleaseTags returns list of preceding release tags
that are reachable from the given commit.

Update #501
2018-05-14 11:17:23 +02:00
Dmitry Vyukov
5060be1a90 pkg/git: add SwitchCommit and GetCommit
Will be useful for bisection logic.

Update #501
2018-05-14 11:17:23 +02:00
Dmitry Vyukov
d39e52252c pkg/kernel: use oldconfig instead of olddefconfig
See the added comment for motivation.

Update #501
2018-05-14 11:17:23 +02:00
Dmitry Vyukov
2a287a4dfc pkg/kernel: accept kernel config as byte slice
We usually have the config in memory,
so saving it to disk is an unnecessary step.
Accept byte slice directly.

Update #501
2018-05-14 11:17:23 +02:00
Dmitry Vyukov
1944eeb95d pkg/kernel: run distclean with -jNCPU 2018-05-14 11:17:18 +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
Ioana Ciornei
481f030ccd executor: fix strncpy compile error
gcc8 is stricter when dealing with strings and strncpy and demands that
the size of the actual string to be copied to be explicitly smaller than
the size of the destination, just to make sure the NULL terminator is
taken into considerantion. This patch fixes the issue.

Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com>
2018-05-13 16:27:22 +02:00
Dmitry Vyukov
045bbd4afb pkg/csource: fix test exit code 2018-05-07 20:40:44 +02:00
Dmitry Vyukov
02e3401638 pkg/csource: skip tests under race detector
csource tests consume too much memory under race detector (>1GB),
and periodically timeout on Travis. So we skip them.
2018-05-07 20:27:06 +02:00
Dmitry Vyukov
bdff58b1a1 pkg/csource: reduce test size
The test times out on travis:

https://travis-ci.org/google/syzkaller/jobs/375965899
https://travis-ci.org/google/syzkaller/jobs/375965900
2018-05-07 19:24:46 +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
99c1f48659 sys/syz-extract: split overly long function
Update #538
2018-05-07 16:50:19 +02:00
Dmitry Vyukov
55a5e98a0a pkg/ifuzz: move generated code to a separate package
This helps to ignore generated code with gometalinter.
There is currently no other way:
https://github.com/alecthomas/gometalinter/issues/270

Update #538
2018-05-07 15:42:28 +02:00
Dmitry Vyukov
5f9dcfdadb pkg/git: remove duplicated code in tests
Update #538
2018-05-07 13:16:29 +02:00
Dmitry Vyukov
b9fea20df7 pkg/report: remove duplicated stub code
Update #538
2018-05-07 13:05:41 +02:00
Dmitry Vyukov
a211da1a40 pkg/db: remove code duplication in test
Update #538
2018-05-06 19:47:40 +02:00
Dmitry Vyukov
2c7e14a847 gometalinter: enable cyclomatic complexity checking
Refactor some functions to be simpler.

Update #538
2018-05-04 18:03:46 +02:00
Dmitry Vyukov
08141db61a gometalinter: enable line length checking
120 columns looks like a reasonable limit
and requires few changes to existing code.

Update #538
2018-05-04 14:24:51 +02:00
Dmitry Vyukov
a630fd8b41 gometalinter: some fixes for unparam
But we still can't enable it as there are more [uninteresting] warnings.

Update #538
2018-05-03 15:48:26 +02:00
Dmitry Vyukov
9fe5658a1b gometalinter: check dot imports
Update #538
2018-05-03 14:41:34 +02:00
Dmitry Vyukov
39302300d9 gometalinter: check unkeyed composite literals
Update #538
2018-05-03 14:01:48 +02:00
Dmitry Vyukov
4c24e4a467 gometalinter: enable package comment checking
Update #538
2018-05-03 13:53:01 +02:00
Dmitry Vyukov
6e2ce6613b pkg/host: fix syz_mount_image detection
Only init admin can mount filesystems with images.
2018-04-29 18:45:45 +02:00
Dmitry Vyukov
1e85f7b9af pkg/ast: support char constants
Frequently it's useful to do something like:

int8['a':'z']
punctuation = ',', '-', ':'
2018-04-29 12:04:22 +02:00
Dmitry Vyukov
c7f6891ca7 pkg/report: reformat code
There is some regression in Go formatting on tip.
I am constantly getting diffs after formatting.
Filed: https://github.com/golang/go/issues/25161
2018-04-29 12:04:22 +02:00
Dmitry Vyukov
190d92e056 sys/linux: extend namespace desciptions
Slightly extend namespace descriptions and move
them to a separate file.
2018-04-27 18:47:58 +02:00
Dmitry Vyukov
0008f52678 pkg/report: fix remaining lockdep report formats
We fixed only 1, but new format affects all lockdep reports.
Fix all of them.
2018-04-27 15:44:47 +02:00
Dmitry Vyukov
3c7caf1d6e pkg/host: enable more fault injection 2018-04-27 15:43:29 +02:00
Dmitry Vyukov
d0b7645387 pkg/report: few report parsing fixes for linux 2018-04-26 14:46:16 +02:00
Dmitry Vyukov
37e76fe20b pkg/scource: rename compiled binary to syz-executor
We call the binary syz-executor because it sometimes shows in bug titles,
and we don't want 2 different bugs for when a crash is triggered during
fuzzing and during repro.
2018-04-24 19:17:07 +02:00
Dmitry Vyukov
fd5157bebf pkg/report: sanitize titles better
Strip non-printable characters from titles.
Trim whitespaces on both ends.
Replace tabs with spaces.
Remove duplicate spaces.
Reduce max title length.
2018-04-24 19:17:07 +02:00
Dmitry Vyukov
98e363b852 pkg/git: don't create shallow repos
Shallow repos created by CheckoutBranch conflict with
what CheckoutCommit tries to do.
Fetch of a shallow repo does not unshallow it.
And then checkout of a non-head commit fails.
2018-04-24 19:17:07 +02:00
Dmitry Vyukov
9366d03f00 dashboard/app: allow testing fixes on exact commit and without patch
This implements 2 features:
1. It's now possible to specify exact commit when testing as:

2. It's possible to test without patch attached
assuming the patch is already committed to the tested tree.

Fixes #558
2018-04-24 13:23:01 +02:00
Dmitry Vyukov
e2f4bf8f38 pkg/gce: improve API rate limit logic
Sometimes we see rate limiting errors.
This is especially bad for e.g. patch testing requests.
Increase default API delay and add backoff logic.
2018-04-24 13:23:01 +02:00
Dmitry Vyukov
33424b08c3 pkg/report: more corrupted report detection 2018-04-24 13:23:01 +02:00
Dmitry Vyukov
e7e85d3609 pkg/kernel: fix gometalinter warning 2018-04-23 16:50:25 +02:00
Dmitry Vyukov
8b5dcf17b0 syz-ci: clean kernel dir before patch test build
This leads to false errors when we are switching between gcc and clang:

kernel build failed: failed to run /usr/bin/make [make bzImage -j 32 CC=/syzkaller/clang-kmsan/bin/clang]: exit status 2
arch/x86/Makefile:184: *** Compiler lacks asm-goto support..  Stop.

Fixes #568
2018-04-23 16:26:26 +02:00
Dmitry Vyukov
ff12bea91c pkg/ipc: fix data race on config.Timeout 2018-04-23 16:26:26 +02:00
Dmitry Vyukov
8b9a3f2c76 pkg/report: add some example arm crashes 2018-04-20 20:14:10 +02:00
Dmitry Vyukov
bf2018dd07 executor: don't fail when ipv6 is not enabled
Check in checkpoint_iptables is not enough as
reset_iptables will fail even if no tables enabled.
Add similar check to reset_iptables.
2018-04-20 20:14:10 +02:00
Dmitry Vyukov
e5453dd396 executor: increase max image size to 128MB
Images of some filesystems need to be that large (xfs, btrfs, f2fs).
2018-04-19 16:59:49 +02:00
Dmitry Vyukov
81daaca980 pkg/host: fix kallsyms names again
Some x86 syscalls now seem to be __x64_ and __ia32_ instead of sys_ or ksys_.
2018-04-19 16:58:24 +02:00
Dmitry Vyukov
19af2a1b35 pkg/report: coarsen "unregister_netdevice" title
This leads to unbounded number of bug reports as syzkaller
can generate new device names dynamically.
Exclude actual device name from title.
2018-04-19 13:58:34 +02:00
Dmitry Vyukov
829f023456 pkg/host: fix kallsyms check
Recent kernel changes to not call syscalls directly from kernel code
renamed syscall symbols from sys_foo to ksys_foo.
Support both formats.
2018-04-18 16:30:13 +02:00
Dmitry Vyukov
2199644490 pkg/report: reformat code 2018-04-18 09:23:00 +02:00
Dmitry Vyukov
85d38101ef pkg/report: ignore pkg/host debug output 2018-04-16 21:23:32 +02:00
Dmitry Vyukov
f24e540fe5 executor: don't fail if IPv6 is not enabled 2018-04-16 21:11:10 +02:00
Dmitry Vyukov
61155cf882 pkg/report: filter out more corrupted reports due to fault injection 2018-04-16 14:01:05 +02:00
Dmitry Vyukov
7a67784ca8 pkg/report: detect hangs in unregister_netdevice
Add special report format for hangs in unregister_netdevice.
And support new format of lockdep reports (otherwise they all
are marked as corrupted).
2018-04-13 17:44:45 +02:00
Hangbin Liu
0a0c5db668 executor: add two slave interfaces for bridge,bond,team
Bridge device is used for forwarding. Bond/team device is used for
load balance and fail over. So it would make more sense to add two
slave interfaces for these devices.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2018-04-13 09:38:31 +02:00
Dmitry Vyukov
eb2295de3e pkg/repro: clean up temp files 2018-04-12 16:06:06 +02:00
Dmitry Vyukov
9cd56d71a8 sys/linux: add veth devices to devnames
Also comment new veth code for future me.
2018-04-11 11:36:25 +02:00
Hangbin Liu
a9b12a986c executor: add salve interface for bond0/team0
Add a veth pair with name bond/team_slave and set their master
to bond0/team0.

Remove veth from devtypes because the cmd `ip link add veth0 type veth`
will actually failed with "RTNETLINK answers: File exists" and no veth
interface created. When create veth device, kernel will create a
pair of veth, so no need to create them one by one.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2018-04-11 11:18:45 +02:00
Dmitry Vyukov
b9f655072c pkg/report: fix typo in test failure message 2018-04-09 17:32:39 +02:00
Dmitry Vyukov
3fdee3b005 pkg/report: improve corrupted report detection
1. If we see should_failslab frames during report parsing,
   that's a corrupted report with intermixed frames from
   fault injection stack.
2. If we matched report title and this report should contains
   a guilty stack frame, but we failed to extract any frame,
   consider it as corrupted.

New tests added. Also one of the old tests is fixed.
2018-04-09 14:19:51 +02:00
Dmitry Vyukov
77bd5117c3 pkg/host: refactor code
Fix warnings pointed out by gometalinter.
2018-04-08 13:38:07 +02:00
Dmitry Vyukov
d70ffd1a2b pkg/report: strip "panic_on_warn set" more aggressively
KMSAN reports can be short, but still include full stack.
The added test is only 28 lines, so reduce the threshold from 40 to 25 lines.
2018-04-07 15:28:34 +02:00
Dmitry Vyukov
d613535f94 pkg/ipc: disable coverage collection by default
syz-manager always passes explicit value for the flag.
syz-stress does not need coverage.
The only real user is syz-execprog. syz-execprog already
forces coverage with -coverfile is given. Coverage is harmful
for external users trying to reproduce reported bugs.
For the remaining cases of syzkaller developers running
syz-execprog on KCOV-enabled kernel, the flag can be given
manually if really needed.

Fixes #554
2018-04-06 21:24:22 +02:00
Dmitry Vyukov
53196ce262 syz-manager: warn about disabled syscalls in enable_syscalls
syz-manager used to silently transitively disable syscalls
for which input resources can't be created.
This caused lots of confusion, or worse, users did not notice
that syzkaller does not actually test what they want.
Fail loudly with a readable explanation when a syscall
explicitly enabled in enable_syscalls is actually disabled.

Note: this requires to slightly change enable/disable_syscalls
matching logic. Previously "foo" would match "foo" and all "foo$BAR",
now it matches only "foo". But "foo*" can be used to match all
disciminations.
2018-04-06 21:08:54 +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
8e4c2e24cb executor: create team device 2018-04-06 17:28:33 +02:00
Dmitry Vyukov
7606c2ac04 pkg/report: don't blame kcov
kcov frame can be present in rcu stalls, ignore it.
2018-04-06 17:24:28 +02:00
Dmitry Vyukov
676bd07e7e sys/linux: test various binfmt's in execve 2018-04-02 20:10:48 +02:00
Dmitry Vyukov
3e679c51c0 pkg/compiler: support non-zero terminated filenames
Now file names become:

string[filename]

with a possibility of using other string features:

stringnoz[filename]
string[filename, CONST_SIZE]

and filename is left as type alias as it is commonly used:

type filename string[filename]
2018-04-02 20:10:07 +02:00
Dmitry Vyukov
dc88925771 executor: fix unchecked result warning 2018-04-01 18:49:53 +02:00
Dmitry Vyukov
99e3b0a7e8 sys/linux: add support for reading partition tables 2018-04-01 18:29:56 +02:00
Dmitry Vyukov
372799e446 pkg/report: skip list functions during function extraction
List functions are very generic and we see lots of different
bug merged into "bug-type in list_function".
2018-04-01 12:23:00 +02:00
Dmitry Vyukov
1b0214295f pkg/report: detect corrupted task hung reports 2018-04-01 12:07:10 +02:00
Dmitry Vyukov
8fbce0e442 executor: fix compilation warnings
SYS_memfd_create define produces warning in scource
if system headers already contain the definition (we strip all ifdefs!).
The same is true for CLONE_NEWCGROUP but we just never hit it yet.
Also fix format string for 32 bits.
Also fix potential uninit var in csource, and a missing new line.
2018-03-30 20:08:05 +02:00
Dmitry Vyukov
7c923cf8d4 sys/linux: add support for mounting filesystem images 2018-03-30 19:51:27 +02:00
Dmitry Vyukov
bf5e585c5e executor: rework cgroups support
Turns out creating a cgroup per test is too expensive.
Moreover, it leads to hanged tasks as cgroup destruction
is asynchronous and overloads kernel work queues.

Create only a single cgroup per proc, but restrict
descriptions to mess with that single group,
instead test processes create own nested cgroups for messing.
2018-03-27 11:39:58 +02:00
Dmitry Vyukov
327060ba9b pkg/report: add few KMSAN report examples 2018-03-26 15:08:10 +02:00
Dmitry Vyukov
60d6f956a2 executor: fix reset of bridge netfilter
We left entries non-zero, so memcmp always failed.
2018-03-25 12:46:05 +02:00
Dmitry Vyukov
2675f92065 sys/linux: add cgroup descriptions 2018-03-25 12:46:05 +02:00
Dmitry Vyukov
7c62f71804 sys/linux: add netlink fou descriptions 2018-03-21 12:18:36 +01:00
Dmitry Vyukov
113a43ffb6 pkg/ipc: test only on simple prog
Don't use random programs for testing.
Sometimes they lead to flakes like:
opendir(./1/file0) failed (errno 13)
2018-03-20 16:56:58 +01:00
Dmitry Vyukov
7e7d7ed26a pkg/report: add another test 2018-03-19 11:05:40 +01: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
7166783e9b pkg/report: fix crash during output parsing
The test case causes rep.StartPos == secondReportPos,
which then makes extraction of description fail,
because report is empty.
2018-03-08 10:17:07 +01:00
Dmitry Vyukov
a5e765400b pkg/report: improve invalid-free format and ignore more mutex-related functions 2018-03-07 13:40:36 +01:00
Dmitry Vyukov
11cf581658 executor: fix ifdef's for csource
There is test failure on travis:
https://travis-ci.org/google/syzkaller/jobs/349948391
I can't reproduce it locally, and it only happened on 1.8, but not on 1.9?
But this seems to be what could have provoked such failure.
2018-03-07 10:50:09 +01:00
Dmitry Vyukov
c9af7e5fda pkg/report: improve KASAN report parsing
The problem is with "BUG: KASAN: (.*)" match which matches
just anything however much it is corrupted.
Mark this match as corrupted.
2018-03-06 19:15:44 +01:00
Dmitry Vyukov
b5fcd0c554 pkg/osutil: use proper gid during sandboxing 2018-03-06 19:15:44 +01:00
Dmitry Vyukov
bbd5104f06 executor: fix includes
We use errno, vaargs, printf in all of fail/error/exitf,
but we include the corresponding headers only when SYZ_USE_TMP_DIR.
Include them whenever fail/error/exitf are used.
2018-03-05 12:59:12 +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
002cecf202 pkg/compiler: allow specifying static size for filename's
Sometimes filenames are embed into structs and need to take fixed space.
2018-03-05 12:10:27 +01:00
Dmitry Vyukov
5ef8dbdf5a pkg/compiler: support size attribute for unions 2018-03-05 12:10:27 +01:00
Dmitry Vyukov
a339951e5f pkg/compiler: add size attribute for structs
The size attribute allows to pad a struct up to the specified size.
2018-03-05 12:10:27 +01:00
Dmitry Vyukov
5110ff445d pkg/compiler: switch attributes from Ident to Type
This allows parametrized attributes like size[10].
But this is not used for now.
2018-03-05 12:10:27 +01:00
Dmitry Vyukov
05b5a32cfd pkg/gce: fix a type 2018-02-27 12:08:16 +01:00
Dmitry Vyukov
64482eb948 pkg/gce: use current instance network
The current instance is not necessary in the default network.
2018-02-27 11:58:41 +01:00
Dmitry Vyukov
1d19aa5799 executor: simplify initialize_tun
Remove executor_pid, enable_tun and setup_tun.
2018-02-26 17:43:13 +01:00
Dmitry Vyukov
b37b65b0e6 sys/linux: remove proc type from network descriptions
We now always create net namespace for testing,
so socket ports and other IDs do not overlap between
different test processes.
Proc types play badly with squashing packets to ANYBLOB.
To squash into a block we need concrete value, but it depends
on process id.
Removing proc also makes tun setup and address descriptions simpler.
2018-02-26 16:48:31 +01:00
Dmitry Vyukov
66cf309385 executor, pkg/csource: make fd numbers consistent
Currently when executor creates fd's it gets: 0, 3, 4.
When tun is enabled: 3, 4, 5.
For C programs: 3, 4, 5.
When run is enabled: 4, 5, 6.

Theoretically it should not matter,
but these fd numbers are probably sometimes are used as data.
So make them consistent in all these cases (3, 4, 5).
2018-02-26 15:54:02 +01:00
Dmitry Vyukov
14dae29c2a executor: use proper default values for resources
We currently use -1 as default value for resources
when the actual value is not available.
-1 is good for fd's, but is not the right default
value for pointers/keys/etc.
Pass from prog and use in executor proper default
value for resources.
2018-02-26 15:00:46 +01:00
Dmitry Vyukov
2145057cb8 pkg/compiler: fix alignment corner case
Fix alignemnt calculation for packed structs with alignment and bitfields.
Amusingly this affected only a single real struct -- ipv6_fragment_ext_header.
2018-02-25 14:44:29 +01:00
Dmitry Vyukov
1f4ae3f413 pkg/compiler: don't assign call IDs statically
IDs change whenever a call is added or removed,
this leads to large diffs unnecessarly.
Assign IDs dynamically.
2018-02-25 14:31:40 +01:00
Dmitry Vyukov
5c1e020706 pkg/compiler: prohibit len of other union options 2018-02-23 14:00:41 +01:00
Dmitry Vyukov
7a7c747c6f pkg/compiler: allow unions as syscall arguments
If all union options can be syscall arguments,
allow the union itself as syscall argument.
2018-02-23 13:50:02 +01:00
Dmitry Vyukov
6153a72ee1 executor: bring up bond and veth devices 2018-02-22 20:16:37 +01:00
Dmitry Vyukov
04cbdbd1ae syz-fuzzer: prioritize signal from successful syscalls
Signal on successful syscalls is more valuable than
signal on unsuccessful syscalls.y
2018-02-20 20:51:41 +01:00
Dmitry Vyukov
5abac1920e pkg/report: add format for "workqueue leaked lock or atomic" crashes 2018-02-20 11:21:33 +01:00
Dmitry Vyukov
c8e73b95c6 sys/linux: fix mmap call args
Also add a test for this.
2018-02-20 10:54:03 +01:00
Dmitry Vyukov
a793204dd2 pkg/compiler: fix corner case in alignment calculation 2018-02-19 21:48:20 +01:00
Dmitry Vyukov
d9222fc03a pkg/report: improve ODEBUG bug reports 2018-02-19 21:48:20 +01:00
Dmitry Vyukov
75a7c5e2d1 prog: rework address allocation
1. mmap all memory always, without explicit mmap calls in the program.
This makes lots of things much easier and removes lots of code.
Makes mmap not a special syscall and allows to fuzz without mmap enabled.

2. Change address assignment algorithm.
Current algorithm allocates unmapped addresses too frequently
and allows collisions between arguments of a single syscall.
The new algorithm analyzes actual allocations in the program
and places new arguments at unused locations.
2018-02-19 21:48:20 +01:00
Dmitry Vyukov
6051a5b552 prog: combine RequiresBitmasks and RequiresChecksums into RequiredFeatures 2018-02-19 21:48:20 +01:00
Dmitry Vyukov
dd768bf1c6 prog: reorder Minimize arguments
Make the predicate the last argument.
It's more common and convenient (arguments are not separated by multiple lines).
2018-02-19 21:48:20 +01:00
Dmitry Vyukov
833f78c7b0 executor: fix build
Older versions of linux require an additional header.
2018-02-17 19:11:57 +01:00
Dmitry Vyukov
9df1a36a98 sys/linux: add bridge netfilter support 2018-02-17 19:02:12 +01:00
Dmitry Vyukov
414c035582 pkg/compiler: support template template arguments
Can be useful for netfilter descriptions.
2018-02-17 19:02:12 +01:00
Dmitry Vyukov
dd4fcef5a2 pkg/compiler: allow len of var-len arrays
All netfilter subsystems use this unfortunately,
so demote this to a warning.
2018-02-17 19:02:12 +01:00
Dmitry Vyukov
77ed06bf16 pkg/report: skip mm/util.c in guilty files 2018-02-14 20:17:11 +01:00
Dmitry Vyukov
88bc17df05 pkg/report: improve corrupted report detection
Detect informational kernel reports that are not bugs in itself,
but contain stack traces. If we see them in the middle of another
report, we know stacks are intermixed and the report is potentially
corrupted.
2018-02-12 11:26:51 +01:00
Dmitry Vyukov
4e9b726d97 pkg/report: harden more against corrupted reports 2018-02-10 13:35:21 +01:00
Dmitry Vyukov
7d9727902f pkg/report: better titles for some kmalloc bugs 2018-02-10 12:33:20 +01:00
Dmitry Vyukov
e67d44e011 executor: compile with -O2
We don't frequently debug it and it does some intensive computations
on coverage, so no reason to not compile with -O2.
2018-02-10 12:14:13 +01:00
Dmitry Vyukov
2b6b214cf2 pkg/csource: fix debug calls
debug calls are only properly stripped if they are on a single line.
2018-02-09 20:31:41 +01:00
Dmitry Vyukov
033b610ec9 sys/linux: improve netfilter descriptions
Put the underflow entry at the end.
Entries must end on an unconditional, non-goto entry,
otherwise fallthrough from the last entry is invalid.

Add arp tables support.

Split unspec matches/targets to unspec and inet.

Reset ipv6 and arp tables in executor.

Fix number of counters in tables.

Plus a bunch of assorted fixes for matches/targets.
2018-02-09 20:14:33 +01:00
Dmitry Vyukov
9fb5ec4367 pkg/report: special-case extraction of guilty file for rcu stalls 2018-02-07 14:22:10 +01:00
Dmitry Vyukov
d2473bc545 pkg/report: improve guilty frame extraction
1. Make extractStackFrame more picky about stray frames.
This fixes some TODO's in tests where we matched completley
unrelated frames printed by another task.

2. Extract KASAN guilty frame from report header
if the frame should not be skipped (e.g. not __lock_acquire).
This makes parsing more tolerant to corrupted reports.
2018-02-07 13:46:35 +01:00
Dmitry Vyukov
f34079dbcf pkg/report: detect when several reports are intermixed
If there are more than one report, detect where the second
report starts and extract description only from the first report.
There are too many cases where several reports gets intermixed
and as the result we extract bogus description.
2018-02-07 09:41:12 +01:00
Dmitry Vyukov
66c15deb7a pkg/report: fix KASAN report parsing
We did not skip kasan_check_read.
Also don't let stack parsing to silently sink to another stack trace.
2018-02-06 15:29:56 +01:00
Dmitry Vyukov
645ce5da79 pkg/report: improve report titles
1. Replace stacktraceRe with custom code which is more flexible.
stacktraceRe stumbled on any unrelated lines and
could not properly parse truncated stacks.

2. Match report regexp earlier.
If we match simler title regexp, but don't match
report regexp or fail to parse stack trace, the report is corrupted.
This eliminates lots of duplicate corrupted oops entries,
which were there only because we had complex regexp's in titles.

3. Ignore low-level frames during stack parsing.
E.g. we never want to report a GPF in lock_acquire or memcpy
(somewhat similar to what we do for guilty files).

4. Add a bunch of specialized formats for WARNINGs.
There is number of generic debugging facilities (like ODEBUG,
debug usercopy, kobject, refcount_t, etc), and the bug
is never in these facilities, it's in the caller instead.

5. Improve some other oops formats.

6. Add a bunch of additional tests.

This resolves most of TODOs in tests.
Fixes #515
2018-02-06 14:44:03 +01:00
Dmitry Vyukov
e86ddaca2e sys/syz-extract: save unsupported consts to the const files
We currently print unsupported consts to console during make extract.
But this is not very useful as there are too many output now.
This also does not allow to understand what's unsupported
in newly checked-in descriptions, or what's unsupported in all current
decriptions.

Save unsupported consts to the const files instead.
This solves all of the above problems.
2018-02-01 20:18:51 +01:00
Dmitry Vyukov
e525e980ea pkg/report: add more TODO cases 2018-02-01 15:49:05 +01:00
Dmitry Vyukov
08d47756d0 executor: fix 32-bit support
ipt_get_entries.entrytable must be pointer aligned,
so in 32-bit build there is no padding before it.
2018-01-28 09:17:03 +01:00
Dmitry Vyukov
08146b1a84 sys/linux: extend netfilter descriptions 2018-01-27 17:08:43 +01:00
Dmitry Vyukov
e8b4970547 pkg/compiler: allow unions with only 1 field
Unions with only 1 field are not actually unions,
and can always be replaced with the option type.
However, they are still useful when there will be
more options in future but currently only 1 is described.
Alternatives are:
 - not using union (but then all existing programs will be
   broken when union is finally introduced)
 - adding a fake field (ugly and reduces fuzzer efficiency)

Allow unions with only 1 field.
2018-01-27 17:08:43 +01:00
Dmitry Vyukov
1d18b11287 pkg/report: fix guilty file regexps 2018-01-25 10:57:31 +01:00
Dmitry Vyukov
866f1102f7 pkg/email: handle emails without Content-Type header
git-send-email sends emails without Content-Type,
let's assume it's text.
2018-01-24 19:37:00 +01:00
Dmitry Vyukov
ca9c302d80 pkg/compiler, prog: fix template parent lens
It's possible that a struct can have 2+ parents,
which is the same template (differs only by arguments).
See the new test case.
Support such case.
2018-01-24 11:35:22 +01:00
Dmitry Vyukov
a5b7566c4a executor: handle old and new selinux mount points 2018-01-23 12:56:00 +01:00
Dmitry Vyukov
3d76cc40d9 pkg/compiler: fix len of parent template struct
Consider the following example:

type len_templ1[DATA1, DATA2] {
	data	DATA1
	inner	len_temp2[DATA2]
}

type len_temp2[DATA] {
	data	DATA
	len	len[len_templ1, int8]
}

Here len refers to a parent struct, but the struct is a template,
so it's actual name is something like "len_templ1[int8, int16]".
Currently this does not work as compiler barks at incorrect
len target.

Make this work.
2018-01-23 11:38:53 +01:00
Dmitry Vyukov
14d1e424b6 pkg/compiler: allow use of empty strings
This comes up in several contexts in netfilter.
2018-01-23 11:05:51 +01:00
Dmitry Vyukov
de3e24c4b6 pkg/compiler: allow strings as template arguments
Needed for netfilter descriptions.
2018-01-23 10:44:01 +01:00
Dmitry Vyukov
40a6602675 sys/linux: add netfilter descriptions
Lots of TODOs and only ipv4, but some start.
2018-01-22 12:19:33 +01:00
Dmitry Vyukov
b7f99b54ae sys/linux: more selinux descriptions 2018-01-18 19:58:49 +01:00
Dmitry Vyukov
3661e26e74 pkg/compiler: support non-zero-terminated strings
Add stringnoz type.
2018-01-18 18:48:39 +01:00
Dmitry Vyukov
c77c36d5fa pkg/report: add another negative test case 2018-01-18 14:55:44 +01:00
Dmitry Vyukov
dcf3aa89fe pkg/report: allow up to 15 lines from "Call Trace" to first frame
Fixes a bunch of reports incorrectly marked as corrupted.
2018-01-18 10:28:07 +01:00
Dmitry Vyukov
d7bc58204e dashboard/app: collect more info for better reports
Collect kernel build commit title/date.
Add support for kernel repo aliases (to be able
to say linux-next instead of full git repo address).
Collect on what managers a bug happened.
Reuse Crash.ReportLen as generic crash reporting priority.
Make it possible to prioritize reporting of particular
kernel repos and arches.

Fixes #473
2018-01-17 19:52:30 +01:00
Dmitry Vyukov
a46e53184f pkg/git: fix potential hang
If extractFixTags exits early with error,
git process will hang due to stdout overflow
and never exit.
2018-01-16 18:46:04 +01:00
Dmitry Vyukov
c206e64a01 syz-ci: use the original syzkaller commit for patch testing
Currently we use the latest syzkaller commit that syz-ci uses itself.
As the result syz-execprog can fail to deserialize the reproducer.
Use the original syzkaller commit.
2018-01-16 13:37:14 +01:00
Dmitry Vyukov
837a69870d pkg/report: add another TODO test case 2018-01-15 20:21:30 +01:00
Dmitry Vyukov
b705c02263 executor: fix tun/device setup for sandbox=namespace
For sandbox=namespace we first create network devices
and then do CLONE_NEWNS, which brings us into a new
namespace which actually does not have any of these devices.
Tun mostly worked, because we hold fd to the tun device.
However, even for tun we could not see the "syz0" device.
2018-01-15 19:09:16 +01:00
Dmitry Vyukov
212f927d3c executor: setup network devices
We test in a new network namespace, which does not have any
devices set up (even lo). Create/up as many devices as possible.
Give them some addresses and use these addresses in descriptions.
2018-01-13 12:52:09 +01:00
Dmitry Vyukov
9ea6693e1b pkg/compiler: allow string/array as template type 2018-01-13 12:52:09 +01:00
Dmitry Vyukov
a94baff95e sys/syz-sysgen: don't generate syz_ syscall numbers
They don't seem to be used today.
2018-01-13 12:52:09 +01:00
Dmitry Vyukov
5585946e22 pkg/compiler: support void type
"void": type with static size 0
	mostly useful inside of templates and varlen unions
	can't be syscall argument
2018-01-13 12:52:09 +01:00
Dmitry Vyukov
6b52293f4d pkg/compiler: support type templates
Netlink descriptions contain tons of code duplication,
and need much more for proper descriptions. Introduce
type templates to simplify writing such descriptions
and remove code duplication.

Note: type templates are experimental, have poor error handling
and are subject to change.

Type templates can be declared as follows:

```
type buffer[DIR] ptr[DIR, array[int8]]
type fileoff[BASE] BASE
type nlattr[TYPE, PAYLOAD] {
	nla_len		len[parent, int16]
	nla_type	const[TYPE, int16]
	payload		PAYLOAD
} [align_4]
```

and later used as follows:

```
syscall(a buffer[in], b fileoff[int64], c ptr[in, nlattr[FOO, int32]])
```
2018-01-13 12:52:09 +01:00
Dmitry Vyukov
9dc808a65e pkg/ast: refactor Walk
Refactor Walk so that it's possible to abort or wrap walk of child nodes.
Will be needed for future changes.
2018-01-11 11:45:35 +01:00
Dmitry Vyukov
7a4d53c30f pkg/report: add test where we fail to provide good title 2018-01-11 11:45:35 +01:00
Dmitry Vyukov
02a19b646c syz-manager: add comment explaining why we don't set corrupted for repros 2018-01-10 09:41:28 +01:00
Dmitry Vyukov
6bfc81c142 syz-fuzzer: improve kmemleak support
Don't print object size (can change from kernel to kernel
and from config to config).
Fix function extraction regexp (must be non-eager).
Account for MSECS_MIN_AGE.
Ignore some known false positives.
2018-01-09 21:24:29 +01:00
Dmitry Vyukov
1014e5506e pkg/report: ignore kernel/workqueue.c as guilty file 2018-01-08 12:56:44 +01:00
Dmitry Vyukov
66288e0e0b pkg/compiler: add builtin bool type aliases
This adds builtin:

type bool8 int8[0:1]
type bool16 int16[0:1]
type bool32 int32[0:1]
type bool64 int64[0:1]
type boolptr intptr[0:1]

We used to use just int's for bools.
But bool types provide several advantages:
 - make true/false probability equal
 - improve description expressiveness
 - reduce search space (we will take advantage of this later)
2018-01-08 12:52:31 +01:00
Dmitry Vyukov
f01cb93788 pkg/compiler: make signalno a type alias
We don't need compiler support for such things anymore,
now we simply can do:

type signalno int32[0:65]
2018-01-08 12:52:31 +01:00
Dmitry Vyukov
402a0dc87e sys: support type aliases (aka typedefs)
Complex types that are often repeated can be given short type aliases using the
following syntax:

```
type identifier underlying_type
```

For example:

```
type signalno int32[0:65]
type net_port proc[20000, 4, int16be]
```

Then, type alias can be used instead of the underlying type in any contexts.
Underlying type needs to be described as if it's a struct field, that is,
with the base type if it's required. However, type alias can be used as syscall
arguments as well. Underlying types are currently restricted to integer types,
`ptr`, `ptr64`, `const`, `flags` and `proc` types.
2018-01-08 12:52:31 +01:00
Dmitry Vyukov
93b4c6f135 pkg/report: add few more test cases where we fail 2018-01-08 12:46:51 +01:00
Dmitry Vyukov
8dc787547e pkg/report: add tests where we produce bad title 2018-01-06 17:40:52 +01:00
Dmitry Vyukov
a8927abe6c prog: support opt for proc types 2018-01-06 17:40:49 +01:00
Dmitry Vyukov
8e6b9eeb27 pkg/compiler: add bitsize type
This is need for few crypto/xfrm descriptions.
2018-01-06 17:40:36 +01:00
Dmitry Vyukov
bb0359b914 pkg/ipc: always prepend handshake errors with executor pid
Helps to understand what program caused it.
2018-01-06 17:39:19 +01:00
Dmitry Vyukov
053171eaf2 pkg/csource: fix build of generated files
On another machine both clang and gcc produce:

test.c:163:32: error: invalid suffix "+procid" on integer constant
       *(uint32_t*)0x20001004 = 0x25dfdbfe+procid*4;

Not sure why this wasn't caught on buildbot.
2018-01-06 15:26:40 +01:00
Dmitry Vyukov
7b28cc9307 pkg/report: add few tests where we mis-detect title/guilty file 2018-01-06 15:10:54 +01:00
Dmitry Vyukov
342feda2bf pkg/report: don't treat CONFIG_DEBUG_OBJECTS debug output as bugs 2018-01-06 14:54:09 +01:00
Dmitry Vyukov
6deb615310 sys/linux: fix some copy-paste errors 2017-12-28 19:16:42 +01:00
Dmitry Vyukov
f9e22d6230 pkg/email: don't add <> to email when name is empty
Just unnecessary clutter.
2017-12-28 08:51:39 +01:00
Dmitry Vyukov
086787dd7e pkg/csource: tidy up generated code a bit
Remove dup newlines around includes.
Makes int values shorter if not hurting readability.
Increase line len to 80.
Remove {} when not needed during copyout.
2017-12-27 20:02:58 +01:00
Dmitry Vyukov
fd3e9f2b97 executor: introduce uint64/32/16/8 types
The "define uint64_t unsigned long long" were too good to work.
With a different toolchain I am getting:

cstdint:69:11: error: expected unqualified-id
  using ::uint64_t;
          ^
executor/common.h:34:18: note: expanded from macro 'uint64_t'

Do it the proper way: introduce uint64/32/16/8 types and use them.

pkg/csource then does s/uint64/uint64_t/ to not clutter code with
additional typedefs.
2017-12-27 11:15:04 +01:00
Dmitry Vyukov
34c18f5f43 executor: fix another format bug
Detected only by clang.
2017-12-27 10:21:12 +01:00
Dmitry Vyukov
09c8f4c00a pkg/report: add more cases where we fail to parse reports 2017-12-27 09:18:26 +01:00
Dmitry Vyukov
17f5c9e05f pkg/csource: add top-level repeat loop
Even if all 3 levels of processes in executor exit,
execprog will still recreate them.
Model the same in csource.
This matters when the inner process kills loop
and then everything stops.
2017-12-27 09:18:26 +01:00
Dmitry Vyukov
c1d8c1b352 pkg/csource: simplify generated code
We already have procid variable, no need to introduce i.
2017-12-27 09:18:26 +01:00
Dmitry Vyukov
b7b7ac19fd executor: check format strings
I see a crash which says:

	#0: too much cover 0 (errno 0)

while the code is:

	uint64_t n = ...;
	if (n >= kCoverSize)
		fail("#%d: too much cover %u", th->id, n);

It seems that the high part of n is set, but we don't see it.

Add printf format attribute to fail and friends and fix all similar cases.
Caught a bunch of similar cases and a missing argument in:

exitf("opendir(%s) failed due to NOFILE, exiting");
2017-12-27 09:18:26 +01:00
Dmitry Vyukov
6f03c35620 dashboard/app: extract fixing tags from commits
Support the new scheme of associating fixing commits with bugs.
Now we provide a tag along the lines of:

Reported-by: <syzbot+a4a91f6fc35e102@syzkaller.appspotmail.com>

The tag is supposed to be added to the commit.
Then we parse commit logs and extract these tags.

The final part on the dashboard is not ready yet,
but syz-ci should already parse and send the tags.
2017-12-27 09:09:18 +01:00
Dmitry Vyukov
8e40909025 pkg/csource: mimic the way syscalls are scheduled in executor
Currently csource uses completely different, simpler way of scheduling
syscalls onto threads (thread per call with random sleeps).
Mimic the way calls are scheduled in executor.

Fixes #312
2017-12-22 18:55:38 +01:00
Dmitry Vyukov
26cd53f078 executor: remove dead code
doexit already contains an infinite loop.
2017-12-22 13:42:27 +01:00
Dmitry Vyukov
3645389673 pkg/csource: fix handling of proc types
Generated program always uses pid=0 even when there are multiple processes.
Make each process use own pid.

Unfortunately required to do quite significant changes to prog,
because the current format only supported fixed pid.

Fixes #490
2017-12-22 11:59:46 +01:00
Dmitry Vyukov
6f298a18e5 pkg/csource: limit thread stacks
We always set RLIMIT_AS to 128MB. I've debugged a program with 21 syscalls.
With collide it creates 42 threads. With default stack size of 8MB this
requires: 42*8 = 336MB. Thread creation fails and nothing works.
Limit thread stacks the same way executor does.

Fixes #488
2017-12-22 11:59:46 +01:00
Dmitry Vyukov
7b62abdb0a pkg/csource: fix string escaping bug 2017-12-22 11:59:46 +01:00
Dmitry Vyukov
af9163c763 pkg/report: add test where we fail to detect guilty function 2017-12-19 13:44:03 +01:00
Dmitry Vyukov
779a655b43 pkg/report: add test where we fail to detect corrupted report 2017-12-19 13:39:14 +01:00
Dmitry Vyukov
a87e30dc1b pkg/email: improve parsing of splitted lines
Allow:

full-commit-title-on-next-line

This allows commit titles between 70 and 80 cols with gmail.

Also be more permissive wrt spaces and tabs.
2017-12-19 13:36:40 +01:00
Dmitry Vyukov
d30c3e81eb pkg/report: add test for a bug in report parsing 2017-12-18 15:34:08 +01:00
Dmitry Vyukov
a20097eafe syz-manager, syz-fuzzer: allow re-minimizing/re-smashing inputs
By default we don't re-minimize/re-smash programs from corpus,
it takes lots of time on start and is unnecessary.
However, when we improve/fix minimization/smashing,
we may want to.

Introduce corpus database versions and allow to re-minimize/re-smash
on version bumps.
2017-12-18 14:10:56 +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
d5beb42ace pkg/csource: make strings more readable
If string contains a file name or a crypto alg name,
don't escape it all to hex.
2017-12-17 11:39:14 +01:00
Dmitry Vyukov
a33677f8bf prog: use dense indexes for copyout instructions
Fixes #174
2017-12-17 11:39:14 +01:00
Dmitry Vyukov
fea5478f46 prog: add DeserializeExec
Factor out program parsing from pkg/csource.
csource code that parses program and at the same time
formats output is very messy and complex.
New aproach also allows to understand e.g.
when a call has copyout instructions which is
useful for better C source output.
2017-12-17 11:39:14 +01:00
Dmitry Vyukov
431d3c90b1 pkg/csource: refactor
csource.go is too large and messy.
Move Build/Format into buid.go.
Move generation of common header into common.go.
Split generation of common header into smaller managable functions.
2017-12-17 11:39:14 +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
eaeccee1d7 pkg/report: add another test 2017-12-17 11:39:14 +01:00
Dmitry Vyukov
019cf5f235 sys: move test syscalls to a separate target
We have them in linux solely for historical reasons.

Fixes #462
2017-12-17 11:39:14 +01:00
Andrey Konovalov
ea8dc17ee9 executor: fix macros in common.h 2017-12-14 08:54:55 +01:00
Andrey Konovalov
06ea774dca pkg/report: fix __this_cpu_* report header call trace capture 2017-12-13 19:48:13 +01:00
Dmitry Vyukov
414a185f4d pkg/report: add another corruped report format 2017-12-12 15:35:21 +01:00
Dmitry Vyukov
433029d5d4 pkg/report: add another guilty file test 2017-12-12 14:23:28 +01:00
Dmitry Vyukov
32f694fc72 pkg/report: properly infer kernel location if kcov is not enabled
We used to infer kernel source location based on __sanitizer_cov_trace_pc symbol.
But it's not present if KCOV is not enabled.
Look at more symbols.
2017-12-12 14:02:59 +01:00
Dmitry Vyukov
4224245438 pkg/report: add few more corrupted reports 2017-12-12 13:51:27 +01:00
Dmitry Vyukov
867fe6a840 pkg/report: improve using __this_cpu_add() in preemptible code report 2017-12-12 13:40:08 +01:00
Dmitry Vyukov
1b3ae9a6d0 pkg/report: handle syzkaller binaries
syzkallerNNN binaries are coming from pkg/repro.
2017-12-12 13:29:45 +01:00
Dmitry Vyukov
081721ff15 pkg/report: clean guilty files 2017-12-12 12:24:52 +01:00