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[1] = {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)) {}
// syz_open_dev$usbfs arguments: [
// dev: ptr[in, buffer] {
// buffer: {2f 64 65 76 2f 62 75 73 2f 75 73 62 2f 30 30 23 2f 30 30 23 00} (length 0x15)
// }
// id: intptr = 0x10 (8 bytes)
// flags: open_flags = 0xa702 (8 bytes)
// ]
// returns fd_usbfs
memcpy((void*)0x2000000000c0, "/dev/bus/usb/00#/00#\000", 21);
res = -1;
res = syz_open_dev(/*dev=*/0x2000000000c0, /*id=*/0x10, /*flags=O_TRUNC|O_NOCTTY|O_LARGEFILE|FASYNC|O_APPEND|0x2*/0xa702);
if (res != -1)
r[0] = res;
// prctl$PR_SET_IO_FLUSHER arguments: [
// option: const = 0x41 (8 bytes)
// arg2: intptr = 0x3 (8 bytes)
// ]
syscall(__NR_prctl, /*option=*/0x41ul, /*arg2=*/3ul, 0, 0, 0);
// mmap arguments: [
// addr: VMA[0x5000]
// len: len = 0x5000 (8 bytes)
// prot: mmap_prot = 0x7 (8 bytes)
// flags: mmap_flags = 0x11 (8 bytes)
// fd: fd (resource)
// offset: intptr = 0x0 (8 bytes)
// ]
syscall(__NR_mmap, /*addr=*/0x200000371000ul, /*len=*/0x5000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_SHARED*/0x11ul, /*fd=*/r[0], /*offset=*/0ul);
return 0;
}
]