Commit Graph

96 Commits

Author SHA1 Message Date
Dmitry Vyukov
204f4fde06 sys/syz-extract: fix for full paths
pkg/ast now uses full paths since 554f8f39c5.
Fix syz-extract accordingly.
2020-05-20 19:38:14 +02:00
Alexander Potapenko
d7f9fffab3 targets: syz-extract: add Clang support for Linux builds
Allow targets.go use Clang instead of the default Linux compiler by
setting the SYZ_CLANG=1 env var. Doing so changes the compiler to
"clang" and the linker to "ld.ldd", assuming they are in $PATH, and adds
the --target and -ferror-limit CFLAGS.

Target also exports KernelCompiler and KernelLinker fields now, which allows
overriding the compiler and linker in the kernel make invocation.

Signed-off-by: Alexander Potapenko <glider@google.com>
2020-05-15 14:08:01 +02:00
Alexander Potapenko
e2993cfc13 targets: replace target.CCompilerPrefix with target.Triple
This field will soon be used in Clang builds. Also, we'd better
encapsulate compiler name generation in targets.go

Signed-off-by: Alexander Potapenko <glider@google.com>
2020-05-15 14:08:01 +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
f4bf31dc3c sys/syz-extract: use -nostdinc on linux
This makes the build completely hermetic.
2020-05-11 16:54:44 +02:00
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
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
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
Anton Lindqvist
09d53fbb27 sys/syz-extract: favor clang on OpenBSD
Clang is the default compiler on amd64 which is the only supported
architecture by syzkaller right now.
2020-03-04 18:27:18 +01:00
Anton Lindqvist
9ef240be5f sys/syz-extract: fix handling of odd prefixed syscalls on OpenBSD
This makes syz-extract work again on OpenBSD.
2020-03-04 18:27:18 +01:00
Dmitry Vyukov
82d32c2951 sys/syz-extract: fix output formatting
Remove spaces in the beginning of the message.
The message is actually multi-line and the spaces
are added only before the first line, which makes
the subsequent lines inconsistently offsetted.
2020-02-21 11:19:15 +01:00
Dmitry Vyukov
d52d4872e3 sys/linux: don't extract from futex.txt and watch_queue.txt
These are not present in linux-next.
2020-02-18 10:31:03 +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
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