// https://syzkaller.appspot.com/bug?id=edf4cdf300eae7bc895016091520e5ca5fd2fb6a // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #define BITMASK(bf_off, bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type, htobe, addr, val, bf_off, bf_len) \ *(type*)(addr) = \ htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | \ (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) 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 { 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[1] = {0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); intptr_t res = 0; memcpy((void*)0x20001080, "/dev/snd/pcmC#D#p\000", 18); res = -1; res = syz_open_dev(0x20001080, 0, 0); if (res != -1) r[0] = res; *(uint32_t*)0x200010c0 = 0; *(uint32_t*)0x200010c4 = 7; *(uint32_t*)0x200010c8 = 0x8000; *(uint32_t*)0x200010cc = 0x10001; *(uint32_t*)0x200010d0 = 0; *(uint32_t*)0x200010d4 = 0; STORE_BY_BITMASK(uint32_t, , 0x200010d8, 0, 0, 1); STORE_BY_BITMASK(uint32_t, , 0x200010d8, 0, 1, 1); STORE_BY_BITMASK(uint32_t, , 0x200010d8, 0, 2, 1); STORE_BY_BITMASK(uint32_t, , 0x200010d8, 0, 3, 1); *(uint32_t*)0x200010dc = 0; *(uint32_t*)0x200010e0 = 0; STORE_BY_BITMASK(uint32_t, , 0x200010e4, 0, 0, 1); STORE_BY_BITMASK(uint32_t, , 0x200010e4, 0, 1, 1); STORE_BY_BITMASK(uint32_t, , 0x200010e4, 0, 2, 1); STORE_BY_BITMASK(uint32_t, , 0x200010e4, 0, 3, 1); *(uint32_t*)0x200010e8 = 0x40000000; *(uint32_t*)0x200010ec = 0x40000000; STORE_BY_BITMASK(uint32_t, , 0x200010f0, 0, 0, 1); STORE_BY_BITMASK(uint32_t, , 0x200010f0, 0, 1, 1); STORE_BY_BITMASK(uint32_t, , 0x200010f0, 0, 2, 1); STORE_BY_BITMASK(uint32_t, , 0x200010f0, 0, 3, 1); *(uint32_t*)0x200010f4 = 0; *(uint32_t*)0x200010f8 = 0; STORE_BY_BITMASK(uint32_t, , 0x200010fc, 0, 0, 1); STORE_BY_BITMASK(uint32_t, , 0x200010fc, 0, 1, 1); STORE_BY_BITMASK(uint32_t, , 0x200010fc, 0, 2, 1); STORE_BY_BITMASK(uint32_t, , 0x200010fc, 0, 3, 1); *(uint32_t*)0x20001100 = 0; *(uint32_t*)0x20001104 = 0; STORE_BY_BITMASK(uint32_t, , 0x20001108, 0, 0, 1); STORE_BY_BITMASK(uint32_t, , 0x20001108, 0, 1, 1); STORE_BY_BITMASK(uint32_t, , 0x20001108, 0, 2, 1); STORE_BY_BITMASK(uint32_t, , 0x20001108, 0, 3, 1); *(uint32_t*)0x2000110c = 0; *(uint32_t*)0x20001110 = 0; STORE_BY_BITMASK(uint32_t, , 0x20001114, 0, 0, 1); STORE_BY_BITMASK(uint32_t, , 0x20001114, 0, 1, 1); STORE_BY_BITMASK(uint32_t, , 0x20001114, 0, 2, 1); STORE_BY_BITMASK(uint32_t, , 0x20001114, 0, 3, 1); *(uint32_t*)0x20001118 = 0; *(uint32_t*)0x2000111c = 0; STORE_BY_BITMASK(uint32_t, , 0x20001120, 0, 0, 1); STORE_BY_BITMASK(uint32_t, , 0x20001120, 0, 1, 1); STORE_BY_BITMASK(uint32_t, , 0x20001120, 0, 2, 1); STORE_BY_BITMASK(uint32_t, , 0x20001120, 0, 3, 1); *(uint32_t*)0x20001124 = 0; *(uint32_t*)0x20001128 = 0; STORE_BY_BITMASK(uint32_t, , 0x2000112c, 0, 0, 1); STORE_BY_BITMASK(uint32_t, , 0x2000112c, 0, 1, 1); STORE_BY_BITMASK(uint32_t, , 0x2000112c, 0, 2, 1); STORE_BY_BITMASK(uint32_t, , 0x2000112c, 0, 3, 1); *(uint32_t*)0x20001130 = 0; *(uint32_t*)0x20001134 = 0; STORE_BY_BITMASK(uint32_t, , 0x20001138, 0, 0, 1); STORE_BY_BITMASK(uint32_t, , 0x20001138, 0, 1, 1); STORE_BY_BITMASK(uint32_t, , 0x20001138, 0, 2, 1); STORE_BY_BITMASK(uint32_t, , 0x20001138, 0, 3, 1); *(uint32_t*)0x2000113c = 0; *(uint32_t*)0x20001140 = 0; STORE_BY_BITMASK(uint32_t, , 0x20001144, 0, 0, 1); STORE_BY_BITMASK(uint32_t, , 0x20001144, 0, 1, 1); STORE_BY_BITMASK(uint32_t, , 0x20001144, 0, 2, 1); STORE_BY_BITMASK(uint32_t, , 0x20001144, 0, 3, 1); *(uint32_t*)0x20001148 = 0; *(uint32_t*)0x2000114c = 0; STORE_BY_BITMASK(uint32_t, , 0x20001150, 0, 0, 1); STORE_BY_BITMASK(uint32_t, , 0x20001150, 0, 1, 1); STORE_BY_BITMASK(uint32_t, , 0x20001150, 0, 2, 1); STORE_BY_BITMASK(uint32_t, , 0x20001150, 0, 3, 1); *(uint32_t*)0x20001154 = 0; *(uint32_t*)0x20001158 = 0; STORE_BY_BITMASK(uint32_t, , 0x2000115c, 0, 0, 1); STORE_BY_BITMASK(uint32_t, , 0x2000115c, 0, 1, 1); STORE_BY_BITMASK(uint32_t, , 0x2000115c, 0, 2, 1); STORE_BY_BITMASK(uint32_t, , 0x2000115c, 0, 3, 1); *(uint32_t*)0x20001160 = 0; *(uint32_t*)0x20001164 = 0; *(uint32_t*)0x20001168 = 0; *(uint32_t*)0x2000116c = 0; *(uint32_t*)0x20001170 = 0; *(uint32_t*)0x20001174 = 0; *(uint64_t*)0x20001178 = 0; memset((void*)0x20001180, 0, 64); syscall(__NR_ioctl, r[0], 0xc1004110, 0x200010c0ul); return 0; }