// https://syzkaller.appspot.com/bug?id=f11774dabfe0c3f2249677224387bfca43f0e9b6 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include 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; } static int inject_fault(int nth) { int fd; fd = open("/proc/thread-self/fail-nth", O_RDWR); if (fd == -1) exit(1); char buf[16]; sprintf(buf, "%d", nth); if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) exit(1); return fd; } static const char* setup_fault() { int fd = open("/proc/self/make-it-fail", O_WRONLY); if (fd == -1) return "CONFIG_FAULT_INJECTION is not enabled"; close(fd); fd = open("/proc/thread-self/fail-nth", O_WRONLY); if (fd == -1) return "kernel does not have systematic fault injection support"; close(fd); static struct { const char* file; const char* val; bool fatal; } files[] = { {"/sys/kernel/debug/failslab/ignore-gfp-wait", "N", true}, {"/sys/kernel/debug/fail_futex/ignore-private", "N", false}, {"/sys/kernel/debug/fail_page_alloc/ignore-gfp-highmem", "N", false}, {"/sys/kernel/debug/fail_page_alloc/ignore-gfp-wait", "N", false}, {"/sys/kernel/debug/fail_page_alloc/min-order", "0", false}, }; unsigned i; for (i = 0; i < sizeof(files) / sizeof(files[0]); i++) { if (!write_file(files[i].file, files[i].val)) { if (files[i].fatal) return "failed to write fault injection file"; } } return NULL; } uint64_t r[2] = {0xffffffffffffffff, 0x0}; int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*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=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; if ((reason = setup_fault())) printf("the reproducer may not work as expected: fault injection setup " "failed: %s\n", reason); intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // socket$inet6_sctp arguments: [ // domain: const = 0xa (8 bytes) // type: sctp_socket_type = 0x5 (8 bytes) // proto: const = 0x84 (4 bytes) // ] // returns sock_sctp6 res = syscall(__NR_socket, /*domain=*/0xaul, /*type=SOCK_SEQPACKET*/ 5ul, /*proto=*/0x84); if (res != -1) r[0] = res; // shutdown arguments: [ // fd: sock (resource) // how: shutdown_flags = 0x0 (8 bytes) // ] syscall(__NR_shutdown, /*fd=*/r[0], /*how=*/0ul); // getsockopt$inet_sctp6_SCTP_SOCKOPT_CONNECTX3 arguments: [ // fd: sock_sctp6 (resource) // level: const = 0x84 (4 bytes) // opt: const = 0x6f (4 bytes) // val: ptr[inout, sctp_getaddrs_old] { // sctp_getaddrs_old { // assoc_id: assoc_id (resource) // addr_num: bytesize = 0x10 (4 bytes) // addrs: ptr[in, array[sockaddr_sctp]] { // array[sockaddr_sctp] { // union sockaddr_sctp { // in: sockaddr_in { // family: const = 0x2 (2 bytes) // port: int16be = 0x4e23 (2 bytes) // addr: union ipv4_addr { // rand_addr: int32be = 0x64010100 (4 bytes) // } // pad = 0x0 (8 bytes) // } // } // } // } // } // } // len: ptr[inout, len] { // len = 0x10 (4 bytes) // } // ] *(uint32_t*)0x200000000200 = 0; *(uint32_t*)0x200000000204 = 0x10; *(uint64_t*)0x200000000208 = 0x2000000001c0; *(uint16_t*)0x2000000001c0 = 2; *(uint16_t*)0x2000000001c2 = htobe16(0x4e23); *(uint32_t*)0x2000000001c4 = htobe32(0x64010100); *(uint32_t*)0x200000000140 = 0x10; res = syscall(__NR_getsockopt, /*fd=*/r[0], /*level=*/0x84, /*opt=*/0x6f, /*val=*/0x200000000200ul, /*len=*/0x200000000140ul); if (res != -1) r[1] = *(uint32_t*)0x200000000200; // getsockopt$inet_sctp6_SCTP_PRIMARY_ADDR arguments: [ // fd: sock_sctp6 (resource) // level: const = 0x84 (4 bytes) // opt: const = 0x7a (4 bytes) // val: ptr[inout, sctp_prim] { // sctp_prim { // ssp_assoc_id: assoc_id (resource) // ssp_addr: union sockaddr_storage_sctp { // in6: sockaddr_storage_in6 { // addr: sockaddr_in6 { // family: const = 0xa (2 bytes) // port: int16be = 0x3 (2 bytes) // flow: int32be = 0x4 (4 bytes) // addr: union ipv6_addr { // mcast1: ipv6_addr_multicast1 { // a0: const = 0xff (1 bytes) // a1: const = 0x1 (1 bytes) // a2: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0xd) a3: const = 0x1 (1 bytes) // } // } // scope: int32 = 0x0 (4 bytes) // } // pad = 0x0 (4 bytes) // pad = 0x0 (96 bytes) // } // } // } // } // len: ptr[inout, len] { // len = 0x84 (4 bytes) // } // ] *(uint32_t*)0x200000000340 = r[1]; *(uint16_t*)0x200000000344 = 0xa; *(uint16_t*)0x200000000346 = htobe16(3); *(uint32_t*)0x200000000348 = htobe32(4); *(uint8_t*)0x20000000034c = -1; *(uint8_t*)0x20000000034d = 1; memset((void*)0x20000000034e, 0, 13); *(uint8_t*)0x20000000035b = 1; *(uint32_t*)0x20000000035c = 0; *(uint32_t*)0x200000000040 = 0x84; inject_fault(11); syscall(__NR_getsockopt, /*fd=*/r[0], /*level=*/0x84, /*opt=*/0x7a, /*val=*/0x200000000340ul, /*len=*/0x200000000040ul); return 0; }