aboutsummaryrefslogtreecommitdiffstats
path: root/prog/size_test.go
Commit message (Collapse)AuthorAgeFilesLines
* tools/syz-linter: check t.Logf/Errorf/Fatalf messagesDmitry Vyukov2024-04-171-1/+1
| | | | | Fix checking of Logf, it has string in 0-th arg. Add checking of t.Errorf/Fatalf.
* prog: fix selection of args eligible for squashingDmitry Vyukov2024-04-151-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes 3 issues: 1. We intended to squash only 'in' pointer elems, but we looked at the pointer direction rather than elem direction. Since pointers themselves are always 'in' we squashed a number of types we didn't want to squash. 2. We can squash filenames, which can lead to generation of escaping filenames, e.g. fuzzer managed to create "/" filename for blockdev_filename as: mount(&(0x7f0000000000)=ANY=[@ANYBLOB='/'], ...) Don't squash filenames. 3. We analyzed a concrete arg to see if it contains something we don't want to squash (e.g. pointers). But the whole type can still contain unsupported things in inactive union options, or in 0-sized arrays. E.g. this happened in the mount case above. Analyze the whole type to check for unsupported things. This also moves most of the analysis to the compiler, so mutation will be a bit faster. This removes the following linux types from squashing. 1. These are not 'in': btrfs_ioctl_search_args_v2 btrfs_ioctl_space_args ethtool_cmd_u fscrypt_add_key_arg fscrypt_get_policy_ex_arg fsverity_digest hiddev_ioctl_string_arg hidraw_report_descriptor ifreq_dev_t[devnames, ptr[inout, ethtool_cmd_u]] ifreq_dev_t[ipv4_tunnel_names, ptr[inout, ip_tunnel_parm]] ifreq_dev_t["sit0", ptr[inout, ip_tunnel_prl]] io_uring_probe ip_tunnel_parm ip_tunnel_prl poll_cq_resp query_port_cmd query_qp_resp resize_cq_resp scsi_ioctl_probe_host_out_buffer sctp_assoc_ids sctp_authchunks sctp_getaddrs sctp_getaddrs_old 2. These contain pointers: binder_objects iovec[in, netlink_msg_route_sched] iovec[in, netlink_msg_route_sched_retired] msghdr_netlink[netlink_msg_route_sched] msghdr_netlink[netlink_msg_route_sched_retired] nvme_of_msg 3. These contain filenames: binfmt_script blockdev_filename netlink_msg_route_sched netlink_msg_route_sched_retired selinux_create_req
* prog: test len calculation of structs with conditionsAleksandr Nogikh2024-02-191-0/+8
|
* pkg/compiler: extend parent reference support in lenAleksandr Nogikh2024-02-191-0/+12
| | | | | | | | | | | | 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.
* pkg/mgrconfig, prog, syz-fuzzer: manager-configurable syscall mutationHrutvik Kanabar2022-09-221-1/+1
| | | | | | | | | | | | | | | | | | Allow manager configuration to specify that certain syscalls should not be mutated. This is expected to be useful when mutating certain syscalls is unlikely to produce interesting executions. For example, mutating a `syz_mount_image` call will likely produce a corrupt image. Some implementation details: - Add a `no_mutate_syscalls` manager config entry, with the same format as `enable_syscalls`. Ensure this is parsed and stored in the config as a set of syscall IDs. - Send this set to fuzzers when they connect to their managers via RPC. Ensure each fuzzer stores a copy of the set. - When mutating arguments of a syscall, check first whether it has been specified as non-mutatable. - For all mutations not managed by a `syz-manager`, retain previous behaviour by ensuring that no syscalls are considered non-mutable.
* prog: support disabled attributeDmitry Vyukov2020-05-041-2/+3
| | | | | Update #477 Update #502
* prog: fix size assignment for squashed argsDmitry Vyukov2020-05-011-0/+7
| | | | | | | | We can have a situation where len target points into a squashed argument. In suca case we don't have the target argument. In such case we simply leave size argument as is. It can't happen during generation, only during mutation and mutation can set size to random values, so it should be fine. This is a lateny bug, we just never had such case before.
* prog: export deserialization test helper for sys/{linux,openbsd}Dmitry Vyukov2020-03-171-64/+64
| | | | | sys/{linux,openbsd} duplicate deserialization test logic as well. Export and reuse the existing helper function.
* prog: factor out common code in testsDmitry Vyukov2020-03-171-82/+68
| | | | Factor out a common test helper for tests that deserialize and check programs.
* pkg/compiler: ensure consistency of syscall argument typesDmitry Vyukov2020-03-171-2/+2
| | | | | | | | | | | | | | | | | | 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: add offsetof typeDmitry Vyukov2019-05-161-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-141-2/+2
| | | | This allows to use len[syscall:arg] expressions.
* prog: implement complex len target supportDmitry Vyukov2019-05-141-1/+4
| | | | | This actually implements support for complex len targets during program generation and mutation.
* prog: introduce strict parsing modeDmitry Vyukov2018-12-101-1/+1
| | | | | | | | | | | Over time we relaxed parsing to handle all kinds of invalid programs (excessive/missing args, wrong types, etc). This is useful when reading old programs from corpus. But this is harmful for e.g. reading test inputs as they can become arbitrary outdated. For runtests which creates additional problem of executing not what is actually written in the test (or at least what author meant). Add strict parsing mode that does not tolerate any errors. For now it just checks excessive syscall arguments.
* executor: overhaulDmitry Vyukov2018-07-241-58/+58
| | | | | | | | | | | | | | | | | Make as much code as possible shared between all OSes. In particular main is now common across all OSes. Make more code shared between executor and csource (in particular, loop function and threaded execution logic). Also make loop and threaded logic shared across all OSes. Make more posix/unix code shared across OSes (e.g. signal handling, pthread creation, etc). Plus other changes along similar lines. Also support test OS in executor (based on portable posix) and add 4 arches that cover all execution modes (fork server/no fork server, shmem/no shmem). This change paves way for testing of executor code and allows to preserve consistency across OSes and executor/csource.
* gometalinter: enable line length checkingDmitry Vyukov2018-05-041-0/+1
| | | | | | | 120 columns looks like a reasonable limit and requires few changes to existing code. Update #538
* all: fix gometalinter warningsDmitry Vyukov2018-03-081-1/+1
| | | | Fix typos, non-canonical code, remove dead code, etc.
* prog: fix isDefaultArgDmitry Vyukov2018-03-081-1/+1
| | | | | Test that isDefaultArg returns true for result of DefaultArg. Fix few bugs uncovered by this test.
* pkg/compiler: allow specifying static size for filename'sDmitry Vyukov2018-03-051-0/+4
| | | | Sometimes filenames are embed into structs and need to take fixed space.
* pkg/compiler: support size attribute for unionsDmitry Vyukov2018-03-051-0/+4
|
* pkg/compiler: add size attribute for structsDmitry Vyukov2018-03-051-0/+4
| | | | The size attribute allows to pad a struct up to the specified size.
* pkg/compiler: fix corner case in alignment calculationDmitry Vyukov2018-02-191-1/+5
|
* prog: fix test outputDmitry Vyukov2018-02-171-1/+1
| | | | Print programs as strings, rather than byte sequences.
* prog: don't serialize default argumentsDmitry Vyukov2018-02-011-1/+1
| | | | | | | This reduces size of a corpus in half. We store corpus on manager and on hub, so this will reduce their memory consumption. But also makes large programs more readable.
* pkg/compiler, prog: fix template parent lensDmitry Vyukov2018-01-241-0/+4
| | | | | | | It's possible that a struct can have 2+ parents, which is the same template (differs only by arguments). See the new test case. Support such case.
* pkg/compiler: fix len of parent template structDmitry Vyukov2018-01-231-0/+4
| | | | | | | | | | | | | | | | | | | | | Consider the following example: type len_templ1[DATA1, DATA2] { data DATA1 inner len_temp2[DATA2] } type len_temp2[DATA] { data DATA len len[len_templ1, int8] } Here len refers to a parent struct, but the struct is a template, so it's actual name is something like "len_templ1[int8, int16]". Currently this does not work as compiler barks at incorrect len target. Make this work.
* pkg/compiler: add bitsize typeDmitry Vyukov2018-01-061-0/+8
| | | | This is need for few crypto/xfrm descriptions.
* prog: mutate len argumentsDmitry Vyukov2017-12-311-3/+0
| | | | Fixes #183
* sys: move test syscalls to a separate targetDmitry Vyukov2017-12-171-1/+1
| | | | | | We have them in linux solely for historical reasons. Fixes #462
* prog: support bytesizeN for vmaDmitry Vyukov2017-11-291-3/+3
| | | | | | I guess this is currently unused, but ignoring bytesizeN for vma looks wrong. If user asks for bytesizeN for vma, divide vma size by N.
* prog: remove default target and all global stateDmitry Vyukov2017-09-151-15/+8
| | | | | | Now each prog function accepts the desired target explicitly. No global, implicit state involved. This is much cleaner and allows cross-OS/arch testing, etc.
* syz-manager/mgrconfig: explicitly specify target in configDmitry Vyukov2017-09-151-0/+5
| | | | | Add target config parameter (e.g. linux/amd64) which controls target OS/arch. No more explicit assumptions about target.
* prog, sys: move types to progDmitry Vyukov2017-09-051-5/+8
| | | | | | | | | | | Large overhaul moves syscalls and arg types from sys to prog. Sys package now depends on prog and contains only generated descriptions of syscalls. Introduce prog.Target type that encapsulates all targer properties, like syscall list, ptr/page size, etc. Also moves OS-dependent pieces like mmap call generation from prog to sys. Update #191
* sys, pkg/compiler: move padding computation to compilerDmitry Vyukov2017-09-041-1/+1
| | | | This makes types constant during execution, everything is precomputed.
* prog: properly remove calls when splicing progsAndrey Konovalov2017-08-011-9/+7
| | | | | | Use removeCall() to update use references. Also add a test and speed up other ones.
* prog: split Arg into smaller structsAndrey Konovalov2017-07-171-4/+4
| | | | | | | | | | | | | | | | | | | | | | Right now Arg is a huge struct (160 bytes), which has many different fields used for different arg kinds. Since most of the args we see in a typical corpus are ArgConst, this results in a significant memory overuse. This change: - makes Arg an interface instead of a struct - adds a SomethingArg struct for each arg kind we have - converts all *Arg pointers into just Arg, since interface variable by itself contains a pointer to the actual data - removes ArgPageSize, now ConstArg is used instead - consolidates correspondence between arg kinds and types, see comments before each SomethingArg struct definition - now LenType args that denote the length of VmaType args are serialized as "0x1000" instead of "(0x1000)"; to preserve backwards compatibility syzkaller is able to parse the old format for now - multiple small changes all over to make the above work After this change syzkaller uses twice less memory after deserializing a typical corpus.
* sys, prog: add length of parent of parent to templatesAndrey Konovalov2017-01-231-1/+5
| | | | | | | | | | | | | | Example: ``` struct s1 { f0 len[s2] # length of s2 } struct s2 { f0 s1 f1 array[int32] } ```
* prog: fix bytesizeN for nonarray fieldsAndrey Konovalov2017-01-191-2/+10
|
* prog: fix calculating parent length in struct with bitfieldsAndrey Konovalov2017-01-191-0/+4
|
* prog: add bytesizeN typesAndrey Konovalov2016-12-201-0/+4
|
* fuzzer: combine progs from corpusAndrey Konovalov2016-11-251-1/+1
|
* prog: assign types to args during constructionDmitry Vyukov2016-11-111-3/+0
| | | | | | Eliminate assignTypeAndDir function and instead assign types to all args during construction. This will allow considerable simplifation of assignSizes.
* Add assign len fields testsAndrey Konovalov2016-10-111-0/+123