// https://syzkaller.appspot.com/bug?id=319d600149b51a6469bb9813513414e4a983e63e // 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 __attribute__((noreturn)) static void doexit(int status) { volatile unsigned i; syscall(__NR_exit_group, status); for (i = 0;; i++) { } } #include #include #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 void exitf(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(kRetryStatus); } #define BITMASK_LEN(type, bf_len) (type)((1ull << (bf_len)) - 1) #define BITMASK_LEN_OFF(type, bf_off, bf_len) \ (type)(BITMASK_LEN(type, (bf_len)) << (bf_off)) #define STORE_BY_BITMASK(type, addr, val, bf_off, bf_len) \ if ((bf_off) == 0 && (bf_len) == 0) { \ *(type*)(addr) = (type)(val); \ } else { \ type new_val = *(type*)(addr); \ new_val &= ~BITMASK_LEN_OFF(type, (bf_off), (bf_len)); \ new_val |= ((type)(val)&BITMASK_LEN(type, (bf_len))) << (bf_off); \ *(type*)(addr) = new_val; \ } 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 void use_temporary_dir() { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) fail("failed to mkdtemp"); if (chmod(tmpdir, 0777)) fail("failed to chmod"); if (chdir(tmpdir)) fail("failed to chdir"); } #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; 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++; } } 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 remove_dir(const char* dir) { DIR* dp; struct dirent* ep; int iter = 0; retry: dp = opendir(dir); if (dp == NULL) { if (errno == EMFILE) { exitf("opendir(%s) failed due to NOFILE, exiting", dir); } exitf("opendir(%s) failed", dir); } while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); struct stat st; if (lstat(filename, &st)) exitf("lstat(%s) failed", filename); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } int i; for (i = 0;; i++) { if (unlink(filename) == 0) break; if (errno == EROFS) { break; } if (errno != EBUSY || i > 100) exitf("unlink(%s) failed", filename); if (umount2(filename, MNT_DETACH)) exitf("umount(%s) failed", filename); } } closedir(dp); int i; for (i = 0;; i++) { if (rmdir(dir) == 0) break; if (i < 100) { if (errno == EROFS) { break; } if (errno == EBUSY) { if (umount2(dir, MNT_DETACH)) exitf("umount(%s) failed", dir); continue; } if (errno == ENOTEMPTY) { if (iter < 100) { iter++; goto retry; } } } exitf("rmdir(%s) failed", dir); } } static void test(); void loop() { int iter; checkpoint_net_namespace(); for (iter = 0;; iter++) { char cwdbuf[256]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) fail("failed to mkdir"); int pid = fork(); if (pid < 0) fail("loop fork failed"); if (pid == 0) { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); if (chdir(cwdbuf)) fail("failed to chdir"); test(); 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 > 5 * 1000) { kill(-pid, SIGKILL); kill(pid, SIGKILL); while (waitpid(-1, &status, __WALL) != pid) { } break; } } remove_dir(cwdbuf); reset_net_namespace(); } } long r[1]; void test() { memset(r, -1, sizeof(r)); r[0] = syscall(__NR_socket, 0xa, 3, 0x3c); memcpy((void*)0x20038b58, "\x72\x61\x77\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", 32); *(uint32_t*)0x20038b78 = 9; *(uint32_t*)0x20038b7c = 3; *(uint32_t*)0x20038b80 = 0x448; *(uint32_t*)0x20038b84 = 0; *(uint32_t*)0x20038b88 = -1; *(uint32_t*)0x20038b8c = -1; *(uint32_t*)0x20038b90 = 0; *(uint32_t*)0x20038b94 = -1; *(uint32_t*)0x20038b98 = 0x378; *(uint32_t*)0x20038b9c = -1; *(uint32_t*)0x20038ba0 = -1; *(uint32_t*)0x20038ba4 = 0x378; *(uint32_t*)0x20038ba8 = -1; *(uint32_t*)0x20038bac = 3; *(uint64_t*)0x20038bb0 = 0x20849fd0; *(uint8_t*)0x20038bb8 = 0; *(uint8_t*)0x20038bb9 = 0; *(uint8_t*)0x20038bba = 0; *(uint8_t*)0x20038bbb = 0; *(uint8_t*)0x20038bbc = 0; *(uint8_t*)0x20038bbd = 0; *(uint8_t*)0x20038bbe = 0; *(uint8_t*)0x20038bbf = 0; *(uint8_t*)0x20038bc0 = 0; *(uint8_t*)0x20038bc1 = 0; *(uint8_t*)0x20038bc2 = 0; *(uint8_t*)0x20038bc3 = 0; *(uint8_t*)0x20038bc4 = 0; *(uint8_t*)0x20038bc5 = 0; *(uint8_t*)0x20038bc6 = 0; *(uint8_t*)0x20038bc7 = 0; *(uint8_t*)0x20038bc8 = 0; *(uint8_t*)0x20038bc9 = 0; *(uint8_t*)0x20038bca = 0; *(uint8_t*)0x20038bcb = 0; *(uint8_t*)0x20038bcc = 0; *(uint8_t*)0x20038bcd = 0; *(uint8_t*)0x20038bce = 0; *(uint8_t*)0x20038bcf = 0; *(uint8_t*)0x20038bd0 = 0; *(uint8_t*)0x20038bd1 = 0; *(uint8_t*)0x20038bd2 = 0; *(uint8_t*)0x20038bd3 = 0; *(uint8_t*)0x20038bd4 = 0; *(uint8_t*)0x20038bd5 = 0; *(uint8_t*)0x20038bd6 = 0; *(uint8_t*)0x20038bd7 = 0; *(uint8_t*)0x20038bd8 = 0; *(uint8_t*)0x20038bd9 = 0; *(uint8_t*)0x20038bda = 0; *(uint8_t*)0x20038bdb = 0; *(uint8_t*)0x20038bdc = 0; *(uint8_t*)0x20038bdd = 0; *(uint8_t*)0x20038bde = 0; *(uint8_t*)0x20038bdf = 0; *(uint8_t*)0x20038be0 = 0; *(uint8_t*)0x20038be1 = 0; *(uint8_t*)0x20038be2 = 0; *(uint8_t*)0x20038be3 = 0; *(uint8_t*)0x20038be4 = 0; *(uint8_t*)0x20038be5 = 0; *(uint8_t*)0x20038be6 = 0; *(uint8_t*)0x20038be7 = 0; *(uint8_t*)0x20038be8 = 0; *(uint8_t*)0x20038be9 = 0; *(uint8_t*)0x20038bea = 0; *(uint8_t*)0x20038beb = 0; *(uint8_t*)0x20038bec = 0; *(uint8_t*)0x20038bed = 0; *(uint8_t*)0x20038bee = 0; *(uint8_t*)0x20038bef = 0; *(uint8_t*)0x20038bf0 = 0; *(uint8_t*)0x20038bf1 = 0; *(uint8_t*)0x20038bf2 = 0; *(uint8_t*)0x20038bf3 = 0; *(uint8_t*)0x20038bf4 = 0; *(uint8_t*)0x20038bf5 = 0; *(uint8_t*)0x20038bf6 = 0; *(uint8_t*)0x20038bf7 = 0; *(uint8_t*)0x20038bf8 = 0; *(uint8_t*)0x20038bf9 = 0; *(uint8_t*)0x20038bfa = 0; *(uint8_t*)0x20038bfb = 0; *(uint8_t*)0x20038bfc = 0; *(uint8_t*)0x20038bfd = 0; *(uint8_t*)0x20038bfe = 0; *(uint8_t*)0x20038bff = 0; *(uint8_t*)0x20038c00 = 0; *(uint8_t*)0x20038c01 = 0; *(uint8_t*)0x20038c02 = 0; *(uint8_t*)0x20038c03 = 0; *(uint8_t*)0x20038c04 = 0; *(uint8_t*)0x20038c05 = 0; *(uint8_t*)0x20038c06 = 0; *(uint8_t*)0x20038c07 = 0; *(uint8_t*)0x20038c08 = 0; *(uint8_t*)0x20038c09 = 0; *(uint8_t*)0x20038c0a = 0; *(uint8_t*)0x20038c0b = 0; *(uint8_t*)0x20038c0c = 0; *(uint8_t*)0x20038c0d = 0; *(uint8_t*)0x20038c0e = 0; *(uint8_t*)0x20038c0f = 0; *(uint8_t*)0x20038c10 = 0; *(uint8_t*)0x20038c11 = 0; *(uint8_t*)0x20038c12 = 0; *(uint8_t*)0x20038c13 = 0; *(uint8_t*)0x20038c14 = 0; *(uint8_t*)0x20038c15 = 0; *(uint8_t*)0x20038c16 = 0; *(uint8_t*)0x20038c17 = 0; *(uint8_t*)0x20038c18 = 0; *(uint8_t*)0x20038c19 = 0; *(uint8_t*)0x20038c1a = 0; *(uint8_t*)0x20038c1b = 0; *(uint8_t*)0x20038c1c = 0; *(uint8_t*)0x20038c1d = 0; *(uint8_t*)0x20038c1e = 0; *(uint8_t*)0x20038c1f = 0; *(uint8_t*)0x20038c20 = 0; *(uint8_t*)0x20038c21 = 0; *(uint8_t*)0x20038c22 = 0; *(uint8_t*)0x20038c23 = 0; *(uint8_t*)0x20038c24 = 0; *(uint8_t*)0x20038c25 = 0; *(uint8_t*)0x20038c26 = 0; *(uint8_t*)0x20038c27 = 0; *(uint8_t*)0x20038c28 = 0; *(uint8_t*)0x20038c29 = 0; *(uint8_t*)0x20038c2a = 0; *(uint8_t*)0x20038c2b = 0; *(uint8_t*)0x20038c2c = 0; *(uint8_t*)0x20038c2d = 0; *(uint8_t*)0x20038c2e = 0; *(uint8_t*)0x20038c2f = 0; *(uint8_t*)0x20038c30 = 0; *(uint8_t*)0x20038c31 = 0; *(uint8_t*)0x20038c32 = 0; *(uint8_t*)0x20038c33 = 0; *(uint8_t*)0x20038c34 = 0; *(uint8_t*)0x20038c35 = 0; *(uint8_t*)0x20038c36 = 0; *(uint8_t*)0x20038c37 = 0; *(uint8_t*)0x20038c38 = 0; *(uint8_t*)0x20038c39 = 0; *(uint8_t*)0x20038c3a = 0; *(uint8_t*)0x20038c3b = 0; *(uint8_t*)0x20038c3c = 0; *(uint8_t*)0x20038c3d = 0; *(uint8_t*)0x20038c3e = 0; *(uint8_t*)0x20038c3f = 0; *(uint32_t*)0x20038c40 = 0; *(uint16_t*)0x20038c44 = 0x200; *(uint16_t*)0x20038c46 = 0x268; *(uint32_t*)0x20038c48 = 0; *(uint64_t*)0x20038c50 = 0; *(uint64_t*)0x20038c58 = 0; *(uint16_t*)0x20038c60 = 0x158; memcpy((void*)0x20038c62, "\x68\x61\x73\x68\x6c\x69\x6d\x69\x74\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00", 29); *(uint8_t*)0x20038c7f = 3; memcpy((void*)0x20038c80, "\x73\x79\x7a\x6b\x61\x6c\x6c\x65\x72\x31\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 255); *(uint64_t*)0x20038d80 = 0x40; *(uint64_t*)0x20038d88 = 0; *(uint32_t*)0x20038d90 = 0x42; *(uint32_t*)0x20038d94 = 0; *(uint32_t*)0x20038d98 = 0; *(uint32_t*)0x20038d9c = 4; *(uint32_t*)0x20038da0 = 0x80000001; *(uint32_t*)0x20038da4 = 8; *(uint8_t*)0x20038da8 = 0; *(uint8_t*)0x20038da9 = 0; *(uint64_t*)0x20038db0 = 0; *(uint16_t*)0x20038db8 = 0x68; memcpy((void*)0x20038dba, "\x43\x54\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00", 29); *(uint8_t*)0x20038dd7 = 2; *(uint16_t*)0x20038dd8 = 0xf; *(uint16_t*)0x20038dda = 0; *(uint32_t*)0x20038ddc = 0; *(uint32_t*)0x20038de0 = 0; memcpy((void*)0x20038de4, "\x70\x70\x74\x70\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 16); memcpy((void*)0x20038df4, "\x73\x79\x7a\x31\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", 32); *(uint64_t*)0x20038e18 = 0; *(uint8_t*)0x20038e20 = 0; *(uint8_t*)0x20038e21 = 0; *(uint8_t*)0x20038e22 = 0; *(uint8_t*)0x20038e23 = 0; *(uint8_t*)0x20038e24 = 0; *(uint8_t*)0x20038e25 = 0; *(uint8_t*)0x20038e26 = 0; *(uint8_t*)0x20038e27 = 0; *(uint8_t*)0x20038e28 = 0; *(uint8_t*)0x20038e29 = 0; *(uint8_t*)0x20038e2a = 0; *(uint8_t*)0x20038e2b = 0; *(uint8_t*)0x20038e2c = 0; *(uint8_t*)0x20038e2d = 0; *(uint8_t*)0x20038e2e = 0; *(uint8_t*)0x20038e2f = 0; *(uint8_t*)0x20038e30 = 0; *(uint8_t*)0x20038e31 = 0; *(uint8_t*)0x20038e32 = 0; *(uint8_t*)0x20038e33 = 0; *(uint8_t*)0x20038e34 = 0; *(uint8_t*)0x20038e35 = 0; *(uint8_t*)0x20038e36 = 0; *(uint8_t*)0x20038e37 = 0; *(uint8_t*)0x20038e38 = 0; *(uint8_t*)0x20038e39 = 0; *(uint8_t*)0x20038e3a = 0; *(uint8_t*)0x20038e3b = 0; *(uint8_t*)0x20038e3c = 0; *(uint8_t*)0x20038e3d = 0; *(uint8_t*)0x20038e3e = 0; *(uint8_t*)0x20038e3f = 0; *(uint8_t*)0x20038e40 = 0; *(uint8_t*)0x20038e41 = 0; *(uint8_t*)0x20038e42 = 0; *(uint8_t*)0x20038e43 = 0; *(uint8_t*)0x20038e44 = 0; *(uint8_t*)0x20038e45 = 0; *(uint8_t*)0x20038e46 = 0; *(uint8_t*)0x20038e47 = 0; *(uint8_t*)0x20038e48 = 0; *(uint8_t*)0x20038e49 = 0; *(uint8_t*)0x20038e4a = 0; *(uint8_t*)0x20038e4b = 0; *(uint8_t*)0x20038e4c = 0; *(uint8_t*)0x20038e4d = 0; *(uint8_t*)0x20038e4e = 0; *(uint8_t*)0x20038e4f = 0; *(uint8_t*)0x20038e50 = 0; *(uint8_t*)0x20038e51 = 0; *(uint8_t*)0x20038e52 = 0; *(uint8_t*)0x20038e53 = 0; *(uint8_t*)0x20038e54 = 0; *(uint8_t*)0x20038e55 = 0; *(uint8_t*)0x20038e56 = 0; *(uint8_t*)0x20038e57 = 0; *(uint8_t*)0x20038e58 = 0; *(uint8_t*)0x20038e59 = 0; *(uint8_t*)0x20038e5a = 0; *(uint8_t*)0x20038e5b = 0; *(uint8_t*)0x20038e5c = 0; *(uint8_t*)0x20038e5d = 0; *(uint8_t*)0x20038e5e = 0; *(uint8_t*)0x20038e5f = 0; *(uint8_t*)0x20038e60 = 0; *(uint8_t*)0x20038e61 = 0; *(uint8_t*)0x20038e62 = 0; *(uint8_t*)0x20038e63 = 0; *(uint8_t*)0x20038e64 = 0; *(uint8_t*)0x20038e65 = 0; *(uint8_t*)0x20038e66 = 0; *(uint8_t*)0x20038e67 = 0; *(uint8_t*)0x20038e68 = 0; *(uint8_t*)0x20038e69 = 0; *(uint8_t*)0x20038e6a = 0; *(uint8_t*)0x20038e6b = 0; *(uint8_t*)0x20038e6c = 0; *(uint8_t*)0x20038e6d = 0; *(uint8_t*)0x20038e6e = 0; *(uint8_t*)0x20038e6f = 0; *(uint8_t*)0x20038e70 = 0; *(uint8_t*)0x20038e71 = 0; *(uint8_t*)0x20038e72 = 0; *(uint8_t*)0x20038e73 = 0; *(uint8_t*)0x20038e74 = 0; *(uint8_t*)0x20038e75 = 0; *(uint8_t*)0x20038e76 = 0; *(uint8_t*)0x20038e77 = 0; *(uint8_t*)0x20038e78 = 0; *(uint8_t*)0x20038e79 = 0; *(uint8_t*)0x20038e7a = 0; *(uint8_t*)0x20038e7b = 0; *(uint8_t*)0x20038e7c = 0; *(uint8_t*)0x20038e7d = 0; *(uint8_t*)0x20038e7e = 0; *(uint8_t*)0x20038e7f = 0; *(uint8_t*)0x20038e80 = 0; *(uint8_t*)0x20038e81 = 0; *(uint8_t*)0x20038e82 = 0; *(uint8_t*)0x20038e83 = 0; *(uint8_t*)0x20038e84 = 0; *(uint8_t*)0x20038e85 = 0; *(uint8_t*)0x20038e86 = 0; *(uint8_t*)0x20038e87 = 0; *(uint8_t*)0x20038e88 = 0; *(uint8_t*)0x20038e89 = 0; *(uint8_t*)0x20038e8a = 0; *(uint8_t*)0x20038e8b = 0; *(uint8_t*)0x20038e8c = 0; *(uint8_t*)0x20038e8d = 0; *(uint8_t*)0x20038e8e = 0; *(uint8_t*)0x20038e8f = 0; *(uint8_t*)0x20038e90 = 0; *(uint8_t*)0x20038e91 = 0; *(uint8_t*)0x20038e92 = 0; *(uint8_t*)0x20038e93 = 0; *(uint8_t*)0x20038e94 = 0; *(uint8_t*)0x20038e95 = 0; *(uint8_t*)0x20038e96 = 0; *(uint8_t*)0x20038e97 = 0; *(uint8_t*)0x20038e98 = 0; *(uint8_t*)0x20038e99 = 0; *(uint8_t*)0x20038e9a = 0; *(uint8_t*)0x20038e9b = 0; *(uint8_t*)0x20038e9c = 0; *(uint8_t*)0x20038e9d = 0; *(uint8_t*)0x20038e9e = 0; *(uint8_t*)0x20038e9f = 0; *(uint8_t*)0x20038ea0 = 0; *(uint8_t*)0x20038ea1 = 0; *(uint8_t*)0x20038ea2 = 0; *(uint8_t*)0x20038ea3 = 0; *(uint8_t*)0x20038ea4 = 0; *(uint8_t*)0x20038ea5 = 0; *(uint8_t*)0x20038ea6 = 0; *(uint8_t*)0x20038ea7 = 0; *(uint32_t*)0x20038ea8 = 0; *(uint16_t*)0x20038eac = 0xa8; *(uint16_t*)0x20038eae = 0x110; *(uint32_t*)0x20038eb0 = 0; *(uint64_t*)0x20038eb8 = 0; *(uint64_t*)0x20038ec0 = 0; *(uint16_t*)0x20038ec8 = 0x68; memcpy((void*)0x20038eca, "\x43\x54\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00", 29); *(uint8_t*)0x20038ee7 = 2; *(uint16_t*)0x20038ee8 = 0x11; *(uint16_t*)0x20038eea = 0; *(uint32_t*)0x20038eec = 0; *(uint32_t*)0x20038ef0 = 0; memcpy((void*)0x20038ef4, "\x6e\x65\x74\x62\x69\x6f\x73\x2d\x6e\x73\x00\x00\x00\x00\x00\x00", 16); memcpy((void*)0x20038f04, "\x73\x79\x7a\x31\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", 32); *(uint64_t*)0x20038f28 = 0; *(uint8_t*)0x20038f30 = 0; *(uint8_t*)0x20038f31 = 0; *(uint8_t*)0x20038f32 = 0; *(uint8_t*)0x20038f33 = 0; *(uint8_t*)0x20038f34 = 0; *(uint8_t*)0x20038f35 = 0; *(uint8_t*)0x20038f36 = 0; *(uint8_t*)0x20038f37 = 0; *(uint8_t*)0x20038f38 = 0; *(uint8_t*)0x20038f39 = 0; *(uint8_t*)0x20038f3a = 0; *(uint8_t*)0x20038f3b = 0; *(uint8_t*)0x20038f3c = 0; *(uint8_t*)0x20038f3d = 0; *(uint8_t*)0x20038f3e = 0; *(uint8_t*)0x20038f3f = 0; *(uint8_t*)0x20038f40 = 0; *(uint8_t*)0x20038f41 = 0; *(uint8_t*)0x20038f42 = 0; *(uint8_t*)0x20038f43 = 0; *(uint8_t*)0x20038f44 = 0; *(uint8_t*)0x20038f45 = 0; *(uint8_t*)0x20038f46 = 0; *(uint8_t*)0x20038f47 = 0; *(uint8_t*)0x20038f48 = 0; *(uint8_t*)0x20038f49 = 0; *(uint8_t*)0x20038f4a = 0; *(uint8_t*)0x20038f4b = 0; *(uint8_t*)0x20038f4c = 0; *(uint8_t*)0x20038f4d = 0; *(uint8_t*)0x20038f4e = 0; *(uint8_t*)0x20038f4f = 0; *(uint8_t*)0x20038f50 = 0; *(uint8_t*)0x20038f51 = 0; *(uint8_t*)0x20038f52 = 0; *(uint8_t*)0x20038f53 = 0; *(uint8_t*)0x20038f54 = 0; *(uint8_t*)0x20038f55 = 0; *(uint8_t*)0x20038f56 = 0; *(uint8_t*)0x20038f57 = 0; *(uint8_t*)0x20038f58 = 0; *(uint8_t*)0x20038f59 = 0; *(uint8_t*)0x20038f5a = 0; *(uint8_t*)0x20038f5b = 0; *(uint8_t*)0x20038f5c = 0; *(uint8_t*)0x20038f5d = 0; *(uint8_t*)0x20038f5e = 0; *(uint8_t*)0x20038f5f = 0; *(uint8_t*)0x20038f60 = 0; *(uint8_t*)0x20038f61 = 0; *(uint8_t*)0x20038f62 = 0; *(uint8_t*)0x20038f63 = 0; *(uint8_t*)0x20038f64 = 0; *(uint8_t*)0x20038f65 = 0; *(uint8_t*)0x20038f66 = 0; *(uint8_t*)0x20038f67 = 0; *(uint8_t*)0x20038f68 = 0; *(uint8_t*)0x20038f69 = 0; *(uint8_t*)0x20038f6a = 0; *(uint8_t*)0x20038f6b = 0; *(uint8_t*)0x20038f6c = 0; *(uint8_t*)0x20038f6d = 0; *(uint8_t*)0x20038f6e = 0; *(uint8_t*)0x20038f6f = 0; *(uint8_t*)0x20038f70 = 0; *(uint8_t*)0x20038f71 = 0; *(uint8_t*)0x20038f72 = 0; *(uint8_t*)0x20038f73 = 0; *(uint8_t*)0x20038f74 = 0; *(uint8_t*)0x20038f75 = 0; *(uint8_t*)0x20038f76 = 0; *(uint8_t*)0x20038f77 = 0; *(uint8_t*)0x20038f78 = 0; *(uint8_t*)0x20038f79 = 0; *(uint8_t*)0x20038f7a = 0; *(uint8_t*)0x20038f7b = 0; *(uint8_t*)0x20038f7c = 0; *(uint8_t*)0x20038f7d = 0; *(uint8_t*)0x20038f7e = 0; *(uint8_t*)0x20038f7f = 0; *(uint8_t*)0x20038f80 = 0; *(uint8_t*)0x20038f81 = 0; *(uint8_t*)0x20038f82 = 0; *(uint8_t*)0x20038f83 = 0; *(uint8_t*)0x20038f84 = 0; *(uint8_t*)0x20038f85 = 0; *(uint8_t*)0x20038f86 = 0; *(uint8_t*)0x20038f87 = 0; *(uint8_t*)0x20038f88 = 0; *(uint8_t*)0x20038f89 = 0; *(uint8_t*)0x20038f8a = 0; *(uint8_t*)0x20038f8b = 0; *(uint8_t*)0x20038f8c = 0; *(uint8_t*)0x20038f8d = 0; *(uint8_t*)0x20038f8e = 0; *(uint8_t*)0x20038f8f = 0; *(uint8_t*)0x20038f90 = 0; *(uint8_t*)0x20038f91 = 0; *(uint8_t*)0x20038f92 = 0; *(uint8_t*)0x20038f93 = 0; *(uint8_t*)0x20038f94 = 0; *(uint8_t*)0x20038f95 = 0; *(uint8_t*)0x20038f96 = 0; *(uint8_t*)0x20038f97 = 0; *(uint8_t*)0x20038f98 = 0; *(uint8_t*)0x20038f99 = 0; *(uint8_t*)0x20038f9a = 0; *(uint8_t*)0x20038f9b = 0; *(uint8_t*)0x20038f9c = 0; *(uint8_t*)0x20038f9d = 0; *(uint8_t*)0x20038f9e = 0; *(uint8_t*)0x20038f9f = 0; *(uint8_t*)0x20038fa0 = 0; *(uint8_t*)0x20038fa1 = 0; *(uint8_t*)0x20038fa2 = 0; *(uint8_t*)0x20038fa3 = 0; *(uint8_t*)0x20038fa4 = 0; *(uint8_t*)0x20038fa5 = 0; *(uint8_t*)0x20038fa6 = 0; *(uint8_t*)0x20038fa7 = 0; *(uint8_t*)0x20038fa8 = 0; *(uint8_t*)0x20038fa9 = 0; *(uint8_t*)0x20038faa = 0; *(uint8_t*)0x20038fab = 0; *(uint8_t*)0x20038fac = 0; *(uint8_t*)0x20038fad = 0; *(uint8_t*)0x20038fae = 0; *(uint8_t*)0x20038faf = 0; *(uint8_t*)0x20038fb0 = 0; *(uint8_t*)0x20038fb1 = 0; *(uint8_t*)0x20038fb2 = 0; *(uint8_t*)0x20038fb3 = 0; *(uint8_t*)0x20038fb4 = 0; *(uint8_t*)0x20038fb5 = 0; *(uint8_t*)0x20038fb6 = 0; *(uint8_t*)0x20038fb7 = 0; *(uint32_t*)0x20038fb8 = 0; *(uint16_t*)0x20038fbc = 0xa8; *(uint16_t*)0x20038fbe = 0xd0; *(uint32_t*)0x20038fc0 = 0; *(uint64_t*)0x20038fc8 = 0; *(uint64_t*)0x20038fd0 = 0; *(uint16_t*)0x20038fd8 = 0x28; memcpy((void*)0x20038fda, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00", 29); *(uint8_t*)0x20038ff7 = 0; *(uint32_t*)0x20038ff8 = 0xfffffffe; syscall(__NR_setsockopt, r[0], 0x29, 0x40, 0x20038b58, 0x4a8); *(uint8_t*)0x20000000 = -1; *(uint8_t*)0x20000001 = -1; *(uint8_t*)0x20000002 = -1; *(uint8_t*)0x20000003 = -1; *(uint8_t*)0x20000004 = -1; *(uint8_t*)0x20000005 = -1; *(uint8_t*)0x20000006 = 0xaa; *(uint8_t*)0x20000007 = 0xaa; *(uint8_t*)0x20000008 = 0xaa; *(uint8_t*)0x20000009 = 0xaa; *(uint8_t*)0x2000000a = 0; *(uint8_t*)0x2000000b = 0; *(uint16_t*)0x2000000c = htobe16(0x8100); STORE_BY_BITMASK(uint16_t, 0x2000000e, 0xe0b, 0, 3); STORE_BY_BITMASK(uint16_t, 0x2000000e, 7, 3, 1); STORE_BY_BITMASK(uint16_t, 0x2000000e, 1, 4, 12); *(uint16_t*)0x20000010 = htobe16(0x8848); STORE_BY_BITMASK(uint32_t, 0x20000012, htobe32(0x10001), 0, 8); STORE_BY_BITMASK(uint32_t, 0x20000012, htobe32(7), 8, 1); STORE_BY_BITMASK(uint32_t, 0x20000012, htobe32(9), 9, 3); STORE_BY_BITMASK(uint32_t, 0x20000012, htobe32(8), 12, 20); STORE_BY_BITMASK(uint32_t, 0x20000016, htobe32(9), 0, 8); STORE_BY_BITMASK(uint32_t, 0x20000016, htobe32(0xc0), 8, 1); STORE_BY_BITMASK(uint32_t, 0x20000016, htobe32(8), 9, 3); STORE_BY_BITMASK(uint32_t, 0x20000016, htobe32(2), 12, 20); } int main() { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); char* cwd = get_current_dir_name(); for (;;) { if (chdir(cwd)) fail("failed to chdir"); use_temporary_dir(); loop(); } }