aboutsummaryrefslogtreecommitdiffstats
path: root/sys/syz-extract/linux.go
Commit message (Collapse)AuthorAgeFilesLines
* sys/syz-extract: add required compiler flagsPimyn Girgis2025-12-031-0/+4
| | | | | Add compiler flags to syz-extract to handle wide character constants and suppress implicit function declaration warnings in kernel headers.
* tools/syz-declextract: support function scopesDmitry Vyukov2025-01-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extract info about function scopes formed by switch'es on function arguments. For example if we have: void foo(..., int cmd, ...) { ... switch (cmd) { case FOO: ... block 1 ... case BAR: ... block 2 ... } ... } We record that any data flow within block 1 is only relevant when foo's arg cmd has value FOO, similarly for block 2 and BAR. This allows to do 3 things: 1. Locate ioctl commands that are switched on within transitively called functions. 2. Infer return value for each ioctl command. 3. Infer argument type when it's not specified in _IO macro. This will also allow to infer other multiplexed syscalls. Descriptions generated on Linux commit c4b9570cfb63501.
* sys/syz-extract: support kvm on armDmitry Vyukov2024-11-261-0/+6
| | | | | | | Add few more hacks to support few more cases. In particular including kvm headers for arm. It will be harder to avoid all these with auto-generated descriptions that pull in lots of random headers.
* all: remove some nolint: goconstTaras Madan2024-09-091-1/+0
|
* pkg/build: introduce the build jobs parameterAleksandr Nogikh2024-08-221-1/+1
| | | | | This parameter defines the number of cores dedicated to the kernel build process. By default, it's equal to the number of available CPUs.
* sys/syz-extract: use CopyFile instead of cp cmdJoey Jiao2024-05-311-2/+2
|
* sys/syz-extract: add -config option to specify base kernel configJoey Jiao2024-05-231-5/+12
| | | | Change-Id: Iffb23c0789bb7cff341b68274a8a2efcbdd7598d
* sys/syz-extract/linux.go: remove one dup and ignore othersTaras Madan2023-10-301-1/+1
| | | | It contributes to #4285 unblocking.
* all: use special placeholder for errorsTaras Madan2023-07-241-4/+4
|
* all: add support for custom linkerAleksandr Nogikh2022-10-121-1/+1
| | | | | Add this as an option to syz-ci and syz-build tools. Otherwise we cannot use clang + ld.lld for kernel builds.
* pkg/ast, pkg/compiler: support per-file metadataDmitry Vyukov2022-04-291-9/+0
| | | | | | | | | | | | | | | | | | | | | We have a bunch of hacks in syz-extract, syz-sysgen and syz-check with respect to description files unsupported on some arches, or that must not be part of make extract. Add 2 meta attribtues to files: meta noextract Tells `make extract` to not extract constants for this file. Though, `syz-extract` can still be invoked manually on this file. meta arches["arch1", "arch2"] Restricts this file only to the given set of architectures. `make extract` and ``make generate` will not use it on other architectures. Later we can potentially use meta attributes to specify git tree/commit that must be used for extraction. Maybe something else. Fixes #2754
* sys/syz-extract: disable DEBUG_INFO_BTFDmitry Vyukov2022-01-111-0/+2
| | | | | | | syz-env make extract fails on upstream commit d1587f7bfe: /usr/bin/env: 'python3': No such file or directory make[3]: *** [Makefile:72: bpf/resolve_btfids] Error 2
* sys/syz-extract: fix linux extractDmitry Vyukov2022-01-111-0/+1
| | | | | | Currently fails with: <stdin>:7:10: fatal error: asm/msr.h: No such file or directory
* sys/linux: add /dev/cpu/X/msr to dev_msr.txtVikram Narayanan2021-11-181-3/+4
|
* sys/syz-extract: restore kvm const extraction for arm64/ppc64Dmitry Vyukov2021-09-161-7/+5
| | | | | | | | | | | | Change #2755 disabled KVM for arm64/ppc64, but KVM is supported on these arches and has extensive support. It's pity to lose that support. The real root cause of the problem with arm64/ppc64 is that some severe compilation errors terminated compilation and did not let compiler spew all error messages. As the result we did not parse all of them and did not disable all of them. Re-try compilation multiple times instead of just 2 to fix this. Update #2754
* sys: skip kvm const extraction for non i386/amd64Aleksandr Nogikh2021-09-131-5/+7
| | | | | | | | | | | | It is impossible to compile a number of definitions in include/uapi/linux/kvm.h for other platforms, which leads to syz-extract failing to update constants. Skip processing of this file for all arches except i386 and amd64. This is a hacky and (hopefully) temporary solution until #2754 is implemented.
* sys/syz-extract: move SOURCEDIR check to callerPatrick Meyer2021-05-201-3/+0
|
* sys/linux: add ieee802154 descriptionsDmitry Vyukov2021-02-121-0/+2
|
* pkg/build: support cross-compilation for linuxDmitry Vyukov2020-11-211-24/+3
| | | | | | We currently only support native build in pkg/build (does not even pass ARCH). Move the existing cross-compilation logic from sys/syz-extract/linux.go and reuse it in both places.
* sys/targets: add OS/Arch name constsDmitry Vyukov2020-10-261-1/+3
| | | | | | | | | | | | We use strings to identify OS/Arch. These strings are duplicated throughout the code base massively. golangci-lint points to possiblity of typos and duplication. We already had to define these names in pkg/csource and disable checking for prog package. A future change triggers such warnings in another package. Add OS/Arch name consts to sys/targets so that they can be used to refer to OS/Arch. Use the consts everywhere.
* sys/syz-extract: ignore *_kvm.txt on linux/riscv64Tobias Klauser2020-06-261-3/+4
| | | | | | | The Linux RISC-V port in linux-next doesn't support KVM yet. Ignore it for now until KVM support is added upstream. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* target: support of big-endian architecturesAlexander Egorenkov2020-06-231-0/+1
| | | | | | | | | | | | * Introduce the new target flag 'LittleEndian' which specifies of which endianness the target is. * Introduce the new requires flag 'littleendian' for tests to selectively enable/disable tests on either little-endian architectures or big-endian ones. * Disable KD unit test on s390x architecture because the test works only on little-endian architecture. Signed-off-by: Alexander Egorenkov <Alexander.Egorenkov@ibm.com>
* sys/syz-extract: fix for full pathsDmitry Vyukov2020-05-201-1/+1
| | | | | pkg/ast now uses full paths since 554f8f39c57d91c1be8724cf4054424c9fb5f151. Fix syz-extract accordingly.
* targets: syz-extract: add Clang support for Linux buildsAlexander Potapenko2020-05-151-0/+6
| | | | | | | | | | | | 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>
* targets: replace target.CCompilerPrefix with target.TripleAlexander Potapenko2020-05-151-2/+4
| | | | | | | 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>
* Get rid of "Cross" in variable namesAlexander Potapenko2020-05-131-2/+2
| | | | | | | | | 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>
* sys/syz-extract: use -nostdinc on linuxDmitry Vyukov2020-05-111-13/+22
| | | | This makes the build completely hermetic.
* sys/syz-extract: run mrproper for all linux archesDmitry Vyukov2020-05-091-9/+14
| | | | | | 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.
* sys/linux: regenerate constsDmitry Vyukov2020-04-141-6/+14
| | | | | | | | | | | 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
* sys/syz-extract: Add mips64le specific include pathsJouni Hogander2019-12-171-0/+2
| | | | | Couple of include paths are needed for syz-extract to work for mips64ler2.
* sys/syz-extract: extract constants from ELFDmitry Vyukov2019-12-021-23/+7
| | | | | | | | | | | | | 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?).
* sys/syz-extract: use clang if gcc is brokenDmitry Vyukov2019-12-011-1/+15
| | | | | | | 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.
* sys/linux: update to current linux-nextDmitry Vyukov2019-11-251-1/+5
| | | | | | | | 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.
* sys/syz-extract: Add "DefineGlibcUse" flag.Marco Vanotti2019-07-161-1/+1
| | | | | | 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.
* sys/linux: switch ppc64le to little-endianDmitry Vyukov2019-05-131-10/+10
| | | | | | | | | | | | | | | | | | 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.
* sys/linux: fix up mptcp descriptionsDmitry Vyukov2019-01-251-2/+8
| | | | | | | 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).
* sys/syz-extract: don't use warning flagsDmitry Vyukov2019-01-241-1/+7
| | | | | CrossCFlags now contains some warning-related flags like -Wall. Some of these break kernel build, don't add any warning-related flags.
* sys/syz-extract: add -includedirs optionJoey Jiao2019-01-191-0/+5
| | | | | | 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
* sys/syz-extract: support missing arch headersDmitry Vyukov2018-10-281-0/+17
| | | | | | | | The latest Linux kernel misses some arch-specific headers on some archs: asm/a.out.h asm/prctl.h asm/mce.h Support that.
* all: fix gometalinter warningsDmitry Vyukov2018-03-081-5/+5
| | | | Fix typos, non-canonical code, remove dead code, etc.
* sys/syz-extract: run make with -jDmitry Vyukov2018-02-171-1/+4
|
* sys/syz-extract: don't run mrproper if already cleanDmitry Vyukov2018-01-131-5/+12
| | | | mrproper takes unreasonable amount of time.
* sys/syz-extract: fix mmap on armDmitry Vyukov2017-11-231-1/+19
| | | | | | | __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.
* syz-extract: select declaring printf or notzoulasc2017-11-061-1/+1
| | | | | | | | Kernels are standalone implementations and can have their own implementations of functions that have different prototypes than the standard ones. In the NetBSD case the kernel printf returns void, and it is declared in <sys/systm.h> so avoid re-declaring it. Select if we are going to declare printf or not depending on the OS.
* sys/syz-extract: factor out compilation functionDmitry Vyukov2017-10-121-119/+21
| | | | | | | Each arch duplicates significant portion of logic to compile the extract source file. Factor this logic into a separate function and reuse it across all OSes.
* executor, sys/windows: initial windows supportDmitry Vyukov2017-09-251-28/+5
|
* sys/syz-extract: support fuchsiaDmitry Vyukov2017-09-251-0/+228