// https://syzkaller.appspot.com/bug?id=9e2db8bd054656b161347fe5d2af68dc04283d25 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #ifndef __NR_memfd_create #define __NR_memfd_create 319 #endif static long syz_open_dev(volatile long a0, volatile long a1, volatile long a2) { if (a0 == 0xc || a0 == 0xb) { char buf[128]; sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1, (uint8_t)a2); return open(buf, O_RDWR, 0); } else { unsigned long nb = a1; char buf[1024]; char* hash; strncpy(buf, (char*)a0, sizeof(buf) - 1); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(nb % 10); nb /= 10; } return open(buf, a2 & ~O_CREAT, 0); } } 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)) { } // memfd_create arguments: [ // name: ptr[in, buffer] { // buffer: {73 79 7a 6b 61 6c 6c 65 72 00} (length 0xa) // } // flags: memfd_flags = 0x0 (8 bytes) // ] // returns fd_memfd memcpy((void*)0x200000000000, "syzkaller\000", 10); res = syscall(__NR_memfd_create, /*name=*/0x200000000000ul, /*flags=*/0ul); if (res != -1) r[0] = res; // ftruncate arguments: [ // fd: fd (resource) // len: intptr = 0x10000 (8 bytes) // ] syscall(__NR_ftruncate, /*fd=*/r[0], /*len=*/0x10000ul); // pwrite64 arguments: [ // fd: fd (resource) // buf: ptr[in, buffer] { // buffer: {80 00 00 00 80 00 00 00 01 00 00 00 00 10 00 00 00 04 00 00 // 04 00 00 00 05 00 00 00} (length 0x1c) // } // count: len = 0x1c (8 bytes) // pos: intptr = 0x2024 (8 bytes) // ] memcpy((void*)0x200000001020, "\x80\x00\x00\x00\x80\x00\x00\x00\x01\x00\x00\x00\x00\x10\x00\x00\x00" "\x04\x00\x00\x04\x00\x00\x00\x05\x00\x00\x00", 28); syscall(__NR_pwrite64, /*fd=*/r[0], /*buf=*/0x200000001020ul, /*count=*/0x1cul, /*pos=*/0x2024ul); // pwrite64 arguments: [ // fd: fd (resource) // buf: ptr[in, buffer] { // buffer: {00 08 00 00 00 00 00 00 00 00 00 00 00 04} (length 0xe) // } // count: len = 0xe (8 bytes) // pos: intptr = 0x2068 (8 bytes) // ] memcpy((void*)0x200000001060, "\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04", 14); syscall(__NR_pwrite64, /*fd=*/r[0], /*buf=*/0x200000001060ul, /*count=*/0xeul, /*pos=*/0x2068ul); // pwrite64 arguments: [ // fd: fd (resource) // buf: nil // count: len = 0x0 (8 bytes) // pos: intptr = 0x2098 (8 bytes) // ] syscall(__NR_pwrite64, /*fd=*/r[0], /*buf=*/0ul, /*count=*/0ul, /*pos=*/0x2098ul); // pwrite64 arguments: [ // fd: fd (resource) // buf: ptr[in, buffer] { // buffer: {54 19 01 00 54 19 01 00 54 19 01 00 54 19 01 00 54 19 01 00} // (length 0x14) // } // count: len = 0x14 (8 bytes) // pos: intptr = 0x2554 (8 bytes) // ] memcpy((void*)0x2000000010e0, "\x54\x19\x01\x00\x54\x19\x01\x00\x54\x19\x01\x00\x54\x19\x01\x00\x54" "\x19\x01\x00", 20); syscall(__NR_pwrite64, /*fd=*/r[0], /*buf=*/0x2000000010e0ul, /*count=*/0x14ul, /*pos=*/0x2554ul); // syz_open_dev$loop arguments: [ // dev: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 6c 6f 6f 70 23 00} (length 0xb) // } // id: intptr = 0x0 (8 bytes) // flags: open_flags = 0x2 (8 bytes) // ] // returns fd_loop memcpy((void*)0x200000002000, "/dev/loop#\000", 11); res = -1; res = syz_open_dev(/*dev=*/0x200000002000, /*id=*/0, /*flags=O_RDWR*/ 2); if (res != -1) r[1] = res; // ioctl$LOOP_SET_FD arguments: [ // fd: fd_loop (resource) // cmd: const = 0x4c00 (4 bytes) // arg: fd (resource) // ] syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0x4c00, /*arg=*/r[0]); // mkdirat arguments: [ // fd: fd_dir (resource) // path: ptr[in, buffer] { // buffer: {2e 2f 6d 6e 74 00} (length 0x6) // } // mode: open_mode = 0x1ff (8 bytes) // ] memcpy((void*)0x200000003000, "./mnt\000", 6); syscall( __NR_mkdirat, /*fd=*/0xffffff9c, /*path=*/0x200000003000ul, /*mode=S_IXOTH|S_IWOTH|S_IROTH|S_IXGRP|S_IWGRP|S_IRGRP|S_IXUSR|S_IWUSR|0x100*/ 0x1fful); // mount arguments: [ // src: ptr[in, blockdev_filename] { // union blockdev_filename { // loop: loop_filename { // prefix: buffer: {2f 64 65 76 2f 6c 6f 6f 70} (length 0x9) // id: proc = 0x0 (1 bytes) // z: const = 0x0 (1 bytes) // } // } // } // dst: ptr[in, buffer] { // buffer: {2e 2f 6d 6e 74 00} (length 0x6) // } // type: ptr[in, buffer] { // buffer: {75 66 73 00} (length 0x4) // } // flags: mount_flags = 0x0 (8 bytes) // data: nil // ] memcpy((void*)0x200000000040, "/dev/loop", 9); *(uint8_t*)0x200000000049 = 0x30; *(uint8_t*)0x20000000004a = 0; memcpy((void*)0x200000003000, "./mnt\000", 6); memcpy((void*)0x200000004000, "ufs\000", 4); syscall(__NR_mount, /*src=*/0x200000000040ul, /*dst=*/0x200000003000ul, /*type=*/0x200000004000ul, /*flags=*/0ul, /*data=*/0ul); return 0; }