blob: 9311db065669d89703cb52d52cfe093c7834783f [file] [log] [blame]
// kernel BUG at mm/kmsan/kmsan.c:LINE! (3)
// https://syzkaller.appspot.com/bug?id=319b9f885144d859b49c153c861a5e575a7ace00
// status:invalid
// autogenerated by syzkaller (http://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <errno.h>
#include <errno.h>
#include <fcntl.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.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 <stdlib.h>
#include <string.h>
#include <sys/stat.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 exitf(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(kRetryStatus);
}
static void use_temporary_dir()
{
char tmpdir_template[] = "./syzkaller.XXXXXX";
char* tmpdir = mkdtemp(tmpdir_template);
if (!tmpdir)
fail("failed to mkdtemp");
if (chmod(tmpdir, 0777))
fail("failed to chmod");
if (chdir(tmpdir))
fail("failed to chdir");
}
static bool write_file(const char* file, const char* what, ...)
{
char buf[1024];
va_list args;
va_start(args, what);
vsnprintf(buf, sizeof(buf), what, args);
va_end(args);
buf[sizeof(buf) - 1] = 0;
int len = strlen(buf);
int fd = open(file, O_WRONLY | O_CLOEXEC);
if (fd == -1)
return false;
if (write(fd, buf, len) != len) {
int err = errno;
close(fd);
errno = err;
return false;
}
close(fd);
return true;
}
static int inject_fault(int nth)
{
int fd;
char buf[16];
fd = open("/proc/thread-self/fail-nth", O_RDWR);
if (fd == -1)
exitf("failed to open /proc/thread-self/fail-nth");
sprintf(buf, "%d", nth + 1);
if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf))
exitf("failed to write /proc/thread-self/fail-nth");
return fd;
}
uint64_t r[1] = {0xffffffffffffffff};
void loop()
{
long res = 0;
res = syscall(__NR_socket, 0xa, 1, 0);
if (res != -1)
r[0] = res;
*(uint32_t*)0x200000c0 = 1;
syscall(__NR_setsockopt, r[0], 6, 0x13, 0x200000c0, 4);
*(uint16_t*)0x20000640 = 0xa;
*(uint16_t*)0x20000642 = htobe16(0);
*(uint32_t*)0x20000644 = 0;
*(uint8_t*)0x20000648 = 0xfe;
*(uint8_t*)0x20000649 = 0x80;
*(uint8_t*)0x2000064a = 0;
*(uint8_t*)0x2000064b = 0;
*(uint8_t*)0x2000064c = 0;
*(uint8_t*)0x2000064d = 0;
*(uint8_t*)0x2000064e = 0;
*(uint8_t*)0x2000064f = 0;
*(uint8_t*)0x20000650 = 0;
*(uint8_t*)0x20000651 = 0;
*(uint8_t*)0x20000652 = 0;
*(uint8_t*)0x20000653 = 0;
*(uint8_t*)0x20000654 = 0;
*(uint8_t*)0x20000655 = 0;
*(uint8_t*)0x20000656 = 0;
*(uint8_t*)0x20000657 = 0xbb;
*(uint32_t*)0x20000658 = 0;
*(uint16_t*)0x200006c0 = 0;
*(uint16_t*)0x200006c2 = 1;
*(uint32_t*)0x200006c4 = 0;
memcpy((void*)0x200006c8,
"\x0d\x77\xbd\xed\x71\x25\x33\x8d\xe4\x71\x45\xb7\x1f\x22\x26\xc0\xb6"
"\x95\x0f\xeb\xa5\x7b\x7d\x52\xd9\xe6\xd1\x35\x09\xbb\x60\x2e\x48\x18"
"\x22\x46\x96\xda\xfe\x09\xc2\x5e\xd1\xd5\xe1\xe8\xdd\x95\x25\xd4\x42"
"\x5e\x2c\x47\x07\xa0\x0f\x8d\xd4\x7a\x4c\x19\xb8\x84\x28\x2e\x4f\x74"
"\x3e\x00\xc7\xa3\xef\xf5\x99\xb1\x3d\x51\x8d\x10",
80);
syscall(__NR_setsockopt, r[0], 6, 0xe, 0x20000640, 0xd8);
*(uint16_t*)0x20000080 = 0xa;
*(uint16_t*)0x20000082 = htobe16(0);
*(uint32_t*)0x20000084 = 0;
*(uint8_t*)0x20000088 = 0;
*(uint8_t*)0x20000089 = 0;
*(uint8_t*)0x2000008a = 0;
*(uint8_t*)0x2000008b = 0;
*(uint8_t*)0x2000008c = 0;
*(uint8_t*)0x2000008d = 0;
*(uint8_t*)0x2000008e = 0;
*(uint8_t*)0x2000008f = 0;
*(uint8_t*)0x20000090 = 0;
*(uint8_t*)0x20000091 = 0;
*(uint8_t*)0x20000092 = -1;
*(uint8_t*)0x20000093 = -1;
*(uint32_t*)0x20000094 = htobe32(0);
*(uint32_t*)0x20000098 = 0;
syscall(__NR_connect, r[0], 0x20000080, 0x1c);
memcpy((void*)0x20000340, "tls", 4);
syscall(__NR_setsockopt, r[0], 6, 0x1f, 0x20000340, 4);
*(uint16_t*)0x20000100 = 0x303;
*(uint16_t*)0x20000102 = 0x33;
syscall(__NR_setsockopt, r[0], 0x11a, 1, 0x20000100, 0x28);
*(uint16_t*)0x20000000 = 0xa;
*(uint16_t*)0x20000002 = htobe16(0);
*(uint32_t*)0x20000004 = 0;
*(uint8_t*)0x20000008 = 0xfe;
*(uint8_t*)0x20000009 = 0x80;
*(uint8_t*)0x2000000a = 0;
*(uint8_t*)0x2000000b = 0;
*(uint8_t*)0x2000000c = 0;
*(uint8_t*)0x2000000d = 0;
*(uint8_t*)0x2000000e = 0;
*(uint8_t*)0x2000000f = 0;
*(uint8_t*)0x20000010 = 0;
*(uint8_t*)0x20000011 = 0;
*(uint8_t*)0x20000012 = 0;
*(uint8_t*)0x20000013 = 0;
*(uint8_t*)0x20000014 = 0;
*(uint8_t*)0x20000015 = 0;
*(uint8_t*)0x20000016 = 0;
*(uint8_t*)0x20000017 = 0xbb;
*(uint32_t*)0x20000018 = 0;
write_file("/sys/kernel/debug/failslab/ignore-gfp-wait", "N");
write_file("/sys/kernel/debug/fail_futex/ignore-private", "N");
inject_fault(0);
syscall(__NR_sendto, r[0], 0x200005c0, 0xfffffdef, 0, 0x20000000, 0x1c);
}
int main()
{
syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
use_temporary_dir();
loop();
return 0;
}