aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/compiler/testdata/errors2.txt
Commit message (Collapse)AuthorAgeFilesLines
* pkg/compiler: allow recursion via arraysDmitry Vyukov2024-11-181-9/+14
| | | | | Permit structs to recursively contain itself in arrays. This is needed for netlink. Amusingly several netlink policies contain itself.
* compiler: support constants in conditional fieldsPaul Chaignon2024-09-091-2/+2
| | | | | | | | | | | | | | | | | | This commit adds support for using the value of constants in conditional fields in addition to integers and flags. Intuitively, this probably looks like it shouldn't be needed: constants are known so the condition can be resolved ahead of time. It is however useful in the case of templates (example in the next commit) where the type of a field may be interchangeably an integer or a constant: type example_t[TYPE] { f1 TYPE f2 int32 (if[value[f1] == 3]) } type example1 example_t[int64] type example2 example_t[const[0, int64]] Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
* compiler: support using int flags in field conditionsPaul Chaignon2024-03-011-2/+2
| | | | | | | | | | | | | | | | | | | Commit ed571339c6ff ("pkg/compiler: support if[expr] attributes") added support for conditional fields in structs and unions. Conditions however cannot refer to flags, as in the following example: struct { f0 flags[some_flags, int32] f1 int32 (if[value[f0] & FLAG1]) } [packed] It will fail to compile with: flags does not refer to an integer This commit adds support for that syntax. Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
* pkg/compiler: support if[expr] attributesAleksandr Nogikh2024-02-191-0/+61
| | | | | | | | | | | | | | | | | | | The expression may either include integers/consts or reference other fields in the structure via value[field1:field2:field3]. The fields on this path must all belong to structures and must not have any if conditions themselves. For unions, mandate that the last field has no conditions (it will be the default one). For structs, convert conditional fields into fields of a union type of the following form: anonymous_union [ value T (if[expression]) void void ]
* pkg/compiler: extend parent reference support in lenAleksandr Nogikh2024-02-191-11/+20
| | | | | | | | | | | | Earlier only len[parent, T] was supported and meant the size of the whole structure. Logically, len[parent:b, T] should be equivalent to just len[b, T]. Let len[parent:parent:a, T] refer to the structure that encloses the current one. Support len fields inside unions.
* compiler/testdata: add missing error casesPaul Chaignon2023-11-291-1/+10
| | | | | | | This commit adds error cases that weren't covered before. They were identified by looking at the coverage numbers for pkg/compiler. Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
* compiler: prohibit homonymous flags and constsPaul Chaignon2023-11-281-0/+3
| | | | | | | | Since both flags and consts can be used as type-options for integers, we want to avoid ambiguity by preventing a flag and a const from having the same name. Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
* compiler: support const as int first argumentPaul Chaignon2023-11-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds support for the following syntax: int8[constant] as an equivalent to: const[constant, int8] The goal is to have a unified const/flags definition that we can use in templates. For example: type template[CLASS, ...] { class int8:3[CLASS] // ... } type singleClassType template[SINGLE_CONST] type subClassType template[abc_class_flags] In this example, the CLASS template field can be either a constant or a flag. This is especially useful when defining both a generic instance of the template as well as specialized instances (ex. bpf_alu_ops and bpf_add_op). Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
* pkg/compiler: prohibit not DirIn resources inside fmtAleksandr Nogikh2023-10-061-0/+4
| | | | | | | | The problem mentioned in the previous commit is actually not only ANY-specific, it's only by a happy coincidence that all our descriptions already avoided such situations. Enforce this rule at the compilation stage.
* prog, pkg/compiler: add `BufferCompressed` buffer type & `compressed_image` ↵Hrutvik Kanabar2022-11-211-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | builtin Create the `BufferCompressed` kind of `BufferType`, which will be used to represent compressed data. Create the corresponding `compressed_image` syzlang builtin, which is backed by `BufferCompressed`. For now, no syscalls use this feature - this will be introduced in future commits. We have to be careful to decompress the data before mutating, and re-compress before storing. We make sure that any deserialised `BufferCompressed` data is valid too. `BufferCompressed` arguments are mutated using a generic heatmap. In future, we could add variants of `BufferCompressed` or populate the `BufferType` sub-kind, using it to choose different kinds of heatmap for different uncompressed data formats. Various operations on compressed data must be forbidden, so we check for `BufferCompressed` in key places. We also have to ensure `compressed_image` can only be used in syscalls that are marked `no_{generate,minimize}`. Therefore, we add a generic compiler check which allows type descriptions to require attributes on the syscalls which use them.
* pkg/compiler: require stricter resource constructorsDmitry Vyukov2022-01-111-0/+8
| | | | | | | | | | | | | Don't consider syscalls that return resources in unions/arrays as constructors. Unions and arrays are problematic because we don't have directed generation in prog.randGen.createResource() and can fail to generate a syscall that returns a particular resource (generate a wrong union option that does not contain the necessary resource). This leads to the following panics: panic: failed to create a resource ifindex with ioctl$sock_SIOCGIFCONF Require each resource to have a constructor syscall that returns the resource outside of unions/arrays.
* pkg/compiler: fix error message spellingDmitry Vyukov2022-01-111-4/+4
| | | | Add missing space before brackets.
* pkg/compiler: prohibit use of len/flags/const/proc types in out fieldsDmitry Vyukov2022-01-111-1/+8
| | | | These types in explict out fields is either unnecessary details or bugs in descriptions.
* pkg/compiler: prohibit use of direction attribute on union fieldsDmitry Vyukov2022-01-111-8/+2
| | | | | | Direction attributes on unions work in a confusing way and don't do what users may think they do. Now we have out_overlay attribute for structs that allows to have overlapping input and output fields.
* pkg/compiler: add out_overlay field attributeDmitry Vyukov2022-01-111-0/+12
|
* pkg/compiler: check for flags with all equal valuesDmitry Vyukov2020-11-131-0/+6
| | | | | | There is no point in having flags when values are equal. This can only mean a typo or other bug. Check for such cases and fix 3 existing precedents.
* pkg, prog: add per-field direction attributeNecip Fazil Yildiran2020-08-131-5/+89
|
* pkg/compiler: check for unused resourcesDmitry Vyukov2020-08-041-1/+4
| | | | | | | | | | If a resource is never used as an input, it is not useful. It's effectively the same as using an integer. Detect such cases, they are quite confusing. Fix all existing errors in descriptions. This uncovered some interesting bugs as well, e.g. use of a completely unrelated fd subtype after copy-paste (while the resource that was supposed to be used there is completely unused).
* pkg/compiler: refactor attribute handlingDmitry Vyukov2020-04-191-0/+5
| | | | | | | | | | | | 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].
* pkg/compiler: check that flags values fit into base typeDmitry Vyukov2020-03-171-0/+3
| | | | | | | | flags[foo, int8] foo = 0x12345678 is always an error, detect these cases. Found some bugs in mptcp, packet sockets, kvm.
* pkg/compiler: check that const values fit into base typeDmitry Vyukov2020-03-171-0/+4
| | | | | const[0x12345678, int8] is always an error, detect these cases. Found some bugs in mptcp, socket proto and fuchsia fidl descriptions.
* pkg/compiler: add tests for generation phaseDmitry Vyukov2020-03-171-0/+2
| | | | | | Add errors3.txt with tests for errors that are produced during generation phase. Refactor tests to reduce duplication. Tidy struct/union size errors: better locations and make testable.
* pkg/ast: introduce hex-encoded string literalsDmitry Vyukov2020-02-101-0/+1
| | | | | | | | | | | | | The stringnozescapes does not make sense with filename, also we may need similar escaping for string flags. Handle escaped strings on ast level instead. This avoids introducing new type and works seamleassly with flags. As alternative I've also tried using strconv.Quote/Unquote but it leads to ugly half-escaped strings: "\xb0\x80s\xe8\xd4N\x91\xe3ڒ,\"C\x82D\xbb\x88\\i\xe2i\xc8\xe9\xd85\xb1\x14):M\xdcn" Make hex-encoded strings a separate string format instead.
* pkg/compiler: check range is consistent with base typePaul Chaignon2019-10-251-0/+13
| | | | | | For any intN, values in the range [-MAX_INTN:MAX_INTN] are accepted. Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
* prog, pkg/compiler: alignment for integer rangesPaul Chaignon2019-10-251-0/+7
| | | | | | | | | Enables the syntax intN[start:end, alignment] for integer ranges. For instance, int32[0:10, 2] represents even 32-bit numbers between 0 and 10 included. With this change, two NEED tags in syscall descriptions can be addressed. Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
* pkg/compiler: add offsetof typeDmitry Vyukov2019-05-161-0/+2
| | | | | | Similar to C offsetof gives offset of a field from the beginning of the parent struct. We have several TODOs in descriptions asking for this.
* pkg/compiler: allow to refer to syscall arguments in len pathsDmitry Vyukov2019-05-141-0/+2
| | | | This allows to use len[syscall:arg] expressions.
* pkg/compiler: support complex len targetsDmitry Vyukov2019-05-141-3/+31
| | | | | | | | | | This change adds compiler support for complex path expressions in len targets. E.g. it allows to refer to a sibling field as len[parent_struct:field:another_field]. See the docs change for details. This is just a compiler change. The feature is not yet supported by the prog package.
* pkg/compiler: support negative integersDmitry Vyukov2018-07-091-0/+5
| | | | | | Currently we have to use 0xffffffffffffffff to represent -1, and we can't express e.g. -20:20 int range. Support negative consts to fix both problems.
* pkg/compiler: check for unused declarationsDmitry Vyukov2018-06-301-0/+35
| | | | | Error on unused structs/unions/resources/flags. Finds tons of bugs.
* pkg/ast: support char constantsDmitry Vyukov2018-04-291-0/+1
| | | | | | | Frequently it's useful to do something like: int8['a':'z'] punctuation = ',', '-', ':'
* pkg/compiler: support size attribute for unionsDmitry Vyukov2018-03-051-0/+8
|
* pkg/compiler: add size attribute for structsDmitry Vyukov2018-03-051-0/+13
| | | | The size attribute allows to pad a struct up to the specified size.
* pkg/compiler: prohibit len of other union optionsDmitry Vyukov2018-02-231-0/+6
|
* pkg/compiler: allow len of var-len arraysDmitry Vyukov2018-02-171-2/+0
| | | | | All netfilter subsystems use this unfortunately, so demote this to a warning.
* pkg/compiler: support type templatesDmitry Vyukov2018-01-131-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]]) ```
* pkg/compiler: add check that len does not refer to array with varlen elementsDmitry Vyukov2017-11-281-0/+2
| | | | | This [almost] always means a bug in descriptions. Fix all bugs identified by the check.
* pkg/compiler: don't genererate missing syscallsDmitry Vyukov2017-09-151-1/+2
| | | | | | | | We used to generate them only because manager had no idea what arch it is testing. So syscalls numbers had to match between all arches. This is not needed anymore. Also don't generate unreferenced structs/resources.
* sys, pkg/compiler: move padding computation to compilerDmitry Vyukov2017-09-041-0/+46
| | | | This makes types constant during execution, everything is precomputed.
* pkg/compiler: detect resources without ctorsDmitry Vyukov2017-09-041-0/+87
Fixes #217