| // BUG: unable to handle kernel paging request in ata_bmdma_qc_prep |
| // https://syzkaller.appspot.com/bug?id=3c5f3a8f9011e7dbba102bb0ad7738de16df73be |
| // status:fixed |
| // autogenerated by syzkaller (http://github.com/google/syzkaller) |
| |
| #define _GNU_SOURCE |
| |
| #include <fcntl.h> |
| #include <stdint.h> |
| #include <stdio.h> |
| #include <string.h> |
| #include <sys/stat.h> |
| #include <sys/syscall.h> |
| #include <unistd.h> |
| |
| #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); |
| } |
| } |
| |
| long r[38]; |
| void loop() |
| { |
| memset(r, -1, sizeof(r)); |
| r[0] = syscall(__NR_mmap, 0x20000000ul, 0xfff000ul, 0x3ul, 0x32ul, |
| 0xfffffffffffffffful, 0x0ul); |
| memcpy((void*)0x20790ff7, "\x2f\x64\x65\x76\x2f\x73\x67\x23\x00", 9); |
| r[2] = syz_open_dev(0x20790ff7ul, 0x1ul, 0x1a3001ul); |
| memcpy((void*)0x20883000, "\x12", 1); |
| r[4] = syscall(__NR_ioctl, r[2], 0x4000000002283ul, 0x20883000ul); |
| *(uint8_t*)0x20515000 = (uint8_t)0x0; |
| *(uint8_t*)0x20515001 = (uint8_t)0x0; |
| *(uint16_t*)0x20515002 = (uint16_t)0x0; |
| *(uint16_t*)0x20515004 = (uint16_t)0x0; |
| *(uint16_t*)0x20515006 = (uint16_t)0x0; |
| *(uint16_t*)0x20515008 = (uint16_t)0x0; |
| STORE_BY_BITMASK(uint8_t, 0x2051500a, 0x6, 0, 4); |
| STORE_BY_BITMASK(uint8_t, 0x2051500a, 0x4, 4, 4); |
| STORE_BY_BITMASK(uint8_t, 0x2051500b, 0x0, 0, 2); |
| STORE_BY_BITMASK(uint8_t, 0x2051500b, 0x0, 2, 6); |
| *(uint16_t*)0x2051500c = (uint16_t)0xbd00; |
| *(uint16_t*)0x2051500e = (uint16_t)0x6400; |
| *(uint16_t*)0x20515010 = (uint16_t)0x0; |
| *(uint8_t*)0x20515012 = (uint8_t)0x0; |
| *(uint8_t*)0x20515013 = (uint8_t)0x0; |
| *(uint16_t*)0x20515014 = (uint16_t)0x0; |
| *(uint32_t*)0x20515016 = (uint32_t)0x0; |
| *(uint8_t*)0x2051501a = (uint8_t)0xac; |
| *(uint8_t*)0x2051501b = (uint8_t)0x14; |
| *(uint8_t*)0x2051501c = (uint8_t)0x0; |
| *(uint8_t*)0x2051501d = (uint8_t)0xbb; |
| *(uint8_t*)0x2051501e = (uint8_t)0x0; |
| *(uint8_t*)0x20515022 = (uint8_t)0x37; |
| *(uint8_t*)0x20515023 = (uint8_t)0x0; |
| *(uint16_t*)0x20515024 = (uint16_t)0x0; |
| *(uint8_t*)0x20515026 = (uint8_t)0xac; |
| *(uint8_t*)0x20515027 = (uint8_t)0x14; |
| *(uint8_t*)0x20515028 = (uint8_t)0x0; |
| *(uint8_t*)0x20515029 = (uint8_t)0xaa; |
| memcpy((void*)0x2051502a, |
| "\xa8\x79\xc6\xc0\xee\x09\xf6\x3f\x13\xab\x22\xc1\x85\x59\x78" |
| "\xd4\x3f\xcf\xce\x0c\x8a\xd4\x15\x9e\x23\x34\x66\xc4\x7c\x4a" |
| "\x0c\xbf\x54\xc1\x4e\x8a\x75\x01\x18\x84\x9a\x32\x38\xda\x92" |
| "\x43\xa6\x83\x76\x72\xc7\x31\xaf\xad\x86\x8e\x01\x83\xcc\xef" |
| "\x88\x9e\x70\x54\xc8\xe4\x83\x7f\x25\xa2\xa9\x8d\xea\x7d\xc6" |
| "\x5f\x38\x50\xb1\x15\x31\xa1\x94\xf0\xae\xd2\x91\x44\xfa\xf3" |
| "\x23\x0a\x4f\xe2\x76\x95\x26\x10\x67\x70\x19\x24\x2c\x1d\x3e" |
| "\x2f\x45\x45\xb6\xef\x6e\x02\x39\x79\x49\x7e\x82\x96\x62\x71" |
| "\x61\x72\xd4\xde\x51\xcb\x95\x5a\x5f\x7e\x72\x1a\xe4\x4f\x68" |
| "\xa6\xaa\x26\xdb\x4b\x62\xba\x93\x3a\x03\xaf\xe6\xff\x88\x5c" |
| "\x96\xce\x4d\x08\x47\x86\x4f", |
| 157); |
| struct csum_inet csum_35; |
| csum_inet_init(&csum_35); |
| csum_inet_update(&csum_35, (const uint8_t*)0x20515022, 165); |
| *(uint16_t*)0x20515024 = csum_inet_digest(&csum_35); |
| struct csum_inet csum_36; |
| csum_inet_init(&csum_36); |
| csum_inet_update(&csum_36, (const uint8_t*)0x2051500a, 24); |
| *(uint16_t*)0x20515014 = csum_inet_digest(&csum_36); |
| r[37] = syscall(__NR_write, r[2], 0x20515000ul, 0xc7ul); |
| } |
| |
| int main() |
| { |
| loop(); |
| return 0; |
| } |