Commit Graph

473 Commits

Author SHA1 Message Date
Dmitry Vyukov
bb26bde008 tools/check-copyright.sh: check py and yml files
Update #1699
2020-05-18 11:34:42 +02:00
Dmitry Vyukov
50749f54cd pkg/report: add ParseAll
ParseAll returns all reports in output.
Use it in syz-symbolize.
2020-05-13 20:49:07 +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
8cbfd71747 tools/syz-db: implement memory benchmarking function
syz-db bench loads a corpus and measures memory consumption.
2020-05-05 14:01:52 +02:00
Dmitry Vyukov
a4d38b39a8 prog: support disabled attribute
Update #477
Update #502
2020-05-04 20:56:20 +02:00
Dmitry Vyukov
58ae5e1862 prog: remove StructDesc
Remove StructDesc, KeyedStruct, StructKey and all associated
logic/complexity in prog and pkg/compiler.
We can now handle recursion more generically with the Ref type,
and Dir/FieldName are not a part of the type anymore.
This makes StructType/UnionType simpler and more natural.

Reduces size of sys/linux/gen/amd64.go from 5201321 to 4180861 (-20%).

Update #1580
2020-05-03 12:55:42 +02:00
Dmitry Vyukov
5457883a51 tools/codecov.yml: add
Add configuratio file for codecov.io
2020-05-02 14:12:25 +02:00
Dmitry Vyukov
4d9915573a organize top level files
Remove .gitattributes, we don't have any of these files now.
Move fuzzit.sh -> tools/fuzzit.sh.
2020-05-02 14:12:25 +02:00
Dmitry Vyukov
58da4c35b1 prog: introduce Field type
Remvoe FieldName from Type and add a separate Field type
that holds field name. Use Field for struct fields, union options
and syscalls arguments, only these really have names.

Reduces size of sys/linux/gen/amd64.go from 5665583 to 5201321 (-8.2%).
Allows to not create new type for squashed any pointer.
But main advantages will follow, e.g. removing StructDesc,
using TypeRef in Arg, etc.

Update #1580
2020-05-02 12:16:06 +02:00
Dmitry Vyukov
bc734e7ada prog: rename {PtrType,ArrayType}.Type to Elem
Name "Type" is confusing when referring to pointer/array element type.
Frequently there are too many Type/typ/typ1/t and typ.Type is not very informative.
It _is_ a type, but what's usually more relevant is that it's an _element_ type.
Let's leave type checking to compiler and give it a more meaningful name.
2020-05-01 13:31:17 +02:00
Dmitry Vyukov
e54e9781a4 prog: remove Dir from Type
Having Dir is Type is handy, but forces us to duplicate lots of types.
E.g. if a struct is referenced as both in and out, then we need to
have 2 copies and 2 copies of structs/types it includes.
If also prevents us from having the struct type as struct identity
(because we can have up to 3 of them).

Revert to the old way we used to do it: propagate Dir as we walk
syscall arguments. This moves lots of dir passing from pkg/compiler
to prog package.
Now Arg contains the dir, so once we build the tree, we can use dirs
as before.

Reduces size of sys/linux/gen/amd64.go from 6058336 to 5661150 (-6.6%).

Update #1580
2020-05-01 13:31:17 +02:00
Dmitry Vyukov
136082ab38 pkg/cmdprof: add package
cmdprof simplifies cpu/memory profiling for command line tools. Use as:

	flag.Parse()
	defer cmdprof.Install
2020-04-30 17:18:29 +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
49bb6b93d5 tools/syz-bisect: fix file presence check
1. Filename should be relative to flagCrash, not the current dir.
2. Use osutil.IsExist, os.Stat can fail for other reasons, e.g. no permissions.
3. Dedup filepresence check.
2020-04-29 11:24:49 +02:00
Jouni Hogander
bc0712ac2b pkg/instance: Use syz or c source file when testing
Currenlty only syz file is taken into account when testing.
Use also c source file if available. Still use syz as a "main"
reproducer.
2020-04-29 11:20:26 +02:00
Dmitry Vyukov
0ce7569ee7 pkg/compiler: deduplicate Types in descriptions
Add prog.Ref Type that serves as a proxy for real types
and allows to deduplicate Types in generated descriptions.
The Ref type is effectively an index in an array of types.
Just before serialization pkg/compiler replaces real types
with the Ref types and prepares corresponding array of real types.
When a Target is registered in prog package, we do the opposite
operation and replace Ref's with the corresponding real types.

This brings improvements across the board:
compiler memory consumption is reduced by 15%,
test building time by 25%, descriptions size by 33%.

Before:
$ du -h sys/linux/gen
54M	sys/linux/gen

$ time GOMAXPROCS=1 go test -p=1 -c ./prog
real	0m54.200s
real	0m53.883s

$ time GOMAXPROCS=1 go install -p=1 ./tools/syz-execprog
real	0m27.911s
real	0m27.767s

