// https://syzkaller.appspot.com/bug?id=a80e74a9109b76b5b3e6cbe79fe9a23fbbefcfc2 // 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, 0xffffffffffffffff}; 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_tcp arguments: [ // domain: const = 0xa (8 bytes) // type: const = 0x1 (8 bytes) // proto: const = 0x0 (4 bytes) // ] // returns sock_tcp6 res = syscall(__NR_socket, /*domain=*/0xaul, /*type=*/1ul, /*proto=*/0); if (res != -1) r[0] = res; // close arguments: [ // fd: fd (resource) // ] syscall(__NR_close, /*fd=*/r[0]); // socket$inet6_mptcp arguments: [ // domain: const = 0xa (8 bytes) // type: const = 0x1 (8 bytes) // proto: const = 0x106 (4 bytes) // ] // returns sock_mptcp6 res = syscall(__NR_socket, /*domain=*/0xaul, /*type=*/1ul, /*proto=*/0x106); if (res != -1) r[1] = res; // setsockopt$inet6_tcp_int arguments: [ // fd: sock_tcp6 (resource) // level: const = 0x6 (4 bytes) // optname: tcp_option_types_int = 0x1e (4 bytes) // optval: ptr[in, int32] { // int32 = 0x400000001 (4 bytes) // } // optlen: len = 0xc2 (8 bytes) // ] *(uint32_t*)0x200000000180 = 1; syscall(__NR_setsockopt, /*fd=*/r[0], /*level=*/6, /*optname=TCP_FASTOPEN_CONNECT*/ 0x1e, /*optval=*/0x200000000180ul, /*optlen=*/0xc2ul); // setsockopt$inet6_tcp_int arguments: [ // fd: sock_tcp6 (resource) // level: const = 0x6 (4 bytes) // optname: tcp_option_types_int = 0x2000000000000022 (4 bytes) // optval: ptr[in, int32] { // int32 = 0x1 (4 bytes) // } // optlen: len = 0x4 (8 bytes) // ] *(uint32_t*)0x200000000000 = 1; syscall(__NR_setsockopt, /*fd=*/r[1], /*level=*/6, /*optname=TCP_FASTOPEN_NO_COOKIE*/ 0x22, /*optval=*/0x200000000000ul, /*optlen=*/4ul); // connect$inet6 arguments: [ // fd: sock_in6 (resource) // addr: ptr[in, sockaddr_in6] { // sockaddr_in6 { // family: const = 0xa (2 bytes) // port: int16be = 0x0 (2 bytes) // flow: int32be = 0x0 (4 bytes) // addr: union ipv6_addr { // ipv4: ipv6_addr_ipv4 { // a0: buffer: {00 00 00 00 00 00 00 00 00 00} (length 0xa) // a1: buffer: {ff ff} (length 0x2) // a3: union ipv4_addr { // local: ipv4_addr_t[const[170, int8]] { // a0: const = 0xac (1 bytes) // a1: const = 0x14 (1 bytes) // a2: const = 0x14 (1 bytes) // a3: const = 0xaa (1 bytes) // } // } // } // } // scope: int32 = 0x2000000b (4 bytes) // } // } // addrlen: len = 0x1c (8 bytes) // ] *(uint16_t*)0x200000000240 = 0xa; *(uint16_t*)0x200000000242 = htobe16(0); *(uint32_t*)0x200000000244 = htobe32(0); memset((void*)0x200000000248, 0, 10); memset((void*)0x200000000252, 255, 2); *(uint8_t*)0x200000000254 = 0xac; *(uint8_t*)0x200000000255 = 0x14; *(uint8_t*)0x200000000256 = 0x14; *(uint8_t*)0x200000000257 = 0xaa; *(uint32_t*)0x200000000258 = 0x2000000b; syscall(__NR_connect, /*fd=*/r[0], /*addr=*/0x200000000240ul, /*addrlen=*/0x1cul); // sendto$inet6 arguments: [ // fd: sock_in6 (resource) // buf: nil // len: len = 0x0 (8 bytes) // f: send_flags = 0x0 (8 bytes) // addr: nil // addrlen: len = 0x0 (8 bytes) // ] inject_fault(1); syscall(__NR_sendto, /*fd=*/r[0], /*buf=*/0ul, /*len=*/0ul, /*f=*/0ul, /*addr=*/0ul, /*addrlen=*/0ul); return 0; }