blob: bf46361290e898e47c70349f585140afa3c34ebd [file] [log] [blame]
// KMSAN: uninit-value in tipc_subscrb_rcv_cb
// https://syzkaller.appspot.com/bug?id=ec45249073777e4fc8fa9d8f1732f594bc2f4023
// status:fixed
// autogenerated by syzkaller (http://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <errno.h>
#include <sched.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/prctl.h>
#include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <unistd.h>
__attribute__((noreturn)) static void doexit(int status)
{
volatile unsigned i;
syscall(__NR_exit_group, status);
for (i = 0;; i++) {
}
}
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
const int kFailStatus = 67;
const int kRetryStatus = 69;
static void fail(const char* msg, ...)
{
int e = errno;
va_list args;
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
fprintf(stderr, " (errno %d)\n", e);
doexit((e == ENOMEM || e == EAGAIN) ? kRetryStatus : kFailStatus);
}
static void loop();
static void sandbox_common()
{
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
setpgrp();
setsid();
struct rlimit rlim;
rlim.rlim_cur = rlim.rlim_max = 128 << 20;
setrlimit(RLIMIT_AS, &rlim);
rlim.rlim_cur = rlim.rlim_max = 8 << 20;
setrlimit(RLIMIT_MEMLOCK, &rlim);
rlim.rlim_cur = rlim.rlim_max = 32 << 20;
setrlimit(RLIMIT_FSIZE, &rlim);
rlim.rlim_cur = rlim.rlim_max = 1 << 20;
setrlimit(RLIMIT_STACK, &rlim);
rlim.rlim_cur = rlim.rlim_max = 0;
setrlimit(RLIMIT_CORE, &rlim);
if (unshare(CLONE_NEWNS)) {
}
if (unshare(CLONE_NEWIPC)) {
}
if (unshare(0x02000000)) {
}
if (unshare(CLONE_NEWUTS)) {
}
if (unshare(CLONE_SYSVSEM)) {
}
}
static int do_sandbox_none(void)
{
if (unshare(CLONE_NEWPID)) {
}
int pid = fork();
if (pid < 0)
fail("sandbox fork failed");
if (pid)
return pid;
sandbox_common();
if (unshare(CLONE_NEWNET)) {
}
loop();
doexit(1);
}
uint64_t r[1] = {0xffffffffffffffff};
void loop()
{
long res = 0;
res = syscall(__NR_socket, 0x1e, 0x80001, 0);
if (res != -1)
r[0] = res;
*(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\x80\x01\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\x26\xda\x36",
126);
*(uint32_t*)0x203bbfd0 = 0x80;
*(uint64_t*)0x203bbfd8 = 0x20454000;
*(uint64_t*)0x203bbfe0 = 0;
*(uint64_t*)0x203bbfe8 = 0x2012e000;
*(uint64_t*)0x203bbff0 = 0;
*(uint32_t*)0x203bbff8 = 0;
syscall(__NR_sendmsg, r[0], 0x203bbfc8, 0);
*(uint8_t*)0x20000080 = 1;
*(uint8_t*)0x20000081 = 3;
*(uint16_t*)0x20000082 = 3;
*(uint16_t*)0x20000084 = 7;
*(uint16_t*)0x20000086 = 1;
*(uint16_t*)0x20000088 = 0x649;
*(uint8_t*)0x2000008a = 0;
*(uint8_t*)0x2000008b = -1;
*(uint8_t*)0x2000008c = -1;
syscall(__NR_write, r[0], 0x20000080, 0xd);
}
int main()
{
syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
int pid = do_sandbox_none();
int status = 0;
while (waitpid(pid, &status, __WALL) != pid) {
}
return 0;
}