blob: 9bf67120ca7e14bf1df64bda5e552122bc74b9e8 [file] [log] [blame]
// KMSAN: uninit-value in tipc_conn_rcv_sub
// https://syzkaller.appspot.com/bug?id=0df95bc3a80b97dfd33dc7f47ebfd7802d03dfc3
// status:fixed
// 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 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);
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[1] = {0xffffffffffffffff};
void execute_call(int call)
{
long res;
switch (call) {
case 0:
res = syscall(__NR_socket, 0x1e, 5, 0);
if (res != -1)
r[0] = res;
break;
case 1:
*(uint64_t*)0x203bbfc8 = 0x20fdbf80;
*(uint16_t*)0x20fdbf80 = 0x1e;
memcpy((void*)0x20fdbf82,
"\x02\xff\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x07\xe7"
"\x7f\x5b\xf8\x6c\x48\x02\x00\x02\x00\x00\x00\xf1\xff\xff\xff\x00"
"\x9a\x48\x00\x75\xe6\xa5\x00\x00\xde\x01\x03\x00\x00\x00\x00\xe4"
"\xff\x06\x4b\x3f\x01\x3a\x00\x00\x00\x08\x00\x00\x00\x8f\x00\x00"
"\x00\x00\xac\x50\xd5\xfe\x32\xc4\x00\x00\x00\x00\x7f\xff\xff\xff"
"\x6a\x00\x83\x56\xed\xb9\xa6\x34\x1c\x1f\xd4\x56\x24\x28\x1e\x00"
"\x07\x0e\xcd\xdd\x02\x06\xc3\x97\x50\xc4\x00\x00\xfd\x00\x00\x09"
"\x00\x00\x00\x00\x00\x0b\x00\x00\xdb\x00\x00\x04\xda\x36",
126);
*(uint32_t*)0x203bbfd0 = 0x64;
*(uint64_t*)0x203bbfd8 = 0x20d1b000;
*(uint64_t*)0x203bbfe0 = 0;
*(uint64_t*)0x203bbfe8 = 0x2012e000;
*(uint64_t*)0x203bbff0 = 0;
*(uint32_t*)0x203bbff8 = 0;
syscall(__NR_sendmsg, r[0], 0x203bbfc8, 0);
break;
case 2:
*(uint64_t*)0x20003500 = 0;
*(uint32_t*)0x20003508 = 0;
*(uint64_t*)0x20003510 = 0x20000a00;
*(uint64_t*)0x20000a00 = 0x20000540;
memcpy((void*)0x20000540, "r", 1);
*(uint64_t*)0x20000a08 = 1;
*(uint64_t*)0x20003518 = 1;
*(uint64_t*)0x20003520 = 0;
*(uint64_t*)0x20003528 = 0;
*(uint32_t*)0x20003530 = 0;
*(uint32_t*)0x20003538 = 0;
syscall(__NR_sendmmsg, r[0], 0x20003500, 1, 0);
break;
}
}
void loop()
{
execute(3);
}
int main()
{
syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
loop();
return 0;
}