Commit Graph

731 Commits

Author SHA1 Message Date
Marco Vanotti
37a6ea34f1 pkg/compiler: add error handler in CollectUnused
* pkg/compiler: Add error handler in `CollectUnused`.

This commit adds an error handler for the `CollectUnused` function. The
error handler just panics on any error, but is useful for debugging.

The error handler is used any time `comp` finds an error, and if it's
missing, it will panic due to a `nil` pointer dereference. At least now
we get a better understanding of the errors.

The only user of `CollectUnused` is `sys/fuchsia/fidlgen`, which is
failing now and will be fixed in a future commit.

The output message looks like this:
```
panic: could not collect unused nodes. fidl_net-stack.txt:110:15:
unknown type zx_chan_zircon_ethernet_Device_client
```

* pkg/compiler Better error handling in CollectUnused

This commit changes the default error handler for compiler to
`ast.LoggingHandler`, meaning that if `nil` is passed as an error
handler, `LoggingHandler` will be used instead.

`CollectUnused` now returns an error if any of the subfunctions produce errors.

`fidlgen` is the only caller of `CollectUnused`, and now checks for errors
as well.

* pkg/compiler Add tests for CollectUnused

This commit adds basic tests for the CollectUnused function. There's one
test that checks that it returns the right nodes, and another one that
makes sure that it returns errors when needed.

To make the test clearer, I had to add the error handler as an explicit
parameter in `CollectUnunsed`, instead of using the default one. This
avoid printing garbage in the logs. The `TestCollectUnusedError` function
uses a nopErrorHandler to avoid printing anything.

* pkg/compiler fix presubmit warnings
2018-11-21 02:37:06 +01:00
Dmitry Vyukov
9aca6b5240 pkg/vcs: also recognize Tested-by: git commit tags
For context see:
https://groups.google.com/d/msg/syzkaller-bugs/xiSF9GdiikU/uBoyYyf3AQAJ
2018-11-20 14:20:38 +01:00
Greg Steuck
9bc2a903f0 openbsd: enable packet injection 2018-11-19 20:29:38 -08:00
Dmitry Vyukov
d8004ff2dc pkg/compiler: add vma64 type
8-byte vma is needed in several places in linux descriptions.
2018-11-17 15:46:37 -08:00
Greg Steuck
538a105600 executor: OpenBSD network package injection
Squash of:

* Doc typo

* Ported some tun related functions.

* Copy vnet.txt from linux to openbsd.

* Simplified syz_emit_ethernet and stubbed out vnet.txt.

* Undo clang-format header sorting: headers are order sensitive.

* Uniquify tap devices by pid.

* clang-format off for includes

* Happier clang-format.

* Partially revert "Uniquify tap devices by pid."

Just rely on procid magic instead of getting it from a flag.
2018-11-17 15:42:37 -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
Julia Hansbrough
b08ee62aec [fuchsia] SSH fix and build invocation fix.
SSH keys are now included at the fx clean-build config.

A proper escape sequence looked weird so use a string literal to pass
that config.

Fixed some typos I found while debugging.
2018-11-16 11:58:29 -08:00
Julia Hansbrough
3a41052e6a [fuchsia] Fix typo in Fuchsia build.
Hey--so I *don't* know a particularly efficient way to test syz-ci right
now.

There's no good config I can find for just running it locally, and I
couldn't find any good unit tests for this function in particular, and
running it manually on a ci server isn't super-appealing since I'd have
to clobber the configuration there to point to my repo instead of the
canonical repo, pull from there, etc.

Do you have any good ideas for testing this before it rolls out?  In
particular I want the invocation to look exactly like:

./scripts/fx set x64 --packages garnet/packages/products/sshd --args 'extra_authorized_keys_file="//.ssh/authorized_keys"'

I thought I'd escaped it properly last time, but, since I couldn't test
it, clearly I goofed.  I *think* this does the right thing but I'd love
a sanity check.  Thanks!
2018-11-15 09:31:46 -08:00
Julia Hansbrough
5f5f6d14e8 [fuchsia] Fix Fuchsia build.
* Needed to clean out the build on the main host. We switched to a
"petal" layout which required a complete rebuild.

* Update SSH interface.  SSH keys have to be set at buildtime via
--args.

