Commit Graph

387 Commits

Author SHA1 Message Date
Dmitry Vyukov
813f363bff all: fix dup types in func args 2020-07-04 15:05:30 +02:00
Dmitry Vyukov
fcb219b67e all: don't compare string len with 0
For strings it's more readable to compare the string itself with "",
instead of comparing len with 0. Fix all such cases.

Update #1876
2020-07-04 15:05:30 +02:00
Necip Fazil Yildiran
3ff434cc0a executor: enable cgroup/cpuset memory pressure calc.
Enable the cpuset.memory_pressure_enabled flag in the root cpuset.
2020-06-29 11:07:03 +02:00
m00nbsd
a2cdad9d42
executor/netbsd: base nth on 2 (#1874) 2020-06-27 17:24:37 +02:00
Tobias Klauser
1cbaafd119 executor: add support for linux/riscv64
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2020-06-26 16:41:30 +02:00
Alexander Egorenkov
b202c7a8a2 pkg/csource: fix casting of parameters for trampolines
Signed-off-by: Alexander Egorenkov <Alexander.Egorenkov@ibm.com>
2020-06-26 12:01:33 +02:00
Alexander Egorenkov
aea82c003a sys/linux: first 64bit big-endian architecture s390x
* mmap syscall is special on Linux s390x because
  the parameters for this syscall are passed as a struct
  on user stack instead of registers.
* Introduce the SyscallTrampolines table into targets.Target
  to address the above problem.
* There is a bug in Linux kernel s390x which causes QEMU TCG
  to hang when KASAN is enabled. The bug has been fixed
  in the forthcoming Linux 5.8 version. Until then do not enable
  KASAN when using QEMU TCG, QEMU KVM shall have no problems with
  KASAN.

Signed-off-by: Alexander Egorenkov <Alexander.Egorenkov@ibm.com>
2020-06-25 23:08:45 +02:00
Alexander Egorenkov
c655ec77ca executor: fix endianness problem in internet checksum
csum_inet_update does not handle odd number of bytes
on big-endian architectures correctly. When calculating
the checksum of odd number of bytes, the last byte must be
interpreted as LSB on little-endian architectures and
as MSB on big-endian ones in a 16-bit half-word.

Futhermore, the checksum tests assume that the underlying architecture
is always little-endian. When a little-endian machine stores
a calculated checksum into memory, then the checksum's bytes
are automatically swapped. But this is NOT true on a big-endian
architecture.

Signed-off-by: Alexander Egorenkov <Alexander.Egorenkov@ibm.com>
2020-06-19 20:49:11 +02:00
Marco Elver
8e3ab94116 executor: Improve used terminology
Improve used terminology by using better verbs to express the effect of
the whitelist/blacklist.

This also changes executor to exclusively show respectful log messages,
and as per recent conversion, converts the last such case.
2020-06-15 09:56:18 +02:00
m00nbsd
dbce178a0e
sys/netbsd: support multiple vHCI buses (#1822) 2020-06-13 12:10:16 +02:00
Dmitry Vyukov
588020678f all: use more respective language
Some terms are normalised on the technical level
but may be oppressive on a societal level.
Replace them with more technically neutral terms.
See the following doc for a longer version:
https://tools.ietf.org/id/draft-knodel-terminology-00.html
2020-06-11 23:19:34 +02:00
m00nbsd
0f23e882fa
sys/netbsd: add support for fault injection (#1817) 2020-06-11 23:16:52 +02:00
Dmitry Vyukov
3f04838a10 .golangci.yml: make goconst checker more strict 2020-06-07 10:41:01 +02:00
Marco Vanotti
c3e9afb345 executor/fuchsia: Don't map memory as executable.
Fuchsia has strict controls over who can map memory as executable.
Refactoring syz-executor to be able to do that involves a non trivial
amount of work: it needs to run as a fuchsia component and replace stdin
for some other mechanism to communicate with syz-fuzzer (probably a fidl
service and a thin client that proxies stdin/stdout to syz-fuzzer via
ssh).

Mapping memory as executable doesn't seem to be used or needed in
syz-executor at all. After talking with Dmitry, he mentioned that it was
used in a deprecated feature: `syz_execute_func` which would execute
random code. It also allows more scenarios during fuzzing.

For now, I'm removing that option to allow syzkaller continue fuzzing.

This change also refactors all of the error messages adding a string
representation of the `zx_status_t` in error logs.
2020-06-05 16:46:48 -03:00
Dmitry Vyukov
503fd5b2f7 .golangci.yml: enable whitespace checker
Points to bad empty lines very precisely.
2020-06-05 12:23:19 +02:00
Andrey Konovalov
6c68daf098 executor: fix printing null master in netlink_device_change
The issues is only present with verbose debugging enabled.

executor/common_linux.h: In function ‘void netlink_device_change(nlmsg*, int, const char*, bool, const char*, const void*, int, const char*)’:
executor/common_linux.h:380:7: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  380 |  debug("netlink: device %s up master %s: %s\n", name, master, strerror(err));
2020-05-29 09:50:00 +02:00
m00nbsd
96c92ad3ab executor: fix a cast in common_usb_netbsd.h 2020-05-24 00:00:55 +02:00
m00nbsd
1f30020f85 executor: fix a USB define on NetBSD 2020-05-21 12:01:24 +02:00
m00nbsd
df09374f0c executor: use the SYZ_USB define for NetBSD 2020-05-21 09:10:30 +02:00
m00nbsd
49c689a527 executor: fix the types used in common_usb_netbsd.h 2020-05-21 09:10:30 +02:00
m00nbsd
67fa1f59b8 executor: add support for USB fuzzing on NetBSD 2020-05-19 23:07:55 +02:00
Dmitry Vyukov
910f427fd9 executor: exclude syz_kvm_setup_cpu on arm
KVM was removed for ARM.
Improved CI finally allows to catch this.
2020-05-18 11:34:42 +02:00
Dmitry Vyukov
b6fa239fd5 pkg/csource: speed up tests
Tests run for too long.
1. Check only 1 arch per OS in short mode.
2. Dedup options. Turns out we generated 2x duplicates in allOptionsSingle.
2020-05-18 11:34:42 +02:00
Andrey Konovalov
8a9f1e7dbd executor, sys/linux: syz_usb_ep_read/write accept endpoint address
This patch changes syz_usb_ep_read/write pseudo-syscalls to accept endpoint
address as specified in its endpoint descriptor, instead of endpoint index.
2020-05-15 16:30:32 +02:00
Andrey Konovalov
55efafca37 executor: stall unknown usb requests
Also don't fail(), leave that to USB_DEBUG and analyze_control_request().
2020-05-15 16:30:32 +02:00
Michael Tüxen
b3fe7470a4
executor: fix typo (#1737) 2020-05-13 17:50:20 +02:00
Michael Tuexen
c7875f08e1 executor: fix #ifdef condition for remove_dir() 2020-05-13 15:56:14 +02:00
Alexander Potapenko
88a97d1a7a Get rid of "Cross" in variable names
Renamed Target.BrokenCrossCompiler to Target.BrokenCompiler and
Target.CrossCFlags to Target.CFlags

"Everything in Target is about Cross now."

Signed-off-by: Alexander Potapenko <glider@google.com>
2020-05-13 13:05:41 +02:00
Dmitry Vyukov
f40567d255 all: reformat code 2020-05-08 14:02:16 +02:00
Dmitry Vyukov
6c70a1c220 all: replace TRAVIS env var with CI
In preparation to running some tests as github actions.
Both Travis and Github define CI env var, while TRAVIS is, well,
too Travis-specific.

Update #1699
2020-05-07 15:41:50 +02:00
Dmitry Vyukov
9941337c5f pkg/csource: init res var in generated call
It seems that gcc in ubuntu on travis got dumber:

<stdin>: In function ‘execute_call’:
<stdin>:1741:6: error: ‘res’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
cc1: all warnings being treated as errors
compiler invocation: arm-linux-gnueabi-gcc [-o /tmp/syz-executor675297211 -DGOOS_linux=1 -DGOARCH_arm=1 -DHOSTGOOS_linux=1 -x c - -O2 -pthread -Wall -Werror -Wparentheses -Wframe-larger-than=16384 -D__LINUX_ARM_ARCH__=6 -march=armv6 -static -Wno-overflow]

https://travis-ci.com/github/dvyukov/syzkaller/jobs/327487382

Though, we generate the same code and res seems to be initialized on all paths.

Initialize it explicitly.
2020-05-04 20:56:20 +02:00
Dmitry Vyukov
a4d38b39a8 prog: support disabled attribute
Update #477
Update #502
2020-05-04 20:56:20 +02:00
Dmitry Vyukov
3b93a8e003 sys/targets: better detection for missing/broken cross-compilers
1. Detect when compiler is present, but is not functioning
(can't build a simple program, common for Linux distros).

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

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

4. Add better error reporting for syz-env.

Fixes #1606
2020-04-29 16:32:33 +02:00
Dmitry Vyukov
cc8708904d sys/linux: add timeout call attributes
Move additional call/prog timeouts to descriptions.

Due to this logic duplication executor used 50ms
for syz_mount_image, while pkg/csource used 100ms.
2020-04-19 10:26:57 +02:00
Dmitry Vyukov
6fe0f49646 executor: remove more code if ENABLE_NAPI_FRAGS is not set
In some configurations tun_frags_enabled ends up being unused
with a compiler warning and failed build.
Remove mode code if ENABLE_NAPI_FRAGS is not enabled.
2020-04-18 14:37:48 +02:00
Dmitry Vyukov
67234372ef prog: refactor target.MakeMmap
Make MakeMmap return more than 1 call.
This is a preparation for future changes.
Also remove addr/size as they are effectively
always the same and can be inferred from the target
(will also conflict with the future changes).
Also rename to MakeDataMmap to better represent
the new purpose: it's just some arbitrary mmap,
but rather mapping of the data segment.
2020-04-18 14:35:45 +02:00
Andrey Konovalov
db9bcd4b9f executor/usb: don't fail when ath9k is not enabled 2020-04-07 18:21:37 +02:00
Andrey Konovalov
09ff5abc02 csource, executor: add usb emulation feature
The feature gets enabled when /dev/raw-gadget is present and accessible.
With this feature enabled, executor will do chmod 0666 /dev/raw-gadget on
startup, which makes it possible to do USB fuzzing in setuid and namespace
sandboxes. There should be no backwards compatibility issues with syz
reproducers that don't explicitly enable this feature, as they currently only
work in none sandbox.
2020-04-03 12:42:06 +02:00
Andrey Konovalov
47232600c3 executor: split out Linux specific USB code 2020-03-28 11:53:20 +01:00
Dmitry Vyukov
bddb05c5eb executor: fix data race
ThreadSanitizer says:

WARNING: ThreadSanitizer: data race (pid=3)
  Atomic read of size 4 at 0x56360e562f08 by main thread:
    #0 __tsan_atomic32_load <null> (libtsan.so.0+0x64249)
    #1 event_isset executor/common_linux.h:51 (syz-executor.0+0x2cf1f)
    #2 handle_completion executor/executor.cc:886 (syz-executor.0+0x2cf1f)
    #3 execute_one executor/executor.cc:732 (syz-executor.0+0x2da3b)
    #4 loop executor/common.h:581 (syz-executor.0+0x2f1aa)
    #5 do_sandbox_none executor/common_linux.h:2694 (syz-executor.0+0x189d6)
    #6 main executor/executor.cc:407 (syz-executor.0+0x189d6)

  Previous write of size 4 at 0x56360e562f08 by thread T1:
    #0 event_reset executor/common_linux.h:32 (syz-executor.0+0x1f5af)
    #1 worker_thread executor/executor.cc:1048 (syz-executor.0+0x1f5af)
    #2 <null> <null> (libtsan.so.0+0x2b0b6)

  Location is global 'threads' of size 2560 at 0x56360e562f00 (syz-executor.0+0x00000008bf08)

  Thread T1 (tid=6, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x2d55b)
    #1 thread_start executor/common.h:256 (syz-executor.0+0x2d707)
    #2 thread_create executor/executor.cc:1037 (syz-executor.0+0x2d707)
    #3 schedule_call executor/executor.cc:811 (syz-executor.0+0x2d707)
    #4 execute_one executor/executor.cc:719 (syz-executor.0+0x2d707)
    #5 loop executor/common.h:581 (syz-executor.0+0x2f1aa)
    #6 do_sandbox_none executor/common_linux.h:2694 (syz-executor.0+0x189d6)
    #7 main executor/executor.cc:407 (syz-executor.0+0x189d6)
2020-03-13 13:16:53 +01:00
Andrey Konovalov
d89275f2aa executor, sys/linux: add ath9k usb descriptions
Among other things this changes timeout for USB programs from 2 to 3 seconds.

ath9k fuzzing also requires ath9k firmware to be present, so system images
need to be regenerated with the updated script.
2020-03-13 07:44:43 +01:00
Dmitry Vyukov
e7caca8e1e executor: minor cleanup of android sandbox
Fix code formatting, clang-tidy warnings, minor style nits.
2020-03-11 12:09:17 +01:00
Dmitry Vyukov
3d010fa6c3 executor: fix clang-tidy warnings 2020-03-11 11:59:39 +01:00
mspectorgoogle
e103bc9e1b
executor: add seccomp support for Android
This adds support for the seccomp filters that are part of Android into
the sandbox.  A process running as untrusted_app in Android has a
restricted set of syscalls that it is allow to run.  This is
accomplished by setting seccomp filters in the zygote process prior to
forking into the application process.  The seccomp filter list comes
directly from the Android source, it cannot be dynamically loaded from
an Android phone because libseccomp_policy.so does not exist as a
library on the system partition.
2020-03-11 11:21:36 +01:00
Andrei Vagin
40bcfdd59e executor: don't exit if NETLINK_GENERIC isnt' supported
NETLINK_GENERIC isn't supported in gVisor.

Fixes: c5ed587f4a ("wireguard: setup some initial devices in a triangle")
Signed-off-by: Andrei Vagin <avagin@google.com>
2020-02-27 09:31:19 +01:00
Dmitry Vyukov
5e0e1d1450 executor: uncomment accidentially commented code
unshare(CLONE_NEWPID) was commented out in 4428511d10 accidentially.
Uncomment it.
Spotted by @xairy:
4428511d10 (r37456572)
2020-02-24 16:05:43 +01:00
Dmitry Vyukov
4428511d10 sys/linux: add NETLINK_RDMA descriptions 2020-02-21 17:38:10 +01:00
Dmitry Vyukov
135c18aadb tools: add script that checks copyright headers
Fixes #1604
2020-02-18 16:05:10 +01:00
Dmitry Vyukov
39cd0f85a1 executor: disable IFF_NAPI_FRAGS
Update #1594
2020-02-18 10:31:02 +01:00
Jason A. Donenfeld
c5ed587f4a
wireguard: setup some initial devices in a triangle
* wireguard: setup some initial devices in a triangle

The fuzzer will wind up undoing some of this, which is fine, but at
least it now has the chance of hitting some other paths it wasn't
before.

Closes: #1599

* wireguard: make code ugly after `make generate` pass

* wireguard: get rid of unused structs that are still interesting

* wireguard: compile in C++ mode with gcc 7

Complex designated initializers are only supported in C++ mode from gcc
8, and for whatever reason syzkaller wants to be compiled in C++ mode.

* wireguard: add braces around debug statements for checker

* wireguard: regenerate go source
2020-02-13 15:28:57 +01:00