Commit Graph

83 Commits

Author SHA1 Message Date
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
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
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
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
edcd9e3c9a sys/syz-extract: use clang if gcc is broken
On my Debian gcc -m32 is hopelessly broken.
Using clang fixes at least arch 386.
Arch arm is still broken b/c clang does not like
some of kernel arm inline assemly constraints.
2019-12-01 10:59:54 +01:00
Dmitry Vyukov
6bfd3dd23b sys/linux: update to current linux-next
Regenerate consts on linux-next next-20191125.
DEVLINK_ATTR_NETNS_* consts were chifted by 1.
__BPF_FUNC_MAX_ID increased as usual.
CRYPTO_ALG_TYPE_BLKCIPHER, CRYPTO_ALG_TYPE_ABLKCIPHER were removed,
replace them with CRYPTO_ALG_TYPE_SKCIPHER.
2019-11-25 14:30:28 +01:00
David Pursell
a3f5ce76b1 sys/fuchsia: fix Fuchsia extract/generate
Updates some paths and add zx_eventpair type definition to fix
`make extract` and `make generate`.
2019-11-14 16:21:01 -08:00
Eric Biggers
6aa8d1eb8f sys/syz-extract: re-enable extraction for fsverity.txt
fsverity is now upstream, so re-enable extracting its consts.
2019-09-19 09:38:51 +02:00
Dmitry Vyukov
96b8132aaf sys/syz-extract: fix too long line 2019-07-16 16:34:29 +02:00
Marco Vanotti
6aad7497a8 sys/syz-extract: Add "DefineGlibcUse" flag.
Instead of defining the __GLIBC_USE macro on every OS, we are just
defining it based on a parameter. That parameter is set to false for all
OSs except for fuchsia.
2019-07-16 16:34:29 +02:00
Marco Vanotti
1472562444 sys/syz-extract: define __GLIBC_USE if not defined.
When I try to run `make extract` for fuchsia, the clang compiler
complains that __GLIBC_USE is undefined.

This CL just defines it to be an always false function-like macro if it
was not defined.
2019-07-16 16:34:29 +02:00
Pascal Perez
77beeccbe0 sys: Updating Fuchsia extraction scripts
Consolidating FIDL library build mappings in one place, so that it can
be used from extraction, and script invoking fidlgen. This also makes
code clearer, and provides a more natural path for evolutions / dealing
with oddities.

Minor doc update post fx command changes.
2019-05-21 14:55:36 -07:00
Dmitry Vyukov
000f08bb18 sys/linux: switch ppc64le to little-endian
make extract recently broke for powerpc on linux-next with:

include/uapi/linux/byteorder/big_endian.h:6:2: error: #error "Unsupported endianness, check your toolchain"
 #error "Unsupported endianness, check your toolchain"

Turns out we always built ppc64le headers as big-endian.
First, kernel was configured as BE.
Then, we used gcc to build an executable program for host
and on x86 gcc does not define __LITTLE_ENDIAN__ so kernel
thought that the toolchain is BE too.

Configure kernel as LE and define __LITTLE_ENDIAN__.

This actually changes values of some consts,
but fortunately just few of them.
2019-05-13 10:26:57 +02:00
Michael Tuexen
a46bda82a4 sys/syz-extract define GENOFFSET when processing FreeBSD sources
This avoids the inclusion of offset.inc files.
2019-04-30 17:55:00 +02:00
Dmitry Vyukov
4e668495fb sys/syz-extract: fix too long line 2019-03-27 09:44:01 +01:00
Marco Vanotti
70d776a21a sys/sys-extract: update import path for fuchsia.
Apparently, sysroot/include doesn't exist in the build-zircon path
anymore. I changed the path in sys-extract to make it point to the
exported sdk include path.

I also ran make extract and make generate to add new fidl definitions.

TEST=ran make extract and make generate.
2019-03-27 09:08:05 +01:00
Dmitry Vyukov
d72db19b2a sys/syz-extract: support more identifier quoting options
That's insanity compilers shuffle them in all possible combinations.
2019-03-14 15:30:58 +01:00
Dmitry Vyukov
1e8208402d sys/linux: regenerate and fix const files
1. Move fsverity descriptions to a separate file which
is not regenerated automatically. It was dropped from linux-next.
2. Fix tlk_device.txt name in syz-extract.
3. Update some socket consts e.g. s/SO_TIMESTAMPING/SO_TIMESTAMPING_OLD/.
4. Regenerate const files on current upstream head.
2019-03-14 13:40:11 +01:00
Mark Johnston
4fc2fa55ac sys/freebsd: avoid mangling syscall names
syz-extract was removing certain prefixes from syscall names, but this
caused some problems:
- freebsd* prefixes are for compatibility syscalls when the syscall ABI
  has changed.  For instance, we have both fstat() and
  freebsd11_fstat(), and it is desirable to fuzz them both.
- Stripping prefixes may leave us with undefined SYS_ constants.  This
  resulted in some test failures in pkg/csource, which emitted code
  referencing SYS_semctl when it should have been SYS___semctl.

