blob: 199354acc3ed82c281441e1cd41b471c18cad1c3 [file] [log] [blame]
// WARNING: kobject bug in netdev_queue_update_kobjects
// https://syzkaller.appspot.com/bug?id=86a8e2ab50527d5a5eb4fad2fc15df609f22d86a
// status:fixed
// autogenerated by syzkaller (http://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.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 <string.h>
const int kFailStatus = 67;
const int kRetryStatus = 69;
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 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));
buf[sizeof(buf) - 1] = 0;
while ((hash = strchr(buf, '#'))) {
*hash = '0' + (char)(a1 % 10);
a1 /= 10;
}
return open(buf, a2, 0);
}
}
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) {
close(fd);
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;
}
static void test();
void loop()
{
while (1) {
test();
}
}
uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff};
void test()
{
long res;
memcpy((void*)0x20000100, "/dev/net/tun", 13);
res = syz_open_dev(0x20000100, 0, 0);
if (res != -1)
r[0] = res;
memcpy((void*)0x200000c0,
"\xd2\x02\xb9\x99\xcf\x85\x00\x00\x00\x00\x00\x88\xf3\x01\xe7\x10",
16);
*(uint16_t*)0x200000d0 = 0x102;
syscall(__NR_ioctl, r[0], 0x400454ca, 0x200000c0);
memcpy((void*)0x20000140,
"\x76\x68\x61\x6e\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
16);
*(uint16_t*)0x20000150 = 0x400;
syscall(__NR_ioctl, r[0], 0x400454d9, 0x20000140);
memcpy((void*)0x20000280, "/dev/net/tun", 13);
res = syz_open_dev(0x20000280, 0, 0);
if (res != -1)
r[1] = res;
memcpy((void*)0x200000c0,
"\xd2\x02\xb9\x99\xcf\x85\x00\x00\x00\x00\x00\x88\xf3\x01\xe7\x10",
16);
*(uint16_t*)0x200000d0 = 0x102;
syscall(__NR_ioctl, r[1], 0x400454ca, 0x200000c0);
memcpy((void*)0x20000200,
"\x05\x00\x00\x00\x00\xe7\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
16);
*(uint16_t*)0x20000210 = 0x200;
write_file("/sys/kernel/debug/failslab/ignore-gfp-wait", "N");
write_file("/sys/kernel/debug/fail_futex/ignore-private", "N");
inject_fault(1);
syscall(__NR_ioctl, r[0], 0x400454d9, 0x20000200);
}
int main()
{
syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
for (;;) {
loop();
}
}