Commit Graph

1256 Commits

Author SHA1 Message Date
Dmitry Vyukov
7711af6356 sys/syz-extract: don't warn about unsupported consts for 1 arch
Only warn about unsupported consts when generating consts for all arches.
2020-05-11 16:54:44 +02:00
Dmitry Vyukov
d44f7473de sys/syz-extract: add another compiler message about missing const
New message from clang.
2020-05-11 16:54:44 +02:00
Ayushi Sharma
3b3a2b78da
sys/netbsd: add __getcwd(2) (#1725) 2020-05-11 00:03:33 -07:00
Dmitry Vyukov
8742a2b9db sys/syz-extract: run mrproper for all linux arches
We only run for the current arch, but it's not enough
to clean a build for another arch.
Run mrproper for all non-clean arches.
2020-05-09 16:08:22 +02:00
Dmitry Vyukov
f40567d255 all: reformat code 2020-05-08 14:02:16 +02:00
Dmitry Vyukov
6c70a1c220 all: replace TRAVIS env var with CI
In preparation to running some tests as github actions.
Both Travis and Github define CI env var, while TRAVIS is, well,
too Travis-specific.

Update #1699
2020-05-07 15:41:50 +02:00
Andrey Konovalov
1b2b36d6ab sys/android: dev_ prefix for ion descriptions 2020-05-07 11:26:03 +02:00
Dmitry Vyukov
e42fa3fd02 prog: refactor hints tests
The way the tests fabricate types dynamically creates
problems during any non-trivial changes to prog package.

Use existing types from descriptions instead.
2020-05-05 14:01:52 +02:00
Dmitry Vyukov
1905d7c090 prog: refactor ANY to not fabricate new types
Currently ANY implementation fabricates new types dynamically.
This is something we don't do anywhere else, generally types
come from compiler and all are static.
Dynamic types will conflict with use of Ref in Arg optimization.
Move ANY types creation into compiler.

Update #1580
2020-05-05 14:01:52 +02:00
Dmitry Vyukov
71db69869e sys/linux: mark some ioctls as disabled
Mark ioctls we disable in init.go as disabled.

Update #477
Update #502
2020-05-04 20:56:20 +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
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
986fa4971c prog: don't squash objects that contain pointers
Squashing pointers creates several problems:
- we need to generate pointer types on the fly,
  something we don't do in any other contexts,
  it complicates other changes
- pointers are very special as values,
  if we change size of the surrounding blobs,
  offsets changes and we will use something that's
  not a pointer as pointer and vise versa,
  boths things are most likley very bad as inputs
- squashing/any implementation is just too complex

This disqualifies several types for squashing:

    <         alloc_pd_cmd
    <         arpt_replace
    <         array[cmsghdr_rds]
    <         create_cq_cmd
    <         create_flow_cmd
    <         create_qp_cmd
    <         create_srq_cmd
    <         ebt_counters_info
    <         ip6t_replace
    <         ipt_replace
    <         mlx5_alloc_pd_cmd
    <         mlx5_create_dv_qp_cmd
    <         open_xrcd_cmd
    <         post_recv_cmd
    <         post_send_cmd
    <         post_srq_recv_cmd
    <         query_qp_cmd
    <         query_srq_cmd
    <         reg_mr_cmd
    <         rereg_mr_cmd
    <         resize_cq_cmd
    <         usbdevfs_urb
    <         vhost_memory
    <         vusb_connect_descriptors

and adds few new:

    >         binder_objects
    >         query_qp_resp
    >         resize_cq_resp
    >         usb_bos_descriptor
    >         usb_string_descriptor

Overall this looks sane.
Majority is still unchanged.
2020-05-01 13:31:17 +02:00
Dmitry Vyukov
ec42220e77 Makefile: generate descriptions on-the-fly
Checking in the generated descriptions files makes few things simpler,
but causes pain for pull requests: (1) PRs that touch descriptions
_always_ conflict, (2) PRs are large and harder to review,
(3) people sometimes forget to add auto-generated files.

The proposed way does not require us to hardcode lots of dependencies
in the Makefile (which is nice) and seem to work.
Let's see how it works.

The main contributor-visible consequence is that the auto-generated
files do not need to be checked-in now.

Credit for figuring the Makefile magic goes to @melver.

Fixes #1291
2020-04-30 17:18:29 +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
3698959af9 sys/targets: fix detection of optional compiler flags
The test source is now C++, so use -x c++.
Stupid bug, but testing this is not trivial
in the context where we specifically make
behavior "flexible"...
2020-04-30 11:54:39 +02:00
Andy Nguyen
c42af8f753 sys: add mldv2 packet structs
Use special values for hop limit to increase likelihood of triggering certain paths.
2020-04-29 18:55:57 +02:00
Andy Nguyen
bd365072bf sys: add more specific ipv6 options
Additionally fix a type for ipv6_hopopts_ext_header
2020-04-29 16:46:34 +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
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
99b258ddc3 sys/openbsd: extend vnet
* started with freebsd/vnet.txt
  * pruned unsupported items
  * gmake extract
  * gmake generate_sys
  * gmake fomat
2020-04-26 04:43:15 +02:00
Andrey Konovalov
b9233cab41 dashboard/config, sys/linux: update usb config 2020-04-23 16:47:51 +02:00
Ayushi Sharma
2e44d63e40
sys/netbsd: add lchmod(2) (#1687) 2020-04-21 13:22:03 +02:00
Dmitry Vyukov
6dfd45e1d0 sys/syz-sysgen: better formatting for syscall descriptions
We don't really need clang-format for auto-generated code.
We can do better ourselves!
2020-04-19 10:26:57 +02:00
Dmitry Vyukov
2152cfbcb2 all: fix liner errors
pkg/compiler/compiler.go:182: line is 125 characters
func (comp *compiler) parseAttrs(descs map[string]*attrDesc, parent ast.Node, attrs []*ast.Type) (res map[*attrDesc]uint64) {
sys/targets/common.go:47:21: unnecessary conversion
				makeMmap(^uint64(target.PageSize)+1, target.PageSize, 0),
				                ^
sys/targets/common.go:61: File is not `gofmt`-ed with `-s`
			&prog.Call{
sys/windows/init.go:35: File is not `gofmt`-ed with `-s`
		&prog.Call{
2020-04-19 10:26:57 +02:00
Dmitry Vyukov
91db3ed8ce prog: add ignore_return and breaks_returns call attribtues
We had these hard-coded for fuchsia and linux accordingly.
Replace with call attributes.
2020-04-19 10:26:57 +02:00
Dmitry Vyukov
1155a0d1d6 sys/linux: sync call timeouts with executor
Timeouts in executor and sys/linux get out of sync. Sync them.
2020-04-19 10:26:57 +02:00
Dmitry Vyukov
cc8708904d sys/linux: add timeout call attributes
Move additional call/prog timeouts to descriptions.

Due to this logic duplication executor used 50ms
for syz_mount_image, while pkg/csource used 100ms.
2020-04-19 10:26:57 +02:00
Dmitry Vyukov
90d17ab898 prog: introduce call attributes
Add common infrastructure for syscall attributes.
Add few attributes we want, but they are not implemented for now
(don't affect behavior, this will follow).
2020-04-19 10:26:57 +02:00
Dmitry Vyukov
0781895e0f pkg/compiler: refactor attribute handling
Introduce common infrastructure for describing and parsing attribute
instead of custom per-attribute code scattered across several locations.

Change align attribute syntax from the weird align_N to align[N].
This also allows to use literal constants as N.

Introduce notion of builtin constants.
Currently we have only PTR_SIZE, which is needed to replace
align_ptr with align[PTR_SIZE].
2020-04-19 10:26:57 +02:00
Dmitry Vyukov
365fba2440 executor: surround the data mapping with PROT_NONE pages
Surround the main data mapping with PROT_NONE pages to make virtual address layout more consistent
across different configurations (static/non-static build) and C repros.
One observed case before: executor had a mapping above the data mapping (output region),
while C repros did not have that mapping above, as the result in one case VMA had next link,
while in the other it didn't and it caused a bug to not reproduce with the C repro.

The bug that reproduces only with the mapping above:
https://lkml.org/lkml/2020/4/17/819
2020-04-18 14:43:29 +02:00
Dmitry Vyukov
67234372ef prog: refactor target.MakeMmap
Make MakeMmap return more than 1 call.
This is a preparation for future changes.
Also remove addr/size as they are effectively
always the same and can be inferred from the target
(will also conflict with the future changes).
Also rename to MakeDataMmap to better represent
the new purpose: it's just some arbitrary mmap,
but rather mapping of the data segment.
2020-04-18 14:35:45 +02:00
Dmitry Vyukov
ea36da8271 sys/linux: use PROT_EXEC for the data section mmap
Turns out the mmap protection get out of sync
between executor and C reproducers.
C reproducers missed PROT_EXEC.
Add PROT_EXEC for linux, freebsd and akaros.
2020-04-18 10:33:03 +02:00
ais2397@gmail.com
c743fcb3e0 sys/netbsd: add minherit(2) 2020-04-16 07:02:15 +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
Dmitry Vyukov
ffe85af864 sys/linux: regenerate consts
On the current linux-next:
f19bb13a0eaf0034a603e3b54a7c3a50faf6821e (next-20200414)

EXT4_EOFBLOCKS_FL was removed by 4337ecd1fe997d2b2135b4434caaccdb47c10c06

ARM does not support KVM anymore, removed by 541ad0150ca4 ("arm: Remove 32bit KVM host support").

Fixes #1676
2020-04-14 07:37:58 +02:00
ais2397@gmail.com
a517e13956 sys/netbsd: fix struct stat 2020-04-13 21:20:21 +02:00
Paul Chaignon
17a986e54c sys/linux: add link_create and link_update commands
Signed-off-by: Paul Chaignon <paul@cilium.io>
2020-04-12 17:03:47 +02:00
Paul Chaignon
95536f1d7b bpf: update BPF constants
Signed-off-by: Paul Chaignon <paul@cilium.io>
2020-04-12 17:03:47 +02:00
Ayushi Sharma
d9ed075d1a
sys/netbsd: adding chflags(2) syscalls (#1661) 2020-04-04 00:07:51 +02:00
Andrey Konovalov
84da034b1e sys/linux: run usb runtests with namespace/setuid sandbox 2020-04-03 12:42:06 +02:00
Ayushi Sharma
46105100bf
sys/netbsd: adding lwp syscalls (#1654) 2020-03-31 14:14:00 +02:00
Mark Johnston
7d95711b32 sys/freebsd: add Capsicum system calls 2020-03-27 05:51:58 +01:00
Mark Johnston
be07a9be5e sys/freebsd: add __realpathat system call 2020-03-27 05:51:58 +01:00
Mark Johnston
87abd520f8 sys/freebsd: add bindat(2) 2020-03-27 05:51:58 +01:00
Mark Johnston
c37c8bf05b sys/freebsd: add POSIX shared memory system calls 2020-03-27 05:51:58 +01:00
Mark Johnston
ed2c77ae59 sys/freebsd: add connectat(2) 2020-03-27 05:51:58 +01:00