| // WARNING: suspicious RCU usage in trace_call_bpf |
| // https://syzkaller.appspot.com/bug?id=b4ec822cd97ffa2800cd27429997e0c8ea82331d |
| // status:fixed |
| // autogenerated by syzkaller (https://github.com/google/syzkaller) |
| |
| #define _GNU_SOURCE |
| |
| #include <endian.h> |
| #include <stdint.h> |
| #include <stdio.h> |
| #include <stdlib.h> |
| #include <string.h> |
| #include <sys/syscall.h> |
| #include <sys/types.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; \ |
| } |
| |
| #ifndef __NR_bpf |
| #define __NR_bpf 321 |
| #endif |
| |
| uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; |
| |
| int main(void) |
| { |
| syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); |
| long res = 0; |
| *(uint32_t*)0x20000040 = 2; |
| *(uint32_t*)0x20000044 = 0x70; |
| *(uint8_t*)0x20000048 = 0x15; |
| *(uint8_t*)0x20000049 = 1; |
| *(uint8_t*)0x2000004a = 0; |
| *(uint8_t*)0x2000004b = 0; |
| *(uint32_t*)0x2000004c = 0; |
| *(uint64_t*)0x20000050 = 0; |
| *(uint64_t*)0x20000058 = 0x4040; |
| *(uint64_t*)0x20000060 = 0; |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 0, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 1, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 2, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 3, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 4, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 5, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 6, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 7, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 8, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 9, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 10, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 11, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 12, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 13, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 14, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 15, 2); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 17, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 18, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0x80, 19, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 20, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 21, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 22, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 23, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 24, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 25, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 26, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 27, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 28, 1); |
| STORE_BY_BITMASK(uint64_t, 0x20000068, 0, 29, 35); |
| *(uint32_t*)0x20000070 = 0; |
| *(uint32_t*)0x20000074 = 0; |
| *(uint64_t*)0x20000078 = 0; |
| *(uint64_t*)0x20000080 = 0; |
| *(uint64_t*)0x20000088 = 0; |
| *(uint64_t*)0x20000090 = 0; |
| *(uint32_t*)0x20000098 = 0; |
| *(uint32_t*)0x2000009c = 0; |
| *(uint64_t*)0x200000a0 = 0; |
| *(uint32_t*)0x200000a8 = 0; |
| *(uint16_t*)0x200000ac = 0; |
| *(uint16_t*)0x200000ae = 0; |
| res = syscall(__NR_perf_event_open, 0x20000040, 0, 0, -1, 0); |
| if (res != -1) |
| r[0] = res; |
| *(uint32_t*)0x20000000 = 5; |
| *(uint32_t*)0x20000004 = 3; |
| *(uint64_t*)0x20000008 = 0x20346fc8; |
| memcpy((void*)0x20346fc8, "\x18\x00\x00\x00\xff\xea\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x99\x01\x95\x00\x00\x00\x00\x00\x00\x00", |
| 24); |
| *(uint64_t*)0x20000010 = 0x200001c0; |
| memcpy((void*)0x200001c0, "GPL", 4); |
| *(uint32_t*)0x20000018 = 0xfefffffc; |
| *(uint32_t*)0x2000001c = 0xfb; |
| *(uint64_t*)0x20000020 = 0x20000080; |
| *(uint32_t*)0x20000028 = 0; |
| *(uint32_t*)0x2000002c = 0; |
| *(uint8_t*)0x20000030 = 0; |
| *(uint8_t*)0x20000031 = 0; |
| *(uint8_t*)0x20000032 = 0; |
| *(uint8_t*)0x20000033 = 0; |
| *(uint8_t*)0x20000034 = 0; |
| *(uint8_t*)0x20000035 = 0; |
| *(uint8_t*)0x20000036 = 0; |
| *(uint8_t*)0x20000037 = 0; |
| *(uint8_t*)0x20000038 = 0; |
| *(uint8_t*)0x20000039 = 0; |
| *(uint8_t*)0x2000003a = 0; |
| *(uint8_t*)0x2000003b = 0; |
| *(uint8_t*)0x2000003c = 0; |
| *(uint8_t*)0x2000003d = 0; |
| *(uint8_t*)0x2000003e = 0; |
| *(uint8_t*)0x2000003f = 0; |
| *(uint32_t*)0x20000040 = 0; |
| *(uint32_t*)0x20000044 = 0; |
| res = syscall(__NR_bpf, 5, 0x20000000, 0x48); |
| if (res != -1) |
| r[1] = res; |
| syscall(__NR_ioctl, r[0], 0x40042408, r[1]); |
| memcpy((void*)0x20000140, "/dev/net/tun", 13); |
| res = syscall(__NR_openat, 0xffffffffffffff9c, 0x20000140, 0, 0); |
| if (res != -1) |
| r[2] = res; |
| memcpy((void*)0x20000040, |
| "\x6e\x72\x30\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", |
| 16); |
| *(uint16_t*)0x20000050 = 0x801; |
| syscall(__NR_ioctl, r[2], 0x400454ca, 0x20000040); |
| return 0; |
| } |