// https://syzkaller.appspot.com/bug?id=01383b29d139cf9c9f9d9bd6e9947474ffe657a6 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #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] = {0x0}; int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=*/7ul, /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul); intptr_t res = 0; syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0xa000ul, /*prot=*/2ul, /*flags=*/0x2172ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mremap, /*addr=*/0x20005000ul, /*len=*/0x4000ul, /*newlen=*/0x1000ul, /*flags=*/0ul, /*newaddr=*/0x20003000ul); res = -1; res = syz_clone(/*flags=*/0, /*stack=*/0, /*stack_len=*/0, /*parentid=*/0, /*childtid=*/0, /*tls=*/0); if (res != -1) r[0] = res; *(uint64_t*)0x20000340 = 0x20000240; *(uint64_t*)0x20000348 = 0xcd; *(uint64_t*)0x20000540 = 0x20000380; *(uint64_t*)0x20000548 = 0x7ffff000; syscall(__NR_process_vm_writev, /*pid=*/r[0], /*loc_vec=*/0x20000340ul, /*loc_vlen=*/1ul, /*rem_vec=*/0x20000540ul, /*rem_vlen=*/0x2d7ul, /*flags=*/0ul); return 0; }