Commit Graph

1088 Commits

Author SHA1 Message Date
Dmitry Vyukov
bfdfc2603c prog: don't fail decoding on non-default out args
We get them in cross-compilation test where an out const
arg has different values in different archs.
No reason to fail deserialization in that case, replace with default
arg instead.
2019-12-21 14:53:37 +01:00
Dmitry Vyukov
bc5869180f sys/linux: fix 240 warnings in descriptions
Sweeping fix of everything up to socket_netlink_route.txt.

Update #590
2019-12-20 16:45:35 +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
4bba9fd162 pkg/compiler: fix alignment of string-formatted values
We used size as alignment, this is very wrong.

Found thanks to syz-check. Update #590
2019-12-20 16:45:34 +01:00
Dmitry Vyukov
08f0467614 sys/test: and another set of bitfield tests
Just trying to get my head around it (and fix this in tests).

Update #1542
2019-12-20 16:45:33 +01:00
Dmitry Vyukov
e30cbdae48 sys/test: and another bitfield test
Just trying to get my head around it (and fix this in tests).

Update #1542
2019-12-19 20:00:44 +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
Dmitry Vyukov
af9047c60a sys/linux: prohibit TIOCSSERIAL
Replace TIOCSSERIAL with TIOCGSERIAL.
TIOCSSERIAL can do nasty things under root, like causing writes to random memory
pretty much like /dev/mem, but this is also working as intended.
For details see:
https://groups.google.com/g/syzkaller-bugs/c/1rVENJf9P4U/m/QtGpapRxAgAJ
https://syzkaller.appspot.com/bug?extid=f4f1e871965064ae689e
TODO: TIOCSSERIAL does some other things that are not dangerous
and would be nice to test, if/when we can sanitize based on sandbox value
we could prohibit it only under sandbox=none.
2019-12-19 19:32:45 +01:00
Dmitry Vyukov
79b211f74b sys/linux: fix caps test for new descriptions 2019-12-18 17:34:36 +01:00
Dmitry Vyukov
52395b6ee8 sys/test: add few other tests for tricky bitfields
Update #1542
2019-12-18 16:42:17 +01:00
Dmitry Vyukov
73c3845438 pkg/compiler: fix incorrect alignment calculation for padding
We assumed that for ConstType alignment is equal to size,
which is perfectly reasonable for normal int8/16/32/64/ptr.
However, padding is also represented by ConstType of arbitrary size,
so if we added 157 bytes of padding that becomes alignment of
the padding field and as the result of the whole struct.
This affects very few structs, but quite radically and quite
important structs.

Discovered thanks to syz-check.

Update #590
2019-12-18 14:44:12 +01:00
Dmitry Vyukov
42dc692776 sys/linux: another batch of syz-check fixes
Update #590
2019-12-18 14:38:24 +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
82b3c9dfee sys/linux: fix few bugs
Fix some descirptions disperancies with kernel and regenerate warnings on next-20191218.
2019-12-18 12:00:12 +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
2f68adff0b sys/linux: support new split sound ioctls
Some sounds ioctls are now explicitly doubled for 32/64 bits. Support that.
Fix mips SOL_SOCKET issues by rearranging includes.
Improve few other fields.
2019-12-18 10:50:24 +01:00
Dmitry Vyukov
0d635f1100 sys/syz-extract: print less output
Don't print every file if extraction is successful.
This makes seeing errors harder as output for each arch takes
more than a single screen.
2019-12-18 10:50:21 +01:00
Andrey Konovalov
f2fe0772a9 sys/linux: various descriptions fixes 2019-12-18 07:48:36 +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
7b9de469e6 sys/linux: regenerate consts
Regenerate on next-20191217.
Rename s/VMADDR_CID_RESERVED/VMADDR_CID_LOCAL/ as it was renamed in kernel.
2019-12-17 11:21:45 +01:00
Dmitry Vyukov
17273b73d6 sys/syz-extract: don't redefine __asm__ in ELF mode
This is not necessary since we build legit object file
for the target binary now. But this breaks mips with:

/linux/arch/mips/include/asm/thread_info.h:53:30: error: register name not specified for ‘__current_thread_info’
 register struct thread_info *__current_thread_info __asm__("$28");

So just remove the old hack.

Follow up to #1536
2019-12-17 11:15:08 +01:00
Jouni Hogander
2b31345f36 Autogenerated files for linux/mips64le
This patch adds all autogenerated files for linux/mips64le. Files are
generated by following commands:

make extract
bin/syz-extract -build -os=linux -arch=mips64le -sourcedir=linux
make generate
2019-12-17 11:10:52 +01:00
Jouni Hogander
24856513b2 sys/syz-extract: Add mips64le specific include paths
Couple of include paths are needed for syz-extract to work for
mips64ler2.
2019-12-17 11:10:52 +01:00
Jouni Hogander
07bfd71dac Implement basic support for MIPS64LE
Add basic stuff to enable MIPS64ELR2 target:
 - build
 - make extract
 - make generate
 - qemu execution
 - system call parsing from /proc/kallsyms
2019-12-17 11:10:52 +01:00
Dmitry Vyukov
f5963ab6ed sys/linux: add a test that files are writable 2019-12-16 19:37:38 +01:00
Andrey Konovalov
0ae38e4489 sys/linux: minor improvements for USB descriptions
1. Define endpoint maxpacket as flags with a few valid values.

