| // possible deadlock in blkdev_reread_part |
| // https://syzkaller.appspot.com/bug?id=4006bcda50967d109d7512134751ca8fb84d393f |
| // status:open |
| // autogenerated by syzkaller (http://github.com/google/syzkaller) |
| |
| #define _GNU_SOURCE |
| #include <endian.h> |
| #include <fcntl.h> |
| #include <stdint.h> |
| #include <stdio.h> |
| #include <string.h> |
| #include <string.h> |
| #include <sys/stat.h> |
| #include <sys/syscall.h> |
| #include <unistd.h> |
| |
| static uintptr_t syz_open_dev(uintptr_t a0, uintptr_t a1, uintptr_t a2) |
| { |
| if (a0 == 0xc || a0 == 0xb) { |
| char buf[128]; |
| sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1, |
| (uint8_t)a2); |
| return open(buf, O_RDWR, 0); |
| } else { |
| char buf[1024]; |
| char* hash; |
| strncpy(buf, (char*)a0, sizeof(buf)); |
| buf[sizeof(buf) - 1] = 0; |
| while ((hash = strchr(buf, '#'))) { |
| *hash = '0' + (char)(a1 % 10); |
| a1 /= 10; |
| } |
| return open(buf, a2, 0); |
| } |
| } |
| |
| static void test(); |
| |
| void loop() |
| { |
| while (1) { |
| test(); |
| } |
| } |
| |
| #ifndef __NR_mmap |
| #define __NR_mmap 192 |
| #endif |
| #ifndef __NR_ioctl |
| #define __NR_ioctl 54 |
| #endif |
| #ifndef __NR_memfd_create |
| #define __NR_memfd_create 356 |
| #endif |
| #undef __NR_mmap |
| #define __NR_mmap __NR_mmap2 |
| |
| long r[3]; |
| void test() |
| { |
| memset(r, -1, sizeof(r)); |
| syscall(__NR_mmap, 0x20000000, 0xfff000, 3, 0x32, -1, 0); |
| memcpy((void*)0x202a0000, "/dev/loop#", 11); |
| r[0] = syz_open_dev(0x202a0000, 0, 0); |
| *(uint32_t*)0x20063f68 = 0; |
| *(uint32_t*)0x20063f6c = 0; |
| *(uint32_t*)0x20063f70 = 0; |
| *(uint32_t*)0x20063f74 = 0; |
| *(uint32_t*)0x20063f78 = 0; |
| *(uint32_t*)0x20063f7c = 0; |
| *(uint32_t*)0x20063f80 = 0xc; |
| *(uint32_t*)0x20063f84 = 8; |
| memcpy((void*)0x20063f88, |
| "\xbd\x5d\x9b\x38\x0e\x76\xac\x0a\x0d\x19\xf8\x2a\x79\xf8\xbb\xff\xd4" |
| "\xae\x6f\x02\xc3\xea\xaa\xa8\x9a\x9b\x7b\xee\x02\x29\xa4\xe5\xe4\x6b" |
| "\x5e\x02\x9c\x11\x3a\x0d\x81\xc3\xc6\xfb\xb6\xb1\x68\x89\xc2\x84\xdf" |
| "\x72\x8c\x51\x4a\x9b\xcc\x8a\x5b\x3a\x2d\xe5\xfc\x14", |
| 64); |
| memcpy((void*)0x20063fc8, "\x7b\x0a\xca\x45\x20\x53\x3b\x44\x37\xbc\x26\x18" |
| "\x44\xd4\x38\x86\x0e\xa9\xb5\xbb\xe8\x70\xb2\xf7" |
| "\xfc\xb9\xf5\x7b\x72\x9d\xfe\x0f", |
| 32); |
| *(uint32_t*)0x20063fe8 = 6; |
| *(uint32_t*)0x20063fec = 1; |
| *(uint32_t*)0x20063ff0 = 0; |
| syscall(__NR_ioctl, r[0], 0x4c02, 0x20063f68); |
| memcpy((void*)0x20fb6ff5, "/dev/loop#", 11); |
| r[1] = syz_open_dev(0x20fb6ff5, 0, 0); |
| memcpy((void*)0x20000000, "\xff\xf8", 2); |
| r[2] = syscall(__NR_memfd_create, 0x20000000, 0); |
| syscall(__NR_ioctl, r[1], 0x4c00, r[2]); |
| } |
| |
| int main() |
| { |
| for (;;) { |
| loop(); |
| } |
| } |