// https://syzkaller.appspot.com/bug?id=1c59192b54b99a4b97d018309b8a38727538e6bc // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000, /*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=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // mkdirat arguments: [ // fd: fd_dir (resource) // path: ptr[in, buffer] { // buffer: {2e 2f 67 61 64 67 65 74 00} (length 0x9) // } // mode: open_mode = 0x1ff (8 bytes) // ] memcpy((void*)0x200000000140, "./gadget\000", 9); syscall( __NR_mkdirat, /*fd=*/0xffffff9c, /*path=*/0x200000000140ul, /*mode=S_IXOTH|S_IWOTH|S_IROTH|S_IXGRP|S_IWGRP|S_IRGRP|S_IXUSR|S_IWUSR|0x100*/ 0x1fful); // mount arguments: [ // src: nil // dst: ptr[in, buffer] { // buffer: {2e 2f 67 61 64 67 65 74 00} (length 0x9) // } // type: ptr[in, buffer] { // buffer: {67 61 64 67 65 74 66 73 00} (length 0x9) // } // flags: mount_flags = 0x0 (8 bytes) // data: nil // ] memcpy((void*)0x2000000001c0, "./gadget\000", 9); memcpy((void*)0x2000000002c0, "gadgetfs\000", 9); syscall(__NR_mount, /*src=*/0ul, /*dst=*/0x2000000001c0ul, /*type=*/0x2000000002c0ul, /*flags=*/0ul, /*data=*/0ul); // openat arguments: [ // fd: fd_dir (resource) // file: ptr[in, buffer] { // buffer: {2e 2f 67 61 64 67 65 74 2f 64 75 6d 6d 79 5f 75 64 63 00} // (length 0x13) // } // flags: open_flags = 0x802 (4 bytes) // mode: open_mode = 0x0 (2 bytes) // ] // returns fd memcpy((void*)0x200000000300, "./gadget/dummy_udc\000", 19); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200000000300ul, /*flags=O_NONBLOCK|O_RDWR*/ 0x802, /*mode=*/0); if (res != -1) r[0] = res; // write arguments: [ // fd: fd (resource) // buf: ptr[in, buffer] { // buffer: {00 00 00 00 09 02 09 00 01 01 00 80 32 12 01 00 02 00 00 00 // 40 25 05 a0 a4 00 01 00 00 00 01} (length 0x1f) // } // count: len = 0x1f (8 bytes) // ] memcpy((void*)0x2000000003c0, "\x00\x00\x00\x00\x09\x02\x09\x00\x01\x01\x00\x80\x32\x12\x01\x00\x02" "\x00\x00\x00\x40\x25\x05\xa0\xa4\x00\x01\x00\x00\x00\x01", 31); syscall(__NR_write, /*fd=*/r[0], /*buf=*/0x2000000003c0ul, /*count=*/0x1ful); // openat arguments: [ // fd: fd_dir (resource) // file: ptr[in, buffer] { // buffer: {2e 2f 67 61 64 67 65 74 2f 65 70 31 69 6e 2d 62 75 6c 6b 00} // (length 0x14) // } // flags: open_flags = 0x2 (4 bytes) // mode: open_mode = 0x0 (2 bytes) // ] // returns fd memcpy((void*)0x200000000400, "./gadget/ep1in-bulk\000", 20); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200000000400ul, /*flags=O_RDWR*/ 2, /*mode=*/0); if (res != -1) r[1] = res; // writev arguments: [ // fd: fd (resource) // vec: ptr[in, array[iovec[in, array[int8]]]] { // array[iovec[in, array[int8]]] { // iovec[in, array[int8]] { // addr: ptr[in, buffer] { // buffer: {84 b5} (length 0x2) // } // len: len = 0xfffffeb7 (8 bytes) // } // iovec[in, array[int8]] { // addr: nil // len: len = 0x3 (8 bytes) // } // } // } // vlen: len = 0x2 (8 bytes) // ] *(uint64_t*)0x200000000440 = 0x200000000480; memcpy((void*)0x200000000480, "\x84\xb5", 2); *(uint64_t*)0x200000000448 = 0xfffffeb7; *(uint64_t*)0x200000000450 = 0; *(uint64_t*)0x200000000458 = 3; syscall(__NR_writev, /*fd=*/r[1], /*vec=*/0x200000000440ul, /*vlen=*/2ul); return 0; }