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$sg arguments: [
// dev: ptr[in, buffer] {
// buffer: {2f 64 65 76 2f 73 67 23 00} (length 0x9)
// }
// id: intptr = 0x0 (8 bytes)
// flags: open_flags = 0x0 (8 bytes)
// ]
// returns fd_sg
memcpy((void*)0x200000000000, "/dev/sg#\000", 9);
res = -1;
res = syz_open_dev(/*dev=*/0x200000000000, /*id=*/0, /*flags=*/0);
if (res != -1)
r[0] = res;
// ioctl$SG_BLKTRACESETUP arguments: [
// fd: fd_sg (resource)
// cmd: const = 0xc0481273 (4 bytes)
// arg: ptr[in, blk_user_trace_setup] {
// blk_user_trace_setup {
// name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x20)
// act_mask: int16 = 0x0 (2 bytes)
// pad = 0x0 (2 bytes)
// buf_size: int32 = 0x10000 (4 bytes)
// buf_nr: int32 = 0x7ffb (4 bytes)
// pad = 0x0 (4 bytes)
// start_lba: int64 = 0x2 (8 bytes)
// end_lba: int64 = 0x0 (8 bytes)
// pid: pid (resource)
// pad = 0x0 (4 bytes)
// }
// }
// ]
memset((void*)0x200000000040, 0, 32);
*(uint16_t*)0x200000000060 = 0;
*(uint32_t*)0x200000000064 = 0x10000;
*(uint32_t*)0x200000000068 = 0x7ffb;
*(uint64_t*)0x200000000070 = 2;
*(uint64_t*)0x200000000078 = 0;
*(uint32_t*)0x200000000080 = 0;
syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0xc0481273, /*arg=*/0x200000000040ul);
// ioctl$SG_BLKTRACETEARDOWN arguments: [
// fd: fd_sg (resource)
// cmd: const = 0x1276 (4 bytes)
// arg: const = 0x0 (8 bytes)
// ]
syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0x1276, /*arg=*/0ul);
return 0;
}
]