// https://syzkaller.appspot.com/bug?id=fd989e9f72500698b45b278430d94d2bf107aa30 // 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 = 0x2 (1 bytes) // xs: int16 = 0x0 (2 bytes) // ys: int16 = 0x6 (2 bytes) // xe: int16 = 0x1fc (2 bytes) // ye: int16 = 0x0 (2 bytes) // mode: tiocl_selection_mode = 0x0 (2 bytes) // } // } // } // ] *(uint8_t*)0x200000000100 = 2; *(uint8_t*)0x200000000101 = 2; *(uint16_t*)0x200000000102 = 0; *(uint16_t*)0x200000000104 = 6; *(uint16_t*)0x200000000106 = 0x1fc; *(uint16_t*)0x200000000108 = 0; *(uint16_t*)0x20000000010a = 0; syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0x541c, /*arg=*/0x200000000100ul); // 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[1] = res; // ioctl$VT_DISALLOCATE arguments: [ // fd: fd_tty (resource) // cmd: const = 0x5608 (4 bytes) // ] syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0x5608, 0); return 0; }