blob: c885de13887b4c4188bf9cbfe174ee9d2056f4be [file] [log] [blame]
// possible deadlock in fifo_open
// https://syzkaller.appspot.com/bug?id=2bf7e8a31b3d0f4a606a861ed1e76926d628617f
// status:open
// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
static long syz_open_procfs(long a0, 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;
}
uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
long res = 0;
memcpy((void*)0x20000000, "personality", 12);
res = syz_open_procfs(-1, 0x20000000);
if (res != -1)
r[0] = res;
syscall(__NR_read, r[0], 0x20000240, 0x72);
res = syscall(__NR_pipe2, 0x20000340, 0);
if (res != -1)
r[1] = *(uint32_t*)0x20000344;
memcpy((void*)0x200001c0, "/proc/self/net/pfkey", 21);
res = syscall(__NR_openat, 0xffffffffffffff9c, 0x200001c0, 0, 0);
if (res != -1)
r[2] = res;
*(uint64_t*)0x20000240 = 0x7ffd;
syscall(__NR_splice, r[2], 0x20000240, r[1], 0, 0x1ff, 0);
memcpy((void*)0x20000040, "./file0", 8);
syscall(__NR_mknod, 0x20000040, 0x103f, 0);
memcpy((void*)0x200003c0, "./file0", 8);
syscall(__NR_execve, 0x200003c0, 0x20000840, 0x20000800);
return 0;
}