| // general protection fault in free_verifier_state |
| // https://syzkaller.appspot.com/bug?id=c6990555752f043feeef0e6ad97a86e5e4608e9b |
| // status:fixed |
| // autogenerated by syzkaller (http://github.com/google/syzkaller) |
| |
| #define _GNU_SOURCE |
| |
| #include <errno.h> |
| #include <fcntl.h> |
| #include <stdarg.h> |
| #include <stdbool.h> |
| #include <stdio.h> |
| #include <sys/stat.h> |
| #include <sys/syscall.h> |
| #include <unistd.h> |
| |
| __attribute__((noreturn)) static void doexit(int status) |
| { |
| volatile unsigned i; |
| syscall(__NR_exit_group, status); |
| for (i = 0;; i++) { |
| } |
| } |
| |
| #include <stdint.h> |
| #include <string.h> |
| |
| const int kFailStatus = 67; |
| const int kRetryStatus = 69; |
| |
| static void exitf(const char* msg, ...) |
| { |
| int e = errno; |
| va_list args; |
| va_start(args, msg); |
| vfprintf(stderr, msg, args); |
| va_end(args); |
| fprintf(stderr, " (errno %d)\n", e); |
| doexit(kRetryStatus); |
| } |
| |
| 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) { |
| close(fd); |
| 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) |
| exitf("failed to open /proc/thread-self/fail-nth"); |
| sprintf(buf, "%d", nth + 1); |
| if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) |
| exitf("failed to write /proc/thread-self/fail-nth"); |
| return fd; |
| } |
| |
| static void test(); |
| |
| void loop() |
| { |
| while (1) { |
| test(); |
| } |
| } |
| |
| #ifndef __NR_bpf |
| #define __NR_bpf 321 |
| #endif |
| |
| void test() |
| { |
| syscall(__NR_mmap, 0x20000000ul, 0xfff000ul, 0x3ul, 0x32ul, |
| 0xfffffffffffffffful, 0x0ul); |
| *(uint32_t*)0x20b4cfd0 = (uint32_t)0x1; |
| *(uint32_t*)0x20b4cfd4 = (uint32_t)0x3; |
| *(uint64_t*)0x20b4cfd8 = (uint64_t)0x205ed000; |
| *(uint64_t*)0x20b4cfe0 = (uint64_t)0x20982ff9; |
| *(uint32_t*)0x20b4cfe8 = (uint32_t)0x1; |
| *(uint32_t*)0x20b4cfec = (uint32_t)0x80; |
| *(uint64_t*)0x20b4cff0 = (uint64_t)0x20e4f000; |
| *(uint32_t*)0x20b4cff8 = (uint32_t)0x0; |
| *(uint32_t*)0x20b4cffc = (uint32_t)0x0; |
| *(uint8_t*)0x205ed000 = (uint8_t)0xdb7; |
| *(uint8_t*)0x205ed001 = (uint8_t)0x0; |
| *(uint16_t*)0x205ed002 = (uint16_t)0x0; |
| *(uint32_t*)0x205ed004 = (uint32_t)0x0; |
| *(uint8_t*)0x205ed008 = (uint8_t)0xffffffffffffffbd; |
| *(uint8_t*)0x205ed009 = (uint8_t)0x1; |
| *(uint16_t*)0x205ed00a = (uint16_t)0x0; |
| *(uint32_t*)0x205ed00c = (uint32_t)0x0; |
| *(uint8_t*)0x205ed010 = (uint8_t)0xd395; |
| *(uint8_t*)0x205ed011 = (uint8_t)0x0; |
| *(uint16_t*)0x205ed012 = (uint16_t)0x0; |
| *(uint32_t*)0x205ed014 = (uint32_t)0x0; |
| memcpy((void*)0x20982ff9, "", 1); |
| write_file("/sys/kernel/debug/failslab/ignore-gfp-wait", "N"); |
| write_file("/sys/kernel/debug/fail_futex/ignore-private", "N"); |
| inject_fault(19); |
| syscall(__NR_bpf, 0x5ul, 0x20b4cfd0ul, 0x30ul); |
| } |
| |
| int main() |
| { |
| loop(); |
| return 0; |
| } |