// https://syzkaller.appspot.com/bug?id=d204aaca3ac260c553e053c566b529f350ea6454 // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #define BITMASK_LEN(type, bf_len) (type)((1ull << (bf_len)) - 1) #define BITMASK_LEN_OFF(type, bf_off, bf_len) \ (type)(BITMASK_LEN(type, (bf_len)) << (bf_off)) #define STORE_BY_BITMASK(type, addr, val, bf_off, bf_len) \ if ((bf_off) == 0 && (bf_len) == 0) { \ *(type*)(addr) = (type)(val); \ } else { \ type new_val = *(type*)(addr); \ new_val &= ~BITMASK_LEN_OFF(type, (bf_off), (bf_len)); \ new_val |= ((type)(val)&BITMASK_LEN(type, (bf_len))) << (bf_off); \ *(type*)(addr) = new_val; \ } struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i; for (i = 0; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += (uint16_t)data[length - 1]; while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static uintptr_t syz_fuse_mount(uintptr_t a0, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5) { uint64_t target = a0; uint64_t mode = a1; uint64_t uid = a2; uint64_t gid = a3; uint64_t maxread = a4; uint64_t flags = a5; int fd = open("/dev/fuse", O_RDWR); if (fd == -1) return fd; char buf[1024]; sprintf(buf, "fd=%d,user_id=%ld,group_id=%ld,rootmode=0%o", fd, (long)uid, (long)gid, (unsigned)mode & ~3u); if (maxread != 0) sprintf(buf + strlen(buf), ",max_read=%ld", (long)maxread); if (mode & 1) strcat(buf, ",default_permissions"); if (mode & 2) strcat(buf, ",allow_other"); syscall(SYS_mount, "", target, "fuse", flags, buf); return fd; } static void execute_one(); extern unsigned long long procid; void loop() { while (1) { execute_one(); } } uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void execute_one() { long res = 0; res = syscall(__NR_socket, 0xa, 0x80803, 0x2f); if (res != -1) r[0] = res; res = syscall(__NR_socket, 0x10, 3, 6); if (res != -1) r[1] = res; *(uint16_t*)0x200004c0 = 0x10; *(uint16_t*)0x200004c2 = 0; *(uint32_t*)0x200004c4 = 0; *(uint32_t*)0x200004c8 = 1; syscall(__NR_bind, r[1], 0x200004c0, 0xc); *(uint8_t*)0x200003c0 = 0xac; *(uint8_t*)0x200003c1 = 0x14; *(uint8_t*)0x200003c2 = 0x14; *(uint8_t*)0x200003c3 = 0; *(uint64_t*)0x200003d0 = htobe64(0); *(uint64_t*)0x200003d8 = htobe64(1); *(uint16_t*)0x200003e0 = htobe16(0); *(uint16_t*)0x200003e2 = htobe16(0); *(uint16_t*)0x200003e4 = htobe16(0); *(uint16_t*)0x200003e6 = htobe16(0); *(uint16_t*)0x200003e8 = 0xa; *(uint8_t*)0x200003ea = 0; *(uint8_t*)0x200003eb = 0; *(uint8_t*)0x200003ec = 0; *(uint32_t*)0x200003f0 = 0; *(uint32_t*)0x200003f4 = 0; *(uint64_t*)0x200003f8 = 0; *(uint64_t*)0x20000400 = 0; *(uint64_t*)0x20000408 = 0; *(uint64_t*)0x20000410 = 0; *(uint64_t*)0x20000418 = 0; *(uint64_t*)0x20000420 = 0; *(uint64_t*)0x20000428 = 0; *(uint64_t*)0x20000430 = 0; *(uint64_t*)0x20000438 = 0; *(uint64_t*)0x20000440 = 0; *(uint64_t*)0x20000448 = 0; *(uint64_t*)0x20000450 = 0; *(uint32_t*)0x20000458 = 0; *(uint32_t*)0x2000045c = 0; *(uint8_t*)0x20000460 = 1; *(uint8_t*)0x20000461 = 0; *(uint8_t*)0x20000462 = 0; *(uint8_t*)0x20000463 = 0; *(uint64_t*)0x20000468 = htobe64(0); *(uint64_t*)0x20000470 = htobe64(1); *(uint32_t*)0x20000478 = htobe32(0); *(uint8_t*)0x2000047c = 0x2b; *(uint16_t*)0x20000480 = 0; *(uint8_t*)0x20000484 = 0xac; *(uint8_t*)0x20000485 = 0x14; *(uint8_t*)0x20000486 = 0x14; *(uint8_t*)0x20000487 = 0xbb; *(uint32_t*)0x20000494 = 0; *(uint8_t*)0x20000498 = 0; *(uint8_t*)0x20000499 = 0; *(uint8_t*)0x2000049a = 0x90; *(uint32_t*)0x2000049c = 0; *(uint32_t*)0x200004a0 = 0; *(uint32_t*)0x200004a4 = 0; syscall(__NR_setsockopt, r[0], 0x29, 0x23, 0x200003c0, 0xe8); *(uint16_t*)0x200000c0 = 0xa; *(uint16_t*)0x200000c2 = htobe16(0); *(uint32_t*)0x200000c4 = 0; *(uint8_t*)0x200000c8 = 0; *(uint8_t*)0x200000c9 = 0; *(uint8_t*)0x200000ca = 0; *(uint8_t*)0x200000cb = 0; *(uint8_t*)0x200000cc = 0; *(uint8_t*)0x200000cd = 0; *(uint8_t*)0x200000ce = 0; *(uint8_t*)0x200000cf = 0; *(uint8_t*)0x200000d0 = 0; *(uint8_t*)0x200000d1 = 0; *(uint8_t*)0x200000d2 = 0; *(uint8_t*)0x200000d3 = 0; *(uint8_t*)0x200000d4 = 0; *(uint8_t*)0x200000d5 = 0; *(uint8_t*)0x200000d6 = 0; *(uint8_t*)0x200000d7 = 0; *(uint32_t*)0x200000d8 = 0; syscall(__NR_connect, r[0], 0x200000c0, 0x1c); *(uint8_t*)0x20000040 = 1; *(uint8_t*)0x20000041 = 0x80; *(uint8_t*)0x20000042 = 0xc2; *(uint8_t*)0x20000043 = 0; *(uint8_t*)0x20000044 = 0; *(uint8_t*)0x20000045 = 0; *(uint8_t*)0x20000046 = 0xaa; *(uint8_t*)0x20000047 = 0xaa; *(uint8_t*)0x20000048 = 0xaa; *(uint8_t*)0x20000049 = 0xaa; *(uint8_t*)0x2000004a = 0; *(uint8_t*)0x2000004b = 0; *(uint16_t*)0x2000004c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, 0x2000004e, 5, 0, 4); STORE_BY_BITMASK(uint8_t, 0x2000004e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, 0x2000004f, 0, 0, 2); STORE_BY_BITMASK(uint8_t, 0x2000004f, 0, 2, 6); *(uint16_t*)0x20000050 = htobe16(0x1c); *(uint16_t*)0x20000052 = htobe16(0); *(uint16_t*)0x20000054 = htobe16(0); *(uint8_t*)0x20000056 = 0; *(uint8_t*)0x20000057 = 2; *(uint16_t*)0x20000058 = 0; *(uint32_t*)0x2000005a = htobe32(0); *(uint32_t*)0x2000005e = htobe32(0xe0000001); *(uint8_t*)0x20000062 = 0; *(uint8_t*)0x20000063 = 0; *(uint16_t*)0x20000064 = 0; *(uint32_t*)0x20000066 = htobe32(0); *(uint32_t*)0x203b5000 = 0; *(uint32_t*)0x203b5004 = 0; *(uint32_t*)0x203b5008 = 0; *(uint32_t*)0x203b500c = 0; *(uint32_t*)0x203b5010 = 0; *(uint32_t*)0x203b5014 = 0; struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x20000062, 8); *(uint16_t*)0x20000064 = csum_inet_digest(&csum_1); struct csum_inet csum_2; csum_inet_init(&csum_2); csum_inet_update(&csum_2, (const uint8_t*)0x2000004e, 20); *(uint16_t*)0x20000058 = csum_inet_digest(&csum_2); memcpy((void*)0x200003c0, "./file0", 8); syscall(__NR_mkdir, 0x200003c0, 0); memcpy((void*)0x20000180, "./file0", 8); syz_fuse_mount(0x20000180, 0x4000, 0, 0, 0, 0); } int main() { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); for (;;) { loop(); } }