Fix the problem by updating syscall descriptions to match the names
given by the FreeBSD kernel.  Add some new descriptions for
compatibility syscalls, fix the mknodat() description (dev_t is now 64
bits wide on FreeBSD), and remove mknod$loop, which appears to be
Linux-specific.
2019-03-07 19:46:55 +01:00
Dmitry Vyukov
6258c9f721 sys/linux: regenerate consts
Regenereate consts on latest linux-next.
2019-02-12 18:34:25 +01:00
Dmitry Vyukov
a3d9f7e34d sys/linux: fix up mptcp descriptions
1. Generate .const files for all arches.
2. Don't extract mptcp consts on android.
3. Remove mptcp includes from vnet.txt.
4. Enable CONFIG_MPTCP in syz-extract (mptcp is not like all other kernel headers).
2019-01-25 16:10:00 +01:00
8litz
6fde58c61b sys/linux: add Multipath TCP description
https://tools.ietf.org/html/rfc6824
2019-01-25 15:42:43 +01:00
Dmitry Vyukov
f87fe5d949 sys/syz-extract: don't use warning flags
CrossCFlags now contains some warning-related flags like -Wall.
Some of these break kernel build, don't add any warning-related flags.
2019-01-24 16:49:38 +01:00
Joey Jiao
8aa587b0a1 sys/syz-extract: add -includedirs option
Kernel modules are in different directories in some cases,
so to include the headers in the module dir or other directories
the includedirs flag is added.
ex: -includedirs path1/include,path2/include
2019-01-19 12:30:10 +01:00
Dmitry Vyukov
0d872150de sys: initial trusty support
Trusty is a set of software components supporting
a Trusted Execution Environment (TEE) on mobile devices.

https://source.android.com/security/trusty

Add syscall descriptions and some boilerplate.
2018-11-07 17:52:06 -08:00
Dmitry Vyukov
6e045ca26d sys/syz-extract: support missing arch headers
The latest Linux kernel misses some arch-specific headers on some archs:
	asm/a.out.h
	asm/prctl.h
	asm/mce.h
