| // KMSAN: uninit-value in do_error_trap |
| // https://syzkaller.appspot.com/bug?id=5201ef9acc2312de450ad1a469760d7c5a802c9d |
| // status:invalid |
| // autogenerated by syzkaller (http://github.com/google/syzkaller) |
| |
| #define _GNU_SOURCE |
| #include <endian.h> |
| #include <stdint.h> |
| #include <string.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; |
| } |
| |
| uint64_t r[1] = {0xffffffffffffffff}; |
| void loop() |
| { |
| long res = 0; |
| *(uint8_t*)0x20000240 = -1; |
| *(uint8_t*)0x20000241 = -1; |
| *(uint8_t*)0x20000242 = -1; |
| *(uint8_t*)0x20000243 = -1; |
| *(uint8_t*)0x20000244 = -1; |
| *(uint8_t*)0x20000245 = -1; |
| *(uint8_t*)0x20000246 = 1; |
| *(uint8_t*)0x20000247 = 0x80; |
| *(uint8_t*)0x20000248 = 0xc2; |
| *(uint8_t*)0x20000249 = 0; |
| *(uint8_t*)0x2000024a = 0; |
| *(uint8_t*)0x2000024b = 0; |
| *(uint16_t*)0x2000024c = htobe16(0x800); |
| STORE_BY_BITMASK(uint8_t, 0x2000024e, 5, 0, 4); |
| STORE_BY_BITMASK(uint8_t, 0x2000024e, 4, 4, 4); |
| STORE_BY_BITMASK(uint8_t, 0x2000024f, 0, 0, 2); |
| STORE_BY_BITMASK(uint8_t, 0x2000024f, 0, 2, 6); |
| *(uint16_t*)0x20000250 = htobe16(0x1c); |
| *(uint16_t*)0x20000252 = htobe16(0); |
| *(uint16_t*)0x20000254 = htobe16(0); |
| *(uint8_t*)0x20000256 = 0; |
| *(uint8_t*)0x20000257 = 0; |
| *(uint16_t*)0x20000258 = 0; |
| *(uint8_t*)0x2000025a = 0xac; |
| *(uint8_t*)0x2000025b = 0x14; |
| *(uint8_t*)0x2000025c = 0x14; |
| *(uint8_t*)0x2000025d = 0xaa; |
| *(uint32_t*)0x2000025e = htobe32(-1); |
| *(uint8_t*)0x20000262 = 0; |
| *(uint8_t*)0x20000263 = 0; |
| *(uint16_t*)0x20000264 = 0; |
| *(uint32_t*)0x20000266 = htobe32(0xe0000002); |
| *(uint32_t*)0x20000080 = 0; |
| *(uint32_t*)0x20000084 = 0; |
| *(uint32_t*)0x20000088 = 0x7dd; |
| *(uint32_t*)0x2000008c = 0; |
| *(uint32_t*)0x20000090 = 0; |
| *(uint32_t*)0x20000094 = 0; |
| struct csum_inet csum_1; |
| csum_inet_init(&csum_1); |
| csum_inet_update(&csum_1, (const uint8_t*)0x20000262, 8); |
| *(uint16_t*)0x20000264 = csum_inet_digest(&csum_1); |
| struct csum_inet csum_2; |
| csum_inet_init(&csum_2); |
| csum_inet_update(&csum_2, (const uint8_t*)0x2000024e, 20); |
| *(uint16_t*)0x20000258 = csum_inet_digest(&csum_2); |
| res = syscall(__NR_socket, 2, 3, 0x3e); |
| if (res != -1) |
| r[0] = res; |
| *(uint16_t*)0x20ee9ff0 = 2; |
| *(uint16_t*)0x20ee9ff2 = htobe16(0); |
| *(uint32_t*)0x20ee9ff4 = htobe32(0); |
| *(uint8_t*)0x20ee9ff8 = 0; |
| *(uint8_t*)0x20ee9ff9 = 0; |
| *(uint8_t*)0x20ee9ffa = 0; |
| *(uint8_t*)0x20ee9ffb = 0; |
| *(uint8_t*)0x20ee9ffc = 0; |
| *(uint8_t*)0x20ee9ffd = 0; |
| *(uint8_t*)0x20ee9ffe = 0; |
| *(uint8_t*)0x20ee9fff = 0; |
| syscall(__NR_sendto, r[0], 0x20ef4000, 0, 0, 0x20ee9ff0, 0x10); |
| memcpy((void*)0x20000200, "/proc/self/net/pfkey", 21); |
| syscall(__NR_openat, 0xffffffffffffff9c, 0x20000200, 0x44c00, 0); |
| *(uint64_t*)0x200001c0 = 0; |
| *(uint64_t*)0x200001c8 = 0x989680; |
| syscall(__NR_recvmmsg, r[0], 0x20000140, 0x50, 2, 0x200001c0); |
| } |
| |
| int main() |
| { |
| syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); |
| loop(); |
| return 0; |
| } |