| // lost connection to test machine (2) |
| // https://syzkaller.appspot.com/bug?id=e56e6e7d53c843019fd5c93c9550579105dac0c7 |
| // status:invalid |
| // autogenerated by syzkaller (http://github.com/google/syzkaller) |
| |
| #define _GNU_SOURCE |
| |
| #include <endian.h> |
| #include <sys/syscall.h> |
| #include <unistd.h> |
| |
| #include <stdint.h> |
| #include <string.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 void test(); |
| |
| void loop() |
| { |
| while (1) { |
| test(); |
| } |
| } |
| |
| #ifndef __NR_setsockopt |
| #define __NR_setsockopt 366 |
| #endif |
| #ifndef __NR_mmap |
| #define __NR_mmap 192 |
| #endif |
| #ifndef __NR_socket |
| #define __NR_socket 359 |
| #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, 0x3, 0x32, 0xffffffff, 0x0); |
| r[0] = syscall(__NR_socket, 0xa, 0x80001, 0x0); |
| memcpy((void*)0x20000000, "\xef\xad\x07\x00\x00\xa7", 6); |
| *(uint8_t*)0x20000006 = 0x0; |
| *(uint8_t*)0x20000007 = 0x0; |
| *(uint8_t*)0x20000008 = 0x0; |
| *(uint8_t*)0x20000009 = 0x0; |
| *(uint8_t*)0x2000000a = 0x0; |
| *(uint8_t*)0x2000000b = 0x0; |
| *(uint16_t*)0x2000000c = htobe16(0x0); |
| STORE_BY_BITMASK(uint8_t, 0x2000000e, 0x5, 0, 4); |
| STORE_BY_BITMASK(uint8_t, 0x2000000e, 0x4, 4, 4); |
| STORE_BY_BITMASK(uint8_t, 0x2000000f, 0x0, 0, 2); |
| STORE_BY_BITMASK(uint8_t, 0x2000000f, 0x0, 2, 6); |
| *(uint16_t*)0x20000010 = htobe16(0x48); |
| *(uint16_t*)0x20000012 = htobe16(0x64 + procid * 0x4ul); |
| *(uint16_t*)0x20000014 = htobe16(0x0); |
| *(uint8_t*)0x20000016 = 0x0; |
| *(uint8_t*)0x20000017 = 0x0; |
| *(uint16_t*)0x20000018 = 0x0; |
| *(uint32_t*)0x2000001a = htobe32(0xe0000002); |
| *(uint32_t*)0x2000001e = htobe32(0xffffffff); |
| *(uint16_t*)0x20000022 = htobe16(0x4e20 + procid * 0x4ul); |
| *(uint16_t*)0x20000024 = htobe16(0x4e20 + procid * 0x4ul); |
| *(uint8_t*)0x20000026 = 0x4; |
| STORE_BY_BITMASK(uint8_t, 0x20000027, 0x1, 0, 4); |
| STORE_BY_BITMASK(uint8_t, 0x20000027, 0x0, 4, 4); |
| *(uint16_t*)0x20000028 = 0x0; |
| STORE_BY_BITMASK(uint8_t, 0x2000002a, 0x0, 0, 1); |
| STORE_BY_BITMASK(uint8_t, 0x2000002a, 0x0, 1, 4); |
| STORE_BY_BITMASK(uint8_t, 0x2000002a, 0x0, 5, 3); |
| memcpy((void*)0x2000002b, "\xd1\xc0\x0c", 3); |
| *(uint8_t*)0x2000002e = 0x0; |
| memcpy((void*)0x2000002f, "\x88\xe3\xfc", 3); |
| memcpy((void*)0x20000032, "\xec\xf6\x3f\x14\x44\x19\x9d\xfa\x64\x99" |
| "\x14\xeb\x5a\xe3\xf3\x4d\xef\x70\xfd\xe5" |
| "\xd6\xfe\xa9\x29\xb7\x3f\x64\x45\x0b\x07" |
| "\x37\xb0\x0a\x09\x2c\x86", |
| 36); |
| struct csum_inet csum_1; |
| csum_inet_init(&csum_1); |
| csum_inet_update(&csum_1, (const uint8_t*)0x2000001a, 4); |
| csum_inet_update(&csum_1, (const uint8_t*)0x2000001e, 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*)0x20000022, 16); |
| *(uint16_t*)0x20000028 = csum_inet_digest(&csum_1); |
| struct csum_inet csum_2; |
| csum_inet_init(&csum_2); |
| csum_inet_update(&csum_2, (const uint8_t*)0x2000000e, 20); |
| *(uint16_t*)0x20000018 = csum_inet_digest(&csum_2); |
| syscall(__NR_setsockopt, r[0], 0x0, 0x40, 0x20000000, 0x0); |
| } |
| |
| int main() |
| { |
| int i; |
| for (i = 0; i < 8; i++) { |
| if (fork() == 0) { |
| procid = i; |
| loop(); |
| return 0; |
| } |
| } |
| sleep(1000000); |
| return 0; |
| } |