aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/compiler/testdata
Commit message (Collapse)AuthorAgeFilesLines
* 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-112-8/+7
| | | | | | 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-113-1/+41
|
* pkg/compiler: warn about confusing comments that fake directivesDmitry Vyukov2021-11-121-0/+5
| | | | | | | | It's a somewhat common mistake to write comments instead of directives: #include <foo> #define FOO BAR because that's how it's done in C. Warn about such cases.
* pkg/compiler: add more tests for templatesDmitry Vyukov2021-10-051-0/+20
| | | | Add 2 more tests for recursive templates.
* pkg/compiler: fix infinite recursion in template instantiationDmitry Vyukov2021-10-051-0/+5
| | | | | | | | | | | | | Fix a bug found by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17240 We handled the case of infinite recursion in templates but only if the full type name matches precisely (A -> B -> A). In this case the name constantly changes due to different template arguments. Per se this is a not an error (and we have real cases that use this, e.g. when an nlattr_t contains nested nlattr_t's), but it's an error if it recurses infinitely. Restrict recursion on the same template to 10 levels.
* pkg/compiler: add glob typeJoey Jiaojg2021-05-262-1/+9
| | | | | | | | | | | | | | | | | | | | * all: add new typename dirname The current way to check files under sysfs or proc is: - define a string to represent each file - open the file - pass the fd to write / read / close The issues above are: - Need to know what file present on target device - Need to write openat for each file With dirname added, which will open one file in the directory randomly and then pass the fd to write/read/close. * all: use typename glob to match filename Fixes #481
* 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-133-6/+108
|
* 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: fix crash on fmt[flags]Dmitry Vyukov2020-07-231-0/+3
| | | | | | | Flags with only 1 value 0 are transformed to ConstType. Fmt did not expect that. Fixes #1965
* pkg/compiler: simplify and enhance handling of builtinsDmitry Vyukov2020-05-051-2/+2
| | | | | | | | | Currently we have special support for each type of builtin node. This is complex and does not scale (we may want other types in future). Prepend the builtin descriptions to the user descriptions instead. This requires a bit of special support, like not reporting any builtin descriptions as unused, but otherwise much simpler and more flexible. Does not produce any diff in generated descriptions.
* pkg/compiler: error on duplicate attributesDmitry Vyukov2020-04-191-0/+1
|
* prog: introduce call attributesDmitry Vyukov2020-04-192-0/+6
| | | | | | Add common infrastructure for syscall attributes. Add few attributes we want, but they are not implemented for now (don't affect behavior, this will follow).
* pkg/compiler: refactor attribute handlingDmitry Vyukov2020-04-193-11/+8
| | | | | | | | | | | | 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-172-0/+7
| | | | | 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-173-0/+24
| | | | | | 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/compiler: ensure consistency of syscall argument typesDmitry Vyukov2020-03-171-52/+52
| | | | | | | | | | | | | | | | | | Ensure that we don't have conflicting sizes for the same argument of the same syscall, e.g.: foo$1(a int16) foo$2(a int32) This is useful for several reasons: - we will be able avoid morphing syscalls into other syscalls - we will be able to figure out more precise sizes for args (lots of them are implicitly intptr, which is the largest type on most important arches) - found few bugs in linux descriptions Update #477 Update #502
* pkg/compiler: don't specify syscall consts for test OSDmitry Vyukov2020-03-171-2/+2
| | | | This is just tedious. Fabricate them on the fly.
* pkg/ast: introduce hex-encoded string literalsDmitry Vyukov2020-02-102-0/+4
| | | | | | | | | | | | | 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: fix alignment of string-formatted valuesDmitry Vyukov2019-12-201-1/+6
| | | | | | We used size as alignment, this is very wrong. Found thanks to syz-check. Update #590
* pkg/compiler: fix incorrect alignment calculation for paddingDmitry Vyukov2019-12-181-1/+10
| | | | | | | | | | | | | | We assumed that for ConstType alignment is equal to size, which is perfectly reasonable for normal int8/16/32/64/ptr. However, padding is also represented by ConstType of arbitrary size, so if we added 157 bytes of padding that becomes alignment of the padding field and as the result of the whole struct. This affects very few structs, but quite radically and quite important structs. Discovered thanks to syz-check. Update #590
* pkg/compiler: define fileoff templatePaul Chaignon2019-11-011-2/+2
| | | | Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
* pkg/compiler: special BASE argument in templatesPaul Chaignon2019-11-012-7/+21
| | | | Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
* pkg/compiler: check range is consistent with base typePaul Chaignon2019-10-252-1/+14
| | | | | | 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-254-1/+14
| | | | | | | | | 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: check first int arg is rangePaul Chaignon2019-10-251-1/+1
| | | | Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
* pkg/compiler: fix root node not visited in typedef checksPaul Chaignon2019-10-231-0/+2
| | | | | | | | | | Without this fix, the compiler throws an error 'template argument BASE is not used' for the following typedef. type templ1[BASE] BASE foo(a ptr[in, templ1[int64]]) Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
* pkg/compiler: detect unused template paramsAndrey Konovalov2019-09-041-2/+2
|
* pkg/compiler: add offsetof typeDmitry Vyukov2019-05-162-0/+4
| | | | | | 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-142-1/+4
| | | | This allows to use len[syscall:arg] expressions.
* pkg/compiler: support complex len targetsDmitry Vyukov2019-05-143-4/+62
| | | | | | | | | | 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: make buffer alias to ptr[array[int8]]Dmitry Vyukov2019-04-012-3/+5
| | | | | | | | | | | Ptr type has special handling of direction (pointers are always input). But buffer type missed this special case all the time. Make buffer less special by aliasing to the ptr[array[int8]] type. As the result buffer type can't have optional trailing "opt" attribute because we don't have such support for templates yet. Change such cases to use ptr type directly. Fixes #1097
* pkg/compiler: don't warn about the same len twiceDmitry Vyukov2019-01-311-0/+21
| | | | Also add tests for warnings while we are here.
* executor: fix handling of big-endian bitfieldsDmitry Vyukov2018-12-081-0/+1
| | | | | Currently we apply big-endian-ness and bitfield-ness in the wrong order in copyin. This leads to totally bogus result. Fix this.
* pkg/compiler: add vma64 typeDmitry Vyukov2018-11-171-0/+7
| | | | 8-byte vma is needed in several places in linux descriptions.
* pkg/compiler: prohibit subargsDmitry Vyukov2018-08-101-0/+2
|
* pkg/compiler: refactor checkTypeDmitry Vyukov2018-08-021-1/+1
| | | | | | | checkType is too long and complex. Move basic type checks and args checks into separate functions. Update #538
* pkg/compiler: support negative integersDmitry Vyukov2018-07-093-2/+10
| | | | | | 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.
* prog, pkg/compiler: support fmt typeDmitry Vyukov2018-07-082-0/+25
| | | | | fmt type allows to convert intergers and resources to string representation.
* pkg/compiler: check for unused declarationsDmitry Vyukov2018-06-303-0/+51
| | | | | Error on unused structs/unions/resources/flags. Finds tons of bugs.
* pkg/compiler: add optional builtin templateDmitry Vyukov2018-05-171-0/+1
| | | | | | | type optional[T] [ val T void void ] [varlen]
* pkg/compiler: detect duplicate fields in template structsDmitry Vyukov2018-05-171-0/+1
|
* pkg/ast: support char constantsDmitry Vyukov2018-04-292-3/+4
| | | | | | | 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-054-2/+42
| | | | The size attribute allows to pad a struct up to the specified size.
* pkg/compiler: switch attributes from Ident to TypeDmitry Vyukov2018-03-051-0/+12
| | | | | This allows parametrized attributes like size[10]. But this is not used for now.