* Update fvm.blk location.
2018-11-12 19:07:01 -08:00
Anton Lindqvist
d55a06c0bf pkg/report: do not interpret reorder_kernel lines as a crash on OpenBSD
Sometimes the reorder_kernel error message is truncated causing the current
ignore pattern to fail. Instead, simply reject all lines containing
`reorder_kernel' in order to reduce noisy crash reports.
2018-11-12 12:34:06 -08:00
Dmitry Vyukov
1f38e9aef7 executor: fix inclusion of kvm arch-specific code
We use GOOS now to figure out target arch
(which can be different from host arch).
2018-10-31 13:43:54 +01: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
Dmitry Vyukov
1ba7fd7e65 all: fix code formatting
Reformat, remove debug leftovers, fix comment style.
2018-10-16 13:57:24 +02: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
751b7baf94 Android: Fix sandbox implementation
My test harness for this code performed some steps that are not
performed when syz-executor is invoked directy.

Specifcally, we need to operate from a directory under /data/data,
and have the correct UID/GID set as the owner of the directory.

My test harness now correctly sets these, all sandbox operations
succeed, and loop() is invoked.
2018-10-12 16:39:26 +02:00
Dmitry Vyukov
ba6ddb4336 pkg/report: improve OpenBSD output parsing
OpenBSD produces \n\r for new lines and split output at 79 column.
Handle both of these things.
2018-10-11 19:47:32 +02:00
Dmitry Vyukov
c3772ff106 pkg/email, pkg/vcs: test that OpenBSD-style commits are handled
OpenBSD does not use "first line is title" convention,
so test that this is parsed properly.
Also test that multi-line fix/dup commands are properly parsed.
2018-10-11 19:47:32 +02:00
Scott Graham
5f818b4b9f executor: Fuchsia: Use zx_task_resume_from_exception()
zx_task_resume() is deprecated; switch to using
zx_task_resume_from_exception() instead.
2018-10-10 19:45:24 +02:00
Dmitry Vyukov
ba8cd6d708 pkg/report: ignore arch/.*/mm/physaddr.c as guilty file
This is called from kfree in the added test.
We already ignore everything related to kmalloc/free
and e.g. arch/.*/mm/fault.c, so it looks reasonable
to ignore this one too.
2018-10-10 17:32:28 +02:00
Dmitry Vyukov
a9495352a0 pkg/host: improve KMEMLEAK detection
EBUSY is returned when KMEMLEAK is in fact turned off,
not when scanning is already turned off.
That can't be recovered.
So instead check that we can write to the file in the check
function and give useful diagnostics.
2018-10-10 15:38:06 +02:00
Dmitry Vyukov
adedaf77a1 executor: tune memcg container logic
The current memcg container seems to lead to lots of hangs/stalls.
Presumably the problem is with oom_score_adj and KASAN.
Executor process tree eats all memory and then the leaf process is killed
but the memory is not returned to memcg due to KASAN quarantine;
and the parent processes are protected from killing with oom_score_adj=-1000.
As the result the kernel locks up.

1. Don't use oom_score_adj=-1000. Instead bump leaf process score to 1000 (kill always).
2. Increase size of memcg to be larger than expected KASAN quarantine size.
2018-10-10 14:22:09 +02:00
Dmitry Vyukov
41e4b32952 pkg/report: ignore printk as guilty file 2018-09-28 16:46:41 +02:00
Dmitry Vyukov
7296c0747f pkg/host: improve KMEMLEAK support
Rewind kmemleak fd before reading it second time,
otherwise we will read truncated reports.

Auto-learn what leak reports we've already seen
and ignore them in future. This is required because
there are some false positives and some fire too frequently.
So now we will hit each leak only once per manager run,
but we still will try to reproduce them.
2018-09-28 14:57:20 +02:00
Dmitry Vyukov
a6143bc982 pkg/report: improve KMEMLEAK report parsing
Skip few more common allocation functions.
2018-09-28 14:57:20 +02:00
Dmitry Vyukov
0c2fa87bc6 executor: fix build on newer linux distros
This sucks a lot, but ebtables.h is now broken too on Debian 4.17:

ebtables.h: In function ‘ebt_entry_target* ebt_get_target(ebt_entry*)’:
ebtables.h:197:19: error: invalid conversion from ‘void*’ to ‘ebt_entry_target*’
2018-09-27 15:34:52 +02:00
Dmitry Vyukov
98b28ead6c pkg/report: fix few fuzz bugs
Improve go-fuzz fuzzer function and fix few new bugs it finds:
1. Panic in linux parser (bad).
2. Akaros can report empty rep.Report.
3. Fuchsia can return empty rep.Report.
2018-09-27 12:50:25 +02:00
Dmitry Vyukov
8899d58437 tools/create-gce-image.sh: mount securityfs and configfs 2018-09-26 14:06:11 +02:00
Dmitry Vyukov
db716d6653 pkg/report: fix guilty file extraction
Account for the case that some file names can appear _before_ crash report starts.
Start extracting guilty file starting from StartPos.
2018-09-26 12:02:43 +02:00
Alexander Popov
0e7547d77c executor: make the debug output useful for race condition debugging
Sometimes race conditions are reproduced by syz-execprog and are not
reproduced by the programs generated with syz-prog2c. In such cases
it's very helpful to know when exactly the fuzzing syscalls are executed.

Unfortunately, adding timestamps to the output of the original 'debug'
mode doesn't work. This mode provides very verbose output, which slows
down executor and breaks the repro.

So let's make the executor debug output less verbose and add
the timestamps.

Signed-off-by: Alexander Popov <alex.popov@linux.com>
2018-09-24 14:55:35 +02:00
Dmitry Vyukov
684e7e3250 pkg/report: ignore more str* functions 2018-09-24 10:59:44 +02:00
Anton Lindqvist
e029c3e058 pkg/symbolizer: favor portable nm(1) format
On OpenBSD, nm(1) does not support the `-S' option.

