// https://syzkaller.appspot.com/bug?id=f97c662bbe81be3a0b21c5211230e35450c5dc02 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #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); } } 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$dri arguments: [ // dev: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 64 72 69 2f 63 61 72 64 23 00} (length 0xf) // } // id: intptr = 0x0 (8 bytes) // flags: open_flags = 0x0 (8 bytes) // ] // returns fd_dri memcpy((void*)0x200000000000, "/dev/dri/card#\000", 15); res = -1; res = syz_open_dev(/*dev=*/0x200000000000, /*id=*/0, /*flags=*/0); if (res != -1) r[0] = res; // ioctl$DRM_IOCTL_MODE_CREATE_DUMB arguments: [ // fd: fd_dri (resource) // cmd: const = 0xc02064b2 (4 bytes) // arg: ptr[inout, drm_mode_create_dumb] { // drm_mode_create_dumb { // height: int32 = 0x7 (4 bytes) // width: int32 = 0x6576 (4 bytes) // bpp: int32 = 0xd (4 bytes) // flags: const = 0x0 (4 bytes) // handle: drm_dumb_handle (resource) // pitch: int32 = 0x0 (4 bytes) // size: int64 = 0x0 (8 bytes) // } // } // ] *(uint32_t*)0x200000000040 = 7; *(uint32_t*)0x200000000044 = 0x6576; *(uint32_t*)0x200000000048 = 0xd; *(uint32_t*)0x20000000004c = 0; syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0xc02064b2, /*arg=*/0x200000000040ul); // mmap arguments: [ // addr: VMA[0x4000] // len: len = 0x4000 (8 bytes) // prot: mmap_prot = 0x4 (8 bytes) // flags: mmap_flags = 0x11 (8 bytes) // fd: fd (resource) // offset: intptr = 0x100000000 (8 bytes) // ] syscall(__NR_mmap, /*addr=*/0x200000001000ul, /*len=*/0x4000ul, /*prot=PROT_EXEC*/ 4ul, /*flags=MAP_FIXED|MAP_SHARED*/ 0x11ul, /*fd=*/r[0], /*offset=*/0x100000000ul); return 0; }