// https://syzkaller.appspot.com/bug?id=e7c8b5465e53b8c65bca5e522ddcb03a41203996 // 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 = 201; 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) { int fd = sock_arg; if (fd < 0) { 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, false); if ((int)sock_arg < 0) close(fd); if (ret < 0) { return -1; } return ret; } uint64_t r[4] = {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*)0x20000040, "nl802154\000", 9); res = -1; res = syz_genetlink_get_family_id(0x20000040, -1); if (res != -1) r[1] = res; *(uint64_t*)0x20000100 = 0; *(uint32_t*)0x20000108 = 0; *(uint64_t*)0x20000110 = 0x200000c0; *(uint64_t*)0x200000c0 = 0x20000000; *(uint32_t*)0x20000000 = 0x30; *(uint16_t*)0x20000004 = r[1]; *(uint16_t*)0x20000006 = 1; *(uint32_t*)0x20000008 = 0; *(uint32_t*)0x2000000c = 0xfffffffd; *(uint8_t*)0x20000010 = 7; *(uint8_t*)0x20000011 = 0; *(uint16_t*)0x20000012 = 0; *(uint16_t*)0x20000014 = 0xa; *(uint16_t*)0x20000016 = 4; memcpy((void*)0x20000018, "wpan3\000", 6); *(uint16_t*)0x20000020 = 8; *(uint16_t*)0x20000022 = 1; *(uint32_t*)0x20000024 = 0; *(uint16_t*)0x20000028 = 8; *(uint16_t*)0x2000002a = 5; *(uint32_t*)0x2000002c = 1; *(uint64_t*)0x200000c8 = 0x30; *(uint64_t*)0x20000118 = 1; *(uint64_t*)0x20000120 = 0; *(uint64_t*)0x20000128 = 0; *(uint32_t*)0x20000130 = 0; syscall(__NR_sendmsg, r[0], 0x20000100ul, 0ul); 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; *(uint64_t*)0x20000240 = 0; *(uint32_t*)0x20000248 = 0; *(uint64_t*)0x20000250 = 0x20000200; *(uint64_t*)0x20000200 = 0x200002c0; *(uint32_t*)0x200002c0 = 0x1e0; *(uint16_t*)0x200002c4 = r[3]; *(uint16_t*)0x200002c6 = 1; *(uint32_t*)0x200002c8 = 0; *(uint32_t*)0x200002cc = 0; *(uint8_t*)0x200002d0 = 0x1e; *(uint8_t*)0x200002d1 = 0; *(uint16_t*)0x200002d2 = 0; *(uint16_t*)0x200002d4 = 0xac; STORE_BY_BITMASK(uint16_t, , 0x200002d6, 0x24, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200002d7, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200002d7, 1, 7, 1); *(uint16_t*)0x200002d8 = 0xa0; STORE_BY_BITMASK(uint16_t, , 0x200002da, 3, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200002db, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200002db, 1, 7, 1); *(uint16_t*)0x200002dc = 8; *(uint16_t*)0x200002de = 1; *(uint32_t*)0x200002e0 = 3; *(uint16_t*)0x200002e4 = 0x40; STORE_BY_BITMASK(uint16_t, , 0x200002e6, 3, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200002e7, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200002e7, 1, 7, 1); *(uint16_t*)0x200002e8 = 0xc; *(uint16_t*)0x200002ea = 4; *(uint64_t*)0x200002ec = 0xaaaaaaaaaaaa0302; *(uint16_t*)0x200002f4 = 6; *(uint16_t*)0x200002f6 = 1; *(uint16_t*)0x200002f8 = 2; *(uint16_t*)0x200002fc = 8; *(uint16_t*)0x200002fe = 2; *(uint32_t*)0x20000300 = 2; *(uint16_t*)0x20000304 = 6; *(uint16_t*)0x20000306 = 1; *(uint16_t*)0x20000308 = 1; *(uint16_t*)0x2000030c = 6; *(uint16_t*)0x2000030e = 3; *(uint16_t*)0x20000310 = 0xaaa0; *(uint16_t*)0x20000314 = 6; *(uint16_t*)0x20000316 = 1; *(uint16_t*)0x20000318 = -1; *(uint16_t*)0x2000031c = 6; *(uint16_t*)0x2000031e = 1; *(uint16_t*)0x20000320 = 2; *(uint16_t*)0x20000324 = 0x4c; STORE_BY_BITMASK(uint16_t, , 0x20000326, 3, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000327, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000327, 1, 7, 1); *(uint16_t*)0x20000328 = 8; *(uint16_t*)0x2000032a = 2; *(uint32_t*)0x2000032c = 1; *(uint16_t*)0x20000330 = 8; *(uint16_t*)0x20000332 = 2; *(uint32_t*)0x20000334 = 2; *(uint16_t*)0x20000338 = 0xc; *(uint16_t*)0x2000033a = 4; *(uint64_t*)0x2000033c = 0xaaaaaaaaaaaa0102; *(uint16_t*)0x20000344 = 0xc; *(uint16_t*)0x20000346 = 4; *(uint64_t*)0x20000348 = 0xaaaaaaaaaaaa0002; *(uint16_t*)0x20000350 = 0xc; *(uint16_t*)0x20000352 = 4; *(uint64_t*)0x20000354 = 0; *(uint16_t*)0x2000035c = 0xc; *(uint16_t*)0x2000035e = 4; *(uint64_t*)0x20000360 = 0xaaaaaaaaaaaa0002; *(uint16_t*)0x20000368 = 8; *(uint16_t*)0x2000036a = 2; *(uint32_t*)0x2000036c = 2; *(uint16_t*)0x20000370 = 8; *(uint16_t*)0x20000372 = 1; *(uint32_t*)0x20000374 = 1; *(uint16_t*)0x20000378 = 8; STORE_BY_BITMASK(uint16_t, , 0x2000037a, 3, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000037b, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000037b, 1, 7, 1); *(uint16_t*)0x2000037c = 4; STORE_BY_BITMASK(uint16_t, , 0x2000037e, 3, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000037f, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000037f, 1, 7, 1); *(uint16_t*)0x20000380 = 0x2c; STORE_BY_BITMASK(uint16_t, , 0x20000382, 0x24, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000383, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000383, 1, 7, 1); *(uint16_t*)0x20000384 = 8; *(uint16_t*)0x20000386 = 1; *(uint32_t*)0x20000388 = 7; *(uint16_t*)0x2000038c = 8; *(uint16_t*)0x2000038e = 1; *(uint32_t*)0x20000390 = 6; *(uint16_t*)0x20000394 = 8; *(uint16_t*)0x20000396 = 1; *(uint32_t*)0x20000398 = 0xbdbc; *(uint16_t*)0x2000039c = 8; *(uint16_t*)0x2000039e = 1; *(uint32_t*)0x200003a0 = 0x400; *(uint16_t*)0x200003a4 = 8; *(uint16_t*)0x200003a6 = 1; *(uint32_t*)0x200003a8 = 0x1f; *(uint16_t*)0x200003ac = 0xc; *(uint16_t*)0x200003ae = 6; *(uint64_t*)0x200003b0 = 0; *(uint16_t*)0x200003b8 = 0xc; *(uint16_t*)0x200003ba = 6; *(uint64_t*)0x200003bc = 2; *(uint16_t*)0x200003c4 = 8; *(uint16_t*)0x200003c6 = 3; *(uint32_t*)0x200003c8 = 0; *(uint16_t*)0x200003cc = 0x20; STORE_BY_BITMASK(uint16_t, , 0x200003ce, 0x24, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200003cf, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200003cf, 1, 7, 1); *(uint16_t*)0x200003d0 = 8; *(uint16_t*)0x200003d2 = 1; *(uint32_t*)0x200003d4 = 0x8000; *(uint16_t*)0x200003d8 = 0xc; *(uint16_t*)0x200003da = 2; *(uint64_t*)0x200003dc = 0xaaaaaaaaaaaa0002; *(uint16_t*)0x200003e4 = 8; *(uint16_t*)0x200003e6 = 1; *(uint32_t*)0x200003e8 = 9; *(uint16_t*)0x200003ec = 0xb4; STORE_BY_BITMASK(uint16_t, , 0x200003ee, 0x24, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200003ef, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200003ef, 1, 7, 1); *(uint16_t*)0x200003f0 = 0x40; STORE_BY_BITMASK(uint16_t, , 0x200003f2, 3, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200003f3, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200003f3, 1, 7, 1); *(uint16_t*)0x200003f4 = 0xc; *(uint16_t*)0x200003f6 = 5; *(uint64_t*)0x200003f8 = 0x2b53; *(uint16_t*)0x20000400 = 8; *(uint16_t*)0x20000402 = 1; *(uint32_t*)0x20000404 = 2; *(uint16_t*)0x20000408 = 0x18; STORE_BY_BITMASK(uint16_t, , 0x2000040a, 3, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000040b, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000040b, 1, 7, 1); *(uint16_t*)0x2000040c = 6; *(uint16_t*)0x2000040e = 1; *(uint16_t*)0x20000410 = 1; *(uint16_t*)0x20000414 = 0xc; *(uint16_t*)0x20000416 = 4; *(uint64_t*)0x20000418 = 0xaaaaaaaaaaaa0202; *(uint16_t*)0x20000420 = 5; *(uint16_t*)0x20000422 = 2; *(uint8_t*)0x20000424 = 0; *(uint16_t*)0x20000428 = 5; *(uint16_t*)0x2000042a = 2; *(uint8_t*)0x2000042c = 0; *(uint16_t*)0x20000430 = 0xc; *(uint16_t*)0x20000432 = 2; *(uint64_t*)0x20000434 = 0xaaaaaaaaaaaa0102; *(uint16_t*)0x2000043c = 0x34; STORE_BY_BITMASK(uint16_t, , 0x2000043e, 3, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000043f, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000043f, 1, 7, 1); *(uint16_t*)0x20000440 = 0xc; *(uint16_t*)0x20000442 = 5; *(uint64_t*)0x20000444 = 0x3620054e; *(uint16_t*)0x2000044c = 8; *(uint16_t*)0x2000044e = 1; *(uint32_t*)0x20000450 = 2; *(uint16_t*)0x20000454 = 8; *(uint16_t*)0x20000456 = 4; *(uint32_t*)0x20000458 = 0xfffffff8; *(uint16_t*)0x2000045c = 0xc; *(uint16_t*)0x2000045e = 5; *(uint64_t*)0x20000460 = 4; *(uint16_t*)0x20000468 = 5; *(uint16_t*)0x2000046a = 2; *(uint8_t*)0x2000046c = 0; *(uint16_t*)0x20000470 = 0xc; *(uint16_t*)0x20000472 = 2; *(uint64_t*)0x20000474 = 0xaaaaaaaaaaaa0202; *(uint16_t*)0x2000047c = 0xc; *(uint16_t*)0x2000047e = 2; *(uint64_t*)0x20000480 = 0; *(uint16_t*)0x20000488 = 8; *(uint16_t*)0x2000048a = 1; *(uint32_t*)0x2000048c = 0xffffff88; *(uint16_t*)0x20000490 = 8; *(uint16_t*)0x20000492 = 1; *(uint32_t*)0x20000494 = 4; *(uint16_t*)0x20000498 = 8; *(uint16_t*)0x2000049a = 1; *(uint32_t*)0x2000049c = 2; *(uint64_t*)0x20000208 = 0x1e0; *(uint64_t*)0x20000258 = 1; *(uint64_t*)0x20000260 = 0; *(uint64_t*)0x20000268 = 0; *(uint32_t*)0x20000270 = 0x20048815; syscall(__NR_sendmsg, r[2], 0x20000240ul, 0x40800ul); return 0; }