The order of symbols from nm(1) varies between platforms, therefore rework the
test case to cope with that.

Fixes #723
2018-09-24 10:12:38 +02:00
Dmitry Vyukov
9a6f6af645 syz-ci: upload coverage reports to GCS
Upload coverage reports from all managers to GCS
after 6 hours of runtime (to make it more apples-to-apples).
2018-09-20 18:29:38 +02:00
Dmitry Vyukov
6c662d569b executor: fix build
Move debug_dump_data back to executor.cc.
debug_dump_data in common_linux.h does not play well
with pkg/csource debug stripping logic. It strips a large
random piece of code since it thinks debug_dump_data
definition is actually debug_dump_data call site.
2018-09-20 14:46:58 +02:00
Anton Lindqvist
5f78ab4b81 executor: move debug_dump_data() into common_linux.h
Compiling the executor on OpenBSD currently fails:

  executor/executor.cc:1316:6: error: unused function 'debug_dump_data'
2018-09-20 11:17:14 +02:00
Dmitry Vyukov
98f4a9612d executor: make sandboxes more modular
Currently we have a global fixed set of sandboxes,
which makes it hard to add new OS-specific ones
(all OSes need to updated to say that they don't
support this sandbox).
Let it each OS say what sandboxes it supports instead.
2018-09-17 11:39:04 +02:00
Zach Riggle
0eca949a6c RFC: android: Add support for untrusted_app sandboxing (#697)
executor: add support for android_untrusted_app sandbox

This adds a new sandbox type, 'android_untrusted_app', which restricts
syz-executor to the privileges which are available to third-party applications,
e.g. those installed from the Google Play store.

In particular, this uses the UID space reserved for applications (instead of
the 'setuid' sandbox, which uses the traditional 'nobody' user / 65534)
as well as a set of groups which the Android-specific kernels are aware of,
and finally ensures that the SELinux context is set appropriately.

Dependencies on libselinux are avoided by manually implementing the few
functions that are needed to change the context of the current process,
and arbitrary files.  The underlying mechanisms are relatively simple.

Fixes google/syzkaller#643

Test: make presubmit
Bug: http://b/112900774
2018-09-17 11:33:11 +02:00
Dmitry Vyukov
fd85ed4885 pkg/runtest, pkg/csource: don't run tests on openbsd
The tests are currently broken on openbsd.
2018-09-17 10:59:06 +02:00
Dmitry Vyukov
2e81ad1926 pkg/symbolizer: skip nm tests on non-linux
The test fails on openbsd, and probably everything else other than linux.
2018-09-17 10:53:13 +02:00
Dmitry Vyukov
a0be1d1210 pkg/build: copy image to output dir
For vmm we need a pre-created image.
So if one is provided in the userspace dir,
copy it to output. This should be enough
to get vmm working.

Update #712
2018-09-17 10:53:06 +02:00
Anton Lindqvist
43f25323dc pkg/build: OpenBSD support, currently limited to building a kcov enabled kernel 2018-09-17 10:49:33 +02:00
Anton Lindqvist
e9b51a9024 pkg/build: fix typo in error messages 2018-09-17 10:49:33 +02:00
Dmitry Vyukov
19e9088bb7 syz-ci: use gmake instead of make on openbsd
Update #712
2018-09-13 12:13:54 +02:00
Dmitry Vyukov
0e29942f77 pkg/report: improve KMSAN report parsing
Extract guilty frame from stack.
Add few more ignored functions.
Add more tests.
2018-09-13 11:21:29 +02:00
Dmitry Vyukov
4ae17b1f4c pkg/instance: support injected boot for vmm
If pkg/build produces a kernel, inject it into vmm config too.
This will allow continuous build with vmm VM type.

Update #712
2018-09-11 16:10:50 +02:00
Dmitry Vyukov
ff2962ae80 syz-ci: de-hardcode kernel object file names
We used to have this list in syz-ci and syz-managers.
Now we have kernel object in sys/targets, so use it instead.

Update #712
2018-09-11 15:43:55 +02:00
Dmitry Vyukov
a54c2b7b92 syz-ci: de-hardcode list of VMs that support overcommit
We currently have this list in multiple places (somewhat diverged).
Specify this "overcommit" property in VM implementations.
In particular, we also want to allow overcommit for "vmm" type.

Update #712
2018-09-11 15:33:45 +02:00
Dmitry Vyukov
472947468d pkg/vcs: add openbsd support
This just says that we want to use git to checkout OpenBSD
without any special/complex features.

Update #712
2018-09-11 14:47:38 +02:00
Dokyung Song
11c256cdcd sys/fuchsia: prune unused structs in syscall description generated by fidlgen
After generating syscall description for fidl files using fidlgen, prune
all unused structs using the exact same mechanism used by the compiler's
check for unused structs. This allows the FIDL compiler to support
modular compilation; it does not need to have global knowledge of
whether each struct is used or not.
2018-09-11 13:01:53 +02:00
Dmitry Vyukov
e3d1d545d3 executor: reset oom_score_adj for test process
oom_score_adj is inherited, so we need to reset it to 0.
2018-09-11 12:39:25 +02:00