blob: 3cacd3a7887c5a3e63db10576078c530174377b1 [file] [log] [blame]
// KMSAN: uninit-value in ip_vs_lblc_check_expire
// https://syzkaller.appspot.com/bug?id=26e23e560b6a7a40da9abf2626587349afe2f762
// status:fixed
// autogenerated by syzkaller (http://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/syscall.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 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 uintptr_t syz_open_dev(uintptr_t a0, uintptr_t a1, uintptr_t a2)
{
if (a0 == 0xc || a0 == 0xb) {
char buf[128];
sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1,
(uint8_t)a2);
return open(buf, O_RDWR, 0);
} else {
char buf[1024];
char* hash;
strncpy(buf, (char*)a0, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = 0;
while ((hash = strchr(buf, '#'))) {
*hash = '0' + (char)(a1 % 10);
a1 /= 10;
}
return open(buf, a2, 0);
}
}
static void execute_one();
extern unsigned long long procid;
void loop()
{
while (1) {
execute_one();
}
}
uint64_t r[1] = {0xffffffffffffffff};
void execute_one()
{
long res = 0;
res = syscall(__NR_socket, 0xa, 1, 0);
if (res != -1)
r[0] = res;
*(uint16_t*)0x20000080 = 0x11;
*(uint8_t*)0x20000084 = 0xac;
*(uint8_t*)0x20000085 = 0x14;
*(uint8_t*)0x20000086 = 0x14;
*(uint8_t*)0x20000087 = 0;
*(uint16_t*)0x20000088 = htobe16(0);
*(uint32_t*)0x2000008c = 0;
memcpy((void*)0x20000090,
"\x6c\x62\x6c\x63\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
16);
*(uint32_t*)0x200000a0 = 0;
*(uint32_t*)0x200000a4 = 0;
*(uint32_t*)0x200000a8 = htobe32(0);
syscall(__NR_setsockopt, r[0], 0, 0x482, 0x20000080, 0x2c);
memcpy((void*)0x20000040, "/dev/input/event#", 18);
syz_open_dev(0x20000040, 0x7ff, 0x101800);
*(uint16_t*)0x208a8000 = 0xa;
*(uint16_t*)0x208a8002 = htobe16(0x4e23);
*(uint32_t*)0x208a8004 = 0;
*(uint8_t*)0x208a8008 = 0;
*(uint8_t*)0x208a8009 = 0;
*(uint8_t*)0x208a800a = 0;
*(uint8_t*)0x208a800b = 0;
*(uint8_t*)0x208a800c = 0;
*(uint8_t*)0x208a800d = 0;
*(uint8_t*)0x208a800e = 0;
*(uint8_t*)0x208a800f = 0;
*(uint8_t*)0x208a8010 = 0;
*(uint8_t*)0x208a8011 = 0;
*(uint8_t*)0x208a8012 = 0;
*(uint8_t*)0x208a8013 = 0;
*(uint8_t*)0x208a8014 = 0;
*(uint8_t*)0x208a8015 = 0;
*(uint8_t*)0x208a8016 = 0;
*(uint8_t*)0x208a8017 = 0;
*(uint32_t*)0x208a8018 = 0;
syscall(__NR_bind, -1, 0x208a8000, 0x1c);
memcpy((void*)0x20000140, "/dev/urandom", 13);
syscall(__NR_openat, 0xffffffffffffff9c, 0x20000140, 0x80800, 0);
syscall(__NR_socket, 0x11, 0x100000803, 0);
*(uint32_t*)0x20000080 = 0x3ff;
syscall(__NR_setsockopt, -1, 0x84, 0x20, 0x20000080, 4);
*(uint32_t*)0x20000440 = 0xc;
syscall(__NR_getsockopt, -1, 1, 0x14, 0x20caaffb, 0x20000440);
syscall(__NR_socket, 0xa, 1, 0);
memcpy((void*)0x20000040, "/dev/full", 10);
syscall(__NR_openat, 0xffffffffffffff9c, 0x20000040, 0x10800, 0);
syscall(__NR_ftruncate, -1, 9);
syscall(__NR_socket, 0x11, 0x803, 0);
*(uint32_t*)0x20000040 = 0;
*(uint16_t*)0x20000044 = -1;
*(uint32_t*)0x20000080 = 8;
syscall(__NR_getsockopt, -1, 0x84, 0x18, 0x20000040, 0x20000080);
syscall(__NR_dup3, 0xffffff9c, -1, 0x80000);
*(uint8_t*)0x20000200 = 1;
*(uint8_t*)0x20000201 = 0;
*(uint8_t*)0x20000202 = 0;
*(uint8_t*)0x20000203 = 0;
*(uint8_t*)0x20000204 = 0;
*(uint8_t*)0x20000205 = 0;
*(uint8_t*)0x20000206 = 0;
*(uint8_t*)0x20000207 = 0;
*(uint8_t*)0x20000208 = 0;
*(uint8_t*)0x20000209 = 0;
*(uint8_t*)0x2000020a = 0;
syscall(__NR_setsockopt, -1, 0x84, 0xb, 0x20000200, 0xb);
syscall(__NR_socket, 0x10, 3, 0);
}
int main()
{
syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
char* cwd = get_current_dir_name();
for (;;) {
if (chdir(cwd))
fail("failed to chdir");
use_temporary_dir();
loop();
}
}