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>
#ifndef __NR_mkdirat
#define __NR_mkdirat 34
#endif
#ifndef __NR_mmap
#define __NR_mmap 222
#endif
#ifndef __NR_mount
#define __NR_mount 40
#endif
#ifndef __NR_openat
#define __NR_openat 56
#endif
#ifndef __NR_prlimit64
#define __NR_prlimit64 261
#endif
#ifndef __NR_write
#define __NR_write 64
#endif
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[2] = {0xffffffffffffffff, 0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000, /*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=*/0x21000000ul, /*len=*/0x1000, /*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)) {}
// prlimit64 arguments: [
// pid: pid (resource)
// res: rlimit_type = 0xe (8 bytes)
// new: ptr[in, rlimit] {
// rlimit {
// soft: intptr = 0x8 (8 bytes)
// hard: intptr = 0x88 (8 bytes)
// }
// }
// old: nil
// ]
*(uint64_t*)0x20000140 = 8;
*(uint64_t*)0x20000148 = 0x88;
syscall(__NR_prlimit64, /*pid=*/0, /*res=RLIMIT_RTPRIO*/0xeul, /*new=*/0x20000140ul, /*old=*/0ul);
// syz_open_dev$dvb_demux arguments: [
// dev: ptr[in, buffer] {
// buffer: {2f 64 65 76 2f 64 76 62 2f 61 64 61 70 74 65 72 23 2f 64 65 6d 75 78 23 00} (length 0x19)
// }
// id: intptr = 0x0 (8 bytes)
// flags: open_flags = 0x20000 (8 bytes)
// ]
// returns fd_dvb_demux
memcpy((void*)0x20000080, "/dev/dvb/adapter#/demux#\000", 25);
syz_open_dev(/*dev=*/0x20000080, /*id=*/0, /*flags=O_LARGEFILE*/0x20000);
// mkdirat arguments: [
// fd: fd_dir (resource)
// path: ptr[in, buffer] {
// buffer: {2e 2f 64 65 62 75 67 00} (length 0x8)
// }
// mode: open_mode = 0x1ff (8 bytes)
// ]
memcpy((void*)0x20000000, "./debug\000", 8);
syscall(__NR_mkdirat, /*fd=*/0xffffff9c, /*path=*/0x20000000ul, /*mode=S_IXOTH|S_IWOTH|S_IROTH|S_IXGRP|S_IWGRP|S_IRGRP|S_IXUSR|S_IWUSR|0x100*/0x1fful);
// mount arguments: [
// src: nil
// dst: ptr[in, buffer] {
// buffer: {2e 2f 64 65 62 75 67 00} (length 0x8)
// }
// type: ptr[in, buffer] {
// buffer: {64 65 62 75 67 66 73 00} (length 0x8)
// }
// flags: mount_flags = 0x0 (8 bytes)
// data: nil
// ]
memcpy((void*)0x20000040, "./debug\000", 8);
memcpy((void*)0x20000080, "debugfs\000", 8);
syscall(__NR_mount, /*src=*/0ul, /*dst=*/0x20000040ul, /*type=*/0x20000080ul, /*flags=*/0ul, /*data=*/0ul);
// openat arguments: [
// fd: fd_dir (resource)
// file: ptr[in, buffer] {
// buffer: {2e 2f 64 65 62 75 67 2f 66 61 69 6c 73 6c 61 62 2f 70 72 6f 62 61 62 69 6c 69 74 79 00} (length 0x1d)
// }
// flags: open_flags = 0x1 (4 bytes)
// mode: open_mode = 0x0 (2 bytes)
// ]
// returns fd
memcpy((void*)0x200000c0, "./debug/failslab/probability\000", 29);
res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200000c0ul, /*flags=O_WRONLY*/1, /*mode=*/0);
if (res != -1)
r[0] = res;
// write arguments: [
// fd: fd (resource)
// buf: ptr[in, buffer] {
// buffer: {31 30} (length 0x2)
// }
// count: len = 0x2 (8 bytes)
// ]
memcpy((void*)0x20000100, "10", 2);
syscall(__NR_write, /*fd=*/r[0], /*buf=*/0x20000100ul, /*count=*/2ul);
// openat arguments: [
// fd: fd_dir (resource)
// file: ptr[in, buffer] {
// buffer: {2e 2f 64 65 62 75 67 2f 66 61 69 6c 73 6c 61 62 2f 74 69 6d 65 73 00} (length 0x17)
// }
// flags: open_flags = 0x1 (4 bytes)
// mode: open_mode = 0x0 (2 bytes)
// ]
// returns fd
memcpy((void*)0x20000140, "./debug/failslab/times\000", 23);
res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x20000140ul, /*flags=O_WRONLY*/1, /*mode=*/0);
if (res != -1)
r[1] = res;
// write arguments: [
// fd: fd (resource)
// buf: ptr[in, buffer] {
// buffer: {31 30 30} (length 0x3)
// }
// count: len = 0x3 (8 bytes)
// ]
memcpy((void*)0x20000180, "100", 3);
syscall(__NR_write, /*fd=*/r[1], /*buf=*/0x20000180ul, /*count=*/3ul);
return 0;
}
]