// https://syzkaller.appspot.com/bug?id=e9fce3026cf377e2a7add56e9444cd379ae0a265 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #ifndef __NR_ioctl #define __NR_ioctl 29 #endif #ifndef __NR_mmap #define __NR_mmap 222 #endif 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 & ~O_CREAT, 0); } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000, /*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=*/0x21000000ul, /*len=*/0x1000, /*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$video4linux arguments: [ // dev: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 76 34 6c 2d 73 75 62 64 65 76 23 00} (length // 0x11) // } // id: intptr = 0x0 (8 bytes) // flags: open_flags = 0x2 (8 bytes) // ] // returns fd_video memcpy((void*)0x20000000, "/dev/v4l-subdev#\000", 17); res = -1; res = syz_open_dev(/*dev=*/0x20000000, /*id=*/0, /*flags=O_RDWR*/ 2); if (res != -1) r[0] = res; // ioctl$VIDIOC_SUBDEV_S_FMT arguments: [ // fd: fd_video (resource) // cmd: const = 0xc0585605 (4 bytes) // arg: ptr[inout, v4l2_subdev_format] { // v4l2_subdev_format { // which: v4l2_subdev_format_whence = 0x1 (4 bytes) // pad: const = 0x0 (4 bytes) // format: v4l2_mbus_framefmt { // width: int32 = 0x280 (4 bytes) // height: int32 = 0x1e0 (4 bytes) // code: media_bus_fmt = 0x3014 (4 bytes) // field: v4l2_field = 0x0 (4 bytes) // colorspace: v4l2_colorspace = 0x0 (4 bytes) // ycbcr_enc: v4l2_ycbcr_encoding = 0x0 (2 bytes) // quantization: v4l2_quantization = 0x0 (2 bytes) // xfer_func: v4l2_xfer_func = 0x0 (2 bytes) // reserved: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00} (length 0x16) // } // reserved: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x20) // } // } // ] *(uint32_t*)0x20000100 = 1; *(uint32_t*)0x20000104 = 0; *(uint32_t*)0x20000108 = 0x280; *(uint32_t*)0x2000010c = 0x1e0; *(uint32_t*)0x20000110 = 0x3014; *(uint32_t*)0x20000114 = 0; *(uint32_t*)0x20000118 = 0; *(uint16_t*)0x2000011c = 0; *(uint16_t*)0x2000011e = 0; *(uint16_t*)0x20000120 = 0; memset((void*)0x20000122, 0, 22); memset((void*)0x20000138, 0, 32); syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0xc0585605, /*arg=*/0x20000100ul); // syz_open_dev$video arguments: [ // dev: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 76 69 64 65 6f 23 00} (length 0xc) // } // id: intptr = 0x4 (8 bytes) // flags: open_flags = 0x2 (8 bytes) // ] // returns fd_video memcpy((void*)0x20000200, "/dev/video#\000", 12); res = -1; res = syz_open_dev(/*dev=*/0x20000200, /*id=*/4, /*flags=O_RDWR*/ 2); if (res != -1) r[1] = res; // ioctl$VIDIOC_S_FMT arguments: [ // fd: fd_video (resource) // cmd: const = 0xc0d05605 (4 bytes) // arg: ptr[inout, v4l2_format[v4l2_buf_type]] { // v4l2_format[v4l2_buf_type] { // type: v4l2_buf_type = 0x1 (4 bytes) // pad = 0x0 (4 bytes) // fmt: union v4l2_format_fmt { // pix: v4l2_pix_format { // width: int32 = 0x280 (4 bytes) // height: int32 = 0x1e0 (4 bytes) // pixelformat: v4l2_pix_format_pixelformat = 0x42474752 (4 bytes) // field: v4l2_field = 0x0 (4 bytes) // bytesperline: int32 = 0x0 (4 bytes) // sizeimage: int32 = 0x0 (4 bytes) // colorspace: v4l2_colorspace = 0x0 (4 bytes) // priv: int32 = 0x0 (4 bytes) // flags: v4l2_pix_format_flags = 0x0 (4 bytes) // ycbcr_enc: v4l2_ycbcr_encoding = 0x0 (4 bytes) // quantization: v4l2_quantization = 0x0 (4 bytes) // xfer_func: v4l2_xfer_func = 0x0 (4 bytes) // } // } // } // } // ] *(uint32_t*)0x20000300 = 1; *(uint32_t*)0x20000308 = 0x280; *(uint32_t*)0x2000030c = 0x1e0; *(uint32_t*)0x20000310 = 0x42474752; *(uint32_t*)0x20000314 = 0; *(uint32_t*)0x20000318 = 0; *(uint32_t*)0x2000031c = 0; *(uint32_t*)0x20000320 = 0; *(uint32_t*)0x20000324 = 0; *(uint32_t*)0x20000328 = 0; *(uint32_t*)0x2000032c = 0; *(uint32_t*)0x20000330 = 0; *(uint32_t*)0x20000334 = 0; syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0xc0d05605, /*arg=*/0x20000300ul); // ioctl$VIDIOC_REQBUFS arguments: [ // fd: fd_video (resource) // cmd: const = 0xc0145608 (4 bytes) // arg: ptr[inout, v4l2_requestbuffers[v4l2_buf_type]] { // v4l2_requestbuffers[v4l2_buf_type] { // count: int32 = 0x2 (4 bytes) // type: v4l2_buf_type = 0x1 (4 bytes) // memory: v4l2_memory = 0x1 (4 bytes) // capabilities: const = 0x0 (4 bytes) // flags: int8 = 0x0 (1 bytes) // reserved: buffer: {00 00 00} (length 0x3) // } // } // ] *(uint32_t*)0x20000400 = 2; *(uint32_t*)0x20000404 = 1; *(uint32_t*)0x20000408 = 1; *(uint32_t*)0x2000040c = 0; *(uint8_t*)0x20000410 = 0; memset((void*)0x20000411, 0, 3); syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0xc0145608, /*arg=*/0x20000400ul); // ioctl$VIDIOC_STREAMON arguments: [ // fd: fd_video (resource) // cmd: const = 0x40045612 (4 bytes) // arg: ptr[in, int32] { // int32 = 0x1 (4 bytes) // } // ] *(uint32_t*)0x20000500 = 1; syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0x40045612, /*arg=*/0x20000500ul); // syz_open_dev$video arguments: [ // dev: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 76 69 64 65 6f 23 00} (length 0xc) // } // id: intptr = 0x6 (8 bytes) // flags: open_flags = 0x51 (8 bytes) // ] // returns fd_video memcpy((void*)0x20000200, "/dev/video#\000", 12); res = -1; res = syz_open_dev(/*dev=*/0x20000200, /*id=*/6, /*flags=O_CREAT|O_WRONLY|0x10*/ 0x51); if (res != -1) r[2] = res; // ioctl$VIDIOC_REQBUFS arguments: [ // fd: fd_video (resource) // cmd: const = 0xc0145608 (4 bytes) // arg: ptr[inout, v4l2_requestbuffers[v4l2_buf_type]] { // v4l2_requestbuffers[v4l2_buf_type] { // count: int32 = 0x1 (4 bytes) // type: v4l2_buf_type = 0x1 (4 bytes) // memory: v4l2_memory = 0x1 (4 bytes) // capabilities: const = 0x0 (4 bytes) // flags: int8 = 0x0 (1 bytes) // reserved: buffer: {00 00 00} (length 0x3) // } // } // ] *(uint32_t*)0x20007100 = 1; *(uint32_t*)0x20007104 = 1; *(uint32_t*)0x20007108 = 1; *(uint32_t*)0x2000710c = 0; *(uint8_t*)0x20007110 = 0; memset((void*)0x20007111, 0, 3); syscall(__NR_ioctl, /*fd=*/r[2], /*cmd=*/0xc0145608, /*arg=*/0x20007100ul); // ioctl$VIDIOC_STREAMON arguments: [ // fd: fd_video (resource) // cmd: const = 0x40045612 (4 bytes) // arg: ptr[in, int32] { // int32 = 0x1 (4 bytes) // } // ] *(uint32_t*)0x20007200 = 1; syscall(__NR_ioctl, /*fd=*/r[2], /*cmd=*/0x40045612, /*arg=*/0x20007200ul); return 0; }