// https://syzkaller.appspot.com/bug?id=1271f605df5183682b1dddf8dd890c73f6d996c4 // autogenerated by syzkaller (https://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 #include #include #include #include #ifndef __NR_bpf #define __NR_bpf 321 #endif static unsigned long long procid; static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } #define BITMASK(bf_off, bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type, htobe, addr, val, bf_off, bf_len) \ *(type*)(addr) = \ htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | \ (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) typedef struct { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); syscall(SYS_futex, &ev->state, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1000000); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, 0); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; for (;;) { uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, &ts); if (__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) return 1; now = current_time_ms(); if (now - start > timeout) return 0; } } static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } struct nlmsg { char* pos; int nesting; struct nlattr* nested[8]; char buf[4096]; }; static void netlink_init(struct nlmsg* nlmsg, int typ, int flags, const void* data, int size) { memset(nlmsg, 0, sizeof(*nlmsg)); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_type = typ; hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags; memcpy(hdr + 1, data, size); nlmsg->pos = (char*)(hdr + 1) + NLMSG_ALIGN(size); } static void netlink_attr(struct nlmsg* nlmsg, int typ, const void* data, int size) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_len = sizeof(*attr) + size; attr->nla_type = typ; if (size > 0) memcpy(attr + 1, data, size); nlmsg->pos += NLMSG_ALIGN(attr->nla_len); } static int netlink_send_ext(struct nlmsg* nlmsg, int sock, uint16_t reply_type, int* reply_len, bool dofail) { if (nlmsg->pos > nlmsg->buf + sizeof(nlmsg->buf) || nlmsg->nesting) exit(1); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_len = nlmsg->pos - nlmsg->buf; struct sockaddr_nl addr; memset(&addr, 0, sizeof(addr)); addr.nl_family = AF_NETLINK; ssize_t n = sendto(sock, nlmsg->buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr)); if (n != (ssize_t)hdr->nlmsg_len) { if (dofail) exit(1); return -1; } n = recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); if (reply_len) *reply_len = 0; if (n < 0) { if (dofail) exit(1); return -1; } if (n < (ssize_t)sizeof(struct nlmsghdr)) { errno = EINVAL; if (dofail) exit(1); return -1; } if (hdr->nlmsg_type == NLMSG_DONE) return 0; if (reply_len && hdr->nlmsg_type == reply_type) { *reply_len = n; return 0; } if (n < (ssize_t)(sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr))) { errno = EINVAL; if (dofail) exit(1); return -1; } if (hdr->nlmsg_type != NLMSG_ERROR) { errno = EINVAL; if (dofail) exit(1); return -1; } errno = -((struct nlmsgerr*)(hdr + 1))->error; return -errno; } static int netlink_query_family_id(struct nlmsg* nlmsg, int sock, const char* family_name, bool dofail) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = CTRL_CMD_GETFAMILY; netlink_init(nlmsg, GENL_ID_CTRL, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, CTRL_ATTR_FAMILY_NAME, family_name, strnlen(family_name, GENL_NAMSIZ - 1) + 1); int n = 0; int err = netlink_send_ext(nlmsg, sock, GENL_ID_CTRL, &n, dofail); if (err < 0) { return -1; } uint16_t id = 0; struct nlattr* attr = (struct nlattr*)(nlmsg->buf + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr))); for (; (char*)attr < nlmsg->buf + n; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) { if (attr->nla_type == CTRL_ATTR_FAMILY_ID) { id = *(uint16_t*)(attr + 1); break; } } if (!id) { errno = EINVAL; return -1; } recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); return id; } static long syz_genetlink_get_family_id(volatile long name, volatile long sock_arg) { int fd = sock_arg; if (fd < 0) { fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (fd == -1) { return -1; } } struct nlmsg nlmsg_tmp; int ret = netlink_query_family_id(&nlmsg_tmp, fd, (char*)name, false); if ((int)sock_arg < 0) close(fd); if (ret < 0) { return -1; } return ret; } #define FS_IOC_SETFLAGS _IOW('f', 2, long) static void remove_dir(const char* dir) { int iter = 0; DIR* dp = 0; retry: while (umount2(dir, MNT_DETACH | UMOUNT_NOFOLLOW) == 0) { } dp = opendir(dir); if (dp == NULL) { if (errno == EMFILE) { exit(1); } exit(1); } struct dirent* ep = 0; 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); while (umount2(filename, MNT_DETACH | UMOUNT_NOFOLLOW) == 0) { } struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } int i; for (i = 0;; i++) { if (unlink(filename) == 0) break; if (errno == EPERM) { int fd = open(filename, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno != EBUSY || i > 100) exit(1); if (umount2(filename, MNT_DETACH | UMOUNT_NOFOLLOW)) exit(1); } } closedir(dp); for (int i = 0;; i++) { if (rmdir(dir) == 0) break; if (i < 100) { if (errno == EPERM) { int fd = open(dir, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno == EBUSY) { if (umount2(dir, MNT_DETACH | UMOUNT_NOFOLLOW)) exit(1); continue; } if (errno == ENOTEMPTY) { if (iter < 100) { iter++; goto retry; } } } exit(1); } } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); for (int i = 0; i < 100; i++) { if (waitpid(-1, status, WNOHANG | __WALL) == pid) return; usleep(1000); } DIR* dir = opendir("/sys/fs/fuse/connections"); if (dir) { for (;;) { struct dirent* ent = readdir(dir); if (!ent) break; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; char abort[300]; snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort", ent->d_name); int fd = open(abort, O_WRONLY); if (fd == -1) { continue; } if (write(fd, abort, 1) < 0) { } close(fd); } closedir(dir); } else { } while (waitpid(-1, status, __WALL) != pid) { } } static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); write_file("/proc/self/oom_score_adj", "1000"); if (symlink("/dev/binderfs", "./binderfs")) { } } #define KMEMLEAK_FILE "/sys/kernel/debug/kmemleak" static void setup_leak() { if (!write_file(KMEMLEAK_FILE, "scan")) exit(1); sleep(5); if (!write_file(KMEMLEAK_FILE, "scan")) exit(1); if (!write_file(KMEMLEAK_FILE, "clear")) exit(1); } static void check_leaks(void) { int fd = open(KMEMLEAK_FILE, O_RDWR); if (fd == -1) exit(1); uint64_t start = current_time_ms(); if (write(fd, "scan", 4) != 4) exit(1); sleep(1); while (current_time_ms() - start < 4 * 1000) sleep(1); if (write(fd, "scan", 4) != 4) exit(1); static char buf[128 << 10]; ssize_t n = read(fd, buf, sizeof(buf) - 1); if (n < 0) exit(1); int nleaks = 0; if (n != 0) { sleep(1); if (write(fd, "scan", 4) != 4) exit(1); if (lseek(fd, 0, SEEK_SET) < 0) exit(1); n = read(fd, buf, sizeof(buf) - 1); if (n < 0) exit(1); buf[n] = 0; char* pos = buf; char* end = buf + n; while (pos < end) { char* next = strstr(pos + 1, "unreferenced object"); if (!next) next = end; char prev = *next; *next = 0; fprintf(stderr, "BUG: memory leak\n%s\n", pos); *next = prev; pos = next; nleaks++; } } if (write(fd, "clear", 5) != 5) exit(1); close(fd); if (nleaks) exit(1); } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 13; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); setup_test(); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); check_leaks(); } } uint64_t r[2] = {0xffffffffffffffff, 0x0}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000040, "./file0\000", 8); res = syscall(__NR_creat, 0x20000040ul, 0ul); if (res != -1) r[0] = res; break; case 1: memcpy((void*)0x200001c0, "team\000", 5); res = -1; res = syz_genetlink_get_family_id(0x200001c0, -1); if (res != -1) r[1] = res; break; case 2: syscall(__NR_ioctl, -1, 0x8933, 0ul); break; case 3: *(uint32_t*)0x20000040 = 0; memcpy((void*)0x20000044, "bond0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000", 24); *(uint32_t*)0x2000005c = 0; *(uint16_t*)0x20000074 = 0; syscall(__NR_ioctl, -1, 0x8983, 0x20000040ul); break; case 4: *(uint64_t*)0x20001180 = 0; *(uint32_t*)0x20001188 = 0; *(uint64_t*)0x20001190 = 0x20001140; *(uint64_t*)0x20001140 = 0x20000400; *(uint32_t*)0x20000400 = 0x2a4; *(uint16_t*)0x20000404 = r[1]; *(uint16_t*)0x20000406 = 1; *(uint32_t*)0x20000408 = 0; *(uint32_t*)0x2000040c = 0; *(uint8_t*)0x20000410 = 1; *(uint8_t*)0x20000411 = 0; *(uint16_t*)0x20000412 = 0; *(uint16_t*)0x20000414 = 8; *(uint16_t*)0x20000416 = 1; *(uint32_t*)0x20000418 = 0; *(uint16_t*)0x2000041c = 0x3c; STORE_BY_BITMASK(uint16_t, , 0x2000041e, 2, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000041f, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000041f, 1, 7, 1); *(uint16_t*)0x20000420 = 0x38; *(uint16_t*)0x20000422 = 1; *(uint16_t*)0x20000424 = 0x24; *(uint16_t*)0x20000426 = 1; memcpy((void*)0x20000428, "notify_peers_" "count\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint16_t*)0x20000448 = 5; *(uint16_t*)0x2000044a = 3; *(uint8_t*)0x2000044c = 3; *(uint16_t*)0x20000450 = 8; *(uint16_t*)0x20000452 = 4; *(uint32_t*)0x20000454 = 0; *(uint16_t*)0x20000458 = 8; *(uint16_t*)0x2000045a = 1; *(uint32_t*)0x2000045c = 0; *(uint16_t*)0x20000460 = 0xb4; STORE_BY_BITMASK(uint16_t, , 0x20000462, 2, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000463, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000463, 1, 7, 1); *(uint16_t*)0x20000464 = 0x38; *(uint16_t*)0x20000466 = 1; *(uint16_t*)0x20000468 = 0x24; *(uint16_t*)0x2000046a = 1; memcpy((void*)0x2000046c, "notify_peers_" "count\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint16_t*)0x2000048c = 5; *(uint16_t*)0x2000048e = 3; *(uint8_t*)0x20000490 = 3; *(uint16_t*)0x20000494 = 8; *(uint16_t*)0x20000496 = 4; *(uint32_t*)0x20000498 = 0; *(uint16_t*)0x2000049c = 0x40; *(uint16_t*)0x2000049e = 7; *(uint16_t*)0x200004a0 = 0x24; *(uint16_t*)0x200004a2 = 1; memcpy((void*)0x200004a4, "lb_tx_hash_to_port_mapping\000\000\000\000\000\000", 32); *(uint16_t*)0x200004c4 = 5; *(uint16_t*)0x200004c6 = 3; *(uint8_t*)0x200004c8 = 3; *(uint16_t*)0x200004cc = 8; *(uint16_t*)0x200004ce = 4; *(uint32_t*)0x200004d0 = 0; *(uint16_t*)0x200004d4 = 8; *(uint16_t*)0x200004d6 = 7; *(uint32_t*)0x200004d8 = 0; *(uint16_t*)0x200004dc = 0x38; *(uint16_t*)0x200004de = 1; *(uint16_t*)0x200004e0 = 0x24; *(uint16_t*)0x200004e2 = 1; memcpy((void*)0x200004e4, "activeport\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000", 32); *(uint16_t*)0x20000504 = 5; *(uint16_t*)0x20000506 = 3; *(uint8_t*)0x20000508 = 3; *(uint16_t*)0x2000050c = 8; *(uint16_t*)0x2000050e = 4; *(uint32_t*)0x20000510 = 0; *(uint16_t*)0x20000514 = 8; *(uint16_t*)0x20000516 = 1; *(uint32_t*)0x20000518 = 0; *(uint16_t*)0x2000051c = 4; STORE_BY_BITMASK(uint16_t, , 0x2000051e, 2, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000051f, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000051f, 1, 7, 1); *(uint16_t*)0x20000520 = 8; *(uint16_t*)0x20000522 = 1; *(uint32_t*)0x20000524 = 0; *(uint16_t*)0x20000528 = 0x170; STORE_BY_BITMASK(uint16_t, , 0x2000052a, 2, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000052b, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000052b, 1, 7, 1); *(uint16_t*)0x2000052c = 0x3c; *(uint16_t*)0x2000052e = 1; *(uint16_t*)0x20000530 = 0x24; *(uint16_t*)0x20000532 = 1; memcpy((void*)0x20000534, "user_linkup_" "enabled\000\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint16_t*)0x20000554 = 5; *(uint16_t*)0x20000556 = 3; *(uint8_t*)0x20000558 = 6; *(uint16_t*)0x2000055c = 4; *(uint16_t*)0x2000055e = 4; *(uint16_t*)0x20000560 = 8; *(uint16_t*)0x20000562 = 6; *(uint32_t*)0x20000564 = 0; *(uint16_t*)0x20000568 = 0x40; *(uint16_t*)0x2000056a = 1; *(uint16_t*)0x2000056c = 0x24; *(uint16_t*)0x2000056e = 1; memcpy((void*)0x20000570, "priority\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000", 32); *(uint16_t*)0x20000590 = 5; *(uint16_t*)0x20000592 = 3; *(uint8_t*)0x20000594 = 0xe; *(uint16_t*)0x20000598 = 8; *(uint16_t*)0x2000059a = 4; *(uint32_t*)0x2000059c = 0; *(uint16_t*)0x200005a0 = 8; *(uint16_t*)0x200005a2 = 6; *(uint32_t*)0x200005a4 = 0; *(uint16_t*)0x200005a8 = 0x40; *(uint16_t*)0x200005aa = 1; *(uint16_t*)0x200005ac = 0x24; *(uint16_t*)0x200005ae = 1; memcpy((void*)0x200005b0, "lb_hash_" "stats\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000", 32); *(uint16_t*)0x200005d0 = 5; *(uint16_t*)0x200005d2 = 3; *(uint8_t*)0x200005d4 = 0xb; *(uint16_t*)0x200005d8 = 8; *(uint16_t*)0x200005da = 4; *(uint32_t*)0x200005dc = 0; *(uint16_t*)0x200005e0 = 8; *(uint16_t*)0x200005e2 = 7; *(uint32_t*)0x200005e4 = 0; *(uint16_t*)0x200005e8 = 0x38; *(uint16_t*)0x200005ea = 1; *(uint16_t*)0x200005ec = 0x24; *(uint16_t*)0x200005ee = 1; memcpy((void*)0x200005f0, "mcast_rejoin_" "count\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint16_t*)0x20000610 = 5; *(uint16_t*)0x20000612 = 3; *(uint8_t*)0x20000614 = 3; *(uint16_t*)0x20000618 = 8; *(uint16_t*)0x2000061a = 4; *(uint32_t*)0x2000061c = 0; *(uint16_t*)0x20000620 = 0x40; *(uint16_t*)0x20000622 = 1; *(uint16_t*)0x20000624 = 0x24; *(uint16_t*)0x20000626 = 1; memcpy((void*)0x20000628, "mode\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint16_t*)0x20000648 = 5; *(uint16_t*)0x2000064a = 3; *(uint8_t*)0x2000064c = 5; *(uint16_t*)0x20000650 = 0xf; *(uint16_t*)0x20000652 = 4; memcpy((void*)0x20000654, "roundrobin\000", 11); *(uint16_t*)0x20000660 = 0x38; *(uint16_t*)0x20000662 = 1; *(uint16_t*)0x20000664 = 0x24; *(uint16_t*)0x20000666 = 1; memcpy((void*)0x20000668, "mcast_rejoin_" "count\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint16_t*)0x20000688 = 5; *(uint16_t*)0x2000068a = 3; *(uint8_t*)0x2000068c = 3; *(uint16_t*)0x20000690 = 8; *(uint16_t*)0x20000692 = 4; *(uint32_t*)0x20000694 = 0; *(uint16_t*)0x20000698 = 8; *(uint16_t*)0x2000069a = 1; *(uint32_t*)0x2000069c = 0; *(uint16_t*)0x200006a0 = 4; STORE_BY_BITMASK(uint16_t, , 0x200006a2, 2, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200006a3, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200006a3, 1, 7, 1); *(uint64_t*)0x20001148 = 0x2a4; *(uint64_t*)0x20001198 = 1; *(uint64_t*)0x200011a0 = 0; *(uint64_t*)0x200011a8 = 0; *(uint32_t*)0x200011b0 = 0; syscall(__NR_sendmsg, -1, 0x20001180ul, 0x20000010ul); break; case 5: *(uint64_t*)0x20001100 = 0x20000040; *(uint16_t*)0x20000040 = 0x10; *(uint16_t*)0x20000042 = 0; *(uint32_t*)0x20000044 = 0; *(uint32_t*)0x20000048 = 0x400; *(uint32_t*)0x20001108 = 0xc; *(uint64_t*)0x20001110 = 0x200010c0; *(uint64_t*)0x200010c0 = 0; *(uint64_t*)0x200010c8 = 0; *(uint64_t*)0x20001118 = 1; *(uint64_t*)0x20001120 = 0; *(uint64_t*)0x20001128 = 0; *(uint32_t*)0x20001130 = 4; syscall(__NR_sendmsg, -1, 0x20001100ul, 0x4000ul); break; case 6: *(uint64_t*)0x20000680 = 0; *(uint64_t*)0x20000688 = 0; *(uint64_t*)0x20000690 = 0; *(uint64_t*)0x20000698 = 0x20000640; *(uint32_t*)0x200006a0 = 0xffffffe1; *(uint32_t*)0x200006a4 = -1; *(uint64_t*)0x200006a8 = 0; *(uint64_t*)0x200006b0 = 0; syscall(__NR_bpf, 0x1aul, 0x20000680ul, 0x38ul); break; case 7: *(uint64_t*)0x20000080 = 0; syscall(__NR_write, r[0], 0x20000080ul, 0xfffffe5eul); break; case 8: memcpy((void*)0x20000100, "./bus\000", 6); syscall(__NR_mkdir, 0x20000100ul, 0ul); break; case 9: memcpy((void*)0x20000400, "./file1\000", 8); syscall(__NR_mkdir, 0x20000400ul, 0ul); break; case 10: memcpy((void*)0x20000040, "./bus\000", 6); memcpy((void*)0x20000080, "overlay\000", 8); memcpy((void*)0x20000000, "upperdir=./bus,workdir=./file1,lowerdir=.", 41); syscall(__NR_mount, 0ul, 0x20000040ul, 0x20000080ul, 0ul, 0x20000000ul); break; case 11: memcpy((void*)0x200001c0, "./bus\000", 6); syscall(__NR_chdir, 0x200001c0ul); break; case 12: memcpy((void*)0x20000140, "./file0\000", 8); syscall(__NR_open, 0x20000140ul, 0x14dc81ul, 0ul); break; } } int main(void) { syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); setup_leak(); for (procid = 0; procid < 8; procid++) { if (fork() == 0) { use_temporary_dir(); loop(); } } sleep(1000000); return 0; }