// https://syzkaller.appspot.com/bug?id=923fea4b7a5ce4e75e1a6dfbfcd4409fb720242e // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #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; \ } static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } static int inject_fault(int nth) { int fd; char buf[16]; fd = open("/proc/thread-self/fail-nth", O_RDWR); if (fd == -1) exit(1); sprintf(buf, "%d", nth + 1); if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) exit(1); return fd; } #ifndef __NR_bpf #define __NR_bpf 321 #endif int main(void) { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); *(uint32_t*)0x20346fd4 = 0; *(uint32_t*)0x20346fd8 = 0; *(uint32_t*)0x20346fdc = 0; *(uint32_t*)0x20346fe0 = 0xdc; *(uint32_t*)0x20346fe4 = 0x40; *(uint32_t*)0x20346fe8 = -1; *(uint32_t*)0x20346fec = 0; *(uint8_t*)0x20346ff0 = 0; *(uint8_t*)0x20346ff1 = 0; *(uint8_t*)0x20346ff2 = 0; *(uint8_t*)0x20346ff3 = 0; *(uint8_t*)0x20346ff4 = 0; *(uint8_t*)0x20346ff5 = 0; *(uint8_t*)0x20346ff6 = 0; *(uint8_t*)0x20346ff7 = 0; *(uint8_t*)0x20346ff8 = 0; *(uint8_t*)0x20346ff9 = 0; *(uint8_t*)0x20346ffa = 0; *(uint8_t*)0x20346ffb = 0; *(uint8_t*)0x20346ffc = 0; *(uint8_t*)0x20346ffd = 0; *(uint8_t*)0x20346ffe = 0; *(uint8_t*)0x20346fff = 0; syscall(__NR_bpf, 0, 0x20346fd4, 0x2c); *(uint32_t*)0x20b7a000 = 1; *(uint32_t*)0x20b7a004 = 5; *(uint64_t*)0x20b7a008 = 0x20346fc8; *(uint8_t*)0x20346fc8 = 0x18; STORE_BY_BITMASK(uint8_t, 0x20346fc9, 0, 0, 4); STORE_BY_BITMASK(uint8_t, 0x20346fc9, 0, 4, 4); *(uint16_t*)0x20346fca = 0; *(uint32_t*)0x20346fcc = 0; *(uint8_t*)0x20346fd0 = 0; *(uint8_t*)0x20346fd1 = 0; *(uint16_t*)0x20346fd2 = 0; *(uint32_t*)0x20346fd4 = 0; STORE_BY_BITMASK(uint8_t, 0x20346fd8, 0x19, 0, 3); STORE_BY_BITMASK(uint8_t, 0x20346fd8, 0, 3, 1); STORE_BY_BITMASK(uint8_t, 0x20346fd8, 7, 4, 4); STORE_BY_BITMASK(uint8_t, 0x20346fd9, 0, 0, 4); STORE_BY_BITMASK(uint8_t, 0x20346fd9, 1, 4, 4); *(uint16_t*)0x20346fda = 0; *(uint32_t*)0x20346fdc = 0; *(uint8_t*)0x20346fe8 = 0x95; *(uint8_t*)0x20346fe9 = 0; *(uint16_t*)0x20346fea = 0; *(uint32_t*)0x20346fec = 0; *(uint64_t*)0x20b7a010 = 0x20f6bffb; memcpy((void*)0x20f6bffb, "GPL", 4); *(uint32_t*)0x20b7a018 = 0; *(uint32_t*)0x20b7a01c = 0x299; *(uint64_t*)0x20b7a020 = 0x201a7f05; *(uint32_t*)0x20b7a028 = 0; *(uint32_t*)0x20b7a02c = 0; *(uint8_t*)0x20b7a030 = 0; *(uint8_t*)0x20b7a031 = 0; *(uint8_t*)0x20b7a032 = 0; *(uint8_t*)0x20b7a033 = 0; *(uint8_t*)0x20b7a034 = 0x97; *(uint8_t*)0x20b7a035 = 0; *(uint8_t*)0x20b7a036 = 0; *(uint8_t*)0x20b7a037 = 0; *(uint8_t*)0x20b7a038 = 0; *(uint8_t*)0x20b7a039 = 0; *(uint8_t*)0x20b7a03a = 0; *(uint8_t*)0x20b7a03b = 0; *(uint8_t*)0x20b7a03c = 0; *(uint8_t*)0x20b7a03d = 0; *(uint8_t*)0x20b7a03e = 0; *(uint8_t*)0x20b7a03f = 0; *(uint32_t*)0x20b7a040 = 0; *(uint32_t*)0x20b7a044 = 0; write_file("/sys/kernel/debug/failslab/ignore-gfp-wait", "N"); write_file("/sys/kernel/debug/fail_futex/ignore-private", "N"); inject_fault(0); syscall(__NR_bpf, 5, 0x20b7a000, 0x18); return 0; }