Commit Graph

611 Commits

Author SHA1 Message Date
Dmitry Vyukov
8c9738f9c7 pkg/build: support bazel in CompilerIdentity 2018-06-22 16:40:45 +02:00
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