Commit Graph

4533 Commits

Author SHA1 Message Date
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
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
Andrey Konovalov
36650b4b2c
Update external_fuzzing_usb.md 2019-12-19 14:25:37 +01:00
Andrey Konovalov
a3bceb3706
Update external_fuzzing_usb.md 2019-12-19 14:24:17 +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
6a19144a4d pkg/ipc: don't use rate limiting for test os
It's not needed for test os and slows down pkg/runtest tests.
2019-12-18 16:35:53 +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
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
240ba66ba8 dashboard/config: update upstream-kasan.config to next-20191218 2019-12-18 11:27:18 +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
Dmitry Vyukov
8ab1308e06 pkg/gce: fix creation of non-preemptible E2 instances 2019-12-18 09:11:16 +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
f950e82d47 prog: export RestoreLinks function
Allows to use compiled descriptions.
Will be useful for static checking utility.
2019-12-17 19:03:39 +01:00
Andrey Konovalov
a6bc9c88b9 dashboard/config: update USB config extraction
Currently the config extraction script can produce an incorrect result, when
one of the configs enables a particular config option, but some other one
doesn't. This change fixes the issue.
2019-12-17 16:27:24 +01:00
Siddharth Muralee
1af3875f3f pkg/build: Fix always true case 2019-12-17 15:02:51 +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
d13d795888 tools/syz-runtest: debug all programs in debug mode 2019-12-16 19:37:38 +01:00
Dmitry Vyukov
f9ae583e77 executor: fix FUTEX_WAKE call
Amusingly we never passed number of threads to wake for FUTEX_WAKE.
It somehow worked reliably on linux (we just needed it to not be 0,
so presumably garbage in registers did it).
However, in gVisor every other syscall wasn't even started
(first syscall on a thread started, but second on the same worker
thread wasn't unable to start).
2019-12-16 19:37:38 +01:00
Dmitry Vyukov
f5963ab6ed sys/linux: add a test that files are writable 2019-12-16 19:37:38 +01:00
Andrey Konovalov
b80769fcdd dashboard/config: disable magic sysrq by default
Also don't try to enable GadgetFS, as it can't be enabled with Raw Gadget.
2019-12-16 16:49:11 +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
Andrey Konovalov
eef6e5808d
Update external_fuzzing_usb.md 2019-12-13 23:59:12 +01:00
Andrey Konovalov
9d84e2277c
Update external_fuzzing_usb.md 2019-12-13 23:53:59 +01:00
Andrey Konovalov
408bbb8461
Update external_fuzzing_usb.md 2019-12-13 23:53:10 +01:00
Anton Lindqvist
5b2ca5dad8 dashboard/config: enable KQUEUE_DEBUG on OpenBSD
Recently introduced used to validate correctness of kqueue event lists.
2019-12-13 20:25:07 +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
Andrey Konovalov
2a752b7c5e
Update external_fuzzing_usb.md 2019-12-12 18:23:52 +01:00
Andrew Donnellan
08003f6440 pkg/vcs: Unset various git environment variables when invoking git
If you try to run git-using tests while the GIT_DIR environment variable
(and GIT_WORK_TREE, etc) happens to be set, the tests are going to do fun
and exciting things on a repository that isn't the test repository it tries
to set up.

As it turns out, if you try to run "make test" using git rebase -x, you'll
end up with GIT_DIR set to the syzkaller tree. Hilarity ensues.

Unset GIT_DIR, GIT_WORK_TREE and a few other environment variables when
invoking git - that way it'll default to looking at the working directory
that we have given it, which is what we expect.

Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
2019-12-12 09:56:25 +01:00
Andrei Vagin
df191c7fd0 vm/gvisor: show a list of processes in case of any failures
Signed-off-by: Andrei Vagin <avagin@google.com>
2019-12-12 09:56:13 +01:00
Andrey Konovalov
d973f52833 executor: update raw gadget interface 2019-12-11 19:20:07 +01:00
Dmitry Vyukov
0d368675f8 dashboard/app: report newer crashes in the next reporting
We used to report the newest crash long time ago.
Then we switched to preserving the crash across reporting
stages b/c what reaches next stage may be not what was
sent upstream in the previous one.
However, it seems to cause more problems now than it solves.
Crash classification become much better + some backlog
of bugs was clearer, so we don't have that may glued bugs.
However, in some cases we report notoriously old crashes
which is bad. Switch to the newest crash agian.
Let's see how this works now.
2019-12-11 11:05:32 +01:00
Dmitry Vyukov
7dbfdaf076 pkg/build: improve extraction of build errors
1. Extract multiple error lines (up to 10).
Gives more complete picture, maybe the first one
is not the most indicative one.

2. Replace weird unicode quotes with normal quotes.
These may be mishandled by some systems that don't understand utf-8.
2019-12-11 10:36:35 +01:00
Dmitry Vyukov
101194ebf6 executor: check pwrite return values again
Build with some gcc's fails:

In file included from executor/executor.cc:133:0:
executor/common_linux.h: In function ‘long int syz_read_part_table(long unsigned int, long unsigned int, long int)’:
executor/common.h:117:15: error: ignoring return value of ‘ssize_t pwrite(int, const void*, size_t, __off_t)’, declared with attribute warn_unused_result [-Werror=unused-result]
    __VA_ARGS__;                                 \
               ^
executor/common_linux.h:1279:3: note: in expansion of macro ‘NONFAILING’
   NONFAILING(pwrite(memfd, segs[i].data, segs[i].size, segs[i].offset));
   ^
executor/common_linux.h: In function ‘long int syz_mount_image(long int, long int, long unsigned int, long unsigned int, long int, long int, long int)’:
executor/common.h:117:15: error: ignoring return value of ‘ssize_t pwrite(int, const void*, size_t, __off_t)’, declared with attribute warn_unused_result [-Werror=unused-result]
    __VA_ARGS__;                                 \
               ^
executor/common_linux.h:1364:3: note: in expansion of macro ‘NONFAILING’
   NONFAILING(pwrite(memfd, segs[i].data, segs[i].size, segs[i].offset));
   ^
cc1plus: all warnings being treated as errors
2019-12-10 18:59:06 +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
Dmitry Vyukov
b730d26a8d pkg/vcs: don't CC people on CC (sic)
Update #1441
2019-12-10 12:35:10 +01:00
Dmitry Vyukov
f9f80dd437 pkg/report: use --git-min-percent=15 for get_maintainer.pl
Update #1441
2019-12-10 12:35:10 +01:00
Dmitry Vyukov
c2c19edbcd pkg/vcs: don't bisect linux past 4.6
Fixes #1532
2019-12-10 12:35:10 +01:00