Commit Graph

438 Commits

Author SHA1 Message Date
Dmitry Vyukov
135c18aadb tools: add script that checks copyright headers
Fixes #1604
2020-02-18 16:05:10 +01:00
Andrey Konovalov
c321812877 docs: link github.com/xairy/raw-gadget 2020-02-06 19:34:17 +01:00
Hye Sung Jung
c8e81ce4c7 docs: fix spelling errors 2020-01-28 17:23:51 +01:00
Dmitry Vyukov
5e48183c6e sys/linux: add ethtool netlink descriptions 2020-01-28 15:08:47 +01:00
Dmitry Vyukov
0e8428d26f tools/syz-check: add limited checking of varlen structs
Stop at the fist varlen field, but check the preceeding ones.
Frequently the varlen array is the last field,
so we should get good checking for these cases.

Update #590
2020-01-23 15:05:21 +01:00
Dmitry Vyukov
9ab9b329d9 sys/linux: check for missing/duplicate netlink attrs
Update #590
2020-01-23 15:05:20 +01:00
Dmitry Vyukov
46961c2ff5 sys/linux: fix more netlink warnings
Handle NLA_BITFIELD32.
Match string attribtues better.
Calculate and check min size for varlen structs.
Fix NLA_UNSPEC size check.
Fix some things in descriptions.

Update #590
2020-01-23 15:05:19 +01:00
Dmitry Vyukov
e4c56f390e tools/syz-check: improve matching netlink attributes
1. Match policies that has a _suffix in our descriptions
(we frequently do this to improve precision or avoid dup names).
2. Rename policies in descriptions to match kernel names.
3. Match policy if there are several such names in kernel.
4. Recognize policies with helper sub-policies.

Update #590
2020-01-22 18:31:15 +01:00
Dmitry Vyukov
02754a8f9a tools/syz-check: check netlink policy descriptions
Overall idea of netlink checking.
Currnetly we check netlink policies for common detectable mistakes.
First, we detect what looks like a netlink policy in our descriptions
(these are structs/unions only with nlattr/nlnext/nlnetw fields).
Then we find corresponding symbols (offset/size) in vmlinux using nm.
Then we read elf headers and locate where these symbols are in the rodata section.
Then read in the symbol data, which is an array of nla_policy structs.
These structs allow to easily figure out type/size of attributes.
Finally we compare our descriptions with the kernel policy description.

Update #590
2020-01-22 12:19:53 +01:00
Dmitry Vyukov
bc8bc756c2 tools/syz-trace2syz/proggen: fix test
For some reason it started using a different syscall...
2020-01-18 21:20:35 +01:00
Dmitry Vyukov
d2f8d5ab46 sys/linux: fix sigset_t/sigaction layout on arm
Update #590
2020-01-18 21:02:24 +01:00
Dmitry Vyukov
773117bf81 tools/syz-check: also check arm/arm64
They mostly duplicate the warnings we already have for amd64/386.
But uncovered few very interesting local things (e.g. epoll_event
is packed only on amd64, so arm/arm64 layout is wrong, but 386
is correct because int64 alignment is different).

Update #590
2020-01-18 21:02:24 +01:00
Dmitry Vyukov
a0f466387d sys/linux: fix 2 netlink data layout bugs
1. Turns out that NLA_F_NESTED is actually used and checked
(nla_parse_nested checks it, while nla_parse_nested_deprecated does not).
Similarly, ipset extensively checks NLA_F_NET_BYTEORDER.
So we need these bits.

2. nla_len must not account for the trailing alighnment padding.
This means we set wrong len for payloads that are not multiple of 4
(int8/int16/strings/arrays/some structs/etc).
2020-01-07 10:02:10 +01:00
Dmitry Vyukov
61f4e7ee54 tools/syz-check: check amd64 and 386 at the same time
Update #590
2019-12-22 19:34:12 +01:00
Dmitry Vyukov
c5907f7c7a tools/syz-check: check templates
Also rename some netfilter types to eliminate massive amounts of template warnings.

Update #590
2019-12-22 11:19:49 +01:00
Dmitry Vyukov
1461be9d82 tools/syz-check: add some TODOs 2019-12-22 10:15:24 +01:00
Dmitry Vyukov
f83f92fd5e tools/syz-check: inject description compilation warnings
Currently we print them as part of `make genereate`,
but nobody reads them, too much output each time.
Don't print them in `make generate` and instead
print in syz-check, the warn files are a good mechanism
to handle "known warnings".
2019-12-20 16:45:34 +01:00
Dmitry Vyukov
ae5ed0b140 pkg/compiler: fix bitfield layout bug
Fixes #1542

