diff options
Diffstat (limited to 'pkg/csource/generated.go')
| -rw-r--r-- | pkg/csource/generated.go | 60 |
1 files changed, 51 insertions, 9 deletions
diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go index 8c80cc363..bceb2dba4 100644 --- a/pkg/csource/generated.go +++ b/pkg/csource/generated.go @@ -3767,6 +3767,18 @@ static void initialize_wifi_devices(void) } #endif +#if SYZ_EXECUTOR || (SYZ_NET_DEVICES && SYZ_NIC_VF) || SYZ_SWAP +static int runcmdline(char* cmdline) +{ + debug("%s\n", cmdline); + int ret = system(cmdline); + if (ret) { + debug("FAIL: %s\n", cmdline); + } + return ret; +} +#endif + #if SYZ_EXECUTOR || SYZ_NET_DEVICES #include <arpa/inet.h> #include <errno.h> @@ -4028,15 +4040,6 @@ error: } #if SYZ_EXECUTOR || SYZ_NIC_VF -static int runcmdline(char* cmdline) -{ - debug("%s\n", cmdline); - int ret = system(cmdline); - if (ret) { - debug("FAIL: %s\n", cmdline); - } - return ret; -} static void netlink_nicvf_setup(void) { @@ -11762,6 +11765,42 @@ static long syz_pkey_set(volatile long pkey, volatile long val) } #endif +#if SYZ_EXECUTOR || SYZ_SWAP +#include <fcntl.h> +#include <stdio.h> +#include <string.h> +#include <sys/stat.h> +#include <sys/swap.h> +#include <sys/types.h> + +#define SWAP_FILE "./swap-file" +#define SWAP_FILE_SIZE (128 * 1000 * 1000) + +static void setup_swap() +{ + swapoff(SWAP_FILE); + unlink(SWAP_FILE); + int fd = open(SWAP_FILE, O_CREAT | O_WRONLY | O_CLOEXEC, 0600); + if (fd == -1) { + failmsg("swap file open failed", "file: %s", SWAP_FILE); + return; + } + fallocate(fd, FALLOC_FL_ZERO_RANGE, 0, SWAP_FILE_SIZE); + close(fd); + char cmdline[64]; + sprintf(cmdline, "mkswap %s", SWAP_FILE); + if (runcmdline(cmdline)) { + fail("mkswap failed"); + return; + } + if (swapon(SWAP_FILE, SWAP_FLAG_PREFER) == 1) { + failmsg("swapon failed", "file: %s", SWAP_FILE); + return; + } +} + +#endif + #elif GOOS_test #include <stdlib.h> @@ -12645,6 +12684,9 @@ int main(void) #if SYZ_802154 setup_802154(); #endif +#if SYZ_SWAP + setup_swap(); +#endif #if SYZ_HANDLE_SEGV install_segv_handler(); #endif |
