aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/osutil
Commit message (Collapse)AuthorAgeFilesLines
* all: use `t.TempDir` to create temporary test directoryEng Zer Jun2022-03-282-13/+2
| | | | | | | | | This commit replaces all `ioutil.TempDir` with `t.TempDir` in tests. The directory created by `t.TempDir` is automatically removed when the test and all its subtests complete. Reference: https://pkg.go.dev/testing#T.TempDir Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
* pkg/build: increase bazel aquery timeoutDmitry Vyukov2021-12-131-1/+1
| | | | | | We've got a timeout of "bazel aquery". It's currently set to 1 minute. On an overloaded machine it can fire falsely, I guess bazel can start only for 1 minute. Increase to 10 minutes.
* pkg/osutil: use memfd_create on LinuxAleksandr Nogikh2021-12-033-26/+84
| | | | | | | | | | Mmapping plain files as shared memory leads to extra burden on the system being fuzzed, because the OS will periodically sync that data to the disk. On Linux, use memfd_create to obtain a file handle for the shared memory region. Experiments have demonstrated than it leads to 5-10% increase in the fuzzing performance.
* pkg/osutil: slightly relaxed Abs checkDmitry Vyukov2021-10-251-9/+12
| | | | | | | | | | | Currently Abs captures pwd in init function and checks that it's not changing over program execution. However, in some test environments (bazel) we need to chdir in test init function because the test process is started in a wrong dir. This causes the check in Abs to fail. Query the pwd lazily on the first Abs call. This does not change behavior for Abs users, but allows to change pwd in other init functions.
* tools/syz-testbed: do not send SIGKILL to syz-managersAleksandr Nogikh2021-10-207-10/+24
| | | | | Doing so can result in syz-manager leaking GCE instances. Set PDEATHSIG to SIGTERM instead, so that syz-manager has a change to exit gracefully.
* pkg: update generated files to go 1.17Alexey Kardashevskiy2021-07-074-0/+4
| | | | | | | | | | | "make generate" produces this diff when go 1.17 (go1.17-c95464f0ea3f==upstream) is used. Seems compatible with >=1.16. https://github.com/golang/go/commit/4d2d89ff42ca documents the syntax. https://github.com/golang/go/commit/eeadce2d8713 enforces "ignore" for unsatisfiable tags hence the pkg/csource/gen.go change. Signed-off-by: Alexey Kardashevskiy <aik@linux.ibm.com>
* pkg/osutil: extend error message on wd changeDmitry Vyukov2020-11-211-1/+1
| | | | Knowning the new wd may help to localize the error.
* sys/linux: descriptions for USB/IPNazime Hande Harputluoglu2020-10-021-0/+10
|
* pkg/osutil: fix LinkFiles/FilesExist for the new pattern formatDmitry Vyukov2020-09-152-57/+64
|
* syz-ci: fix seeds copyingDmitry Vyukov2020-09-141-15/+0
| | | | | | | | | | | | | 1. Copy seeds from syzkaller checkout into syzkaller build dir. They need to be stable. 2. Make the code generic (current is linux-specific). 3. Don't copy seeds to workdir/seeds. We can load them directly from sys/OS/test. There are some unresolved comments for LinkDir on #2053 anyway. Follow up to #2053
* pkg/osutil: support glob patterns in CopyFilesDmitry Vyukov2020-09-142-10/+120
| | | | Follow up to #2053
* syz-manager: add test file as corpusJiaheng Hu2020-09-141-0/+15
| | | | | | | This commit enables the syz-manager to add unit test files as corpus to accelerate fuzzing. The syz-ci would copy unit tests into the worker/seeds folder for each manager process, and the manager would add those tests as seed into the corpus.
* tools/syz-linter: fix comments checkDmitry Vyukov2020-07-101-1/+1
| | | | | | | Turns out ast.Inspect does not visit most comments. Walk file.Comments manually. Update #1876
* pkg/osutil: remove appengine tagDmitry Vyukov2020-07-0610-59/+12
| | | | | Appengine doesn't provide appengine tag anymore. Resort to use of syscall package for ExitStatus instead.
* pkg/osutil: don't use os.ProcessState.ExitCode on appengineDmitry Vyukov2020-07-063-5/+25
| | | | It's not present in Go 1.11.
* pkg/bisect: minor style fix upsDmitry Vyukov2020-07-021-4/+10
|
* pkg/osutil: use functionality from x/sys/unixTobias Klauser2020-06-291-18/+4
| | | | | | | | | | Use unix.Unmount instead of manually wrapping SYS_UMOUNT2. Use unix.IoctlSetPointerInt instead of manually wrapping SYS_IOCTL. This also allows to use FS_IOC_SETFLAGS instead of manually defining it for each GOARCH. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* pkg/osutil: implement support for linux/riscv64Tobias Klauser2020-06-261-1/+1
| | | | Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* sys/linux: first 64bit big-endian architecture s390xAlexander Egorenkov2020-06-251-1/+1
| | | | | | | | | | | | | | | * mmap syscall is special on Linux s390x because the parameters for this syscall are passed as a struct on user stack instead of registers. * Introduce the SyscallTrampolines table into targets.Target to address the above problem. * There is a bug in Linux kernel s390x which causes QEMU TCG to hang when KASAN is enabled. The bug has been fixed in the forthcoming Linux 5.8 version. Until then do not enable KASAN when using QEMU TCG, QEMU KVM shall have no problems with KASAN. Signed-off-by: Alexander Egorenkov <Alexander.Egorenkov@ibm.com>
* .golangci.yml: enable nestif checkerDmitry Vyukov2020-06-051-14/+18
| | | | Prevents functions with too many nested if's.
* pkg/osutil: don't sandbox on CIDmitry Vyukov2020-05-181-1/+1
| | | | | | CI does not have syzkaller user, but may run under root. Update #1699
* Implement basic support for MIPS64LEJouni Hogander2019-12-171-1/+1
| | | | | | | | | Add basic stuff to enable MIPS64ELR2 target: - build - make extract - make generate - qemu execution - system call parsing from /proc/kallsyms
* vm: add workdir_template functionalityDmitry Vyukov2019-12-031-0/+24
| | | | | | | | | | | | | | | | | The new manager config argument workdir_template refers to a directory. Optional. Each VM will get a recursive copy of the files that are present in workdir_template. VM config can then use these private copies as needed. The copy directory can be referenced with "{{TEMPLATE}}" string. This is different from using the files directly in that each instance will get own clean, private, scratch copy of the files. Currently supported only for qemu_args argument of qemu VM type. Use example: Create a template dir with necessary files: $ mkdir /mytemplatedir $ truncate -s 64K /mytemplatedir/fd Then specify the dir in the manager config: "workdir_template": "/mytemplatedir" Then use these files in VM config: "qemu_args": "-fda {{TEMPLATE}}/fd"
* pkg/osutil: fix arm buildAndrey Konovalov2019-09-161-1/+1
| | | | pkg/osutil/osutil_linux.go:44:13: cannot use info.Totalram (type uint32) as type uint64 in return argument
* tools/syz-env: restrict Makefile parallelism based on RAMDmitry Vyukov2019-07-196-0/+26
| | | | | | | Ensure that we have at least 1GB per Makefile job. Go compiler/linker can consume significant amount of memory (observed to consume at least 600MB). See #1276 for context. Update #1276
* pkg/osutil: kill subprocesses more reliablyDmitry Vyukov2019-03-188-0/+26
| | | | | | | | | | In some cases we start scp, which starts ssh, then kill scp but the ssh subprocess is not killed. As the result cmd.Wait hangs waiting for EOF on the stdout/stderr, which are still kept alive by ssh subprocess. But ssh just hangs forever. Create a process group for each command and kill whole process group. Hopefully this will help.
* pkg/osutil: return output with errors from RunDmitry Vyukov2019-03-171-1/+1
| | | | | | | | | Turns out git bisect fails to communicate some outcomes (multiple potential commits), and the only way to understand what happened is parsing plain English output. Extracting the output from the error is quite unhandy. So return it with the error. Update #501
* pkg/osutil: fix disabling of sandboxDmitry Vyukov2019-03-171-9/+7
| | | | | | If sandboxing is disabled don't unshare net namespace too. Update #501
* pkg/ipc: generate better temp name for executorDmitry Vyukov2019-02-081-1/+29
| | | | | | | | | Just appending the pid number can produce conflicting names if the name itself ends with digits (standard temp file naming convention). So append ".PID". Also remove beginning from too long names instead of ending. Temp files in tests has unique numbers at the end, we need to preserve them to avoid file name conflicts.
* pkg/osutil: always remove old file in RenameDmitry Vyukov2018-12-201-1/+2
|
* pkg/osutil: provide better RenameDmitry Vyukov2018-12-171-0/+10
| | | | | os.Rename fails for cross-device renaming (e.g. to/from tmpfs). This is quite unpleasant. Provide own version that falls back to copying.
* pkg/runtest: fixes for fuchsiaDmitry Vyukov2018-09-061-4/+2
| | | | | | | Add simple fuchsia program, the one that is run during image testing. Fix csource errno printing for fuchsia. Fix creation of executable files (chmod is not implemented on fuchsia). Check that we get signal/coverage from all syscalls.
* Add mandatory OpenBSD bits (#689)Anton Lindqvist2018-08-282-2/+2
| | | | | | | | | | | | | | | | | | all: add openbsd support squash of the following commits: * openbsd: add mandatory bits * report: add OpenBSD support * executor: skip building kvm on OpenBSD * executor: add OpenBSD support Linking against libutil is necessary due to usage of openpty(3). * executor: fix typo in fail() message * fixup! report: add OpenBSD support * fixup! openbsd: add mandatory bits * fixup! openbsd: add mandatory bits * fixup! openbsd: add mandatory bits * fixup! report: add OpenBSD support * gometalinter: skip sys/openbsd
* pkg/osutil: replace UmountAll with RemoveAllDmitry Vyukov2018-08-046-7/+16
| | | | | | | | In pkg/ipc we don't just want to UmountAll, we want to remove all handling as many cases as possible (mounts, read-only files, etc, similar to executor's remove_dir). So unmounting and removing needs to be a single function, so that it can handle all these cases.
* pkg/ipc: remove abort signal and buffer sizeDmitry Vyukov2018-08-033-19/+0
| | | | | | They were needed for intermediate gvisor support. Now that we have end-to-end support for gvisor, they are not needed anymore. Remove.
* pkg/osutil: minor tweaksDmitry Vyukov2018-08-031-4/+18
| | | | | | 1. Make it clear when a command times out. 2. Don't add trailing newline for VerboseError if output is empty. 3. Fix WriteExecFile for the case when the file already exists.
* pkg/host: check that we can open files rather than that they existDmitry Vyukov2018-07-101-0/+13
| | | | | | | See issue #640 where /dev/net/tun is present, but open fails with ENODEV. Check that we can actually open all these files. Fixes #640
* pkg/osutil: allow to provide own stdout/stderr during cmd executionDmitry Vyukov2018-07-051-2/+6
| | | | Useful if caller wants to collect only stdout or stderr.
* pkg/build: add gvisor supportDmitry Vyukov2018-06-221-6/+15
|
* pkg/kernel: allow to split full make outputDmitry Vyukov2018-05-171-2/+23
| | | | | | | | | | | Currently kernel build failures are insanely verbose (contain full kernel build output) and there is no way to separate short descriptions from full output. Make it possible. Also try to extract failure root cause froom build log. Use this in pkg/bisect to not pollute log on build failures. Update #501
* pkg/osutil: allow disabling sandboxing with env varDmitry Vyukov2018-05-171-14/+21
| | | | | | | | If SYZ_DISABLE_SANDBOXING=yes is set, don't do user sandboxing. Will be usefule for bisection tool which runs locally, but needs to build kernel. Update #501
* pkg/osutil: introduce TempFile helperDmitry Vyukov2018-05-141-0/+11
| | | | Introduce TempFile helper and use it in several packages.
* all: fix gometalinter warningsDmitry Vyukov2018-03-081-7/+10
| | | | Fix typos, non-canonical code, remove dead code, etc.
* pkg/osutil: use proper gid during sandboxingDmitry Vyukov2018-03-061-2/+2
|
* pkg/report: handle syzkaller binariesDmitry Vyukov2017-12-121-0/+1
| | | | syzkallerNNN binaries are coming from pkg/repro.
* pkg/osutil: properly set gid for sandboxingDmitry Vyukov2017-11-171-11/+25
|
* pkg/kernel: sandbox make invocationDmitry Vyukov2017-11-177-2/+110
|
* pkg/osutil: don't leace runaway processesDmitry Vyukov2017-11-168-17/+66
| | | | | | When manager is stopped there are sometimes runaway qemu processes still running. Set PDEATHSIG for all subprocesses. We never need child processes outliving parents.
* all: basic building on netbsdDmitry Vyukov2017-10-232-1/+3
| | | | | This just makes make TARGETOS=netbsd succeed. We don't yet have prog target for netbsd.
* executor, pkg/ipc: unify ipc protocol between linux and other OSesDmitry Vyukov2017-10-168-28/+170
| | | | | | | | | | | | | | | | | We currently use more complex and functional protocol on linux, and a simple ad-hoc protocol on other OSes. This leads to code duplication in both ipc and executor. Linux supports coverage, shared memory communication and fork server, which would also be useful for most other OSes. Unify communication protocol and parametrize it by (1) use of shmem or only pipes, (2) use of fork server. This reduces duplication in ipc and executor and will allow to support the useful features for other OSes easily. Finally, this fixes akaros support as it currently uses syz-stress running on host (linux) and executor running on akaros.