aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource/common.go
Commit message (Collapse)AuthorAgeFilesLines
* pkg/csource: do not delete comments inside macrosAleksandr Nogikh2022-01-131-1/+1
| | | | This prevents syzkaller from replacing /*{{{NAME}}}*/ within them.
* all: replace collide mode by `async` call propertyAleksandr Nogikh2021-12-101-5/+5
| | | | | | | | | | | | | Replace the currently existing straightforward approach to race triggering (that was almost entirely implemented inside syz-executor) with a more flexible one. The `async` call property instructs syz-executor not to block until the call has completed execution and proceed immediately to the next call. The decision on what calls to mark with `async` is made by syz-fuzzer. Ultimately this should let us implement more intelligent race provoking strategies as well as make more fine-grained reproducers.
* all: refactor fault injection into call propsAleksandr Nogikh2021-09-221-1/+1
| | | | | | | | | | | | Now that call properties mechanism is implemented, we can refactor fault injection. Unfortunately, it is impossible to remove all traces of the previous apprach. In reprolist and while performing syz-ci jobs, syzkaller still needs to parse the old format. Remove the old prog options-based approach whenever possible and replace it with the use of call properties.
* sys/targets: fix darwin reproducersPatrick Meyer2021-09-021-3/+3
| | | | | | | | Using clang++ as CPP isn't supported by syzkaller. Note that g++ is a symlink to clang++ on macOS. Install gcc from from homebrew instead. Also removing -static, as macOS actively breaks and discourages this: https://developer.apple.com/library/archive/qa/qa1118/_index.html
* sys/targets: add darwin/amd64 targetPatrick Meyer2021-05-201-0/+3
|
* sys/linux: add ieee802154 descriptionsDmitry Vyukov2021-02-121-0/+1
|
* pkg/csource: setup sysctl's in C reproducersDmitry Vyukov2020-10-281-0/+1
| | | | | | Sysctl's are not captured as part of reproducers. This can result in failure to reproduce a bug on developer machine. Include sysctl setup as part of C reproducers.
* sys/targets: add OS/Arch name constsDmitry Vyukov2020-10-261-5/+0
| | | | | | | | | | | | We use strings to identify OS/Arch. These strings are duplicated throughout the code base massively. golangci-lint points to possiblity of typos and duplication. We already had to define these names in pkg/csource and disable checking for prog package. A future change triggers such warnings in another package. Add OS/Arch name consts to sys/targets so that they can be used to refer to OS/Arch. Use the consts everywhere.
* all: integrate with mac80211_hwsimAleksandr Nogikh2020-09-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Two virtual wireless devices are instantiated during network devices initialization. A new flag (-wifi) is added that controls whether these virtual wifi devices are instantiated and configured during proc initialization. Also, two new pseudo syscalls are added: 1. syz_80211_inject_frame(mac_addr, packet, packet_len) -- injects an arbitrary packet into the wireless stack. It is injected as if it originated from the device identitied by mac_addr. 2. syz_80211_join_ibss(interface_name, ssid, ssid_len, mode) -- puts a specific network interface into IBSS state and joins an IBSS network. Arguments of syz_80211_join_ibss: 1) interface_name -- null-terminated string that identifies a wireless interface 2) ssid, ssid_len -- SSID of an IBSS network to join to 3) mode -- mode of syz_80211_join_ibss operation (see below) Modes of operation: JOIN_IBSS_NO_SCAN (0x0) -- channel scan is not performed and syz_80211_join_ibss waits until the interface reaches IF_OPER_UP. JOIN_IBSS_BG_SCAN (0x1) -- channel scan is performed (takes ~ 9 seconds), syz_80211_join_ibss does not await IF_OPER_UP. JOIN_IBSS_BG_NO_SCAN (0x2) -- channel scan is not performed, syz_80211_join_ibss does not await IF_OPER_UP. Local testing ensured that these syscalls are indeed able to set up an operating network and inject packets into mac80211.
* pkg/csource: add comment re ignoring cpp errorsDmitry Vyukov2020-08-141-1/+8
| | | | Clarify why we ignore cpp errors.
* executor: remove block commentsDmitry Vyukov2020-08-041-1/+1
| | | | | | | | | 1. We don't generally use /* */ block comments, few precedents we have are inconsistent with the rest of the code. 2. pkg/csource does not strip them from the resulting code. Remove the cases we have and add a test to prevent new ones being added.
* all: initialize vhci in linuxTheOfficialFloW2020-07-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * all: initialize vhci in linux * executor/common_linux.h: improve vhci initialization * pkg/repro/repro.go: add missing vhci options * executor/common_linux.h: fix type and add missing header * executor, pkg: do it like NetInjection * pkg/csource/csource.go: do not emit syz_emit_vhci if vhci is not enabled * executor/common_linux.h: fix format string * executor/common_linux.h: initialize with memset For som reason {0} gets complains about missing braces... * executor/common_linux.h: simplify vhci init * executor/common_linux.h: try to bring all available hci devices up * executor/common_linux.h: find which hci device has been registered * executor/common_linux.h: use HCI_VENDOR_PKT response to retrieve device id * sys/linux/dev_vhci.txt: fix structs of inquiry and report packets * executor/common_linux.h: remove unnecessary return statement and check vendor_pkt read size * executor/common_linux.h: remove unnecessary return statement and check vendor_pkt read size * sys/linux/dev_vhci.txt: pack extended_inquiry_info_t * sys/linux/l2cap.txt: add l2cap_conf_opt struct * executor/common_linux.h: just fill bd addr will 0xaa * executor/common_linux.h: just fill bd addr will 0xaa
* csource, executor: add usb emulation featureAndrey Konovalov2020-04-031-0/+1
| | | | | | | | | 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.
* pkg/csource: rename some optionsDmitry Vyukov2019-11-161-8/+8
| | | | | Rename some options in preparation for subsequent changes which will align names across the code base.
* executor: refactor sandbox flagsDmitry Vyukov2019-11-161-5/+5
| | | | In preparation for future changes.
* executor: rename some macrosDmitry Vyukov2019-11-161-30/+30
| | | | | Rename some macros in preparation for subsequent changes which will align names across the code base.
* pkg/csoruce: test that executor does not mis-spell any of the SYZ_* macrosDmitry Vyukov2019-11-161-14/+17
|
* executor: move fixed pci devlink handle into network namespaceJiri Pirko2019-11-031-0/+1
| | | | | | | | In case there is a fixed pci devlink handle "pci/pci/0000:00:10.0" on the system (initial network namespace), it is moved to a working network namespace. Signed-off-by: Jiri Pirko <jiri@mellanox.com>
* executor, host, csource: Add support to enable KCSANMarco Elver2019-10-041-0/+1
| | | | | | | | | By default, the current KCSAN .config does not enable KCSAN during boot, since we encounter races during boot which would prevent syzkaller from ever executing. This adds support to detect if KCSAN is available, and enables it on the fuzzer host.
* pkg/csource: fix failing syz-runtest for NetBSDSiddharth M2019-08-211-0/+1
| | | | | | * pkg/csource: fix failing syz-runtest for NetBSD * update common.go
* executor: implement support for leak checkingDmitry Vyukov2019-05-201-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Leak checking support was half done and did not really work. This is heavy-lifting to make it work. 1. Move leak/fault setup into executor. pkg/host was a wrong place for them because we need then in C repros too. The pkg/host periodic callback functionality did not work too, we need it in executor so that we can reuse it in C repros too. Remove setup/callback functions in pkg/host entirely. 2. Do leak setup/checking in C repros. The way leak checking is invoked is slightly different from fuzzer, but much better then no support at all. At least the checking code is shared. 3. Add Leak option to pkg/csource and -leak flag to syz-prog2c. 4. Don't enalbe leak checking in fuzzer while we are triaging initial corpus. It's toooo slow. 5. Fix pkg/repro to do something more sane for leak bugs. Few other minor fixes here and there.
* all: add optional close_fds feature to reproducersAndrey Konovalov2019-04-091-0/+1
| | | | | | | | Instead of always closing open fds (number 3 to 30) after each program, add an options called EnableCloseFds. It can be passed to syz-execprog, syz-prog2c and syz-stress via the -enable and -disable flags. Set the default value to true. Also minimize C repros over it, except for when repeat is enabled.
* csource: use /*FOO*/ instead of [[FOO]]Andrey Konovalov2019-04-091-1/+1
| | | | The latter differently confuses different versions of clang-format.
* pkg/runtest: make tests pass on freebsdDmitry Vyukov2019-03-071-0/+2
| | | | | | The problem is stupid: <endian.h> should be included as <sys/endian.h> on freebsd. Pass actual host OS to executor build as HOSTGOOS and use it to figure out how we should include this header.
* pkg/csource: sort sys/types.h to the top on FreeBSDMark Johnston2019-03-071-1/+3
| | | | | sys/types.h is a special header that is required by many other system headers on FreeBSD.
* execprog, stress, prog2c: unify flags to enable additional featuresAndrey Konovalov2019-03-051-2/+3
| | | | | | | | | | | This change makes all syz-execprog, syz-prog2c and syz-stress accept -enable and -disable flags to enable or disable additional features (tun, net_dev, net_reset, cgroups and binfmt_misc) instead of having a separate flag for each of them. The default (without any flags) behavior isn't changed: syz-execprog and syz-stress enabled all the features (provided the runtime supports them) and syz-prog2c disables all of them.
* pkg/csource: add support for creating reproducers on OpenBSDAnton Lindqvist2018-11-171-1/+2
|
* RFC: android: Add support for untrusted_app sandboxing (#697)Zach Riggle2018-09-171-26/+28
| | | | | | | | | | | | | | | | | | | | | 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
* pkg/csource: refactor defineListDmitry Vyukov2018-08-021-76/+35
| | | | | | Make it simpler and shorter. Update #538
* pkg/csource: rafactor option checkingDmitry Vyukov2018-07-311-3/+1
| | | | Update #538
* pkg/csource: rewrite gen.sh in GoDmitry Vyukov2018-07-271-1/+1
| | | | | | | | | | Shell files cause portability problems. On Linux it's hard to install /bin/sh, /bin/bash is not present on *BSD. Any solution is hard to test on Darwin. Don't even want to mention Windows. Just do it in Go.
* pkg/csource: add option to trace syscall resultsDmitry Vyukov2018-07-271-0/+6
| | | | This will be needed for testing of generated programs.
* pkg/csource: tidy generated codeDmitry Vyukov2018-07-271-9/+27
| | | | | | | | | | | 1. Remove unnecessary includes. 2. Remove thunk function in threaded mode. 3. Inline syscalls into main for the simplest case. 4. Define main in common.h rather than form with printfs. 5. Fix generation for repeat mode (we had 2 infinite loops: in main and in loop). 6. Remove unused functions (setup/reset_loop, setup/reset_test, sandbox_namespace, etc).
* executor: overhaulDmitry Vyukov2018-07-241-14/+24
| | | | | | | | | | | | | | | | | Make as much code as possible shared between all OSes. In particular main is now common across all OSes. Make more code shared between executor and csource (in particular, loop function and threaded execution logic). Also make loop and threaded logic shared across all OSes. Make more posix/unix code shared across OSes (e.g. signal handling, pthread creation, etc). Plus other changes along similar lines. Also support test OS in executor (based on portable posix) and add 4 arches that cover all execution modes (fork server/no fork server, shmem/no shmem). This change paves way for testing of executor code and allows to preserve consistency across OSes and executor/csource.
* pkg/csource: support fuchsiaDmitry Vyukov2018-06-291-3/+6
| | | | Lots of assorted heavylifting to support csource on fuchsia.
* Makefile, sys/targets: move all native compilation logic to sys/targetsDmitry Vyukov2018-06-061-1/+1
| | | | | | | | | | | | | | | 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.
* pkg/csource: minimize netdevices and net resetDmitry Vyukov2018-05-171-3/+6
| | | | | | Add separate options to minimize netdevices setup and net namespace reset. Fixes #581
* sys/linux: add cgroup descriptionsDmitry Vyukov2018-03-251-0/+3
|
* all: fix gometalinter warningsDmitry Vyukov2018-03-081-1/+1
| | | | Fix typos, non-canonical code, remove dead code, etc.
* prog: combine RequiresBitmasks and RequiresChecksums into RequiredFeaturesDmitry Vyukov2018-02-191-2/+3
|
* sys/linux: extend netfilter descriptionsDmitry Vyukov2018-01-271-0/+3
|
* executor: introduce uint64/32/16/8 typesDmitry Vyukov2017-12-271-0/+10
| | | | | | | | | | | | | | | 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.
* pkg/csource: refactorDmitry Vyukov2017-12-171-0/+123
| | | | | | | 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.
* pkg/csource: support akarosDmitry Vyukov2017-10-161-2042/+0
|
* executor: write debug output to stderrDmitry Vyukov2017-10-161-2/+2
| | | | | | We print all other output to stderr, write debug output to stderr as well. This does not matter for the main use case of running syz-execprog -debug, but can is helpful if we want to communicate with syz-executor via stdin/stdout.
* executor: include missing headerDmitry Vyukov2017-10-101-3/+6
| | | | writev requires <sys/uio.h>. Include it.
* executor: support fragmentation in syz_emit_ethernetDmitry Vyukov2017-10-021-16/+67
| | | | | | A recent linux commit "tun: enable napi_gro_frags() for TUN/TAP driver" added support for fragmentation when emitting packets via tun. Support this feature in syz_emit_ethernet.
* executor: fix execution of windows syscallsDmitry Vyukov2017-09-271-1/+6
| | | | | First, they must be called with stdcall convention. Second, wrap them in __try/__except because they can crash.
* executor, sys/windows: initial windows supportDmitry Vyukov2017-09-251-54/+59
|
* all: more assorted fuchsia supportDmitry Vyukov2017-09-221-147/+148
|