// https://syzkaller.appspot.com/bug?id=5a34035b13d7f4215357b46093ca6d5c45c93f93 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #ifndef __NR_ioctl #define __NR_ioctl 29 #endif #ifndef __NR_mmap #define __NR_mmap 222 #endif #ifndef __NR_openat #define __NR_openat 56 #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[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*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=*/0x21000000ul, /*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)) { } // openat arguments: [ // fd: fd_dir (resource) // file: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 31 00} (length 0x8) // } // flags: open_flags = 0x48840 (4 bytes) // mode: open_mode = 0x0 (2 bytes) // ] // returns fd memcpy((void*)0x20000000, "./file1\000", 8); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x20000000ul, /*flags=O_NONBLOCK|O_NOFOLLOW|O_NOATIME|O_CREAT*/ 0x48840, /*mode=*/0); if (res != -1) r[0] = res; // 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 = 0xffffffff7ffffffd (8 bytes) // flags: open_flags = 0x1ea1e2 (8 bytes) // ] // returns fd_loop memcpy((void*)0x20000240, "/dev/loop#\000", 11); res = -1; res = syz_open_dev( /*dev=*/0x20000240, /*id=*/0xffffffff7ffffffd, /*flags=O_NOFOLLOW|O_NOCTTY|O_NOATIME|O_LARGEFILE|O_EXCL|0x182062*/ 0x1ea1e2); if (res != -1) r[1] = res; // openat$sysfs arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // dir: ptr[in, buffer] { // buffer: {2f 73 79 73 2f 6b 65 72 6e 65 6c 2f 6e 6f 74 65 73} (length // 0x11) // } // flags: open_flags = 0x103a00 (4 bytes) // mode: open_mode = 0x150 (2 bytes) // ] // returns fd memcpy((void*)0x20000040, "/sys/kernel/notes", 17); res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*dir=*/0x20000040ul, /*flags=O_TRUNC|O_SYNC|O_NONBLOCK|FASYNC*/ 0x103a00, /*mode=S_IWGRP|S_IXUSR|S_IRUSR*/ 0x150); if (res != -1) r[2] = res; // ioctl$LOOP_CONFIGURE arguments: [ // fd: fd_loop (resource) // cmd: const = 0x4c0a (4 bytes) // arg: ptr[in, loop_config] { // loop_config { // fd: fd_loop (resource) // block_size: int32 = 0x0 (4 bytes) // info: loop_info64 { // lo_device: const = 0x0 (8 bytes) // lo_inode: const = 0x0 (8 bytes) // lo_rdevice: const = 0x0 (8 bytes) // lo_offset: int64 = 0x4 (8 bytes) // lo_sizelimit: int64 = 0x20000003 (8 bytes) // lo_number: const = 0x0 (4 bytes) // lo_enc_type: lo_encrypt_type = 0x0 (4 bytes) // lo_enc_key_size: int32 = 0xb (4 bytes) // lo_flags: lo_flags = 0xc (4 bytes) // lo_file_name: buffer: {fa f9 83 57 e5 a1 14 99 89 fc 8d be c3 bd // 02 b8 2a 12 8b ba d0 09 9c eb dc 25 f5 ab b5 34 46 4c 51 6b dd 8a // 0f 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00} (length 0x40) lo_crypt_name: buffer: {32 d8 cc // 26 f7 06 1a 74 df 2c fc 06 c8 9f 3d 9e 23 4b 30 c5 09 97 d3 be f4 // 09 ff 21 76 ff 7b 55 cd 0a 5d 81 cd 4a 52 4b d3 ff e7 0c 7f 2a 04 // 00 2f 7b 6a a5 4c c5 0a 1f ca ed 1e 15 08 37 48 00} (length 0x40) // lo_enc_key: buffer: {71 52 37 64 1a 8c cf 16 2e 43 ac 61 f7 00 00 // 00 00 00 9b 41 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x20) // lo_init: array[int64] { // int64 = 0x9 (8 bytes) // int64 = 0xa (8 bytes) // } // } // reserved: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00} (length 0x40) // } // } // ] *(uint32_t*)0x20001140 = r[0]; *(uint32_t*)0x20001144 = 0; *(uint64_t*)0x20001148 = 0; *(uint64_t*)0x20001150 = 0; *(uint64_t*)0x20001158 = 0; *(uint64_t*)0x20001160 = 4; *(uint64_t*)0x20001168 = 0x20000003; *(uint32_t*)0x20001170 = 0; *(uint32_t*)0x20001174 = 0; *(uint32_t*)0x20001178 = 0xb; *(uint32_t*)0x2000117c = 0xc; memcpy((void*)0x20001180, "\xfa\xf9\x83\x57\xe5\xa1\x14\x99\x89\xfc\x8d\xbe\xc3\xbd\x02\xb8\x2a" "\x12\x8b\xba\xd0\x09\x9c\xeb\xdc\x25\xf5\xab\xb5\x34\x46\x4c\x51\x6b" "\xdd\x8a\x0f\x35\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 64); memcpy((void*)0x200011c0, "\x32\xd8\xcc\x26\xf7\x06\x1a\x74\xdf\x2c\xfc\x06\xc8\x9f\x3d\x9e\x23" "\x4b\x30\xc5\x09\x97\xd3\xbe\xf4\x09\xff\x21\x76\xff\x7b\x55\xcd\x0a" "\x5d\x81\xcd\x4a\x52\x4b\xd3\xff\xe7\x0c\x7f\x2a\x04\x00\x2f\x7b\x6a" "\xa5\x4c\xc5\x0a\x1f\xca\xed\x1e\x15\x08\x37\x48\x00", 64); memcpy((void*)0x20001200, "\x71\x52\x37\x64\x1a\x8c\xcf\x16\x2e\x43\xac\x61\xf7\x00\x00\x00\x00" "\x00\x9b\x41\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 32); *(uint64_t*)0x20001220 = 9; *(uint64_t*)0x20001228 = 0xa; memset((void*)0x20001230, 0, 64); syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0x4c0a, /*arg=*/0x20001140ul); // ioctl$LOOP_CHANGE_FD arguments: [ // fd: fd_loop (resource) // cmd: const = 0x4c06 (4 bytes) // arg: fd (resource) // ] syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0x4c06, /*arg=*/r[2]); return 0; }