// https://syzkaller.appspot.com/bug?id=36c527e4621386a8d2759fde3492c5d9bacce9ea // 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 #include #ifndef __NR_bpf #define __NR_bpf 280 #endif #ifndef __NR_mmap #define __NR_mmap 222 #endif #ifndef __NR_openat #define __NR_openat 56 #endif #ifndef __NR_sendmsg #define __NR_sendmsg 211 #endif #ifndef __NR_socket #define __NR_socket 198 #endif #ifndef __NR_socketpair #define __NR_socketpair 199 #endif 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 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; } const int kInitNetNsFd = 201; #define MAX_FDS 30 static long syz_init_net_socket(volatile long domain, volatile long type, volatile long proto) { int netns = open("/proc/self/ns/net", O_RDONLY); if (netns == -1) return netns; if (setns(kInitNetNsFd, 0)) return -1; int sock = syscall(__NR_socket, domain, type, proto); int err = errno; if (setns(netns, 0)) { exit(1); } close(netns); errno = err; return sock; } 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; } static void setup_gadgetfs(); static void setup_binderfs(); static void setup_fusectl(); static void sandbox_common_mount_tmpfs(void) { write_file("/proc/sys/fs/mount-max", "100000"); if (mkdir("./syz-tmp", 0777)) exit(1); if (mount("", "./syz-tmp", "tmpfs", 0, NULL)) exit(1); if (mkdir("./syz-tmp/newroot", 0777)) exit(1); if (mkdir("./syz-tmp/newroot/dev", 0700)) exit(1); unsigned bind_mount_flags = MS_BIND | MS_REC | MS_PRIVATE; if (mount("/dev", "./syz-tmp/newroot/dev", NULL, bind_mount_flags, NULL)) exit(1); if (mkdir("./syz-tmp/newroot/proc", 0700)) exit(1); if (mount("syz-proc", "./syz-tmp/newroot/proc", "proc", 0, NULL)) exit(1); if (mkdir("./syz-tmp/newroot/selinux", 0700)) exit(1); const char* selinux_path = "./syz-tmp/newroot/selinux"; if (mount("/selinux", selinux_path, NULL, bind_mount_flags, NULL)) { if (errno != ENOENT) exit(1); if (mount("/sys/fs/selinux", selinux_path, NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); } if (mkdir("./syz-tmp/newroot/sys", 0700)) exit(1); if (mount("/sys", "./syz-tmp/newroot/sys", 0, bind_mount_flags, NULL)) exit(1); if (mount("/sys/kernel/debug", "./syz-tmp/newroot/sys/kernel/debug", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); if (mount("/sys/fs/smackfs", "./syz-tmp/newroot/sys/fs/smackfs", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); if (mount("/proc/sys/fs/binfmt_misc", "./syz-tmp/newroot/proc/sys/fs/binfmt_misc", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); if (mkdir("./syz-tmp/newroot/syz-inputs", 0700)) exit(1); if (mount("/syz-inputs", "./syz-tmp/newroot/syz-inputs", NULL, bind_mount_flags | MS_RDONLY, NULL) && errno != ENOENT) exit(1); if (mkdir("./syz-tmp/pivot", 0777)) exit(1); if (syscall(SYS_pivot_root, "./syz-tmp", "./syz-tmp/pivot")) { if (chdir("./syz-tmp")) exit(1); } else { if (chdir("/")) exit(1); if (umount2("./pivot", MNT_DETACH)) exit(1); } if (chroot("./newroot")) exit(1); if (chdir("/")) exit(1); setup_gadgetfs(); setup_binderfs(); setup_fusectl(); } static void setup_gadgetfs() { if (mkdir("/dev/gadgetfs", 0777)) { } if (mount("gadgetfs", "/dev/gadgetfs", "gadgetfs", 0, NULL)) { } } static void setup_fusectl() { if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) { } } static void setup_binderfs() { if (mkdir("/dev/binderfs", 0777)) { } if (mount("binder", "/dev/binderfs", "binder", 0, NULL)) { } if (symlink("/dev/binderfs", "./binderfs")) { } } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); if (getppid() == 1) exit(1); int netns = open("/proc/self/ns/net", O_RDONLY); if (netns == -1) exit(1); if (dup2(netns, kInitNetNsFd) < 0) exit(1); close(netns); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = (200 << 20); setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 32 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 136 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); if (unshare(CLONE_NEWNS)) { } if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } typedef struct { const char* name; const char* value; } sysctl_t; static const sysctl_t sysctls[] = { {"/proc/sys/kernel/shmmax", "16777216"}, {"/proc/sys/kernel/shmall", "536870912"}, {"/proc/sys/kernel/shmmni", "1024"}, {"/proc/sys/kernel/msgmax", "8192"}, {"/proc/sys/kernel/msgmni", "1024"}, {"/proc/sys/kernel/msgmnb", "1024"}, {"/proc/sys/kernel/sem", "1024 1048576 500 1024"}, }; unsigned i; for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++) write_file(sysctls[i].name, sysctls[i].value); } static int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, __WALL) != pid) { } return WEXITSTATUS(status); } static void drop_caps(void) { struct __user_cap_header_struct cap_hdr = {}; struct __user_cap_data_struct cap_data[2] = {}; cap_hdr.version = _LINUX_CAPABILITY_VERSION_3; cap_hdr.pid = getpid(); if (syscall(SYS_capget, &cap_hdr, &cap_data)) exit(1); const int drop = (1 << CAP_SYS_PTRACE) | (1 << CAP_SYS_NICE); cap_data[0].effective &= ~drop; cap_data[0].permitted &= ~drop; cap_data[0].inheritable &= ~drop; if (syscall(SYS_capset, &cap_hdr, &cap_data)) exit(1); } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid != 0) return wait_for_loop(pid); sandbox_common(); drop_caps(); if (unshare(CLONE_NEWNET)) { } write_file("/proc/sys/net/ipv4/ping_group_range", "0 65535"); sandbox_common_mount_tmpfs(); loop(); 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"); } static void close_fds() { for (int fd = 3; fd < MAX_FDS; fd++) close(fd); } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter = 0; for (;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { setup_test(); execute_one(); close_fds(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // syz_init_net_socket$bt_rfcomm arguments: [ // fam: const = 0x1f (8 bytes) // type: bt_rfcomm_type = 0x1 (8 bytes) // proto: const = 0x3 (8 bytes) // ] // returns sock_bt_rfcomm syz_init_net_socket(/*fam=*/0x1f, /*type=SOCK_STREAM*/ 1, /*proto=*/3); // openat$tcp_congestion arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: ptr[in, buffer] { // buffer: {2f 70 72 6f 63 2f 73 79 73 2f 6e 65 74 2f 69 70 76 34 2f 74 // 63 70 5f 63 6f 6e 67 65 73 74 69 6f 6e 5f 63 6f 6e 74 72 6f 6c 00} // (length 0x2a) // } // flags: const = 0x35c (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd_tcp_congestion memcpy((void*)0x20000180, "/proc/sys/net/ipv4/tcp_congestion_control\000", 42); syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x20000180ul, /*flags=*/0x35c, /*mode=*/0); // socket$unix arguments: [ // domain: const = 0x1 (8 bytes) // type: unix_socket_type = 0x5 (8 bytes) // proto: const = 0x0 (4 bytes) // ] // returns sock_unix syscall(__NR_socket, /*domain=*/1ul, /*type=SOCK_SEQPACKET*/ 5ul, /*proto=*/0); // bpf$PROG_LOAD arguments: [ // cmd: const = 0x5 (8 bytes) // arg: ptr[in, bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], fd_bpf_prog[opt]]] { // bpf_prog_t[flags[bpf_prog_type, int32], bpf_prog_attach_types, // bpf_btf_id[opt], fd_bpf_prog[opt]] { // type: bpf_prog_type = 0x9 (4 bytes) // ninsn: bytesize8 = 0x1b (4 bytes) // insns: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {18 00 00 00 61 d8 d8 37 00 00 00 00 2c 2c 00 // 00 18 11 db f3} (length 0x14) // } // union ANYUNION { // ANYRES32: ANYRES32 (resource) // } // union ANYUNION { // ANYBLOB: buffer: {00 00 00 00 00 00 00 00 b7 02 00 00 14 00 00 // 00 b7 03 00 00 00 00 00 00 85 00 00 00 83 00 00 00 bf 09 00 00 // 00 00 00 00 55 09 01 00 00 00 00 00 95 00 00 00 00 00 00 00 85 // 00 00 00 23 00 00 00 18 49 00 00 04 00 00 00 00 00 00 00 00 00 // 00 00 18 00 00 00 07 00 00 00 00 00 00 00 02 00 00 00 18 11 00 // 00} (length 0x64) // } // union ANYUNION { // ANYRES32: ANYRES32 (resource) // } // union ANYUNION { // ANYBLOB: buffer: {00 00 00 00 00 00 00 00 b7 02 00 00 00 00 00 // 00 85 00 00 00 86 00 00 00 18 34 00 00 01 00 00 00 00 00 00 00 // 00 00 00 00 85 20 00 00 04} (length 0x2d) // } // } // } // license: nil // loglev: int32 = 0x800 (4 bytes) // logsize: len = 0x0 (4 bytes) // log: nil // kern_version: bpf_kern_version = 0x41100 (4 bytes) // flags: bpf_prog_load_flags = 0x44 (4 bytes) // prog_name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0x10) prog_ifindex: ifindex (resource) expected_attach_type: // union bpf_prog_attach_types { // fallback: bpf_attach_types = 0x23 (4 bytes) // } // btf_fd: fd_btf (resource) // func_info_rec_size: const = 0x8 (4 bytes) // func_info: nil // func_info_cnt: len = 0x0 (4 bytes) // line_info_rec_size: const = 0x10 (4 bytes) // line_info: nil // line_info_cnt: len = 0x0 (4 bytes) // attach_btf_id: bpf_btf_id (resource) // attach_prog_fd: fd_bpf_prog (resource) // core_relo_cnt: len = 0x0 (4 bytes) // fd_array: nil // core_relos: nil // core_relo_rec_size: const = 0x10 (4 bytes) // log_true_size: int32 = 0x2 (4 bytes) // prog_token_fd: union _bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_prog_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad: union _bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_pad_wrapper { // value: const = 0x0 (4 bytes) // } // } // } // size: len = 0x94 (8 bytes) // ] // returns fd_bpf_prog *(uint32_t*)0x20001280 = 9; *(uint32_t*)0x20001284 = 0x1b; *(uint64_t*)0x20001288 = 0x20000080; memcpy((void*)0x20000080, "\x18\x00\x00\x00\x61\xd8\xd8\x37\x00\x00\x00\x00\x2c\x2c\x00\x00\x18" "\x11\xdb\xf3", 20); *(uint32_t*)0x20000094 = -1; memcpy((void*)0x20000098, "\x00\x00\x00\x00\x00\x00\x00\x00\xb7\x02\x00\x00\x14\x00\x00\x00\xb7" "\x03\x00\x00\x00\x00\x00\x00\x85\x00\x00\x00\x83\x00\x00\x00\xbf\x09" "\x00\x00\x00\x00\x00\x00\x55\x09\x01\x00\x00\x00\x00\x00\x95\x00\x00" "\x00\x00\x00\x00\x00\x85\x00\x00\x00\x23\x00\x00\x00\x18\x49\x00\x00" "\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x07" "\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x18\x11\x00\x00", 100); *(uint32_t*)0x200000fc = 1; memcpy((void*)0x20000100, "\x00\x00\x00\x00\x00\x00\x00\x00\xb7\x02\x00\x00\x00\x00\x00\x00\x85" "\x00\x00\x00\x86\x00\x00\x00\x18\x34\x00\x00\x01\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x85\x20\x00\x00\x04", 45); *(uint64_t*)0x20001290 = 0; *(uint32_t*)0x20001298 = 0x800; *(uint32_t*)0x2000129c = 0; *(uint64_t*)0x200012a0 = 0; *(uint32_t*)0x200012a8 = 0x41100; *(uint32_t*)0x200012ac = 0x44; memset((void*)0x200012b0, 0, 16); *(uint32_t*)0x200012c0 = 0; *(uint32_t*)0x200012c4 = 0x23; *(uint32_t*)0x200012c8 = -1; *(uint32_t*)0x200012cc = 8; *(uint64_t*)0x200012d0 = 0; *(uint32_t*)0x200012d8 = 0; *(uint32_t*)0x200012dc = 0x10; *(uint64_t*)0x200012e0 = 0; *(uint32_t*)0x200012e8 = 0; *(uint32_t*)0x200012ec = -1; *(uint32_t*)0x200012f0 = -1; *(uint32_t*)0x200012f4 = 0; *(uint64_t*)0x200012f8 = 0; *(uint64_t*)0x20001300 = 0; *(uint32_t*)0x20001308 = 0x10; *(uint32_t*)0x2000130c = 2; *(uint32_t*)0x20001310 = 0; syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x20001280ul, /*size=*/0x94ul); // syz_init_net_socket$ax25 arguments: [ // domain: const = 0x3 (8 bytes) // type: ax25_socket_types = 0x2 (8 bytes) // proto: ax25_protocols = 0x0 (8 bytes) // ] // returns sock_ax25 syz_init_net_socket(/*domain=*/3, /*type=SOCK_DGRAM*/ 2, /*proto=*/0); // socket$nl_generic arguments: [ // domain: const = 0x10 (8 bytes) // type: const = 0x3 (8 bytes) // proto: const = 0x10 (4 bytes) // ] // returns sock_nl_generic syscall(__NR_socket, /*domain=*/0x10ul, /*type=*/3ul, /*proto=*/0x10); // socket arguments: [ // domain: socket_domain = 0x2a (8 bytes) // type: socket_type = 0x2 (8 bytes) // proto: int32 = 0x0 (4 bytes) // ] // returns sock syscall(__NR_socket, /*domain=AF_QIPCRTR*/ 0x2aul, /*type=SOCK_DGRAM*/ 2ul, /*proto=*/0); // sendmsg$NFT_BATCH arguments: [ // fd: sock_nl_netfilter (resource) // msg: ptr[in, msghdr_netlink[nft_batch_msg]] { // msghdr_netlink[nft_batch_msg] { // addr: nil // addrlen: len = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // vec: ptr[in, iovec[in, nft_batch_msg]] { // iovec[in, nft_batch_msg] { // addr: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {14 00 00 00 10 00 01 00 00 00 51 00 00 // 00 00 00 00 00 00 0a 20 00 00 00 09 00 01 00 73 79 7a 30 // 00 00 00 00 14 00 00 00 10 00 01} (length 0x2b) // } // } // } // len: len = 0x48 (8 bytes) // } // } // vlen: const = 0x1 (8 bytes) // ctrl: const = 0x0 (8 bytes) // ctrllen: const = 0x0 (8 bytes) // f: send_flags = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x20050800 (8 bytes) // ] *(uint64_t*)0x200000c0 = 0; *(uint32_t*)0x200000c8 = 0; *(uint64_t*)0x200000d0 = 0x20000000; *(uint64_t*)0x20000000 = 0x20000100; memcpy((void*)0x20000100, "\x14\x00\x00\x00\x10\x00\x01\x00\x00\x00\x51\x00\x00\x00\x00\x00\x00" "\x00\x00\x0a\x20\x00\x00\x00\x09\x00\x01\x00\x73\x79\x7a\x30\x00\x00" "\x00\x00\x14\x00\x00\x00\x10\x00\x01", 43); *(uint64_t*)0x20000008 = 0x48; *(uint64_t*)0x200000d8 = 1; *(uint64_t*)0x200000e0 = 0; *(uint64_t*)0x200000e8 = 0; *(uint32_t*)0x200000f0 = 0; syscall(__NR_sendmsg, /*fd=*/(intptr_t)-1, /*msg=*/0x200000c0ul, /*f=MSG_FASTOPEN|MSG_BATCH|MSG_CONFIRM|0x10000*/ 0x20050800ul); // syz_init_net_socket$nl_generic arguments: [ // domain: const = 0x10 (8 bytes) // type: const = 0x3 (8 bytes) // proto: const = 0x10 (8 bytes) // ] // returns sock_nl_generic_init res = -1; res = syz_init_net_socket(/*domain=*/0x10, /*type=*/3, /*proto=*/0x10); if (res != -1) r[0] = res; // syz_genetlink_get_family_id$nbd arguments: [ // name: ptr[in, buffer] { // buffer: {6e 62 64 00} (length 0x4) // } // fd: sock_nl_generic_init (resource) // ] // returns genl_nbd_family_id memcpy((void*)0x20000380, "nbd\000", 4); res = -1; res = syz_genetlink_get_family_id(/*name=*/0x20000380, /*fd=*/-1); if (res != -1) r[1] = res; // socketpair$nbd arguments: [ // domain: const = 0x1 (8 bytes) // type: const = 0x1 (8 bytes) // proto: const = 0x0 (4 bytes) // fds: ptr[out, nbd_sock_pair] { // nbd_sock_pair { // client: sock_nbd_client (resource) // server: sock_nbd_server (resource) // } // } // ] res = syscall(__NR_socketpair, /*domain=*/1ul, /*type=*/1ul, /*proto=*/0, /*fds=*/0x20000200ul); if (res != -1) r[2] = *(uint32_t*)0x20000200; // sendmsg$NBD_CMD_CONNECT arguments: [ // fd: sock_nl_generic_init (resource) // msg: ptr[in, msghdr_netlink[netlink_msg_t[genl_nbd_family_id, // genlmsghdr_t[NBD_CMD_CONNECT], nbd_attr_policy]]] { // msghdr_netlink[netlink_msg_t[genl_nbd_family_id, // genlmsghdr_t[NBD_CMD_CONNECT], nbd_attr_policy]] { // addr: nil // addrlen: len = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // vec: ptr[in, iovec[in, netlink_msg_t[genl_nbd_family_id, // genlmsghdr_t[NBD_CMD_CONNECT], nbd_attr_policy]]] { // iovec[in, netlink_msg_t[genl_nbd_family_id, // genlmsghdr_t[NBD_CMD_CONNECT], nbd_attr_policy]] { // addr: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {90 00 00 00} (length 0x4) // } // union ANYUNION { // ANYRES16: ANYRES16 (resource) // } // union ANYUNION { // ANYBLOB: buffer: {01 00 00 00 00 00 00 00 00 00 01 00 00 // 00 0c 00 05 97 ff 00 00 00 00 00 00 00 0c 00 02 00 00 00 // 00 00 00 00 00 00 04 00 07 80 0c 00 08 00 00 00 00 00 00 // 00 00 00 08 00 0a 00 00 00 00 00 44 00 07 80 08 00 01 00} // (length 0x46) // } // union ANYUNION { // ANYRES32: ANYRES32 (resource) // } // union ANYUNION { // ANYBLOB: buffer: {38 00 01 00} (length 0x4) // } // union ANYUNION { // ANYRES32: ANYRES32 (resource) // } // union ANYUNION { // ANYBLOB: buffer: {64 80 04 00} (length 0x4) // } // union ANYUNION { // ANYRES32: ANYRES32 (resource) // } // union ANYUNION { // ANYBLOB: buffer: {08} (length 0x1) // } // } // } // len: len = 0x90 (8 bytes) // } // } // vlen: const = 0x1 (8 bytes) // ctrl: const = 0x0 (8 bytes) // ctrllen: const = 0x0 (8 bytes) // f: send_flags = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x0 (8 bytes) // ] *(uint64_t*)0x200002c0 = 0; *(uint32_t*)0x200002c8 = 0; *(uint64_t*)0x200002d0 = 0x20000280; *(uint64_t*)0x20000280 = 0x200000c0; memcpy((void*)0x200000c0, "\x90\x00\x00\x00", 4); *(uint16_t*)0x200000c4 = r[1]; memcpy( (void*)0x200000c6, "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x0c\x00\x05\x97" "\xff\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x02\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x04\x00\x07\x80\x0c\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x08\x00\x0a\x00\x00\x00\x00\x00\x44\x00\x07\x80\x08\x00\x01\x00", 70); *(uint32_t*)0x2000010c = -1; memcpy((void*)0x20000110, "\x38\x00\x01\x00", 4); *(uint32_t*)0x20000114 = r[2]; memcpy((void*)0x20000118, "\x64\x80\x04\x00", 4); *(uint32_t*)0x2000011c = -1; memset((void*)0x20000120, 8, 1); *(uint64_t*)0x20000288 = 0x90; *(uint64_t*)0x200002d8 = 1; *(uint64_t*)0x200002e0 = 0; *(uint64_t*)0x200002e8 = 0; *(uint32_t*)0x200002f0 = 0; syscall(__NR_sendmsg, /*fd=*/r[0], /*msg=*/0x200002c0ul, /*f=*/0ul); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; do_sandbox_none(); return 0; }