// https://syzkaller.appspot.com/bug?id=790cf4b424c696d37e981ba9fa60ec62ee96a35b // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #ifndef __NR_clone #define __NR_clone 220 #endif #ifndef __NR_exit #define __NR_exit 93 #endif #ifndef __NR_madvise #define __NR_madvise 233 #endif #ifndef __NR_mmap #define __NR_mmap 222 #endif #ifndef __NR_mprotect #define __NR_mprotect 226 #endif #ifndef __NR_openat #define __NR_openat 56 #endif #define USLEEP_FORKED_CHILD (3 * 50 * 1000) static long handle_clone_ret(long ret) { if (ret != 0) { return ret; } usleep(USLEEP_FORKED_CHILD); syscall(__NR_exit, 0); while (1) { } } static long syz_clone(volatile long flags, volatile long stack, volatile long stack_len, volatile long ptid, volatile long ctid, volatile long tls) { long sp = (stack + stack_len) & ~15; long ret = (long)syscall(__NR_clone, flags & ~CLONE_VM, sp, ptid, ctid, tls); return handle_clone_ret(ret); } uint64_t r[1] = {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)) { } // 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); // openat$cgroup_ro arguments: [ // fd: fd_cgroup (resource) // file: ptr[in, buffer] { // buffer: {6d 65 6d 6f 72 79 2e 65 76 65 6e 74 73 00} (length 0xe) // } // flags: const = 0x275a (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd memcpy((void*)0x200001c0, "memory.events\000", 14); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200001c0ul, /*flags=*/0x275a, /*mode=*/0); if (res != -1) r[0] = res; // mmap arguments: [ // addr: VMA[0x3000] // len: len = 0x3000 (8 bytes) // prot: mmap_prot = 0x2000001 (8 bytes) // flags: mmap_flags = 0x12 (8 bytes) // fd: fd (resource) // offset: intptr = 0x704c2000 (8 bytes) // ] syscall(__NR_mmap, /*addr=*/0x200a0000ul, /*len=*/0x3000ul, /*prot=PROT_GROWSUP|PROT_READ*/ 0x2000001ul, /*flags=MAP_FIXED|MAP_PRIVATE*/ 0x12ul, /*fd=*/r[0], /*offset=*/0x704c2000ul); // syz_clone arguments: [ // flags: clone_flags = 0x42000000 (8 bytes) // stack: nil // stack_len: bytesize = 0x0 (8 bytes) // parentid: nil // childtid: nil // tls: nil // ] // returns pid syz_clone(/*flags=CLONE_NEWNET|CLONE_NEWCGROUP*/ 0x42000000, /*stack=*/0, /*stack_len=*/0, /*parentid=*/0, /*childtid=*/0, /*tls=*/0); // mprotect arguments: [ // addr: VMA[0x800000] // len: len = 0x800000 (8 bytes) // prot: mmap_prot = 0x6 (8 bytes) // ] syscall(__NR_mprotect, /*addr=*/0x20000000ul, /*len=*/0x800000ul, /*prot=PROT_WRITE|PROT_EXEC*/ 6ul); return 0; }