Support that.
2018-10-28 19:10:11 +01:00
Dmitry Vyukov
ecb386fe6f sys: check that target consts are defined
Currently when we get target consts with target.ConstMap["name"]
during target initialization, we just get 0 for missing consts.
This is error-prone as we can mis-type a const, or a const may
be undefined only on some archs (as we have common unix code
shared between several OSes).
Check that all the consts are actually defined.
The check detects several violations, to fix them:
1. move mremap to linux as it's only defined on linux
2. move S_IFMT to openbsd, as it's only defined and used on openbsd
3. define missing MAP_ANONYMOUS for freebsd and netbsd
4. fix extract for netbsd
2018-10-19 19:11:22 +01:00
Anton Lindqvist
b771b17ec9 Add mandatory OpenBSD bits (#689)
all: add openbsd support

squash of the following commits:

* openbsd: add mandatory bits
* report: add OpenBSD support
* executor: skip building kvm on OpenBSD
* executor: add OpenBSD support
Linking against libutil is necessary due to usage of openpty(3).
* executor: fix typo in fail() message
* fixup! report: add OpenBSD support
* fixup! openbsd: add mandatory bits
* fixup! openbsd: add mandatory bits
* fixup! openbsd: add mandatory bits
* fixup! report: add OpenBSD support
* gometalinter: skip sys/openbsd
2018-08-28 10:07:26 -07:00
Dokyung Song
7ef1de9ea4 sys/fuchsia: description for fuchsia.io FIDL interfaces 2018-08-27 14:01:34 -07:00
Dmitry Vyukov
88d4a8fc56 sys/syz-extract: refactor main
main is too long and complex. Move more logic into helper functions.

Update #538
2018-08-02 16:57:32 +02:00
Dmitry Vyukov
8ef497b652 gometalinter: clean up vetshadow
This just cleans up existing warnings.
vetshadow is not enabled yet because it crashes.

Update #538
2018-07-31 20:38:33 +02:00
Dmitry Vyukov
3439016dc2 sys/akaros: add all syscalls 2018-07-06 20:19:03 +02:00
Dmitry Vyukov
6479ab2a75 Makefile, sys/targets: move all native compilation logic to sys/targets
We currently have native cross-compilation logic duplicated
in Makefile and in sys/targets. Some pieces are missed in one
place, some are in another. Only pkg/csource knows how to check
for -static support.

Move all CC/CFLAGS logic to sys/targets and pull results in Makefile.

This should make Makefile work on distros that have broken x86_64-linux-gnu-gcc,
now we will use just gcc. And this removes the need to define NOSTATIC,
as it's always auto-detected.

This also paves the way for making pkg/csource work on OSes other than Linux.
2018-06-06 10:02:03 +02:00
Dmitry Vyukov
9fb3ae4dfd pkg/osutil: introduce TempFile helper
Introduce TempFile helper and use it in several packages.
2018-05-14 11:17:23 +02:00
Dmitry Vyukov
63ef537b14 sys/syz-extract: improve compier error messages
Print each constant on separate line.
When compiler prints error messages it prints whole line
containing an error. So currently it prints all constants (thousands).
With this change it prints just the problematic constant.
2018-05-11 15:48:33 +02:00
Dmitry Vyukov
c8229620ff sys/linux: regenerate video4linux consts on the right tree
Now generated on:
https://source.codeaurora.org/quic/la/kernel/msm-4.9 msm-4.9
2018-05-11 15:09:33 +02:00
Dmitry Vyukov
2d35915b13 sys/linux: add missing consts for video4linux.txt
For now other arches are regenerated on upstream tree.
It does not contain a bunch of consts, so we define them to 1 for now.
arm64 consts are left intact.
video4linux.txt is added to "android" files in syz-extract,
so that future make extract runs don't overwrite arm64 consts.

Also fix VIDIOC_G_FBUF argument direction, currently tests crash with:

panic: call ioctl$VIDIOC_G_FBUF: pointer arg 'buffer' has output direction [recovered]
	panic: call ioctl$VIDIOC_G_FBUF: pointer arg 'buffer' has output direction
2018-05-11 14:24:16 +02:00
Dmitry Vyukov
99c1f48659 sys/syz-extract: split overly long function
Update #538
2018-05-07 16:50:19 +02:00
Dmitry Vyukov
78b251cbd7 all: fix too long lines
Not sure why I have not seen warnings about
these lines on another machine...
2018-05-05 16:00:01 +02:00
Dmitry Vyukov
500489e312 sys/syz-extract: provide readable error on missing input file
Currently syz-extract crashes with nil deref panic if
it is executed manually and is gives an absent file name.
Output a readable error.
2018-04-19 19:43:27 +02:00
Dmitry Vyukov
374050e904 sys/syz-extract: fix linux/arm
At some point extract for linux/arm started to fail with:

extracting from key.txt
	failed to run compiler: exit status 1
/tmp/ccT6o7iZ.s: Assembler messages:
/tmp/ccT6o7iZ.s:4: Error: unknown pseudo-op: `.syntax'

This is caused by arch/arm/include/asm/unified.h:

__asm__(".syntax unified");

Ignore all __asm__ directives as we are cross compiling.
2018-04-02 20:09:30 +02:00
Julia Hansbrough
040e73d644 fuchsia: Fix the extractor tool.
The include path in Zircon has changed; updated syz-extract/fuchsia.go
to include this, and re-ran extract to get updated *.const files.
2018-03-21 09:50:47 +01:00
Dmitry Vyukov
36d1c4540a all: fix gometalinter warnings
Fix typos, non-canonical code, remove dead code, etc.
2018-03-08 18:48:26 +01:00
Dmitry Vyukov
32aa64c5ac sys/syz-extract: run make with -j 2018-02-17 19:02:12 +01:00
Julia Hansbrough
a1bc9d40ad syz/syz-extract: Update Fuchsia extractor with current Fuchsia paths.
A change in Zircon a while back moved around where sysroots are located
in Fuchsia; this update will allow for proper extraction.
2018-02-04 12:21:23 +01:00
Dmitry Vyukov
e86ddaca2e sys/syz-extract: save unsupported consts to the const files
We currently print unsupported consts to console during make extract.
But this is not very useful as there are too many output now.
This also does not allow to understand what's unsupported
in newly checked-in descriptions, or what's unsupported in all current
decriptions.

Save unsupported consts to the const files instead.
This solves all of the above problems.
2018-02-01 20:18:51 +01:00
Dmitry Vyukov
1623c95de1 sys/syz-extract: don't run mrproper if already clean
mrproper takes unreasonable amount of time.
2018-01-13 12:52:09 +01:00
Dmitry Vyukov
6b52293f4d pkg/compiler: support type templates
Netlink descriptions contain tons of code duplication,
and need much more for proper descriptions. Introduce
type templates to simplify writing such descriptions
and remove code duplication.

Note: type templates are experimental, have poor error handling
and are subject to change.

Type templates can be declared as follows:

```
type buffer[DIR] ptr[DIR, array[int8]]
type fileoff[BASE] BASE
type nlattr[TYPE, PAYLOAD] {
	nla_len		len[parent, int16]
	nla_type	const[TYPE, int16]
	payload		PAYLOAD
} [align_4]
```

and later used as follows:

```
syscall(a buffer[in], b fileoff[int64], c ptr[in, nlattr[FOO, int32]])
```
2018-01-13 12:52:09 +01:00
Dmitry Vyukov
7166c86520 sys/linux: add ion and ashmem devices support
Note: ion supercedes the old android interface,
which is moved to sys/android.
2018-01-09 21:24:28 +01:00
Dmitry Vyukov
7061d1973b sys/syz-extract: fix mmap on arm
__NR_mmap is missing on arm entirely,
so we disable mmap during generate.
Patch mmap to mmap2 right in syz-extract,
so that mmap is never missing.
2017-11-23 08:51:04 +01:00