// https://syzkaller.appspot.com/bug?id=1108a8ef04002c926deaf3f231d7be6f3bec5ac7 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define BITMASK(bf_off, bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type, htobe, addr, val, bf_off, bf_len) \ *(type*)(addr) = \ htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | \ (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct nlmsg { char* pos; int nesting; struct nlattr* nested[8]; char buf[4096]; }; static void netlink_init(struct nlmsg* nlmsg, int typ, int flags, const void* data, int size) { memset(nlmsg, 0, sizeof(*nlmsg)); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_type = typ; hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags; memcpy(hdr + 1, data, size); nlmsg->pos = (char*)(hdr + 1) + NLMSG_ALIGN(size); } static void netlink_attr(struct nlmsg* nlmsg, int typ, const void* data, int size) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_len = sizeof(*attr) + size; attr->nla_type = typ; if (size > 0) memcpy(attr + 1, data, size); nlmsg->pos += NLMSG_ALIGN(attr->nla_len); } static int netlink_send_ext(struct nlmsg* nlmsg, int sock, uint16_t reply_type, int* reply_len, bool dofail) { if (nlmsg->pos > nlmsg->buf + sizeof(nlmsg->buf) || nlmsg->nesting) exit(1); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_len = nlmsg->pos - nlmsg->buf; struct sockaddr_nl addr; memset(&addr, 0, sizeof(addr)); addr.nl_family = AF_NETLINK; ssize_t n = sendto(sock, nlmsg->buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr)); if (n != (ssize_t)hdr->nlmsg_len) { if (dofail) exit(1); return -1; } n = recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); if (reply_len) *reply_len = 0; if (n < 0) { if (dofail) exit(1); return -1; } if (n < (ssize_t)sizeof(struct nlmsghdr)) { errno = EINVAL; if (dofail) exit(1); return -1; } if (hdr->nlmsg_type == NLMSG_DONE) return 0; if (reply_len && hdr->nlmsg_type == reply_type) { *reply_len = n; return 0; } if (n < (ssize_t)(sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr))) { errno = EINVAL; if (dofail) exit(1); return -1; } if (hdr->nlmsg_type != NLMSG_ERROR) { errno = EINVAL; if (dofail) exit(1); return -1; } errno = -((struct nlmsgerr*)(hdr + 1))->error; return -errno; } static int netlink_query_family_id(struct nlmsg* nlmsg, int sock, const char* family_name, bool dofail) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = CTRL_CMD_GETFAMILY; netlink_init(nlmsg, GENL_ID_CTRL, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, CTRL_ATTR_FAMILY_NAME, family_name, strnlen(family_name, GENL_NAMSIZ - 1) + 1); int n = 0; int err = netlink_send_ext(nlmsg, sock, GENL_ID_CTRL, &n, dofail); if (err < 0) { return -1; } uint16_t id = 0; struct nlattr* attr = (struct nlattr*)(nlmsg->buf + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr))); for (; (char*)attr < nlmsg->buf + n; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) { if (attr->nla_type == CTRL_ATTR_FAMILY_ID) { id = *(uint16_t*)(attr + 1); break; } } if (!id) { errno = EINVAL; return -1; } recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); return id; } const int kInitNetNsFd = 239; static long syz_init_net_socket(volatile long domain, volatile long type, volatile long proto) { return syscall(__NR_socket, domain, type, proto); } static long syz_genetlink_get_family_id(volatile long name, volatile long sock_arg) { bool dofail = false; int fd = sock_arg; if (fd < 0) { dofail = true; fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (fd == -1) { return -1; } } struct nlmsg nlmsg_tmp; int ret = netlink_query_family_id(&nlmsg_tmp, fd, (char*)name, dofail); if ((int)sock_arg < 0) close(fd); if (ret < 0) { return -1; } return ret; } uint64_t r[6] = {0xffffffffffffffff, 0x0, 0xffffffffffffffff, 0x0, 0xffffffffffffffff, 0x0}; int main(void) { syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); intptr_t res = 0; res = -1; res = syz_init_net_socket(0x10, 3, 0x10); if (res != -1) r[0] = res; memcpy((void*)0x20000180, "nl802154\000", 9); res = -1; res = syz_genetlink_get_family_id(0x20000180, -1); if (res != -1) r[1] = res; *(uint64_t*)0x20000800 = 0; *(uint32_t*)0x20000808 = 0; *(uint64_t*)0x20000810 = 0x200007c0; *(uint64_t*)0x200007c0 = 0x20000740; *(uint32_t*)0x20000740 = 0x54; *(uint16_t*)0x20000744 = r[1]; *(uint16_t*)0x20000746 = 1; *(uint32_t*)0x20000748 = 0x70bd2a; *(uint32_t*)0x2000074c = 0x25dfdbfb; *(uint8_t*)0x20000750 = 7; *(uint8_t*)0x20000751 = 0; *(uint16_t*)0x20000752 = 0; *(uint16_t*)0x20000754 = 0xc; *(uint16_t*)0x20000756 = 0x17; *(uint64_t*)0x20000758 = 0; *(uint16_t*)0x20000760 = 8; *(uint16_t*)0x20000762 = 1; *(uint32_t*)0x20000764 = 3; *(uint16_t*)0x20000768 = 0xa; *(uint16_t*)0x2000076a = 4; memcpy((void*)0x2000076c, "wpan4\000", 6); *(uint16_t*)0x20000774 = 8; *(uint16_t*)0x20000776 = 1; *(uint32_t*)0x20000778 = 0; *(uint16_t*)0x2000077c = 8; *(uint16_t*)0x2000077e = 1; *(uint32_t*)0x20000780 = 2; *(uint16_t*)0x20000784 = 8; *(uint16_t*)0x20000786 = 3; *(uint32_t*)0x20000788 = 0; *(uint16_t*)0x2000078c = 8; *(uint16_t*)0x2000078e = 5; *(uint32_t*)0x20000790 = 1; *(uint64_t*)0x200007c8 = 0x54; *(uint64_t*)0x20000818 = 1; *(uint64_t*)0x20000820 = 0; *(uint64_t*)0x20000828 = 0; *(uint32_t*)0x20000830 = 0x14; syscall(__NR_sendmsg, r[0], 0x20000800ul, 0x800ul); res = -1; res = syz_init_net_socket(0x10, 3, 0x10); if (res != -1) r[2] = res; memcpy((void*)0x20000040, "nl802154\000", 9); res = -1; res = syz_genetlink_get_family_id(0x20000040, -1); if (res != -1) r[3] = res; res = -1; res = syz_init_net_socket(0x10, 3, 0x10); if (res != -1) r[4] = res; memcpy((void*)0x200002c0, "wpan4\000\000\000\000\000\000\000\000\000\000\000", 16); res = syscall(__NR_ioctl, r[2], 0x8933, 0x200002c0ul); if (res != -1) r[5] = *(uint32_t*)0x200002d0; *(uint64_t*)0x20000640 = 0; *(uint32_t*)0x20000648 = 0; *(uint64_t*)0x20000650 = 0x20000600; *(uint64_t*)0x20000600 = 0x20000300; *(uint32_t*)0x20000300 = 0x198; *(uint16_t*)0x20000304 = r[3]; *(uint16_t*)0x20000306 = 1; *(uint32_t*)0x20000308 = 0; *(uint32_t*)0x2000030c = 0; *(uint8_t*)0x20000310 = 0x17; *(uint8_t*)0x20000311 = 0; *(uint16_t*)0x20000312 = 0; *(uint16_t*)0x20000314 = 8; *(uint16_t*)0x20000316 = 3; *(uint32_t*)0x20000318 = r[5]; *(uint16_t*)0x2000031c = 0x4c; STORE_BY_BITMASK(uint16_t, , 0x2000031e, 0x25, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000031f, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000031f, 1, 7, 1); *(uint16_t*)0x20000320 = 0x24; *(uint16_t*)0x20000322 = 3; memcpy((void*)0x20000324, "\x00\x50\x78\xfd\xc3\x94\xf6\xcc\xfc\x65\x4f\xc3\xd3\x42\xd7\x8a\x5b" "\x6e\xe8\xb7\x87\x1c\x52\x1d\x77\xa0\xcd\x0d\xbf\x92\xc9\x4c", 32); *(uint16_t*)0x20000344 = 5; *(uint16_t*)0x20000346 = 2; *(uint8_t*)0x20000348 = 0x81; *(uint16_t*)0x2000034c = 0x14; *(uint16_t*)0x2000034e = 4; memcpy((void*)0x20000350, "\xe2\x1f\x3e\x3d\x8b\x37\x73\x4b\x26\xc9\x8f\x00\x1c\x84\x02\x72", 16); *(uint16_t*)0x20000360 = 5; *(uint16_t*)0x20000362 = 2; *(uint8_t*)0x20000364 = 1; *(uint16_t*)0x20000368 = 0xc0; STORE_BY_BITMASK(uint16_t, , 0x2000036a, 0x25, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000036b, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000036b, 1, 7, 1); *(uint16_t*)0x2000036c = 0x18; STORE_BY_BITMASK(uint16_t, , 0x2000036e, 1, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000036f, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000036f, 1, 7, 1); *(uint16_t*)0x20000370 = 0x14; STORE_BY_BITMASK(uint16_t, , 0x20000372, 3, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000373, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000373, 1, 7, 1); *(uint16_t*)0x20000374 = 6; *(uint16_t*)0x20000376 = 3; *(uint16_t*)0x20000378 = 0xaaa2; *(uint16_t*)0x2000037c = 6; *(uint16_t*)0x2000037e = 1; *(uint16_t*)0x20000380 = -1; *(uint16_t*)0x20000384 = 0x14; *(uint16_t*)0x20000386 = 4; memcpy((void*)0x20000388, "\xe1\xb9\xe6\xfe\x0a\xc3\x55\x09\x93\xe6\x23\xa6\x88\x39\x57\x38", 16); *(uint16_t*)0x20000398 = 0x14; *(uint16_t*)0x2000039a = 4; memcpy((void*)0x2000039c, "\x99\xe4\x31\x8c\xb1\x0e\x6b\x2b\x84\x7b\x65\x34\x2f\x83\xe9\x94", 16); *(uint16_t*)0x200003ac = 0x24; *(uint16_t*)0x200003ae = 3; memcpy((void*)0x200003b0, "\x50\x55\x55\xaa\xb7\x2a\x56\x1f\xc1\xd9\x98\x5e\xc4\xd7\x1c\x3d\xd3" "\x4b\x5c\xee\xbd\xcf\x92\x4e\x4f\x72\x89\x5a\xfd\xa8\x3e\x31", 32); *(uint16_t*)0x200003d0 = 0x58; STORE_BY_BITMASK(uint16_t, , 0x200003d2, 1, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200003d3, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200003d3, 1, 7, 1); *(uint16_t*)0x200003d4 = 5; *(uint16_t*)0x200003d6 = 2; *(uint8_t*)0x200003d8 = 3; *(uint16_t*)0x200003dc = 0xc; *(uint16_t*)0x200003de = 5; *(uint64_t*)0x200003e0 = 0xfffffffffffff5e0; *(uint16_t*)0x200003e8 = 0xc; *(uint16_t*)0x200003ea = 5; *(uint64_t*)0x200003ec = 2; *(uint16_t*)0x200003f4 = 0xc; *(uint16_t*)0x200003f6 = 5; *(uint64_t*)0x200003f8 = 3; *(uint16_t*)0x20000400 = 5; *(uint16_t*)0x20000402 = 2; *(uint8_t*)0x20000404 = 0; *(uint16_t*)0x20000408 = 0xc; *(uint16_t*)0x2000040a = 5; *(uint64_t*)0x2000040c = 0x4c7ad8ef; *(uint16_t*)0x20000414 = 0xc; STORE_BY_BITMASK(uint16_t, , 0x20000416, 3, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000417, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000417, 1, 7, 1); *(uint16_t*)0x20000418 = 6; *(uint16_t*)0x2000041a = 1; *(uint16_t*)0x2000041c = 1; *(uint16_t*)0x20000420 = 5; *(uint16_t*)0x20000422 = 2; *(uint8_t*)0x20000424 = 2; *(uint16_t*)0x20000428 = 0x70; STORE_BY_BITMASK(uint16_t, , 0x2000042a, 0x25, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000042b, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000042b, 1, 7, 1); *(uint16_t*)0x2000042c = 0x50; STORE_BY_BITMASK(uint16_t, , 0x2000042e, 1, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000042f, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000042f, 1, 7, 1); *(uint16_t*)0x20000430 = 0xc; *(uint16_t*)0x20000432 = 5; *(uint64_t*)0x20000434 = 0x8001; *(uint16_t*)0x2000043c = 8; *(uint16_t*)0x2000043e = 4; *(uint32_t*)0x20000440 = 0x100; *(uint16_t*)0x20000444 = 8; *(uint16_t*)0x20000446 = 4; *(uint32_t*)0x20000448 = 3; *(uint16_t*)0x2000044c = 5; *(uint16_t*)0x2000044e = 2; *(uint8_t*)0x20000450 = 1; *(uint16_t*)0x20000454 = 8; *(uint16_t*)0x20000456 = 4; *(uint32_t*)0x20000458 = 0x101; *(uint16_t*)0x2000045c = 8; *(uint16_t*)0x2000045e = 1; *(uint32_t*)0x20000460 = 2; *(uint16_t*)0x20000464 = 8; *(uint16_t*)0x20000466 = 1; *(uint32_t*)0x20000468 = 2; *(uint16_t*)0x2000046c = 8; *(uint16_t*)0x2000046e = 4; *(uint32_t*)0x20000470 = 6; *(uint16_t*)0x20000474 = 8; *(uint16_t*)0x20000476 = 4; *(uint32_t*)0x20000478 = 0xfff; *(uint16_t*)0x2000047c = 5; *(uint16_t*)0x2000047e = 2; *(uint8_t*)0x20000480 = 0; *(uint16_t*)0x20000484 = 0x14; *(uint16_t*)0x20000486 = 4; memcpy((void*)0x20000488, "\xcc\x68\xf8\xe4\xeb\x2c\x81\x1a\x7b\x41\x6d\xbd\xec\xa3\x88\x6d", 16); *(uint64_t*)0x20000608 = 0x198; *(uint64_t*)0x20000658 = 1; *(uint64_t*)0x20000660 = 0; *(uint64_t*)0x20000668 = 0; *(uint32_t*)0x20000670 = 0x40840; syscall(__NR_sendmsg, r[4], 0x20000640ul, 0x8000ul); return 0; }