// https://syzkaller.appspot.com/bug?id=6dcd14a729df98f989c7b76d254226ae67084efd // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #define BITMASK_LEN(type, bf_len) (type)((1ull << (bf_len)) - 1) #define BITMASK_LEN_OFF(type, bf_off, bf_len) \ (type)(BITMASK_LEN(type, (bf_len)) << (bf_off)) #define STORE_BY_BITMASK(type, addr, val, bf_off, bf_len) \ if ((bf_off) == 0 && (bf_len) == 0) { \ *(type*)(addr) = (type)(val); \ } else { \ type new_val = *(type*)(addr); \ new_val &= ~BITMASK_LEN_OFF(type, (bf_off), (bf_len)); \ new_val |= ((type)(val)&BITMASK_LEN(type, (bf_len))) << (bf_off); \ *(type*)(addr) = new_val; \ } struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i; for (i = 0; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += (uint16_t)data[length - 1]; while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static uintptr_t syz_open_dev(uintptr_t a0, uintptr_t a1, uintptr_t 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)); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(a1 % 10); a1 /= 10; } return open(buf, a2, 0); } } static void test(); void loop() { while (1) { test(); } } #ifndef __NR_mmap #define __NR_mmap 192 #endif #ifndef __NR_write #define __NR_write 4 #endif #ifndef __NR_readv #define __NR_readv 145 #endif #undef __NR_mmap #define __NR_mmap __NR_mmap2 long r[1]; uint64_t procid; void test() { memset(r, -1, sizeof(r)); syscall(__NR_mmap, 0x20000000, 0xfff000, 3, 0x32, -1, 0); memcpy((void*)0x208c8000, "/dev/sg#", 9); r[0] = syz_open_dev(0x208c8000, 0, 0x8002); *(uint8_t*)0x20ace000 = 2; *(uint8_t*)0x20ace001 = 0x83; *(uint16_t*)0x20ace002 = 0xfcc; *(uint16_t*)0x20ace004 = 1; *(uint16_t*)0x20ace006 = 4; *(uint16_t*)0x20ace008 = -1; STORE_BY_BITMASK(uint8_t, 0x20ace00a, 0x1e, 0, 4); STORE_BY_BITMASK(uint8_t, 0x20ace00a, 4, 4, 4); STORE_BY_BITMASK(uint8_t, 0x20ace00b, 1, 0, 2); STORE_BY_BITMASK(uint8_t, 0x20ace00b, 7, 2, 6); *(uint16_t*)0x20ace00c = htobe16(0x88); *(uint16_t*)0x20ace00e = htobe16(0x67 + procid * 4); *(uint16_t*)0x20ace010 = htobe16(0); *(uint8_t*)0x20ace012 = 0x86; *(uint8_t*)0x20ace013 = 0x6e; *(uint16_t*)0x20ace014 = 0; *(uint8_t*)0x20ace016 = 0xac; *(uint8_t*)0x20ace017 = 0x14; *(uint8_t*)0x20ace018 = 0 + procid * 1; *(uint8_t*)0x20ace019 = 0xbb; *(uint32_t*)0x20ace01a = htobe32(0); *(uint8_t*)0x20ace01e = 0x89; *(uint8_t*)0x20ace01f = 0x2b; *(uint8_t*)0x20ace020 = 0x1f; *(uint32_t*)0x20ace021 = htobe32(0xe0000001); *(uint32_t*)0x20ace025 = htobe32(0xe0000002); *(uint32_t*)0x20ace029 = htobe32(5); *(uint32_t*)0x20ace02d = htobe32(0xe0000002); *(uint8_t*)0x20ace031 = 0xac; *(uint8_t*)0x20ace032 = 0x14; *(uint8_t*)0x20ace033 = 0 + procid * 1; *(uint8_t*)0x20ace034 = 0xbb; *(uint32_t*)0x20ace035 = htobe32(0); *(uint32_t*)0x20ace039 = htobe32(0x7f000001); *(uint32_t*)0x20ace03d = htobe32(0x7ff); *(uint32_t*)0x20ace041 = htobe32(0); *(uint32_t*)0x20ace045 = htobe32(0xe0000002); *(uint8_t*)0x20ace049 = 0x86; *(uint8_t*)0x20ace04a = 0x10; *(uint32_t*)0x20ace04b = htobe32(0x1f); *(uint8_t*)0x20ace04f = 0; *(uint8_t*)0x20ace050 = 2; *(uint8_t*)0x20ace051 = 5; *(uint8_t*)0x20ace052 = 2; *(uint8_t*)0x20ace053 = 0; *(uint8_t*)0x20ace054 = 2; *(uint8_t*)0x20ace055 = 0; *(uint8_t*)0x20ace056 = 2; *(uint8_t*)0x20ace057 = 7; *(uint8_t*)0x20ace058 = 2; *(uint8_t*)0x20ace059 = 7; *(uint8_t*)0x20ace05a = 0x27; *(uint8_t*)0x20ace05b = 5; *(uint8_t*)0x20ace05c = 0xac; *(uint8_t*)0x20ace05d = 0x14; *(uint8_t*)0x20ace05e = 0 + procid * 1; *(uint8_t*)0x20ace05f = 0xbb; *(uint32_t*)0x20ace060 = htobe32(0x7f000001); *(uint32_t*)0x20ace064 = htobe32(0); *(uint8_t*)0x20ace068 = 0xac; *(uint8_t*)0x20ace069 = 0x14; *(uint8_t*)0x20ace06a = 0 + procid * 1; *(uint8_t*)0x20ace06b = 0xbb; *(uint32_t*)0x20ace06c = htobe32(0x7f000001); *(uint32_t*)0x20ace070 = htobe32(-1); *(uint32_t*)0x20ace074 = htobe32(0x7f000001); *(uint32_t*)0x20ace078 = htobe32(9); *(uint32_t*)0x20ace07c = htobe32(0x3f); *(uint16_t*)0x20ace082 = htobe16(0x4e23 + procid * 4); *(uint16_t*)0x20ace084 = htobe16(0x4e21 + procid * 4); *(uint8_t*)0x20ace086 = 4; STORE_BY_BITMASK(uint8_t, 0x20ace087, 1, 0, 4); STORE_BY_BITMASK(uint8_t, 0x20ace087, 0x52, 4, 4); *(uint16_t*)0x20ace088 = 0; STORE_BY_BITMASK(uint8_t, 0x20ace08a, 0, 0, 1); STORE_BY_BITMASK(uint8_t, 0x20ace08a, 0, 1, 4); STORE_BY_BITMASK(uint8_t, 0x20ace08a, 0xce, 5, 3); memcpy((void*)0x20ace08b, "\x77\xfd\x93", 3); *(uint8_t*)0x20ace08e = 6; memcpy((void*)0x20ace08f, "\x41\x9e\x5f", 3); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x20ace016, 4); csum_inet_update(&csum_1, (const uint8_t*)0x20ace01a, 4); uint16_t csum_1_chunk_2 = 0x2100; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 2); uint16_t csum_1_chunk_3 = 0x1000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 2); csum_inet_update(&csum_1, (const uint8_t*)0x20ace082, 16); *(uint16_t*)0x20ace088 = csum_inet_digest(&csum_1); struct csum_inet csum_2; csum_inet_init(&csum_2); csum_inet_update(&csum_2, (const uint8_t*)0x20ace00a, 120); *(uint16_t*)0x20ace014 = csum_inet_digest(&csum_2); syscall(__NR_write, r[0], 0x20ace000, 0x92); *(uint32_t*)0x204f2000 = 0x207bc000; *(uint32_t*)0x204f2004 = 0; *(uint32_t*)0x204f2008 = 0x20180000; *(uint32_t*)0x204f200c = 0; *(uint32_t*)0x204f2010 = 0x20035f1b; *(uint32_t*)0x204f2014 = 0; *(uint32_t*)0x204f2018 = 0x20523f39; *(uint32_t*)0x204f201c = 0; *(uint32_t*)0x204f2020 = 0x203daf4b; *(uint32_t*)0x204f2024 = 0; *(uint32_t*)0x204f2028 = 0x20fa5000; *(uint32_t*)0x204f202c = 0; *(uint32_t*)0x204f2030 = 0x20729000; *(uint32_t*)0x204f2034 = 0; *(uint32_t*)0x204f2038 = 0x2041fff8; *(uint32_t*)0x204f203c = 0; *(uint32_t*)0x204f2040 = 0x20982000; *(uint32_t*)0x204f2044 = 0; *(uint32_t*)0x204f2048 = 0x20142000; *(uint32_t*)0x204f204c = 1; syscall(__NR_readv, r[0], 0x204f2000, 0xa); } int main() { for (procid = 0; procid < 8; procid++) { if (fork() == 0) { for (;;) { loop(); } } } sleep(1000000); return 0; }