blob: 1a6cd8c6f1638d36db41c7c079ed2ae0cae4d86f [file] [log] [blame]
// BUG: Bad page state (6)
// https://syzkaller.appspot.com/bug?id=d58de93e9884519b6fd299a5ebd5e49295ede044
// status:invalid
// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
static long syz_open_dev(long a0, long a1, long 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);
}
}
#ifndef __NR_memfd_create
#define __NR_memfd_create 319
#endif
uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
long res = 0;
memcpy((void*)0x200005c0, "/dev/loop#\000", 11);
res = syz_open_dev(0x200005c0, 0, 0x4801);
if (res != -1)
r[0] = res;
memcpy((void*)0x20000140,
"cgroup2\000u\2656\340\217\227\341\fB\211\342\226F/"
"<\217\306\244\030\"\200\'\277Mu\223\036#\213A\317U\257\317}\322("
"Eg\355Zs\2173\202\252\3464\236\0203j\337hd\231\353\035\223y\353(",
70);
res = syscall(__NR_memfd_create, 0x20000140, 0);
if (res != -1)
r[1] = res;
*(uint64_t*)0x20000340 = 0x20000540;
memcpy((void*)0x20000540, "\'", 1);
*(uint64_t*)0x20000348 = 1;
syscall(__NR_pwritev, r[1], 0x20000340, 1, 0x81808);
syscall(__NR_ioctl, r[0], 0x4c00, r[1]);
syscall(__NR_sendfile, r[0], r[1], 0, 0x2000005);
return 0;
}