text: // KMSAN: uninit-value in do_syslog
  // https://syzkaller.appspot.com/bug?id=40ddb50bf2c5894f59f8d8316c444d2b971f8196
  // status:invalid
  // 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 = 160 << 20;
    setrlimit(RLIMIT_AS, &rlim);
    rlim.rlim_cur = rlim.rlim_max = 8 << 20;
    setrlimit(RLIMIT_MEMLOCK, &rlim);
    rlim.rlim_cur = rlim.rlim_max = 136 << 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, 2, 1, 0);
    if (res != -1)
      r[0] = res;
    memcpy((void*)0x20789fd4, "\x87\x35\xd9\x61\x27\x34\x5d\xec\xed\x18\xb8\x6c"
                              "\x09\xbb\x2e\x83\xc6\x81\x74\x70\x8d\x6d\xb9\x60"
                              "\x78\x2f\x2e\xa9\x48\xdd\xbc\xc1\xde\x84\xde\x44"
                              "\x42\xed\x43\xfd\xb0\x2b\xf2\x12",
           44);
    syscall(__NR_setsockopt, r[0], 0, 0x40000048f, 0x20789fd4, 0x2c);
  }
  
  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;
  }
  