blob: 7aceb43c42af117e84fffe26fce0c817af525417 [file] [log] [blame]
// kernel BUG at mm/kmsan/kmsan.c:LINE! (2)
// https://syzkaller.appspot.com/bug?id=839a59a94993f042cf8ca431000ab5f56324a06a
// status:invalid
// autogenerated by syzkaller (http://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <linux/futex.h>
#include <pthread.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/syscall.h>
#include <unistd.h>
struct thread_t {
int created, running, call;
pthread_t th;
};
static struct thread_t threads[16];
static void execute_call(int call);
static int running;
static int collide;
static void* thr(void* arg)
{
struct thread_t* th = (struct thread_t*)arg;
for (;;) {
while (!__atomic_load_n(&th->running, __ATOMIC_ACQUIRE))
syscall(SYS_futex, &th->running, FUTEX_WAIT, 0, 0);
execute_call(th->call);
__atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED);
__atomic_store_n(&th->running, 0, __ATOMIC_RELEASE);
syscall(SYS_futex, &th->running, FUTEX_WAKE);
}
return 0;
}
static void execute(int num_calls)
{
int call, thread;
running = 0;
for (call = 0; call < num_calls; call++) {
for (thread = 0; thread < sizeof(threads) / sizeof(threads[0]); thread++) {
struct thread_t* th = &threads[thread];
if (!th->created) {
th->created = 1;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, 128 << 10);
pthread_create(&th->th, &attr, thr, th);
}
if (!__atomic_load_n(&th->running, __ATOMIC_ACQUIRE)) {
th->call = call;
__atomic_fetch_add(&running, 1, __ATOMIC_RELAXED);
__atomic_store_n(&th->running, 1, __ATOMIC_RELEASE);
syscall(SYS_futex, &th->running, FUTEX_WAKE);
if (collide && call % 2)
break;
struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 20 * 1000 * 1000;
syscall(SYS_futex, &th->running, FUTEX_WAIT, 1, &ts);
if (running)
usleep((call == num_calls - 1) ? 10000 : 1000);
break;
}
}
}
}
uint64_t r[4] = {0xffffffffffffffff, 0x0, 0xffffffffffffffff, 0xffffffff};
void execute_call(int call)
{
long res;
switch (call) {
case 0:
memcpy((void*)0x200000c0, "/dev/nullb0", 12);
res = syscall(__NR_openat, 0xffffffffffffff9c, 0x200000c0, 0x4002, 0);
if (res != -1)
r[0] = res;
break;
case 1:
syscall(__NR_prctl, 0x27, 0x20000080);
break;
case 2:
res = syscall(__NR_io_setup, 0x5b3, 0x20000040);
if (res != -1)
r[1] = *(uint64_t*)0x20000040;
break;
case 3:
memcpy((void*)0x20000000, "/dev/vcs", 9);
res = syscall(__NR_openat, 0xffffffffffffff9c, 0x20000000, 0x2000, 0);
if (res != -1)
r[2] = res;
break;
case 4:
*(uint32_t*)0x20000100 = 1;
*(uint32_t*)0x20000104 = 2;
*(uint32_t*)0x20000108 = 7;
*(uint32_t*)0x2000010c = 2;
*(uint32_t*)0x20000110 = 0xffff0000;
*(uint64_t*)0x20000118 = 7;
*(uint64_t*)0x20000120 = 0xfffffffffffff189;
*(uint8_t*)0x20000128 = 0;
*(uint8_t*)0x20000129 = 0;
*(uint8_t*)0x2000012a = 0;
*(uint8_t*)0x2000012b = 0;
*(uint8_t*)0x2000012c = 0;
*(uint8_t*)0x2000012d = 0;
*(uint8_t*)0x2000012e = 0;
*(uint8_t*)0x2000012f = 0;
*(uint8_t*)0x20000130 = 0;
*(uint8_t*)0x20000131 = 0;
*(uint8_t*)0x20000132 = 0;
*(uint8_t*)0x20000133 = 0;
*(uint8_t*)0x20000134 = 0;
*(uint8_t*)0x20000135 = 0;
*(uint8_t*)0x20000136 = 0;
*(uint8_t*)0x20000137 = 0;
*(uint8_t*)0x20000138 = 0;
*(uint8_t*)0x20000139 = 0;
*(uint8_t*)0x2000013a = 0;
*(uint8_t*)0x2000013b = 0;
*(uint8_t*)0x2000013c = 0;
*(uint8_t*)0x2000013d = 0;
*(uint8_t*)0x2000013e = 0;
*(uint8_t*)0x2000013f = 0;
*(uint8_t*)0x20000140 = 0;
*(uint8_t*)0x20000141 = 0;
*(uint8_t*)0x20000142 = 0;
*(uint8_t*)0x20000143 = 0;
*(uint8_t*)0x20000144 = 0;
*(uint8_t*)0x20000145 = 0;
*(uint8_t*)0x20000146 = 0;
*(uint8_t*)0x20000147 = 0;
syscall(__NR_ioctl, r[2], 0x40485404, 0x20000100);
break;
case 5:
syscall(__NR_mremap, 0x20ffc000, 0x1000, 0x1000, 3, 0x20ffd000);
break;
case 6:
*(uint32_t*)0x20000900 = 0;
*(uint16_t*)0x20000904 = 0x18;
*(uint16_t*)0x20000906 = 0xfa00;
*(uint64_t*)0x20000908 = 2;
*(uint64_t*)0x20000910 = 0x200008c0;
*(uint16_t*)0x20000918 = 0x13f;
*(uint8_t*)0x2000091a = 8;
*(uint8_t*)0x2000091b = 0;
*(uint8_t*)0x2000091c = 0;
*(uint8_t*)0x2000091d = 0;
*(uint8_t*)0x2000091e = 0;
*(uint8_t*)0x2000091f = 0;
res = syscall(__NR_write, r[2], 0x20000900, 0x20);
if (res != -1)
r[3] = *(uint32_t*)0x200008c0;
break;
case 7:
*(uint32_t*)0x20000940 = 0xe;
*(uint16_t*)0x20000944 = 0x18;
*(uint16_t*)0x20000946 = 0xfa00;
*(uint64_t*)0x20000948 = 0x200001c0;
*(uint8_t*)0x200001c0 = 2;
*(uint32_t*)0x20000950 = r[3];
*(uint32_t*)0x20000954 = 0;
*(uint32_t*)0x20000958 = 0;
*(uint32_t*)0x2000095c = 1;
syscall(__NR_write, r[2], 0x20000940, 0x20);
break;
case 8:
*(uint64_t*)0x20001540 = 0x20000180;
*(uint64_t*)0x20000180 = 0;
*(uint32_t*)0x20000188 = 0;
*(uint32_t*)0x2000018c = 0;
*(uint16_t*)0x20000190 = 0;
*(uint16_t*)0x20000192 = 0;
*(uint32_t*)0x20000194 = r[0];
*(uint64_t*)0x20000198 = 0x20000000;
*(uint64_t*)0x200001a0 = 0xfffffce4;
*(uint64_t*)0x200001a8 = 0;
*(uint64_t*)0x200001b0 = 0;
*(uint32_t*)0x200001b8 = 0;
*(uint32_t*)0x200001bc = -1;
syscall(__NR_io_submit, r[1], 1, 0x20001540);
break;
}
}
void loop()
{
execute(9);
collide = 1;
execute(9);
}
int main()
{
syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
loop();
return 0;
}