Found thanks to syz-check. Update #590
2019-12-20 16:45:34 +01:00
Dmitry Vyukov
20c6855484 prog: refactor bitfields representation
All callers of BitfieldMiddle just want static size (0 for middle).
Make it so: Size for middle bitfields just returns 0. Removes lots of if's.
Introduce Type.UnitSize, which now holds the underlying type for bitfields.
This will be needed to fix #1542 b/c even if UnitSize=4 for last bitfield
Size can be anywhere from 0 to 4 (not necessary equal to UnitSize due to overlapping).
2019-12-19 19:32:45 +01:00
Andrey Konovalov
fa392d3014 tools/create-image.sh: install tcpdump
It's quite useful for debugging network related stuff.
2019-12-19 18:52:51 +01:00
Dmitry Vyukov
fa33c32796 tools/syz-check: don't print our/kernel field name twice if equal 2019-12-18 12:04:56 +01:00
Dmitry Vyukov
6462728414 tools/syz-check: print descriptions compilation errors
If one changes descriptions concurrently with re-running syz-check,
it's likely something won't compile first time. Print errors.
2019-12-18 11:58:49 +01:00
Dmitry Vyukov
1b49002e79 tools/syz-check: don't print line numbers for warnings
Line numbers create huge diffs when lines change slightly.
That's very unhandy b/c we want to look at added/removed warnings.
2019-12-18 10:50:24 +01:00
Dmitry Vyukov
64ca0a3711 tools/syz-check: add description checking utility
syz-check parses vmlinux dwarf, extracts struct descriptions,
compares them with what we have (size, fields, alignment, etc)
and produces .warn files.
This is first raw version, it can be improved in a number of ways.
But it already helped to identify a critical issue #1542
and shows some wrong struct descriptions.

Update #590
2019-12-17 19:03:39 +01:00
Dmitry Vyukov
d13d795888 tools/syz-runtest: debug all programs in debug mode 2019-12-16 19:37:38 +01:00
Andrey Konovalov
d973f52833 executor: update raw gadget interface 2019-12-11 19:20:07 +01:00
Marco Vanotti
607350e438 syz/targets: add SyzExecutorCmd flag
This commit adds a new attribute to syzkaller targets that tells
syzkaller how to invoke the syz-executor command.

Some systems, like Fuchsia, are now building syz-executor as part of the
build, and there is no need to copy it over, or to run it from `/tmp`.
In fact, that might stop working at some time in the future in Fuchsia.

All places that used to copy syz-executor into the target machine will
now check for the SyzExecutorCmd flag, and won't copy it if the flag is
set.
2019-12-09 15:13:49 -08:00
Dmitry Vyukov
d20ee9bd98 tools: add fops_probe utility
fops_probe utility helps to understand what file_operations callbacks
are attached to a particular file. Requries KCOV and KALLSYMS.
Build with:
	g++ tools/fops_probe/fops_probe.cc -Wall -static -o fops_probe
Then copy the binary to target machine and run as:
	./fops_probe /dev/fb0
You should see output similar to:

	ffffffff81bcccb9 vfs_read
	................
	ffffffff83af85c3 fb_read
	ffffffff83b52af5 cirrusfb_sync

	ffffffff81bcd219 vfs_write
	................
	ffffffff83af7fe2 fb_write
	ffffffff83b52af5 cirrusfb_sync

	ffffffff81c1b745 do_vfs_ioctl
	ffffffff83af7ea9 fb_ioctl

	ffffffff81a4ea44 do_mmap
	................
	ffffffff83af716c fb_mmap

which allows to understand what callbacks are associated with /dev/fb0.
2019-12-03 18:48:14 +01:00
Matthew Dempsky
f4b7ed0781 tools/fuchsia: remove custom Go toolchain scripts
These used to be required to build Fuchsia's Go toolchain to build
syz-fuzzer to run on Fuchsia. However, Fuchsia now uses HostFuzzer
mode, so only syz-executor (written in C) needs to run on Fuchsia; all
Go code runs on the Host OS (currently Linux).
2019-11-19 17:20:14 -08:00
Dmitry Vyukov
587cec15e2 pkg/host: add Features.Supported
To reduce diff in future changes. Currently no-op.
2019-11-16 09:58:54 +01:00
Dmitry Vyukov
aa27601f9e pkg/host: rename some features
Rename some features in preparation for subsequent changes
which will align names across the code base.
2019-11-16 09:58:54 +01:00
Dmitry Vyukov
157653cfe7 pkg/csource: rename some options
Rename some options in preparation for subsequent changes
which will align names across the code base.
2019-11-16 09:58:54 +01:00
Andrey Konovalov
90f3b019e4 executor, pkg/host: update usb raw-gadget interface
The patches are being upstreamed and the interface has changed.
2019-11-15 14:53:30 +01:00
Andrey Konovalov
be7a4ab6d8 tools/syz-usbgen: update patch to dump usb ids
The patch doesn't properly work on some kernels, some ids might not be printed.
2019-11-15 14:45:46 +01:00
Dmitry Vyukov
30cb7f98cd pkg/bisect: detect wrong bisections
Detect bisection to merge commits and to commits that don't affect
kernel binary (comments, other arches, whitespaces, etc).
Such bisections are not reported in emails (but shown on web).

