// https://syzkaller.appspot.com/bug?id=d07412a238e801f00f35d25aad24832210ca2304 // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include __attribute__((noreturn)) static void doexit(int status) { volatile unsigned i; syscall(__NR_exit_group, status); for (i = 0;; i++) { } } #include #include #include #include #include const int kFailStatus = 67; const int kRetryStatus = 69; static void fail(const char* msg, ...) { int e = errno; va_list args; va_start(args, msg); vfprintf(stderr, msg, args); va_end(args); fprintf(stderr, " (errno %d)\n", e); doexit((e == ENOMEM || e == EAGAIN) ? kRetryStatus : kFailStatus); } static uint64_t current_time_ms() { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) fail("clock_gettime failed"); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static uintptr_t syz_open_dev(uintptr_t a0, uintptr_t a1, uintptr_t a2) { if (a0 == 0xc || a0 == 0xb) { char buf[128]; sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1, (uint8_t)a2); return open(buf, O_RDWR, 0); } else { char buf[1024]; char* hash; strncpy(buf, (char*)a0, sizeof(buf)); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(a1 % 10); a1 /= 10; } return open(buf, a2, 0); } } static uintptr_t syz_open_procfs(uintptr_t a0, uintptr_t a1) { char buf[128]; memset(buf, 0, sizeof(buf)); if (a0 == 0) { snprintf(buf, sizeof(buf), "/proc/self/%s", (char*)a1); } else if (a0 == (uintptr_t)-1) { snprintf(buf, sizeof(buf), "/proc/thread-self/%s", (char*)a1); } else { snprintf(buf, sizeof(buf), "/proc/self/task/%d/%s", (int)a0, (char*)a1); } int fd = open(buf, O_RDWR); if (fd == -1) fd = open(buf, O_RDONLY); return fd; } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); setsid(); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 32 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); if (unshare(CLONE_NEWNS)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid < 0) fail("sandbox fork failed"); if (pid) return pid; sandbox_common(); if (unshare(CLONE_NEWNET)) { } loop(); doexit(1); } #define XT_TABLE_SIZE 1536 #define XT_MAX_ENTRIES 10 struct xt_counters { uint64_t pcnt, bcnt; }; struct ipt_getinfo { char name[32]; unsigned int valid_hooks; unsigned int hook_entry[5]; unsigned int underflow[5]; unsigned int num_entries; unsigned int size; }; struct ipt_get_entries { char name[32]; unsigned int size; void* entrytable[XT_TABLE_SIZE / sizeof(void*)]; }; struct ipt_replace { char name[32]; unsigned int valid_hooks; unsigned int num_entries; unsigned int size; unsigned int hook_entry[5]; unsigned int underflow[5]; unsigned int num_counters; struct xt_counters* counters; char entrytable[XT_TABLE_SIZE]; }; struct ipt_table_desc { const char* name; struct ipt_getinfo info; struct ipt_replace replace; }; static struct ipt_table_desc ipv4_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "mangle"}, {.name = "raw"}, {.name = "security"}, }; static struct ipt_table_desc ipv6_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "mangle"}, {.name = "raw"}, {.name = "security"}, }; #define IPT_BASE_CTL 64 #define IPT_SO_SET_REPLACE (IPT_BASE_CTL) #define IPT_SO_GET_INFO (IPT_BASE_CTL) #define IPT_SO_GET_ENTRIES (IPT_BASE_CTL + 1) struct arpt_getinfo { char name[32]; unsigned int valid_hooks; unsigned int hook_entry[3]; unsigned int underflow[3]; unsigned int num_entries; unsigned int size; }; struct arpt_get_entries { char name[32]; unsigned int size; void* entrytable[XT_TABLE_SIZE / sizeof(void*)]; }; struct arpt_replace { char name[32]; unsigned int valid_hooks; unsigned int num_entries; unsigned int size; unsigned int hook_entry[3]; unsigned int underflow[3]; unsigned int num_counters; struct xt_counters* counters; char entrytable[XT_TABLE_SIZE]; }; struct arpt_table_desc { const char* name; struct arpt_getinfo info; struct arpt_replace replace; }; static struct arpt_table_desc arpt_tables[] = { {.name = "filter"}, }; #define ARPT_BASE_CTL 96 #define ARPT_SO_SET_REPLACE (ARPT_BASE_CTL) #define ARPT_SO_GET_INFO (ARPT_BASE_CTL) #define ARPT_SO_GET_ENTRIES (ARPT_BASE_CTL + 1) static void checkpoint_iptables(struct ipt_table_desc* tables, int num_tables, int family, int level) { struct ipt_get_entries entries; socklen_t optlen; int fd, i; fd = socket(family, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) fail("socket(%d, SOCK_STREAM, IPPROTO_TCP)", family); for (i = 0; i < num_tables; i++) { struct ipt_table_desc* table = &tables[i]; strcpy(table->info.name, table->name); strcpy(table->replace.name, table->name); optlen = sizeof(table->info); if (getsockopt(fd, level, IPT_SO_GET_INFO, &table->info, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } fail("getsockopt(IPT_SO_GET_INFO)"); } if (table->info.size > sizeof(table->replace.entrytable)) fail("table size is too large: %u", table->info.size); if (table->info.num_entries > XT_MAX_ENTRIES) fail("too many counters: %u", table->info.num_entries); memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + table->info.size; if (getsockopt(fd, level, IPT_SO_GET_ENTRIES, &entries, &optlen)) fail("getsockopt(IPT_SO_GET_ENTRIES)"); table->replace.valid_hooks = table->info.valid_hooks; table->replace.num_entries = table->info.num_entries; table->replace.size = table->info.size; memcpy(table->replace.hook_entry, table->info.hook_entry, sizeof(table->replace.hook_entry)); memcpy(table->replace.underflow, table->info.underflow, sizeof(table->replace.underflow)); memcpy(table->replace.entrytable, entries.entrytable, table->info.size); } close(fd); } static void reset_iptables(struct ipt_table_desc* tables, int num_tables, int family, int level) { struct xt_counters counters[XT_MAX_ENTRIES]; struct ipt_get_entries entries; struct ipt_getinfo info; socklen_t optlen; int fd, i; fd = socket(family, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) fail("socket(%d, SOCK_STREAM, IPPROTO_TCP)", family); for (i = 0; i < num_tables; i++) { struct ipt_table_desc* table = &tables[i]; if (table->info.valid_hooks == 0) continue; memset(&info, 0, sizeof(info)); strcpy(info.name, table->name); optlen = sizeof(info); if (getsockopt(fd, level, IPT_SO_GET_INFO, &info, &optlen)) fail("getsockopt(IPT_SO_GET_INFO)"); if (memcmp(&table->info, &info, sizeof(table->info)) == 0) { memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + entries.size; if (getsockopt(fd, level, IPT_SO_GET_ENTRIES, &entries, &optlen)) fail("getsockopt(IPT_SO_GET_ENTRIES)"); if (memcmp(table->replace.entrytable, entries.entrytable, table->info.size) == 0) continue; } table->replace.num_counters = info.num_entries; table->replace.counters = counters; optlen = sizeof(table->replace) - sizeof(table->replace.entrytable) + table->replace.size; if (setsockopt(fd, level, IPT_SO_SET_REPLACE, &table->replace, optlen)) fail("setsockopt(IPT_SO_SET_REPLACE)"); } close(fd); } static void checkpoint_arptables(void) { struct arpt_get_entries entries; socklen_t optlen; unsigned i; int fd; fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) fail("socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)"); for (i = 0; i < sizeof(arpt_tables) / sizeof(arpt_tables[0]); i++) { struct arpt_table_desc* table = &arpt_tables[i]; strcpy(table->info.name, table->name); strcpy(table->replace.name, table->name); optlen = sizeof(table->info); if (getsockopt(fd, SOL_IP, ARPT_SO_GET_INFO, &table->info, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } fail("getsockopt(ARPT_SO_GET_INFO)"); } if (table->info.size > sizeof(table->replace.entrytable)) fail("table size is too large: %u", table->info.size); if (table->info.num_entries > XT_MAX_ENTRIES) fail("too many counters: %u", table->info.num_entries); memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + table->info.size; if (getsockopt(fd, SOL_IP, ARPT_SO_GET_ENTRIES, &entries, &optlen)) fail("getsockopt(ARPT_SO_GET_ENTRIES)"); table->replace.valid_hooks = table->info.valid_hooks; table->replace.num_entries = table->info.num_entries; table->replace.size = table->info.size; memcpy(table->replace.hook_entry, table->info.hook_entry, sizeof(table->replace.hook_entry)); memcpy(table->replace.underflow, table->info.underflow, sizeof(table->replace.underflow)); memcpy(table->replace.entrytable, entries.entrytable, table->info.size); } close(fd); } static void reset_arptables() { struct xt_counters counters[XT_MAX_ENTRIES]; struct arpt_get_entries entries; struct arpt_getinfo info; socklen_t optlen; unsigned i; int fd; fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) fail("socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)"); for (i = 0; i < sizeof(arpt_tables) / sizeof(arpt_tables[0]); i++) { struct arpt_table_desc* table = &arpt_tables[i]; if (table->info.valid_hooks == 0) continue; memset(&info, 0, sizeof(info)); strcpy(info.name, table->name); optlen = sizeof(info); if (getsockopt(fd, SOL_IP, ARPT_SO_GET_INFO, &info, &optlen)) fail("getsockopt(ARPT_SO_GET_INFO)"); if (memcmp(&table->info, &info, sizeof(table->info)) == 0) { memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + entries.size; if (getsockopt(fd, SOL_IP, ARPT_SO_GET_ENTRIES, &entries, &optlen)) fail("getsockopt(ARPT_SO_GET_ENTRIES)"); if (memcmp(table->replace.entrytable, entries.entrytable, table->info.size) == 0) continue; } table->replace.num_counters = info.num_entries; table->replace.counters = counters; optlen = sizeof(table->replace) - sizeof(table->replace.entrytable) + table->replace.size; if (setsockopt(fd, SOL_IP, ARPT_SO_SET_REPLACE, &table->replace, optlen)) fail("setsockopt(ARPT_SO_SET_REPLACE)"); } close(fd); } #include #include struct ebt_table_desc { const char* name; struct ebt_replace replace; char entrytable[XT_TABLE_SIZE]; }; static struct ebt_table_desc ebt_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "broute"}, }; static void checkpoint_ebtables(void) { socklen_t optlen; unsigned i; int fd; fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) fail("socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)"); for (i = 0; i < sizeof(ebt_tables) / sizeof(ebt_tables[0]); i++) { struct ebt_table_desc* table = &ebt_tables[i]; strcpy(table->replace.name, table->name); optlen = sizeof(table->replace); if (getsockopt(fd, SOL_IP, EBT_SO_GET_INIT_INFO, &table->replace, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } fail("getsockopt(EBT_SO_GET_INIT_INFO)"); } if (table->replace.entries_size > sizeof(table->entrytable)) fail("table size is too large: %u", table->replace.entries_size); table->replace.num_counters = 0; table->replace.entries = table->entrytable; optlen = sizeof(table->replace) + table->replace.entries_size; if (getsockopt(fd, SOL_IP, EBT_SO_GET_INIT_ENTRIES, &table->replace, &optlen)) fail("getsockopt(EBT_SO_GET_INIT_ENTRIES)"); } close(fd); } static void reset_ebtables() { struct ebt_replace replace; char entrytable[XT_TABLE_SIZE]; socklen_t optlen; unsigned i, j, h; int fd; fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) fail("socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)"); for (i = 0; i < sizeof(ebt_tables) / sizeof(ebt_tables[0]); i++) { struct ebt_table_desc* table = &ebt_tables[i]; if (table->replace.valid_hooks == 0) continue; memset(&replace, 0, sizeof(replace)); strcpy(replace.name, table->name); optlen = sizeof(replace); if (getsockopt(fd, SOL_IP, EBT_SO_GET_INFO, &replace, &optlen)) fail("getsockopt(EBT_SO_GET_INFO)"); replace.num_counters = 0; table->replace.entries = 0; for (h = 0; h < NF_BR_NUMHOOKS; h++) table->replace.hook_entry[h] = 0; if (memcmp(&table->replace, &replace, sizeof(table->replace)) == 0) { memset(&entrytable, 0, sizeof(entrytable)); replace.entries = entrytable; optlen = sizeof(replace) + replace.entries_size; if (getsockopt(fd, SOL_IP, EBT_SO_GET_ENTRIES, &replace, &optlen)) fail("getsockopt(EBT_SO_GET_ENTRIES)"); if (memcmp(table->entrytable, entrytable, replace.entries_size) == 0) continue; } for (j = 0, h = 0; h < NF_BR_NUMHOOKS; h++) { if (table->replace.valid_hooks & (1 << h)) { table->replace.hook_entry[h] = (struct ebt_entries*)table->entrytable + j; j++; } } table->replace.entries = table->entrytable; optlen = sizeof(table->replace) + table->replace.entries_size; if (setsockopt(fd, SOL_IP, EBT_SO_SET_ENTRIES, &table->replace, optlen)) fail("setsockopt(EBT_SO_SET_ENTRIES)"); } close(fd); } static void checkpoint_net_namespace(void) { checkpoint_ebtables(); checkpoint_arptables(); checkpoint_iptables(ipv4_tables, sizeof(ipv4_tables) / sizeof(ipv4_tables[0]), AF_INET, SOL_IP); checkpoint_iptables(ipv6_tables, sizeof(ipv6_tables) / sizeof(ipv6_tables[0]), AF_INET6, SOL_IPV6); } static void reset_net_namespace(void) { reset_ebtables(); reset_arptables(); reset_iptables(ipv4_tables, sizeof(ipv4_tables) / sizeof(ipv4_tables[0]), AF_INET, SOL_IP); reset_iptables(ipv6_tables, sizeof(ipv6_tables) / sizeof(ipv6_tables[0]), AF_INET6, SOL_IPV6); } static void execute_one(); extern unsigned long long procid; static void loop() { checkpoint_net_namespace(); int iter; for (iter = 0;; iter++) { int pid = fork(); if (pid < 0) fail("clone failed"); if (pid == 0) { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); execute_one(); doexit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { int res = waitpid(-1, &status, __WALL | WNOHANG); if (res == pid) { break; } usleep(1000); if (current_time_ms() - start < 3 * 1000) continue; kill(-pid, SIGKILL); kill(pid, SIGKILL); while (waitpid(-1, &status, __WALL) != pid) { } break; } reset_net_namespace(); } } struct thread_t { int created, running, call; pthread_t th; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static int collide; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { while (!__atomic_load_n(&th->running, __ATOMIC_ACQUIRE)) syscall(SYS_futex, &th->running, FUTEX_WAIT, 0, 0); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); __atomic_store_n(&th->running, 0, __ATOMIC_RELEASE); syscall(SYS_futex, &th->running, FUTEX_WAKE); } return 0; } static void execute(int num_calls) { int call, thread; running = 0; for (call = 0; call < num_calls; call++) { for (thread = 0; thread < sizeof(threads) / sizeof(threads[0]); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); pthread_create(&th->th, &attr, thr, th); } if (!__atomic_load_n(&th->running, __ATOMIC_ACQUIRE)) { th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); __atomic_store_n(&th->running, 1, __ATOMIC_RELEASE); syscall(SYS_futex, &th->running, FUTEX_WAKE); if (collide && call % 2) break; struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 20 * 1000 * 1000; syscall(SYS_futex, &th->running, FUTEX_WAIT, 1, &ts); if (running) usleep((call == num_calls - 1) ? 10000 : 1000); break; } } } } uint64_t r[14] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0}; void execute_call(int call) { long res; switch (call) { case 0: res = syscall(__NR_socket, 1, 1, 0); if (res != -1) r[0] = res; break; case 1: syscall(__NR_unshare, 0x40600); break; case 2: memcpy((void*)0x20000000, "/dev/vcs#", 10); res = syz_open_dev(0x20000000, 3, 2); if (res != -1) r[1] = res; break; case 3: *(uint64_t*)0x20000600 = 0x20000080; *(uint16_t*)0x20000080 = 2; *(uint16_t*)0x20000082 = htobe16(0x4e24); *(uint32_t*)0x20000084 = htobe32(7); *(uint8_t*)0x20000088 = 0; *(uint8_t*)0x20000089 = 0; *(uint8_t*)0x2000008a = 0; *(uint8_t*)0x2000008b = 0; *(uint8_t*)0x2000008c = 0; *(uint8_t*)0x2000008d = 0; *(uint8_t*)0x2000008e = 0; *(uint8_t*)0x2000008f = 0; *(uint32_t*)0x20000608 = 0x10; *(uint64_t*)0x20000610 = 0x20000480; *(uint64_t*)0x20000480 = 0x200000c0; *(uint64_t*)0x20000488 = 0x4c; *(uint64_t*)0x20000490 = 0x20000140; *(uint64_t*)0x20000498 = 5; *(uint64_t*)0x200004a0 = 0x20000180; *(uint64_t*)0x200004a8 = 0x61; *(uint64_t*)0x200004b0 = 0x20000200; *(uint64_t*)0x200004b8 = 0xfa; *(uint64_t*)0x200004c0 = 0x20000300; *(uint64_t*)0x200004c8 = 0x76; *(uint64_t*)0x200004d0 = 0x20000380; *(uint64_t*)0x200004d8 = 0xf7; *(uint64_t*)0x20000618 = 6; *(uint64_t*)0x20000620 = 0x20000580; memcpy((void*)0x20000580, "\x58\x00\x00\x00\x00\x00\x00\x00\x14\x01\x00\x00" "\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00", 24); *(uint64_t*)0x20000598 = 0x20000500; memcpy((void*)0x20000500, "\xff\xff\x00\x00\x00\x00\x00\x00", 8); *(uint64_t*)0x200005a0 = 0x20000540; *(uint64_t*)0x20000628 = 0x28; *(uint32_t*)0x20000630 = 0x4000000; syscall(__NR_sendmsg, r[1], 0x20000600, 0x40000d0); break; case 4: syscall(__NR_pread64, r[0], 0x20000040, 0xffffffffffffffd5, 0); break; case 5: syscall(__NR_ioctl, -1, 0x2289, 0x20000fff); break; case 6: *(uint8_t*)0x20000040 = 0x7f; *(uint8_t*)0x20000041 = 0x45; *(uint8_t*)0x20000042 = 0x4c; *(uint8_t*)0x20000043 = 0x46; *(uint8_t*)0x20000044 = 0; *(uint8_t*)0x20000045 = -1; *(uint8_t*)0x20000046 = 0; *(uint8_t*)0x20000047 = 1; *(uint64_t*)0x20000048 = 6; *(uint16_t*)0x20000050 = 2; *(uint16_t*)0x20000052 = 7; *(uint32_t*)0x20000054 = 0x43b; *(uint32_t*)0x20000058 = 0xde; *(uint32_t*)0x2000005c = 0x38; *(uint32_t*)0x20000060 = 0x78; *(uint32_t*)0x20000064 = 8; *(uint16_t*)0x20000068 = 0; *(uint16_t*)0x2000006a = 0x20; *(uint16_t*)0x2000006c = 2; *(uint16_t*)0x2000006e = 0; *(uint16_t*)0x20000070 = 3; *(uint16_t*)0x20000072 = 1; *(uint32_t*)0x20000078 = 5; *(uint32_t*)0x2000007c = 0x62; *(uint32_t*)0x20000080 = 0x1f; *(uint32_t*)0x20000084 = 5; *(uint32_t*)0x20000088 = 0x788; *(uint32_t*)0x2000008c = 0x200; *(uint32_t*)0x20000090 = 0xff; *(uint32_t*)0x20000094 = 5; *(uint32_t*)0x20000098 = 0x60000000; *(uint32_t*)0x2000009c = 8; *(uint32_t*)0x200000a0 = 8; *(uint32_t*)0x200000a4 = 0x20; *(uint32_t*)0x200000a8 = 0x8000; *(uint32_t*)0x200000ac = 0x1ff; *(uint32_t*)0x200000b0 = 5; *(uint32_t*)0x200000b4 = 0x3ff; memcpy((void*)0x200000b8, "\xab\xbd\x21\xa5\x0f\x57\x4b\x73\x6e\x03\x2e\x74\xea\x9c\xc3\xea" "\xc1\x2e\x39\x6a\x5c\x1a\xdf\x0a\x63\x04\x38\x72\x31\x67\x79\x1b" "\xb3\x99\x09\x1d\xc8\xe4\x36\x2c\x50\x79\x12\xb0\x62\xab\xc0\xfe" "\xa2\x8e\x24\x60\xe3\x3b\x3b\xf4\x31\xbb\x01\xc7\xcd\x38\x5d\xd8" "\xdc\x91\xc1\x7a\x47\xd8\xf1\x58\x1b\x33\x27\xf5\x3b\x3f\x4d\x71" "\x39\x9e\x67\xb4\x6a\x4d\xc7\xe8\xbe", 89); syscall(__NR_write, -1, 0x20000040, 0xd1); break; case 7: res = syscall(__NR_fcntl, -1, 0x406, -1); if (res != -1) r[2] = res; break; case 8: *(uint32_t*)0x20000180 = 0; *(uint16_t*)0x20000184 = 5; *(uint32_t*)0x200001c0 = 8; res = syscall(__NR_getsockopt, r[2], 0x84, 0x18, 0x20000180, 0x200001c0); if (res != -1) r[3] = *(uint32_t*)0x20000180; break; case 9: *(uint32_t*)0x20000200 = 0; *(uint32_t*)0x20000204 = 0xb0; memcpy((void*)0x20000208, "\xc3\xd4\x47\x35\xa3\xcb\x15\x85\x6b\xe8\xd2\x79\xae\x87\x68\x5d" "\xa6\xd6\xd0\x3a\xdd\x12\x5a\xd5\x25\xd4\xba\x76\xb9\x66\xe3\xda" "\x00\x23\x9a\xe5\x31\x38\xaa\xbb\x11\x26\x23\x12\xe7\xe8\xed\xa1" "\xf6\x71\x22\xeb\x64\x96\x7f\x5f\x31\x50\xf7\x6b\x79\x34\x99\xfb" "\x70\x0e\x4d\xb6\x5d\x21\xea\x5f\x08\x7c\x4c\x7d\x45\x2e\xb6\x7f" "\xaf\xc6\xcf\x0c\x44\x4e\xdd\x7e\x72\xbb\x39\x0c\x8c\xce\x9b\x92" "\x4a\x16\x63\x1b\xf7\x23\x05\xda\x57\x05\x77\x3b\x9a\x22\x61\xf7" "\x68\x73\xa9\x31\x9a\x8d\x3c\x6d\xa4\x07\xf1\xa5\xa8\x35\x1e\x1e" "\xb8\x2d\xe8\x42\x85\x6e\x84\x90\x74\xd4\x54\x8f\xec\x36\x0a\x09" "\xc0\x64\xbb\xbf\x7a\x70\x74\x16\x6d\xd4\x42\xd3\x37\x44\x58\x2b" "\xf7\x1e\xa8\xb4\x52\xad\x2d\x51\x68\xab\xcc\x66\x65\xe3\x1d\x12", 176); *(uint32_t*)0x200002c0 = 0xb8; res = syscall(__NR_getsockopt, r[2], 0x84, 0x6d, 0x20000200, 0x200002c0); if (res != -1) r[4] = *(uint32_t*)0x20000200; break; case 10: *(uint8_t*)0x20000400 = 0xac; *(uint8_t*)0x20000401 = 0x14; *(uint8_t*)0x20000402 = 0x14; *(uint8_t*)0x20000403 = 0xbb; *(uint8_t*)0x20000404 = 0xac; *(uint8_t*)0x20000405 = 0x14; *(uint8_t*)0x20000406 = 0x14; *(uint8_t*)0x20000407 = 0xbb; *(uint32_t*)0x20000408 = htobe32(0xe0000002); syscall(__NR_setsockopt, r[2], 0, 0x28, 0x20000400, 0xc); break; case 11: *(uint32_t*)0x20000300 = r[3]; *(uint32_t*)0x20000304 = 1; *(uint32_t*)0x20000308 = 0xffffffc0; *(uint16_t*)0x2000030c = -1; *(uint16_t*)0x2000030e = 0xd8cb; *(uint16_t*)0x20000310 = 5; *(uint16_t*)0x20000312 = 0; *(uint32_t*)0x20000314 = 4; *(uint32_t*)0x20000318 = r[4]; *(uint16_t*)0x2000031c = 2; *(uint16_t*)0x2000031e = htobe16(0x4e22); *(uint8_t*)0x20000320 = 0xac; *(uint8_t*)0x20000321 = 0x14; *(uint8_t*)0x20000322 = 0x14; *(uint8_t*)0x20000323 = 0xbb; *(uint8_t*)0x20000324 = 0; *(uint8_t*)0x20000325 = 0; *(uint8_t*)0x20000326 = 0; *(uint8_t*)0x20000327 = 0; *(uint8_t*)0x20000328 = 0; *(uint8_t*)0x20000329 = 0; *(uint8_t*)0x2000032a = 0; *(uint8_t*)0x2000032b = 0; *(uint32_t*)0x2000039c = 0x7ff; *(uint32_t*)0x200003a0 = 3; *(uint32_t*)0x200003a4 = 0; *(uint32_t*)0x200003a8 = 0x800; *(uint32_t*)0x200003ac = 0; *(uint32_t*)0x200003c0 = 0xb0; syscall(__NR_getsockopt, r[2], 0x84, 0xe, 0x20000300, 0x200003c0); break; case 12: *(uint16_t*)0x20000140 = 2; *(uint64_t*)0x20000148 = 0x20000000; *(uint16_t*)0x20000000 = 0; *(uint8_t*)0x20000002 = -1; *(uint8_t*)0x20000003 = -1; *(uint32_t*)0x20000004 = 5; *(uint16_t*)0x20000008 = 8; *(uint8_t*)0x2000000a = 0xc8; *(uint8_t*)0x2000000b = 5; *(uint32_t*)0x2000000c = 4; syscall(__NR_ioctl, r[2], 0x401054d5, 0x20000140); break; case 13: res = syscall(__NR_socketpair, 1, 5, 0, 0x20000000); if (res != -1) r[5] = *(uint32_t*)0x20000000; break; case 14: syscall(__NR_recvfrom, r[5], 0x20000040, 0x86, 0x40, 0, 0); break; case 15: res = syscall(__NR_socket, 0x40000000015, 6, 0xfc); if (res != -1) r[6] = res; break; case 16: *(uint32_t*)0x200000c0 = 9; *(uint16_t*)0x200000c8 = 0xa; *(uint16_t*)0x200000ca = htobe16(0x4e21); *(uint32_t*)0x200000cc = 0xfffffdce; *(uint8_t*)0x200000d0 = 0xfe; *(uint8_t*)0x200000d1 = 0x80; *(uint8_t*)0x200000d2 = 0; *(uint8_t*)0x200000d3 = 0; *(uint8_t*)0x200000d4 = 0; *(uint8_t*)0x200000d5 = 0; *(uint8_t*)0x200000d6 = 0; *(uint8_t*)0x200000d7 = 0; *(uint8_t*)0x200000d8 = 0; *(uint8_t*)0x200000d9 = 0; *(uint8_t*)0x200000da = 0; *(uint8_t*)0x200000db = 0; *(uint8_t*)0x200000dc = 0; *(uint8_t*)0x200000dd = 0; *(uint8_t*)0x200000de = 0; *(uint8_t*)0x200000df = 0xaa; *(uint32_t*)0x200000e0 = 0x80000001; *(uint16_t*)0x20000148 = 0xa; *(uint16_t*)0x2000014a = htobe16(0x4e23); *(uint32_t*)0x2000014c = 3; *(uint8_t*)0x20000150 = 0xfe; *(uint8_t*)0x20000151 = 0x80; *(uint8_t*)0x20000152 = 0; *(uint8_t*)0x20000153 = 0; *(uint8_t*)0x20000154 = 0; *(uint8_t*)0x20000155 = 0; *(uint8_t*)0x20000156 = 0; *(uint8_t*)0x20000157 = 0; *(uint8_t*)0x20000158 = 0; *(uint8_t*)0x20000159 = 0; *(uint8_t*)0x2000015a = 0; *(uint8_t*)0x2000015b = 0; *(uint8_t*)0x2000015c = 0; *(uint8_t*)0x2000015d = 0; *(uint8_t*)0x2000015e = 0; *(uint8_t*)0x2000015f = 0xaa; *(uint32_t*)0x20000160 = 2; syscall(__NR_setsockopt, r[6], 0x29, 0x2f, 0x200000c0, 0x108); break; case 17: syscall(__NR_mmap, 0x20000000, 0xfb8000, 0, 0x12, r[6], 0); break; case 18: *(uint8_t*)0x20000080 = 0x73; *(uint8_t*)0x20000081 = 0x79; *(uint8_t*)0x20000082 = 0x7a; *(uint8_t*)0x20000083 = 0; *(uint8_t*)0x20000084 = 0; syscall(__NR_keyctl, 1, 0x20000080); break; case 19: res = syscall(__NR_inotify_init1, 0); if (res != -1) r[7] = res; break; case 20: syscall(__NR_fcntl, r[7], 8, -1); break; case 21: res = syscall(__NR_fcntl, r[7], 0x10, 0x20000400); if (res != -1) r[8] = *(uint32_t*)0x20000404; break; case 22: syscall(__NR_ptrace, 0x4206, r[8], 0, 0); break; case 23: memcpy((void*)0x20000000, "/proc/self/net/pfkey", 21); res = syscall(__NR_openat, 0xffffffffffffff9c, 0x20000000, 0x8000, 0); if (res != -1) r[9] = res; break; case 24: *(uint32_t*)0x20000780 = 0; *(uint16_t*)0x20000784 = 0x80; *(uint16_t*)0x20000786 = 7; *(uint16_t*)0x20000788 = 1; *(uint16_t*)0x2000078a = 1; *(uint16_t*)0x2000078c = 6; *(uint16_t*)0x2000078e = 6; *(uint16_t*)0x20000790 = 9; *(uint16_t*)0x20000792 = 0; *(uint16_t*)0x20000794 = 1; *(uint32_t*)0x200008c0 = 0x16; res = syscall(__NR_getsockopt, r[9], 0x84, 0x77, 0x20000780, 0x200008c0); if (res != -1) r[10] = *(uint32_t*)0x20000780; break; case 25: *(uint32_t*)0x20000900 = r[10]; *(uint32_t*)0x20000904 = 2; *(uint32_t*)0x20000940 = 8; syscall(__NR_getsockopt, r[9], 0x84, 0x11, 0x20000900, 0x20000940); break; case 26: res = syscall(__NR_socket, 2, 0x4000000000000001, 0); if (res != -1) r[11] = res; break; case 27: *(uint16_t*)0x20366000 = 2; *(uint16_t*)0x20366002 = htobe16(0x4e23); *(uint32_t*)0x20366004 = htobe32(-1); *(uint8_t*)0x20366008 = 0; *(uint8_t*)0x20366009 = 0; *(uint8_t*)0x2036600a = 0; *(uint8_t*)0x2036600b = 0; *(uint8_t*)0x2036600c = 0; *(uint8_t*)0x2036600d = 0; *(uint8_t*)0x2036600e = 0; *(uint8_t*)0x2036600f = 0; syscall(__NR_bind, r[11], 0x20366000, 0x10); break; case 28: *(uint16_t*)0x20deaff0 = 2; *(uint16_t*)0x20deaff2 = htobe16(0x4e23); *(uint32_t*)0x20deaff4 = htobe32(0x7f000001); *(uint8_t*)0x20deaff8 = 0; *(uint8_t*)0x20deaff9 = 0; *(uint8_t*)0x20deaffa = 0; *(uint8_t*)0x20deaffb = 0; *(uint8_t*)0x20deaffc = 0; *(uint8_t*)0x20deaffd = 0; *(uint8_t*)0x20deaffe = 0; *(uint8_t*)0x20deafff = 0; syscall(__NR_sendto, r[11], 0x20fd0000, 0x67d0a4f154ddf4a1, 0x20000801, 0x20deaff0, 0x10); break; case 29: *(uint32_t*)0x20000ac0 = r[10]; memcpy((void*)0x20000ac4, "\x7a\x00\x00\x00\x84\xac\x3b\xf5\x72\x6d\x95\xa7\x5f\xad\xd4\xf8" "\x4b\x03\x22\x1a\x4a\x7c\x6e\x8a\x89\xf8\xd6\xde\x95\xbf\x96\xaf" "\x5a\x41\xfc\x59\xda\x16\xf6\xa3\xc1\x15\xb0\x62\x60\x69\x7e\x66" "\x66\x85\xf8\x6f\x0a\x60\x56\xdc\x5f\xfe\xb3\xe2\x69\x56\xe8\x04" "\x55\xc7\xae\xe3\xdb\xf3\x02\x35\x9f\xcb\x56\xaf\xe9\xfe\x65\xcf" "\x2d\xb0\x02\x0c\x47\xd9\xd9\x05\x00\x5d\xf6\xde\xab\xd2\x5e\x31" "\x55\x3a\x9d\x4d\x81\x8c\xf6\xe4\xf4\xac\xf7\x20\x10\x97\x95\xcf" "\xf2\xe5\xa1\xf4\xa1\x51\x74\x87\x4b\x4e\x28\x9a\x3b\x5a", 126); *(uint32_t*)0x20000b80 = 2; syscall(__NR_getsockopt, r[9], 0x84, 0x1b, 0x20000ac0, 0x20000b80); break; case 30: memcpy((void*)0x20000a80, "\x66\x65\x74\x2f\x74\x63\x70\x00\x5c\x51\xae\x32\xf0\x98\x42\x45" "\x33\xa6\xd4\x15\x78\x08\x20\xfc\x1b\x57\x35\x23\x25\xd2\x69\xc6" "\x5f\x30\xe8\x6d\x3f\x4b\x98\x08\xdb\x80\x52\xb5\x52\xa6\xf6\x2b" "\x7f\x3b\x8f\x3e\xc6\x44\x41\x23\xce\x19\x22\x8f\x00\x7b", 62); res = syz_open_procfs(r[8], 0x20000a80); if (res != -1) r[12] = res; break; case 31: *(uint64_t*)0x20000540 = 0x20000280; *(uint64_t*)0x20000548 = 0x61; *(uint64_t*)0x20000550 = 0x20000480; *(uint64_t*)0x20000558 = 0x90; syscall(__NR_preadv, r[12], 0x20000540, 2, 0); break; case 32: *(uint32_t*)0x20000440 = 0; *(uint16_t*)0x20000444 = 2; *(uint16_t*)0x20000446 = htobe16(0x4e21); *(uint32_t*)0x20000448 = htobe32(-1); *(uint8_t*)0x2000044c = 0; *(uint8_t*)0x2000044d = 0; *(uint8_t*)0x2000044e = 0; *(uint8_t*)0x2000044f = 0; *(uint8_t*)0x20000450 = 0; *(uint8_t*)0x20000451 = 0; *(uint8_t*)0x20000452 = 0; *(uint8_t*)0x20000453 = 0; *(uint32_t*)0x200004c4 = 0x76e; *(uint32_t*)0x200004c8 = 8; *(uint32_t*)0x200004cc = 0x81; *(uint32_t*)0x200004d0 = 0x3f; *(uint32_t*)0x200004d4 = 5; *(uint32_t*)0x20000380 = 0x98; res = syscall(__NR_getsockopt, r[9], 0x84, 0xf, 0x20000440, 0x20000380); if (res != -1) r[13] = *(uint32_t*)0x20000440; break; case 33: *(uint32_t*)0x20000580 = r[13]; *(uint32_t*)0x20000584 = 0x3f; *(uint32_t*)0x20000588 = 2; *(uint16_t*)0x2000058c = 1; *(uint16_t*)0x2000058e = 0x8000; *(uint16_t*)0x20000590 = 2; *(uint16_t*)0x20000592 = 3; *(uint32_t*)0x20000594 = 1; *(uint32_t*)0x20000598 = 0; *(uint16_t*)0x2000059c = 0xa; *(uint16_t*)0x2000059e = htobe16(0x4e20); *(uint32_t*)0x200005a0 = 0x3685; *(uint8_t*)0x200005a4 = 0xfe; *(uint8_t*)0x200005a5 = 0x80; *(uint8_t*)0x200005a6 = 0; *(uint8_t*)0x200005a7 = 0; *(uint8_t*)0x200005a8 = 0; *(uint8_t*)0x200005a9 = 0; *(uint8_t*)0x200005aa = 0; *(uint8_t*)0x200005ab = 0; *(uint8_t*)0x200005ac = 0; *(uint8_t*)0x200005ad = 0; *(uint8_t*)0x200005ae = 0; *(uint8_t*)0x200005af = 0; *(uint8_t*)0x200005b0 = 0; *(uint8_t*)0x200005b1 = 0; *(uint8_t*)0x200005b2 = 0; *(uint8_t*)0x200005b3 = 0xaa; *(uint32_t*)0x200005b4 = 0xcfb; *(uint32_t*)0x2000061c = 9; *(uint32_t*)0x20000620 = 0x51c; *(uint32_t*)0x20000624 = 0x80000001; *(uint32_t*)0x20000628 = 4; *(uint32_t*)0x2000062c = 1; *(uint32_t*)0x20000640 = 0xb0; syscall(__NR_getsockopt, r[9], 0x84, 0xe, 0x20000580, 0x20000640); break; case 34: *(uint64_t*)0x200009c0 = 0x20000680; memcpy((void*)0x20000680, "\xb2\x91\xa5\x7f\x8c\xa8\xbe\x91\xc8\xe4\x49\x4e" "\xa4\x11\xd0\x54\x3d\x53\x93\x47\x80\xbb\x4f\x97" "\xa9\xdb\x2c\x9b\x70\xdd\x6a\x1c\xd8\xb1\xd0\xee" "\x3c\x12\x9f\x25", 40); *(uint64_t*)0x200009c8 = 0x28; *(uint64_t*)0x200009d0 = 0xce; *(uint64_t*)0x200009d8 = 7; syscall(__NR_kexec_load, 0xffffffffffffffc1, 1, 0x200009c0, 0x160000); break; case 35: syscall(__NR_ioctl, r[9], 0x4b62, 0x20000140); break; case 36: *(uint32_t*)0x20000200 = 0; *(uint32_t*)0x20000240 = 2; syscall(__NR_getsockopt, -1, 0x84, 0x1b, 0x20000200, 0x20000240); break; case 37: *(uint32_t*)0x20000a00 = 4; syscall(__NR_getsockopt, r[9], 0x84, 0x20, 0x20000980, 0x20000a00); break; case 38: syscall(__NR_ptrace, 0x4207, r[8]); break; case 39: *(uint64_t*)0x200000c0 = 0x20000040; *(uint64_t*)0x200000c8 = 0xfffffffffffffdb8; syscall(__NR_ptrace, 0x4205, r[8], 0x202, 0x200000c0); break; case 40: syscall(__NR_ptrace, 0x12, r[8], 0, 0x20000c00); break; case 41: *(uint32_t*)0x20001600 = 0xe8; syscall(__NR_getsockopt, r[9], 0x29, 0x22, 0x20001500, 0x20001600); break; case 42: syscall(__NR_socketpair, 0xa, 0xa, 9, 0x20000a40); break; case 43: memcpy((void*)0x20000300, "\x39\x77\x85\x2f\xfc\x70\xa9\x08\x55\x5e\xd3\x3b" "\x15\xe3\x1b\xc6\x19\xb7\x7b\xeb\x1e\x11\x4d\xb0" "\xf5\x12\x24\x2b\x2c\x0f\xc3\x45\xc3\xd1\xe8\x92" "\xd4\x61\x7d\x0a\x3b\xfe\x91\xac\x56\x03\x44\xcb" "\x16\x23\x96\x5f\xda\x67\x68\x3f\x90\xaf\x16\x4a" "\xb2\x5e\x1a\x96\xad\x16\xd8", 67); syscall(__NR_ptrace, 0xf, r[8], 0x100000000, 0x20000300); break; case 44: *(uint64_t*)0x20001980 = 0x20000080; *(uint16_t*)0x20000080 = 0x10; *(uint16_t*)0x20000082 = 0; *(uint32_t*)0x20000084 = 0x25dfdbff; *(uint32_t*)0x20000088 = 0x20014000; *(uint32_t*)0x20001988 = 0xc; *(uint64_t*)0x20001990 = 0x20001940; *(uint64_t*)0x20001940 = 0x200003c0; *(uint32_t*)0x200003c0 = 0x10; *(uint16_t*)0x200003c4 = 0; *(uint16_t*)0x200003c6 = 1; *(uint32_t*)0x200003c8 = 0x70bd26; *(uint32_t*)0x200003cc = 0x25dfdbfd; *(uint64_t*)0x20001948 = 0x10; *(uint64_t*)0x20001998 = 1; *(uint64_t*)0x200019a0 = 0; *(uint64_t*)0x200019a8 = 0; *(uint32_t*)0x200019b0 = 0x408c0; syscall(__NR_sendmsg, r[9], 0x20001980, 0); break; } } void execute_one() { execute(45); collide = 1; execute(45); } int main() { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); for (;;) { int pid = do_sandbox_none(); int status = 0; while (waitpid(pid, &status, __WALL) != pid) { } } }