aboutsummaryrefslogtreecommitdiffstats
path: root/tools/syz-declextract/syz-declextract.cpp
Commit message (Collapse)AuthorAgeFilesLines
* tools/syz-declextract: rewriteDmitry Vyukov2024-12-111-1016/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | syz-declextract accumulated a bunch of code health problems so that now it's hard to change/extend it, lots of new features can only be added in in hacky ways and cause lots of code duplication. It's also completly untested. Rewrite the tool to: - move as much code as possible to Go (working with the clang tool is painful for a number of reasons) - allow testing and add unit tests (first layer of tests test what information is produced by the clang tool, second layer of tests test how that information is transformed to descriptions) - allow extending the clang tool output to export arbitrary info in non-hacky way (now it produces arbitrary JSON instead of a mix of incomplete descriptions and interfaces) - remove code duplication in the clang tool and provide common infrastructure to add new analysis w/o causing more duplication - provide more convinient primitives in the clang tool - improve code style consistency and stick to the LLVM code style (in particular, variable names must start with a capital letter, single-statement blocks are not surrounded with {}) - remove intermixing of code that works on different levels (currently we have AST analysis + busness logic + printfs all intermixed with each other) - provide several helper Go packages for better code structuring (e.g. pkg/clangtool just runs the tool on source files in parallel and returns results, this already separates a bunch of low-level logic from the rest of the code under a simple abstraction) I've tried to make the output match the current output as much as possible so that the diff is managable (in some cases at the cost of code quality, this should be fixed in future commits). There are still some differences, but hopefully they are managable for review (more includes/defines, reordered some netlink attributes). Fixed minor bugs are fixed along the way, but mostly NFC: 1. Some unions were incorrectly emitted as [varlen] (C unions are never varlen). 2. Only a of [packed], [align[N]] attributes was emitted for struct (both couldn't be emitted).
* tools/syz-declextract: prefix flags with auto_Dmitry Vyukov2024-11-261-1/+1
| | | | They can clash with our manual flags names.
* tools/syz-declextract: support nested netlink policiesDmitry Vyukov2024-11-181-26/+44
|
* tools/syz-declextract: don't generate NLA_REJECT/TYPE_MAX attrsDmitry Vyukov2024-11-181-1/+4
| | | | These are not accepted as inputs (NLA_REJECT is usually used in dump operation).
* tools/syz-declextract: add heuristic for sigsetsizeDmitry Vyukov2024-11-141-1/+6
|
* tools/syz-declextract: refactor int type conversionDmitry Vyukov2024-11-141-62/+63
| | | | | | | Allow to specialize "intptr". Pass isSyscallParam to int*Subtype b/c if they need to return const/flags, they will need isSyscallParam. Move makeConst/Flags/etc to before int*Subtype b/c they may need to use them.
* tools/syz-declextract: improve name matching heuristicsDmitry Vyukov2024-11-141-12/+19
|
* tools/syz-declextract: fix struct name in some casesDmitry Vyukov2024-11-141-1/+1
| | | | | | | | | | | | | | Remove const/volatile qualifiers from types before generating name. Currently for some kernel I am getting this otherwise: const sigset_t$auto_record { sig intptr } __aio_sigset$auto_record { sigmask ptr[in, const sigset_t$auto_record] sigsetsize intptr }
* tools/syz-declextract: fix generic netlink family namesDmitry Vyukov2024-11-131-5/+6
|
* tools/syz-declextract: fix flags typeDmitry Vyukov2024-11-131-11/+23
| | | | | If flags is a struct field, it needs base type. Add the base type.
* tools/syz-declextract: fix reserved struct field namesDmitry Vyukov2024-11-131-1/+1
|
* tools/syz-declextract: handle more reserved namesDmitry Vyukov2024-11-131-19/+22
|
* tools/syz-declextract: handle _Bool typeDmitry Vyukov2024-11-131-1/+1
|
* tools/syz-declextract: improve declaration name extractionDmitry Vyukov2024-11-131-7/+20
| | | | | | | Extracting declaration name is trickier than removing casts. If the initialized type is a union, then the expression may also contain InitListExpr and other nodes. Remove all of them in a more robust way.
* tools/syz-declextract: add syscall entry functionDmitry Vyukov2024-11-121-2/+3
|
* tools/syz-declextract: add io_uring function/accessDmitry Vyukov2024-11-121-5/+13
|
* tools/syz-declextract: add entry function and access levelDmitry Vyukov2024-11-121-10/+43
| | | | For now for netlink only.
* tools/syz-declextract: properly remove unused declarationsDmitry Vyukov2024-11-111-3/+5
| | | | | | | | | | | Currently we have a number of hacks to deal with unused bits: - remove some netlink syscalls if no policy union present - generate the huge union for unused policies - manually remove 1 struct But we still got more unused structs after recent changes. Properly remove all unused bits using the compiler knowledge. This is both simpler and more reliable.
* tools/syz-declextract: enumerate io_uring operationsDmitry Vyukov2024-11-111-0/+28
|
* tools/syz-declextract: refactor designated init extractionDmitry Vyukov2024-11-111-44/+58
| | | | | Factor it out into a easier to use function, and improve encapsulation.
* tools/syz-declextract: annotate interfaces with descriptions presenceDmitry Vyukov2024-11-111-4/+4
|
* tools/syz-declextract: restructure for better scalabilityDmitry Vyukov2024-11-111-35/+36
| | | | | Move AST matcher setup to each interface extractor. This keeps related things together.
* tools/syz-declextract: rework interface list handlingDmitry Vyukov2024-10-251-35/+21
| | | | | | | | Produce both descriptions and interface list in one run (it's slow, we don't want/need to run the tool twice). Produce output in json format. Later we will add more properties, and will do more processing of the list.
* tools/syz-declextract: assorted cosmetic changesDmitry Vyukov2024-10-251-11/+10
|
* tools/syz-declextract: check that record has attrs before trying to access themPimyn Girgis2024-10-181-1/+1
|
* tools/syz-declextract: add outputFormat flag to choose between minimal and ↵Pimyn Girgis2024-10-161-16/+38
| | | | | | | final descriptions Minimal descriptions are netlink commands and syscall names, while final descriptions are complete syzkaller descriptions.
* tools/syz-declextract: code restructuring for better typesPimyn Girgis2024-10-091-128/+203
|
* tools/syz-declextract: extract structs from system callsPimyn Girgis2024-09-251-48/+13
|
* tools/syz-declextract: extract structs for netlink policies from len fieldPimyn Girgis2024-09-251-17/+349
| | | | | Introduce generic methods that can be used to extract structs and use them on Netlink policies to extract structs from the len field.
* tools/syz-declextract: better type extractionPimyn Girgis2024-09-091-19/+121
| | | | | | | NLA policy type field is now treated as an expression and then translated into an NLA type. Previously, it was treated as a simple Enum, which was not always the case. This makes for much better type extraction. Fields `len` and `name` are now used to better specify the type, for example NLA_BINARY of len 8 is an array[int8, 0:8]. And a policy that ends with NS_FD is an fd_namespace.
* tools/syz-declextract: restructuring for clang toolPimyn Girgis2024-09-091-64/+78
| | | | | Split the Matcher into two classes for system calls and netlinks. Made the system call extraction more robust by avoiding using constants and extracting their values instead.
* tools/syz-declextract: extract genl_family and generate descriptionsPimyn Girgis2024-09-031-19/+161
| | | | | Extract genl_family and generate descriptions based on the attached policies and commands. Fix Issue with the go tool where the clang tool would fail and remain undetected.
* tools/syz-declextract: extract netlink interfacePimyn Girgis2024-08-221-12/+135
| | | | modify syz-declextract to extract information about netlinks and generate descriptions
* tools/syz-declextract, sys/linux: generate descriptions with auto attribute ↵Pimyn Girgis2024-08-121-3/+13
| | | | | | | | | and filter syscalls based on architectures Start generating descriptions directly in syz-declextract. Automatically generated descriptions are marked with "auto" attribute and parameter names are changed if they use a reserved keyword. By default, all parameters are of type intptr; This is intended to change later. "run" now produces deterministic output and filters system calls to only allow ones supported by syzkaller supported architectures, and renames any system calls that need to be renamed.
* tools/syz-declextract: run syz-declextract on files specified by a ↵Pimyn Girgis2024-07-311-0/+4
| | | | | | compilation database Run multiple instances of syz-declextract only on files specifed by a compilation database.
* tools/syz-declextract: parse Linux Headers to extract metadata about syscallsPimyn Girgis2024-07-301-258/+71
| | | | | Clang tool that uses AST matchers to extract relevant metadata about Linux system calls. The tool is to be extended later to support more interfaces, collect more relevant metadata and to automatically generate syzkaller descriptions
* sys/windows: add more descriptionsDmitry Vyukov2017-09-271-0/+279