map[SimplifiedCRepro:// 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/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
static long syz_open_dev(volatile long a0, volatile long a1, volatile 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 {
unsigned long nb = a1;
char buf[1024];
char* hash;
strncpy(buf, (char*)a0, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = 0;
while ((hash = strchr(buf, '#'))) {
*hash = '0' + (char)(nb % 10);
nb /= 10;
}
return open(buf, a2 & ~O_CREAT, 0);
}
}
uint64_t r[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
intptr_t res = 0;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// openat arguments: [
// fd: fd_dir (resource)
// file: ptr[in, buffer] {
// buffer: {2e 2f 63 67 72 6f 75 70 00} (length 0x9)
// }
// flags: open_flags = 0x0 (4 bytes)
// mode: open_mode = 0x0 (2 bytes)
// ]
// returns fd
memcpy((void*)0x200000000200, "./cgroup\000", 9);
res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200000000200ul, /*flags=*/0, /*mode=*/0);
if (res != -1)
r[0] = res;
// openat$cgroup_int arguments: [
// fd: fd_cgroup (resource)
// file: ptr[in, buffer] {
// buffer: {63 70 75 2e 6d 61 78 00} (length 0x8)
// }
// flags: const = 0x2 (4 bytes)
// mode: const = 0x0 (2 bytes)
// ]
// returns fd_cgroup_int
memcpy((void*)0x200000000040, "cpu.max\000", 8);
res = syscall(__NR_openat, /*fd=*/r[0], /*file=*/0x200000000040ul, /*flags=*/2, /*mode=*/0);
if (res != -1)
r[1] = res;
// openat arguments: [
// fd: fd_dir (resource)
// file: ptr[in, buffer] {
// buffer: {2e 2f 63 67 72 6f 75 70 00} (length 0x9)
// }
// flags: open_flags = 0x0 (4 bytes)
// mode: open_mode = 0x0 (2 bytes)
// ]
// returns fd
memcpy((void*)0x200000000200, "./cgroup\000", 9);
res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200000000200ul, /*flags=*/0, /*mode=*/0);
if (res != -1)
r[2] = res;
// openat$cgroup_int arguments: [
// fd: fd_cgroup (resource)
// file: ptr[in, buffer] {
// buffer: {63 70 75 2e 6d 61 78 00} (length 0x8)
// }
// flags: const = 0x2 (4 bytes)
// mode: const = 0x0 (2 bytes)
// ]
// returns fd_cgroup_int
memcpy((void*)0x200000000040, "cpu.max\000", 8);
res = syscall(__NR_openat, /*fd=*/r[2], /*file=*/0x200000000040ul, /*flags=*/2, /*mode=*/0);
if (res != -1)
r[3] = res;
// sendfile arguments: [
// fdout: fd (resource)
// fdin: fd (resource)
// off: ptr[inout, intptr] {
// intptr = 0x4 (8 bytes)
// }
// count: intptr = 0x4 (8 bytes)
// ]
*(uint64_t*)0x200000000000 = 4;
syscall(__NR_sendfile, /*fdout=*/r[3], /*fdin=*/r[1], /*off=*/0x200000000000ul, /*count=*/4ul);
// syz_open_dev$tty20 arguments: [
// dev: const = 0xc (8 bytes)
// major: const = 0x4 (8 bytes)
// minor: proc = 0x1 (8 bytes)
// ]
// returns fd_tty
syz_open_dev(/*dev=*/0xc, /*major=*/4, /*minor=*/0x15);
// ioctl$BTRFS_IOC_GET_SUBVOL_ROOTREF arguments: [
// fd: fd (resource)
// cmd: const = 0xd000943d (4 bytes)
// arg: nil
// ]
syscall(__NR_ioctl, /*fd=*/(intptr_t)-1, /*cmd=*/0xd000943d, /*arg=*/0ul);
// ioctl$BTRFS_IOC_INO_LOOKUP_USER arguments: [
// fd: fd (resource)
// cmd: const = 0xd000943e (4 bytes)
// arg: nil
// ]
syscall(__NR_ioctl, /*fd=*/(intptr_t)-1, /*cmd=*/0xd000943e, /*arg=*/0ul);
return 0;
}
]