Update #1271
2019-11-07 11:07:03 +01:00
Andrey Konovalov
80aca15c2a executor: update the list of raw usb events
The number of reported event types changed.
2019-11-05 15:11:22 +01:00
Zubin Mithra
0a2d7d8293 pkg/bisect: modify Run() to return information about commit
* Modify Run() to return the commit object when a failure occurs on the
oldest tested release(for BisectCause) and latest tested
release(for BisectFix).
* Modify tests to check the returned commit object.
2019-11-05 09:15:56 +01:00
Andrey Konovalov
76630fc947 executor, pkg/host, dashboard/config: rename usb-fuzzer to usb raw-gadget
The interface is being upstreamed and the name has changed.
2019-11-04 15:43:43 +01:00
Dmitry Vyukov
2079602763 pkg/csource: fix lint warnings
CI failed:
https://travis-ci.org/google/syzkaller/jobs/606730911?utm_medium=notification&utm_source=github_status
2019-11-03 14:44:53 +01:00
Jiri Pirko
d40d75d2d7 executor: move fixed pci devlink handle into network namespace
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>
2019-11-03 14:20:59 +01:00
Dmitry Vyukov
4ee855e7ec tools/syz-testbuild: fix too long line 2019-10-22 15:58:22 +02:00
Dmitry Vyukov
084e388155 pkg/vcs: make EnvForCommit return full compiler path
All callers of EnvForCommit need the compiler path,
so move this logic into EnvForCommit to avoid duplication.
Also simplifies tests because test impl can now return
an empty compiler (which should be unused).
2019-10-22 15:41:03 +02:00
Zubin Mithra
a2bdbd8c37 pkg/bisect: add initial testing support for cause bisection
(note: incomplete change)

Refactor existing code as follows:
* Move reusable test utility functions from git_repo_test.go to
pkg/vcs/test_util.go and make them exported.
* Split Run() into Run()+runImpl().
* Change type of bisect.go:env.inst to `instance.BuilderTester`.
Change usage inside syz-testbuild/testbuild.go accordingly.
* Move most of linux.PreviousReleaseTags() into vcs/git.go as
git.previousReleaseTags().
* Allow build.CompilerIdentity to be mocked.

Introduce the following changes:
* instance.BuilderTester is an interface with methods
	BuildSyzkaller()
	BuildKernel()
	Test()
NewEnv() now returns this interface.
* type testEnv implements instance.BuilderTester.
* type testBuilder implements builder interface. Add a entry into table
inside pkg/build/build.go:getBuilder() to return testBuilder object.
2019-10-22 10:09:57 +02:00
Andrew Turner
c59a7cd871 tools: Run 2to3 on check_links.py
The python binary may not be Python 2. Support Python 3 by running the
2to3 conversion tool on it.

This has been tested with both Python 2 and 3.
2019-10-21 15:56:27 +02:00
Zwb
b5268b89c2 tools/create-image.sh: add a new option seek
The usage of current create-image.sh:

    ```
    ./create-image.sh -d=stretch -f=minimal --add-perf

    The options are in the following:

    -d, --distribution         Set on which debian distribution to create
    -f, --feature              Check what packages to install in the image, options are minimal, full
    -s, --seek                 Image size (MB), default 2048 (2G)
    -p, --add-perf             Add perf support with this option enabled

    The default image size may too small (2G) in some debugging scenarios, so change it to configurable.
2019-10-15 12:40:28 +02:00
Dmitry Vyukov
64612bfd3c tools/syz-reprolist: add utility to extract list of reproducers 2019-10-08 12:39:23 +02:00
Dmitry Vyukov
0f33548a39 tools/syz-trace2syz: disable golangci-lint
A new version of golangci-lint started failing trying to build syz-trace2syz
(because we already ignore some files).
Ignore the rest of files to fix the failure.
2019-10-08 12:31:54 +02:00
Marco Elver
b2f369e56e executor, host, csource: Add support to enable KCSAN
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.
2019-10-04 13:44:09 +02:00
Veronica Radu
9d33246a91 sys/linux: add new syscall descriptions for devio and usbmon
Update #533
2019-10-01 13:55:20 +02:00
Andrey Konovalov
2b854f96b1 tools: add syz-expand
The syz-expand tools allows to parse a program and print it including all
the default values. This is mainly useful for debugging, like doing manual
program modifications while trying to come up with a reproducer for some
particular kernel behavior.
2019-09-23 17:13:23 +02:00