$ TIME="%e %P %M" GOMAXPROCS=1 time go tool compile ./sys/linux/gen
20.59 100% 3200016
20.97 100% 3445976
20.25 100% 3209684

After:
$ du -h sys/linux/gen
36M	sys/linux/gen

$ time GOMAXPROCS=1 go test -p=1 -c ./prog
real	0m42.290s
real	0m43.230s

$ time GOMAXPROCS=1 go install -p=1 ./tools/syz-execprog
real	0m24.337s
real	0m24.727s

$ TIME="%e %P %M" GOMAXPROCS=1 time go tool compile ./sys/linux/gen
19.11 100% 2764952
19.66 100% 2787624
19.35 100% 2749376

Update #1580
2020-04-26 05:58:31 +02:00
Greg Steuck
1839757871 tools/create-openbsd*: update to 6.7 2020-04-17 07:27:39 +02:00
Dmitry Vyukov
3f3c557402 sys/linux: add some more ipv4/6 addresses
Add few private ipv4/6 addresses that may affect kernel behavior.
2020-04-14 09:11:27 +02:00
Andrey Konovalov
81c5026f57 runtest: fix using configs with namespace/setuid sandbox 2020-04-03 12:42:06 +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
ca1beb07f0 tools/create-image.sh: make sure filesystem root has correct permissions 2020-04-03 12:42:06 +02:00
Jouni Högander
5ed396e666 tools/syz-symbolize: Store crash report if outdir is given
We want to check if the original crash reproducer was generated is
reproduced. We need to generate syzkaller style crash report on
reproducer log and check if hash matches with the original hash.
This patch adds outdir flags to syz-symbolize and stores crashes found
from given log into it.
2020-04-03 11:01:08 +02:00
Dmitry Vyukov
22968402ee tools/create-gce-image.sh: fix sysctl.kernel.hung_task_all_cpu_backtrace=1
Turns out this is not a sysctl, even though it's prefixed with sysctl:
https://groups.google.com/d/msg/syzkaller/EJP7uvY4O-c/XLrhrBqGAQAJ
2020-03-31 15:28:17 +02:00
Dmitry Vyukov
c8d1cc20df tools/create-gce-image.sh: enable sysctl.kernel.hung_task_all_cpu_backtrace=1
The format of this knob has changed again:
https://groups.google.com/d/msg/syzkaller/EJP7uvY4O-c/XLrhrBqGAQAJ
2020-03-30 10:55:36 +02:00
Andrey Konovalov
fd6a38e1fc tools, dashboard: move net.ifnames=0 to create-gce-image.sh
Looks like it affects not only android-5.4.
2020-03-28 12:29:27 +01:00
Dmitry Vyukov
68660b21c2 tools/syz-trace2syz/proggen: fix test for new descriptions 2020-03-24 09:17:26 +01:00
Dmitry Vyukov
0a96a13cb9 tools/syz-check: extend usage docs
Allow to run for only 1 arch and extend docs.
2020-03-18 09:23:24 +01:00
Dmitry Vyukov
9b1f3e6653 prog: control program length
We have _some_ limits on program length, but they are really soft.
When we ask to generate a program with 10 calls, sometimes we get
100-150 calls. There are also no checks when we accept external
programs from corpus/hub. Issue #1630 contains an example where
this crashes VM (executor limit on number of 1000 resources is
violated). Larger programs also harm the process overall (slower,
consume more memory, lead to monster reproducers, etc).

Add a set of measure for hard control over program length.
Ensure that generated/mutated programs are not too long;
drop too long programs coming from corpus/hub in manager;
drop too long programs in hub.
As a bonus ensure that mutation don't produce programs with
0 calls (which is currently possible and happens).

Fixes #1630
2020-03-13 13:16:53 +01:00
Dmitry Vyukov
05359321bb all: fix new golangci-lint warnings
Newer version started producing more warnings. Fix them.
2020-03-13 08:26:02 +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
181be2d924 tools/syz-reprolist: cache errors 2020-03-03 09:35:16 +01:00
Mark Johnston
1253d6f07f tools: specify the search path for find(1) 2020-02-24 10:18:37 +01:00
Mark Johnston
502ca6cde7 tools: avoid hard-coding the path to interpreters
On BSD they are usually installed under /usr/local/.
2020-02-24 10:18:37 +01:00
Dmitry Vyukov
a35df73a56 tools/check-copyright.sh: also check cc/h/S files 2020-02-21 17:56:49 +01:00
Dmitry Vyukov
b6ed147834 prog: dump orig prog if Deserialize panics
We are seeing some one-off panics during Deserialization
and it's unclear if it's machine memory corrpution or
an actual bug in prog. I leam towards machine memory corruption
but it's impossible to prove without seeing the orig program.

Move git revision to prog and it's more base package
(sys can import prog, prog can't import sys).
2020-02-21 10:22:07 +01:00
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