| // BUG: pagefault on kernel address ADDR in non-whitelisted uaccess |
| // https://syzkaller.appspot.com/bug?id=093e7092e01bed192b564b04528826cc6f1dbf91 |
| // status:fixed |
| // autogenerated by syzkaller (https://github.com/google/syzkaller) |
| |
| #define _GNU_SOURCE |
| |
| #include <endian.h> |
| #include <fcntl.h> |
| #include <stdint.h> |
| #include <stdio.h> |
| #include <stdlib.h> |
| #include <string.h> |
| #include <sys/stat.h> |
| #include <sys/syscall.h> |
| #include <sys/types.h> |
| #include <unistd.h> |
| |
| static long syz_open_dev(long a0, long a1, 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 { |
| char buf[1024]; |
| char* hash; |
| strncpy(buf, (char*)a0, sizeof(buf) - 1); |
| buf[sizeof(buf) - 1] = 0; |
| while ((hash = strchr(buf, '#'))) { |
| *hash = '0' + (char)(a1 % 10); |
| a1 /= 10; |
| } |
| return open(buf, a2, 0); |
| } |
| } |
| |
| uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff}; |
| |
| int main(void) |
| { |
| syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); |
| long res = 0; |
| memcpy((void*)0x20000040, "/dev/video#", 12); |
| res = syz_open_dev(0x20000040, 0x6287, 0); |
| if (res != -1) |
| r[0] = res; |
| *(uint32_t*)0x20000100 = 3; |
| *(uint32_t*)0x20000108 = 0; |
| *(uint32_t*)0x2000010c = 0; |
| *(uint32_t*)0x20000110 = 0; |
| *(uint32_t*)0x20000114 = 0; |
| *(uint32_t*)0x20000118 = 0; |
| *(uint32_t*)0x2000011c = 0; |
| *(uint64_t*)0x20000120 = 0x20000200; |
| *(uint32_t*)0x20000200 = 0xca; |
| *(uint32_t*)0x20000204 = 0; |
| *(uint32_t*)0x20000208 = 0; |
| *(uint32_t*)0x2000020c = 0; |
| *(uint64_t*)0x20000210 = 0; |
| *(uint32_t*)0x20000128 = 2; |
| *(uint64_t*)0x20000130 = 0x20000240; |
| *(uint8_t*)0x20000138 = 0; |
| syscall(__NR_ioctl, r[0], 0xc0d05605, 0x20000100); |
| memcpy((void*)0x20000040, "/dev/video#", 12); |
| res = syz_open_dev(0x20000040, 0x107fff, 0); |
| if (res != -1) |
| r[1] = res; |
| *(uint32_t*)0x20000240 = 2; |
| syscall(__NR_ioctl, r[1], 0xc0045627, 0x20000240); |
| *(uint32_t*)0x200000c0 = 3; |
| *(uint32_t*)0x200000c8 = 0; |
| *(uint32_t*)0x200000cc = 0; |
| *(uint32_t*)0x200000d0 = 0; |
| *(uint32_t*)0x200000d4 = 0; |
| *(uint32_t*)0x200000d8 = 0; |
| *(uint32_t*)0x200000dc = 0; |
| *(uint64_t*)0x200000e0 = 0x20000080; |
| *(uint32_t*)0x20000080 = 0; |
| *(uint32_t*)0x20000084 = 0; |
| *(uint32_t*)0x20000088 = 0; |
| *(uint32_t*)0x2000008c = 0; |
| *(uint64_t*)0x20000090 = 0x20000000; |
| *(uint32_t*)0x20000000 = 0; |
| *(uint32_t*)0x20000004 = 0; |
| *(uint32_t*)0x20000008 = 0; |
| *(uint32_t*)0x2000000c = 0; |
| *(uint64_t*)0x20000010 = 0; |
| *(uint32_t*)0x200000e8 = 0; |
| *(uint64_t*)0x200000f0 = 0x200000c0; |
| *(uint8_t*)0x200000f8 = 0; |
| syscall(__NR_ioctl, r[1], 0xc0d05604, 0x200000c0); |
| return 0; |
| } |