| // BUG: unable to handle kernel NULL pointer dereference in radix_tree_lookup_slot |
| // https://syzkaller.appspot.com/bug?id=03da9219e708545ae027f3c90976384fac65af4a |
| // status:invalid |
| // autogenerated by syzkaller (http://github.com/google/syzkaller) |
| |
| #define _GNU_SOURCE |
| #include <endian.h> |
| #include <errno.h> |
| #include <signal.h> |
| #include <stdarg.h> |
| #include <stdio.h> |
| #include <sys/prctl.h> |
| #include <sys/syscall.h> |
| #include <sys/time.h> |
| #include <sys/wait.h> |
| #include <time.h> |
| #include <unistd.h> |
| |
| __attribute__((noreturn)) static void doexit(int status) |
| { |
| volatile unsigned i; |
| syscall(__NR_exit_group, status); |
| for (i = 0;; i++) { |
| } |
| } |
| #include <errno.h> |
| #include <stdarg.h> |
| #include <stdint.h> |
| #include <stdio.h> |
| #include <string.h> |
| |
| const int kFailStatus = 67; |
| const int kRetryStatus = 69; |
| |
| static void fail(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((e == ENOMEM || e == EAGAIN) ? kRetryStatus : kFailStatus); |
| } |
| |
| static uint64_t current_time_ms() |
| { |
| struct timespec ts; |
| |
| if (clock_gettime(CLOCK_MONOTONIC, &ts)) |
| fail("clock_gettime failed"); |
| return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; |
| } |
| |
| static void execute_one(); |
| extern unsigned long long procid; |
| |
| static void loop() |
| { |
| int iter; |
| for (iter = 0;; iter++) { |
| int pid = fork(); |
| if (pid < 0) |
| fail("clone failed"); |
| if (pid == 0) { |
| prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); |
| setpgrp(); |
| execute_one(); |
| int fd; |
| for (fd = 3; fd < 30; fd++) |
| close(fd); |
| doexit(0); |
| } |
| |
| int status = 0; |
| uint64_t start = current_time_ms(); |
| for (;;) { |
| int res = waitpid(-1, &status, __WALL | WNOHANG); |
| if (res == pid) { |
| break; |
| } |
| usleep(1000); |
| if (current_time_ms() - start < 5 * 1000) |
| continue; |
| kill(-pid, SIGKILL); |
| kill(pid, SIGKILL); |
| while (waitpid(-1, &status, __WALL) != pid) { |
| } |
| break; |
| } |
| } |
| } |
| |
| #ifndef __NR_bpf |
| #define __NR_bpf 321 |
| #endif |
| #ifndef __NR_seccomp |
| #define __NR_seccomp 317 |
| #endif |
| |
| void execute_one() |
| { |
| *(uint32_t*)0x204f9fe4 = 5; |
| *(uint32_t*)0x204f9fe8 = 0xa; |
| *(uint32_t*)0x204f9fec = 6; |
| *(uint32_t*)0x204f9ff0 = 0x1ff; |
| *(uint32_t*)0x204f9ff4 = 0; |
| *(uint32_t*)0x204f9ff8 = -1; |
| *(uint32_t*)0x204f9ffc = 0; |
| *(uint8_t*)0x204fa000 = 0; |
| *(uint8_t*)0x204fa001 = 0; |
| *(uint8_t*)0x204fa002 = 0; |
| *(uint8_t*)0x204fa003 = 0; |
| *(uint8_t*)0x204fa004 = 0; |
| *(uint8_t*)0x204fa005 = 0; |
| *(uint8_t*)0x204fa006 = 0; |
| *(uint8_t*)0x204fa007 = 0; |
| *(uint8_t*)0x204fa008 = 0; |
| *(uint8_t*)0x204fa009 = 0; |
| *(uint8_t*)0x204fa00a = 0; |
| *(uint8_t*)0x204fa00b = 0; |
| *(uint8_t*)0x204fa00c = 0; |
| *(uint8_t*)0x204fa00d = 0; |
| *(uint8_t*)0x204fa00e = 0; |
| *(uint8_t*)0x204fa00f = 0; |
| syscall(__NR_bpf, 0, 0x204f9fe4, 0x2c); |
| *(uint16_t*)0x20000080 = 2; |
| *(uint64_t*)0x20000088 = 0x20000040; |
| *(uint16_t*)0x20000040 = 0x401; |
| *(uint8_t*)0x20000042 = 1; |
| *(uint8_t*)0x20000043 = 8; |
| *(uint32_t*)0x20000044 = 0xbbe6; |
| *(uint16_t*)0x20000048 = 0x200; |
| *(uint8_t*)0x2000004a = 6; |
| *(uint8_t*)0x2000004b = 1; |
| *(uint32_t*)0x2000004c = 3; |
| syscall(__NR_seccomp, 0, 1, 0x20000080); |
| } |
| |
| int main() |
| { |
| syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); |
| for (;;) { |
| loop(); |
| } |
| } |