2. Define bits of bmNetworkCapabilities.
2019-12-16 09:28:02 +01:00
Dmitry Vyukov
a5c1ab05b3 sys/test: add more tests for bitfields
Add tests for issue #1542

The correct results are obtained with the following program:

struct foo {
	unsigned char	f0;
	unsigned int	f1:4;
	unsigned short	f2:4;
};

struct bar {
	char f0;
	struct foo foo;
};

int main() {
	struct bar y;
	memset(&y, 0, sizeof(y));
	y.f0 = 0x12;
	y.foo.f0 = 0x34;
	y.foo.f1 = 0x56;
	y.foo.f2 = 0x78;
	int i;
	for (i = 0; i < sizeof(y); i++)
		printf("%02x", ((unsigned char*)&y)[i]);
	printf("\n");
}
2019-12-13 15:26:10 +01:00
Dmitry Vyukov
cb704a294c executor: fix syz_mount_image
1. It always crashed in cover_reset when coverage is disabled.
2. Use NONFAILING when accessing image segments.
3. Give it additional 100 ms as it may be slow.
4. Add a test for syz_mount_image.
2019-12-10 16:08:35 +01:00
Andrey Konovalov
5a5826a14e sys/linux, dashboard: update USB config and IDs 2019-12-10 12:45:34 +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
Marco Vanotti
1f9a4e330b sys/targets: change clang++ to clang for fuchsia
Syzkaller binaries are built in C mode even if they are c++ binaries.
Recent clang version (clang++-10) consider this an error/warning,
causing issues during build time.

Change-Id: Ia6d1ab46597efc42772c1c7a63188c3c04a729a7
2019-12-09 15:13:49 -08:00
Marco Vanotti
701420fdad sys/targets: fix path for libdriver.so in Fuchsia 2019-12-09 15:13:49 -08:00
Dmitry Vyukov
1508f45368 sys/linux: refine few framebuffer/kbd ioctls 2019-12-07 18:45:45 +01:00
Andrey Konovalov
98b4ef2d37 sys/linux: update USB TODOs 2019-12-05 15:53:48 +01:00
Siddharth Muralee
9fd5a512f3 sys/netbsd: fix the build issues with posix_spawn 2019-12-05 10:06:13 +01:00
Siddharth M
b91ea9289b make required changes to sys/netbsd 2019-12-05 10:06:13 +01:00
R3x
a734d2a6d9 sys/netbsd: add the newer vfork syscall 2019-12-05 10:06:13 +01:00
R3x
e06d2ea701 sys/netbsd: Added posix_spawn and fork syscalls 2019-12-05 10:06:13 +01:00
Dmitry Vyukov
dfe2e9d84a sys/linux: enforce arguments of all syz_open_dev calls
Opening random devices can lead to havoc.
Enforce device major/minor.
2019-12-03 18:48:14 +01:00
Dmitry Vyukov
cbfd910250 sys/linux: more tuning of tty devices
Enable /dev/tty{1-6}. These seem to be special.
Few first connected to framebuffers. But the rest
seem to be different from e.g. tty20 anyway.
Also /dev/tty is different from the rest.
/dev/ttyS3 and /dev/ttyprintk are different.
Properly pair BSD pty terminals.
2019-12-03 18:48:14 +01:00
Dmitry Vyukov
a715d760ae sys/linux: add /dev/fb1
qemu -vga cirrus results in /dev/fb0 and /dev/fb1.
2019-12-03 18:48:14 +01:00
Dmitry Vyukov
ab342da3f9 sys/linux: add binderfs descriptions 2019-12-02 18:21:43 +01:00
Dmitry Vyukov
dc01aea003 sys/linux: add /dev/fb descriptions
Framebuffer descriptions + open more tty dev nodes.
2019-12-02 18:17:04 +01:00
Dmitry Vyukov
82d81ba98e sys/linux: regenerate consts
Regenerate consts now that make extract is fixed.
Interestingly some arm consts have changed (arm/i386 abi difference?).
2019-12-02 14:44:04 +01:00
Dmitry Vyukov
3aa380090f sys/syz-extract: extract constants from ELF
Add a second mode that extracts constant values from
ELF object, instead of running the executable.
This allows to not (1) link binaries, (2) use proper cross-compiler.
It finally fixes 386/arm extracts for my distro.
Hopefully not makes things worse for others,
should generally be safer/more reliable.
The current mode is left b/c I can't test all OSes,
windows binaries are not ELF, so we may need it anyway.
But later we may switch more OSes to this new mode
if they break (fuchsia?).
2019-12-02 14:36:47 +01:00
Dmitry Vyukov
f879db37f9 sys/linux: more device refinements
Add some mode /dev/nodes*
Add anoter midi device.
2019-12-01 19:51:52 +01:00
Dmitry Vyukov
5d12311f3a sys/linux: add /dev/ptp descriptions 2019-12-01 19:07:51 +01:00
Dmitry Vyukov
9dfc7e00d5 sys/linux: refine some device types
/dev/pmem0 is a block device.
/dev/adsp1 is the same as /dev/dsp1.
dmmidi,admmidi,amidi is the same as /dev/snd/midi.
2019-12-01 18:29:00 +01:00
Dmitry Vyukov
27d609bf84 sys/linux: add /dev/snd/pcm* descriptions 2019-12-01 17:47:28 +01:00