// https://syzkaller.appspot.com/bug?id=5695b7136fec23c0dd672138eeb7da71c836214d // 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[2] = {0xffffffffffffffff, 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$tty1 arguments: [ // dev: const = 0xc (8 bytes) // major: const = 0x4 (8 bytes) // minor: intptr = 0x1 (8 bytes) // ] // returns fd_tty res = -1; res = syz_open_dev(/*dev=*/0xc, /*major=*/4, /*minor=*/1); if (res != -1) r[0] = res; // ioctl$TIOCL_SETSEL arguments: [ // fd: fd_tty (resource) // cmd: const = 0x541c (4 bytes) // arg: ptr[in, tiocl_selection_arg] { // tiocl_selection_arg { // subcode: const = 0x2 (1 bytes) // data: tiocl_selection { // subcode: const = 0xc (1 bytes) // xs: int16 = 0xa00 (2 bytes) // ys: int16 = 0xc7e (2 bytes) // xe: int16 = 0x101 (2 bytes) // ye: int16 = 0x100 (2 bytes) // mode: tiocl_selection_mode = 0x0 (2 bytes) // } // } // } // ] *(uint8_t*)0x200000000000 = 2; *(uint8_t*)0x200000000001 = 0xc; *(uint16_t*)0x200000000002 = 0xa00; *(uint16_t*)0x200000000004 = 0xc7e; *(uint16_t*)0x200000000006 = 0x101; *(uint16_t*)0x200000000008 = 0x100; *(uint16_t*)0x20000000000a = 0; syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0x541c, /*arg=*/0x200000000000ul); // openat$fb1 arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 66 62 31 00} (length 0x9) // } // flags: open_flags = 0x800 (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd_fb memcpy((void*)0x200000000140, "/dev/fb1\000", 9); res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x200000000140ul, /*flags=O_NONBLOCK*/ 0x800, /*mode=*/0); if (res != -1) r[1] = res; // openat$ptp0 arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: nil // flags: open_flags = 0x80042 (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd_ptp syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0ul, /*flags=O_CREAT|O_CLOEXEC|O_RDWR*/ 0x80042, /*mode=*/0); // ioctl$FBIOPUT_CON2FBMAP arguments: [ // fd: fd_fb (resource) // cmd: const = 0x4610 (4 bytes) // arg: ptr[in, fb_con2fbmap] { // fb_con2fbmap { // console: int32 = 0x1 (4 bytes) // framebuffer: int32 = 0x0 (4 bytes) // } // } // ] *(uint32_t*)0x200000000180 = 1; *(uint32_t*)0x200000000184 = 0; syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0x4610, /*arg=*/0x200000000180ul); return 0; }