// https://syzkaller.appspot.com/bug?id=bda19bf6b14e7fddccf28ac6f0205c7df6d8c32e // 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 static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } 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 execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { execute_one(); 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[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // socket$inet6_sctp arguments: [ // domain: const = 0x1c (4 bytes) // type: sctp_socket_type = 0x1 (4 bytes) // proto: const = 0x84 (1 bytes) // ] // returns sock_sctp6 res = syscall(SYS_socket, /*domain=*/0x1c, /*type=SOCK_STREAM*/ 1, /*proto=*/0x84); if (res != -1) r[0] = res; // sendmsg$inet6_sctp arguments: [ // fd: sock_sctp6 (resource) // msg: ptr[in, msghdr_sctp] { // msghdr_sctp { // msg_name: ptr[in, sockaddr_sctp] { // union sockaddr_sctp { // in6: sockaddr_in6 { // len: len = 0x1c (1 bytes) // family: const = 0x1c (1 bytes) // port: proc = 0x0 (2 bytes) // flow: int32 = 0x400 (4 bytes) // addr: union ipv6_addr { // loopback: ipv6_addr_loopback { // a0: const = 0x57 (8 bytes) // a1: const = 0x1 (8 bytes) // } // } // scope: int32 = 0x6 (4 bytes) // } // } // } // msg_namelen: len = 0x1c (4 bytes) // msg_iov: ptr[in, array[iovec_in]] { // array[iovec_in] { // iovec_in { // addr: ptr[in, buffer] { // buffer: {f3 d4 0e a7} (length 0x4) // } // len: len = 0x4 (4 bytes) // } // } // } // msg_iovlen: len = 0x1 (4 bytes) // msg_control: ptr[in, array[cmsghdr_sctp]] { // array[cmsghdr_sctp] { // union cmsghdr_sctp { // sndinfo: cmsghdr_sctp_sndinfo { // len: len = 0x1c (4 bytes) // level: const = 0x84 (4 bytes) // type: const = 0x4 (4 bytes) // msg: sctp_sndinfo { // snd_sid: int16 = 0x6 (2 bytes) // snd_flags: sctp_sndrcv_flags = 0x800 (2 bytes) // snd_ppid: int32 = 0xb (4 bytes) // snd_context: int32 = 0x1 (4 bytes) // snd_assoc_id: assoc_id (resource) // } // } // } // union cmsghdr_sctp { // dstaddrv4: cmsghdr_sctp_dstaddrv4 { // len: len = 0x10 (4 bytes) // level: const = 0x84 (4 bytes) // type: const = 0x9 (4 bytes) // msg: union ipv4_addr { // rand_addr: int32be = 0x57f8 (4 bytes) // } // } // } // } // } // msg_controllen: bytesize = 0x2c (4 bytes) // msg_flags: send_flags = 0x188 (4 bytes) // } // } // f: send_flags = 0x20044 (4 bytes) // ] *(uint32_t*)0x10002900 = 0x10002780; *(uint8_t*)0x10002780 = 0x1c; *(uint8_t*)0x10002781 = 0x1c; *(uint16_t*)0x10002782 = htobe16(0x4e20); *(uint32_t*)0x10002784 = 0x400; *(uint64_t*)0x10002788 = htobe64(0x57); *(uint64_t*)0x10002790 = htobe64(1); *(uint32_t*)0x10002798 = 6; *(uint32_t*)0x10002904 = 0x1c; *(uint32_t*)0x10002908 = 0x10002840; *(uint32_t*)0x10002840 = 0x100027c0; memcpy((void*)0x100027c0, "\xf3\xd4\x0e\xa7", 4); *(uint32_t*)0x10002844 = 4; *(uint32_t*)0x1000290c = 1; *(uint32_t*)0x10002910 = 0x10002880; *(uint32_t*)0x10002880 = 0x1c; *(uint32_t*)0x10002884 = 0x84; *(uint32_t*)0x10002888 = 4; *(uint16_t*)0x1000288c = 6; *(uint16_t*)0x1000288e = 0x800; *(uint32_t*)0x10002890 = 0xb; *(uint32_t*)0x10002894 = 1; *(uint32_t*)0x10002898 = 0; *(uint32_t*)0x1000289c = 0x10; *(uint32_t*)0x100028a0 = 0x84; *(uint32_t*)0x100028a4 = 9; *(uint32_t*)0x100028a8 = htobe32(0x57f8); *(uint32_t*)0x10002914 = 0x2c; *(uint32_t*)0x10002918 = 0x188; syscall(SYS_sendmsg, /*fd=*/(intptr_t)r[0], /*msg=*/0x10002900, /*f=MSG_NOSIGNAL|MSG_DONTROUTE|0x40*/ 0x20044); } int main(void) { syscall(SYS_mmap, /*addr=*/0x10000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x1012, /*fd=*/(intptr_t)-1, /*offset=*/0); const char* reason; (void)reason; loop(); return 0; }