// autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include 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, 0); } } #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=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*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=*/0x200001000000ul, /*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)) { } // syz_open_dev$usbfs arguments: [ // dev: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 62 75 73 2f 75 73 62 2f 30 30 23 2f 30 30 23 // 00} (length 0x15) // } // id: intptr = 0x204 (8 bytes) // flags: open_flags = 0x2 (8 bytes) // ] // returns fd_usbfs memcpy((void*)0x2000000000c0, "/dev/bus/usb/00#/00#\000", 21); res = -1; res = syz_open_dev(/*dev=*/0x2000000000c0, /*id=*/0x204, /*flags=O_RDWR*/ 2); if (res != -1) r[0] = res; // mmap arguments: [ // addr: VMA[0x400000] // len: len = 0x400000 (8 bytes) // prot: mmap_prot = 0x1000002 (8 bytes) // flags: mmap_flags = 0x11012 (8 bytes) // fd: fd (resource) // offset: intptr = 0x108000 (8 bytes) // ] syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x400000ul, /*prot=PROT_GROWSDOWN|PROT_WRITE*/ 0x1000002ul, /*flags=MAP_NONBLOCK|MAP_FIXED|MAP_EXECUTABLE|0x2*/ 0x11012ul, /*fd=*/r[0], /*offset=*/0x108000ul); // syz_clone arguments: [ // flags: clone_flags = 0x2001100 (8 bytes) // stack: nil // stack_len: bytesize = 0x0 (8 bytes) // parentid: nil // childtid: nil // tls: nil // ] // returns pid syz_clone(/*flags=CLONE_PIDFD|CLONE_NEWCGROUP|CLONE_VM*/ 0x2001100, /*stack=*/0, /*stack_len=*/0, /*parentid=*/0, /*childtid=*/0, /*tls=*/0); return 0; }