// https://syzkaller.appspot.com/bug?id=c3a86955dfb2a2aac97d7417be4693e022583610 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #ifndef __NR_ioctl #define __NR_ioctl 29 #endif #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_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)) { } // 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*)0x20000000, "./debug\000", 8); memcpy((void*)0x20000180, "debugfs\000", 8); syscall(__NR_mount, /*src=*/0ul, /*dst=*/0x20000000ul, /*type=*/0x20000180ul, /*flags=*/0ul, /*data=*/0ul); // openat arguments: [ // fd: fd_dir (resource) // file: ptr[in, buffer] { // buffer: {2e 2f 64 65 62 75 67 2f 64 79 6e 61 6d 69 63 5f 64 65 62 75 // 67 2f 63 6f 6e 74 72 6f 6c 00} (length 0x1e) // } // flags: open_flags = 0x2 (4 bytes) // mode: open_mode = 0x60 (2 bytes) // ] // returns fd memcpy((void*)0x20000080, "./debug/dynamic_debug/control\000", 30); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x20000080ul, /*flags=O_RDWR*/ 2, /*mode=S_IRGRP|S_IXUSR*/ 0x60); if (res != -1) r[0] = res; // write arguments: [ // fd: fd (resource) // buf: ptr[in, buffer] { // buffer: {2b 70} (length 0x2) // } // count: len = 0x2 (8 bytes) // ] memcpy((void*)0x20000100, "+p", 2); syscall(__NR_write, /*fd=*/r[0], /*buf=*/0x20000100ul, /*count=*/2ul); // syz_open_dev$dvb_frontend arguments: [ // dev: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 64 76 62 2f 61 64 61 70 74 65 72 23 2f 66 72 // 6f 6e 74 65 6e 64 23 00} (length 0x1c) // } // id: intptr = 0x0 (8 bytes) // flags: open_flags = 0x2 (8 bytes) // ] // returns fd_dvb_frontend memcpy((void*)0x20000080, "/dev/dvb/adapter#/frontend#\000", 28); res = -1; res = syz_open_dev(/*dev=*/0x20000080, /*id=*/0, /*flags=O_RDWR*/ 2); if (res != -1) r[1] = res; // ioctl$FE_GET_PROPERTY arguments: [ // fd: fd_dvb_frontend (resource) // cmd: const = 0x80106f53 (4 bytes) // arg: ptr[inout, dtv_properties] { // dtv_properties { // num: int32 = 0x5 (4 bytes) // pad = 0x0 (4 bytes) // props: ptr[in, array[dtv_property]] { // array[dtv_property] { // dtv_property { // cmd: dtv_property_cmd = 0x16 (4 bytes) // reserved: buffer: {00 00 00 00 00 00 00 00 00 00 00 00} // (length 0xc) u: union dtv_property_u { // data: int32 = 0x6 (4 bytes) // } // result: int32 = 0x10 (4 bytes) // } // dtv_property { // cmd: dtv_property_cmd = 0x2f (4 bytes) // reserved: buffer: {00 00 00 00 00 00 00 00 00 00 00 00} // (length 0xc) u: union dtv_property_u { // buffer: dtv_property_u_buffer { // data: buffer: {08 ca 57 e2 62 1c 77 14 53 7e 2f bd d5 75 // 6c d0 01 fb e9 6f 40 06 23 42 7d 72 df 4b e9 7a 4b a5} // (length 0x20) len: len = 0x20 (4 bytes) reserved1: buffer: // {00 00 00 00 00 00 00 00 00 00 00 00} (length 0xc) // reserved2: const = 0x0 (8 bytes) // } // } // result: int32 = 0x3 (4 bytes) // } // dtv_property { // cmd: dtv_property_cmd = 0x31 (4 bytes) // reserved: buffer: {00 00 00 00 00 00 00 00 00 00 00 00} // (length 0xc) u: union dtv_property_u { // st: dtv_fe_stats { // len: len = 0x4 (1 bytes) // stat: array[dtv_stats] { // dtv_stats { // scale: fecap_scale = 0x0 (1 bytes) // u: union dtv_stats_u { // uvalue: int64 = 0x6 (8 bytes) // } // } // dtv_stats { // scale: fecap_scale = 0x0 (1 bytes) // u: union dtv_stats_u { // uvalue: int64 = 0x58b7 (8 bytes) // } // } // dtv_stats { // scale: fecap_scale = 0x1 (1 bytes) // u: union dtv_stats_u { // uvalue: int64 = 0x9 (8 bytes) // } // } // dtv_stats { // scale: fecap_scale = 0x0 (1 bytes) // u: union dtv_stats_u { // svalue: int64 = 0x7fff (8 bytes) // } // } // } // } // } // result: int32 = 0x0 (4 bytes) // } // dtv_property { // cmd: dtv_property_cmd = 0x2b (4 bytes) // reserved: buffer: {00 00 00 00 00 00 00 00 00 00 00 00} // (length 0xc) u: union dtv_property_u { // data: int32 = 0x1 (4 bytes) // } // result: int32 = 0x1000 (4 bytes) // } // dtv_property { // cmd: dtv_property_cmd = 0x22 (4 bytes) // reserved: buffer: {00 00 00 00 00 00 00 00 00 00 00 00} // (length 0xc) u: union dtv_property_u { // st: dtv_fe_stats { // len: len = 0x4 (1 bytes) // stat: array[dtv_stats] { // dtv_stats { // scale: fecap_scale = 0x2 (1 bytes) // u: union dtv_stats_u { // uvalue: int64 = 0x7 (8 bytes) // } // } // dtv_stats { // scale: fecap_scale = 0x2 (1 bytes) // u: union dtv_stats_u { // svalue: int64 = 0x9 (8 bytes) // } // } // dtv_stats { // scale: fecap_scale = 0x2 (1 bytes) // u: union dtv_stats_u { // uvalue: int64 = 0x7 (8 bytes) // } // } // dtv_stats { // scale: fecap_scale = 0x3 (1 bytes) // u: union dtv_stats_u { // uvalue: int64 = 0x80000000 (8 bytes) // } // } // } // } // } // result: int32 = 0x7 (4 bytes) // } // } // } // } // } // ] *(uint32_t*)0x20000c00 = 5; *(uint64_t*)0x20000c08 = 0x20000a80; *(uint32_t*)0x20000a80 = 0x16; memset((void*)0x20000a84, 0, 12); *(uint32_t*)0x20000a90 = 6; *(uint32_t*)0x20000ac8 = 0x10; *(uint32_t*)0x20000acc = 0x2f; memset((void*)0x20000ad0, 0, 12); memcpy((void*)0x20000adc, "\x08\xca\x57\xe2\x62\x1c\x77\x14\x53\x7e\x2f\xbd\xd5\x75\x6c\xd0\x01" "\xfb\xe9\x6f\x40\x06\x23\x42\x7d\x72\xdf\x4b\xe9\x7a\x4b\xa5", 32); *(uint32_t*)0x20000afc = 0x20; memset((void*)0x20000b00, 0, 12); *(uint64_t*)0x20000b0c = 0; *(uint32_t*)0x20000b14 = 3; *(uint32_t*)0x20000b18 = 0x31; memset((void*)0x20000b1c, 0, 12); *(uint8_t*)0x20000b28 = 4; *(uint8_t*)0x20000b29 = 0; *(uint64_t*)0x20000b2a = 6; *(uint8_t*)0x20000b32 = 0; *(uint64_t*)0x20000b33 = 0x58b7; *(uint8_t*)0x20000b3b = 1; *(uint64_t*)0x20000b3c = 9; *(uint8_t*)0x20000b44 = 0; *(uint64_t*)0x20000b45 = 0x7fff; *(uint32_t*)0x20000b60 = 0; *(uint32_t*)0x20000b64 = 0x2b; memset((void*)0x20000b68, 0, 12); *(uint32_t*)0x20000b74 = 1; *(uint32_t*)0x20000bac = 0x1000; *(uint32_t*)0x20000bb0 = 0x22; memset((void*)0x20000bb4, 0, 12); *(uint8_t*)0x20000bc0 = 4; *(uint8_t*)0x20000bc1 = 2; *(uint64_t*)0x20000bc2 = 7; *(uint8_t*)0x20000bca = 2; *(uint64_t*)0x20000bcb = 9; *(uint8_t*)0x20000bd3 = 2; *(uint64_t*)0x20000bd4 = 7; *(uint8_t*)0x20000bdc = 3; *(uint64_t*)0x20000bdd = 0x80000000; *(uint32_t*)0x20000bf8 = 7; syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0x80106f53, /*arg=*/0x20000c00ul); return 0; }