// https://syzkaller.appspot.com/bug?id=386c42c7796b556fde3ec8283905ae52c37ebbd2 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #ifndef __NR_landlock_create_ruleset #define __NR_landlock_create_ruleset 444 #endif #ifndef __NR_landlock_restrict_self #define __NR_landlock_restrict_self 446 #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[1] = {0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*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=*/0x200001000000ul, /*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)) { } // socket$netlink arguments: [ // domain: const = 0x10 (8 bytes) // type: const = 0x3 (8 bytes) // proto: netlink_proto = 0x0 (4 bytes) // ] // returns sock_netlink syscall(__NR_socket, /*domain=*/0x10ul, /*type=*/3ul, /*proto=*/0); // landlock_create_ruleset arguments: [ // attr: ptr[in, landlock_ruleset_attr] { // landlock_ruleset_attr { // handled_access_fs: landlock_access_fs_flags = 0x7f6e (8 bytes) // handled_access_net: landlock_access_net_flags = 0x0 (8 bytes) // scoped: landlock_scope_flags = 0x0 (8 bytes) // quiet_access_fs: landlock_access_fs_flags = 0x0 (8 bytes) // quiet_access_net: landlock_access_net_flags = 0x0 (8 bytes) // quiet_scoped: landlock_scope_flags = 0x0 (8 bytes) // } // } // size: bytesize = 0x30 (8 bytes) // flags: landlock_create_ruleset_flags = 0x0 (8 bytes) // ] // returns fd_ruleset *(uint64_t*)0x200000000300 = 0x7f6e; *(uint64_t*)0x200000000308 = 0; *(uint64_t*)0x200000000310 = 0; *(uint64_t*)0x200000000318 = 0; *(uint64_t*)0x200000000320 = 0; *(uint64_t*)0x200000000328 = 0; res = syscall(__NR_landlock_create_ruleset, /*attr=*/0x200000000300ul, /*size=*/0x30ul, /*flags=*/0ul); if (res != -1) r[0] = res; // landlock_restrict_self arguments: [ // ruleset_fd: fd_ruleset (resource) // flags: landlock_restrict_self_flags = 0x0 (8 bytes) // ] syscall(__NR_landlock_restrict_self, /*ruleset_fd=*/r[0], /*flags=*/0ul); // landlock_restrict_self arguments: [ // ruleset_fd: fd_ruleset (resource) // flags: landlock_restrict_self_flags = 0x0 (8 bytes) // ] syscall(__NR_landlock_restrict_self, /*ruleset_fd=*/r[0], /*flags=*/0ul); // socket$unix arguments: [ // domain: const = 0x1 (8 bytes) // type: unix_socket_type = 0x1 (8 bytes) // proto: const = 0x0 (4 bytes) // ] // returns sock_unix syscall(__NR_socket, /*domain=*/1ul, /*type=SOCK_STREAM*/ 1ul, /*proto=*/0); // syz_open_dev$radio arguments: [ // dev: nil // id: proc = 0xffffffffffffffff (8 bytes) // flags: const = 0x2 (8 bytes) // ] // returns fd_video syz_open_dev(/*dev=*/0, /*id=*/0, /*flags=*/2); // ioctl$VIDIOC_G_EXT_CTRLS arguments: [ // fd: fd_video (resource) // cmd: const = 0xc0205648 (4 bytes) // arg: ptr[inout, v4l2_ext_controls] { // v4l2_ext_controls { // ctrl_class: v4l2_ext_ctrl_class = 0xf010000 (4 bytes) // count: int32 = 0x0 (4 bytes) // error_idx: int32 = 0x1ff (4 bytes) // request_fd: fd_request (resource) // reserved: const = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // controls: nil // } // } // ] *(uint32_t*)0x200000002700 = 0xf010000; *(uint32_t*)0x200000002704 = 0; *(uint32_t*)0x200000002708 = 0x1ff; *(uint32_t*)0x20000000270c = -1; *(uint32_t*)0x200000002710 = 0; *(uint64_t*)0x200000002718 = 0; syscall(__NR_ioctl, /*fd=*/(intptr_t)-1, /*cmd=*/0xc0205648, /*arg=*/0x200000002700ul); // bind$unix arguments: [ // fd: sock_unix (resource) // addr: ptr[in, sockaddr_un] { // union sockaddr_un { // file: sockaddr_un_file { // family: unix_socket_family = 0x1 (2 bytes) // path: buffer: {2e 2f 66 69 6c 65 30 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 // 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 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 00 00 // 00 00 00} (length 0x6c) // } // } // } // addrlen: len = 0x6e (8 bytes) // ] *(uint16_t*)0x200000000000 = 1; memcpy((void*)0x200000000002, "./" "file0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 108); syscall(__NR_bind, /*fd=*/(intptr_t)-1, /*addr=*/0x200000000000ul, /*addrlen=*/0x6eul); return 0; }