// https://syzkaller.appspot.com/bug?id=39c14fc7603902f1515310fd025caaf33d444c92 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include static long syz_open_procfs(volatile long a0, volatile long a1) { char buf[128]; memset(buf, 0, sizeof(buf)); if (a0 == 0) { snprintf(buf, sizeof(buf), "/proc/self/%s", (char*)a1); } else if (a0 == -1) { snprintf(buf, sizeof(buf), "/proc/thread-self/%s", (char*)a1); } else { snprintf(buf, sizeof(buf), "/proc/self/task/%d/%s", (int)a0, (char*)a1); } int fd = open(buf, O_RDWR); if (fd == -1) fd = open(buf, O_RDONLY); return fd; } #ifndef __NR_mmap #define __NR_mmap 192 #endif #ifndef __NR_pipe #define __NR_pipe 42 #endif #ifndef __NR_read #define __NR_read 3 #endif #ifndef __NR_sendfile #define __NR_sendfile 187 #endif #undef __NR_mmap #define __NR_mmap __NR_mmap2 uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, 0x1ffff000, 0x1000, 0, 0x32, -1, 0); syscall(__NR_mmap, 0x20000000, 0x1000000, 7, 0x32, -1, 0); syscall(__NR_mmap, 0x21000000, 0x1000, 0, 0x32, -1, 0); intptr_t res = 0; res = syscall(__NR_pipe, 0x20000040); if (res != -1) { r[0] = *(uint32_t*)0x20000040; r[1] = *(uint32_t*)0x20000044; } memcpy((void*)0x20dec000, "smaps\000", 6); res = -1; res = syz_open_procfs(0, 0x20dec000); if (res != -1) r[2] = res; syscall(__NR_sendfile, (intptr_t)r[1], (intptr_t)r[2], 0, 0x320f); syscall(__NR_read, (intptr_t)r[0], 0x20000080, 0xbe); return 0; }