// https://syzkaller.appspot.com/bug?id=f291840edb89cf5710bde3b8abd6021687077d6c // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #ifndef __NR_dup #define __NR_dup 23 #endif #ifndef __NR_ioctl #define __NR_ioctl 29 #endif #ifndef __NR_madvise #define __NR_madvise 233 #endif #ifndef __NR_mmap #define __NR_mmap 222 #endif #ifndef __NR_openat #define __NR_openat 56 #endif uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*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=*/0x21000000ul, /*len=*/0x1000ul, /*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$nullb arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 6e 75 6c 6c 62 30 00} (length 0xc) // } // flags: open_flags = 0x169802 (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd_block memcpy((void*)0x20001000, "/dev/nullb0\000", 12); res = syscall( __NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x20001000ul, /*flags=O_SYNC|O_NONBLOCK|O_NOFOLLOW|O_NOATIME|O_LARGEFILE|O_RDWR*/ 0x169802, /*mode=*/0); if (res != -1) r[0] = res; // ioctl$BLKBSZSET arguments: [ // fd: fd_block (resource) // cmd: const = 0x40081271 (4 bytes) // arg: ptr[in, intptr] { // intptr = 0x10000 (8 bytes) // } // ] *(uint64_t*)0x20000100 = 0x10000; syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0x40081271, /*arg=*/0x20000100ul); // openat$nullb arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 6e 75 6c 6c 62 30 00} (length 0xc) // } // flags: open_flags = 0x282 (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd_block memcpy((void*)0x20000000, "/dev/nullb0\000", 12); res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x20000000ul, /*flags=O_TRUNC|O_EXCL|O_RDWR*/ 0x282, /*mode=*/0); if (res != -1) r[1] = res; // dup arguments: [ // oldfd: fd (resource) // ] // returns fd res = syscall(__NR_dup, /*oldfd=*/r[1]); if (res != -1) r[2] = res; // mmap arguments: [ // addr: VMA[0xb36000] // len: len = 0xb36000 (8 bytes) // prot: mmap_prot = 0x2000007 (8 bytes) // flags: mmap_flags = 0x38011 (8 bytes) // fd: fd (resource) // offset: intptr = 0x0 (8 bytes) // ] syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0xb36000ul, /*prot=PROT_GROWSUP|PROT_WRITE|PROT_READ|PROT_EXEC*/ 0x2000007ul, /*flags=MAP_STACK|MAP_POPULATE|MAP_NONBLOCK|MAP_FIXED|0x1*/ 0x38011ul, /*fd=*/r[2], /*offset=*/0ul); // madvise arguments: [ // addr: VMA[0x800000] // len: len = 0x800000 (8 bytes) // advice: madvise_flags = 0xe (8 bytes) // ] syscall(__NR_madvise, /*addr=*/0x20000000ul, /*len=*/0x800000ul, /*advice=MADV_HUGEPAGE*/ 0xeul); // madvise arguments: [ // addr: VMA[0xc00000] // len: len = 0xc00000 (8 bytes) // advice: madvise_flags = 0x64 (8 bytes) // ] syscall(__NR_madvise, /*addr=*/0x20000000ul, /*len=*/0xc00000ul, /*advice=MADV_HWPOISON*/ 0x64ul); return 0; }