blob: aa3c50cff1f7b92654980cb3c2e3c5112dec1b25 [file] [log] [blame]
// KMSAN: uninit-value in __x64_sys_sendmmsg
// https://syzkaller.appspot.com/bug?id=8668085845db2da92973c0505216c034ef56f8ce
// status:invalid
// autogenerated by syzkaller (http://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <stdint.h>
#include <string.h>
#include <sys/syscall.h>
#include <unistd.h>
#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;
}
uint64_t r[1] = {0xffffffffffffffff};
void loop()
{
long res = 0;
res = syscall(__NR_socket, 2, 0x4000000000000001, 0);
if (res != -1)
r[0] = res;
*(uint16_t*)0x20000080 = 2;
*(uint16_t*)0x20000082 = htobe16(0x4e23);
*(uint32_t*)0x20000084 = htobe32(-1);
*(uint8_t*)0x20000088 = 0;
*(uint8_t*)0x20000089 = 0;
*(uint8_t*)0x2000008a = 0;
*(uint8_t*)0x2000008b = 0;
*(uint8_t*)0x2000008c = 0;
*(uint8_t*)0x2000008d = 0;
*(uint8_t*)0x2000008e = 0;
*(uint8_t*)0x2000008f = 0;
syscall(__NR_bind, r[0], 0x20000080, 0x10);
*(uint16_t*)0x20003e00 = 2;
*(uint16_t*)0x20003e02 = htobe16(0x4e23);
*(uint32_t*)0x20003e04 = htobe32(0);
*(uint8_t*)0x20003e08 = 0;
*(uint8_t*)0x20003e09 = 0;
*(uint8_t*)0x20003e0a = 0;
*(uint8_t*)0x20003e0b = 0;
*(uint8_t*)0x20003e0c = 0;
*(uint8_t*)0x20003e0d = 0;
*(uint8_t*)0x20003e0e = 0;
*(uint8_t*)0x20003e0f = 0;
syscall(__NR_sendto, r[0], 0x20000140, 0, 0x200007ff, 0x20003e00, 0x10);
*(uint64_t*)0x20003840 = 0x20000140;
*(uint16_t*)0x20000140 = 0x1d;
*(uint32_t*)0x20000144 = 0;
*(uint32_t*)0x20000148 = 0;
*(uint32_t*)0x2000014c = 0;
*(uint32_t*)0x20003848 = 0x80;
*(uint64_t*)0x20003850 = 0x20000500;
*(uint64_t*)0x20003858 = 0;
*(uint64_t*)0x20003860 = 0x20000580;
*(uint64_t*)0x20003868 = 0;
*(uint32_t*)0x20003870 = 0;
*(uint32_t*)0x20003878 = 0;
*(uint64_t*)0x20003880 = 0x20000680;
*(uint16_t*)0x20000680 = 2;
*(uint16_t*)0x20000682 = htobe16(0);
*(uint32_t*)0x20000684 = htobe32(0x7f000001);
*(uint8_t*)0x20000688 = 0;
*(uint8_t*)0x20000689 = 0;
*(uint8_t*)0x2000068a = 0;
*(uint8_t*)0x2000068b = 0;
*(uint8_t*)0x2000068c = 0;
*(uint8_t*)0x2000068d = 0;
*(uint8_t*)0x2000068e = 0;
*(uint8_t*)0x2000068f = 0;
*(uint32_t*)0x20003888 = 0x80;
*(uint64_t*)0x20003890 = 0x20000d40;
*(uint64_t*)0x20003898 = 0;
*(uint64_t*)0x200038a0 = 0x20006fc0;
*(uint64_t*)0x20006fc0 = 0x10;
*(uint32_t*)0x20006fc8 = 1;
*(uint32_t*)0x20006fcc = 0xdbd2;
*(uint64_t*)0x200038a8 = 0x10;
*(uint32_t*)0x200038b0 = 0;
*(uint32_t*)0x200038b8 = 0;
syscall(__NR_sendmmsg, r[0], 0x20003840, 2, 0);
*(uint8_t*)0x20000080 = 0xaa;
*(uint8_t*)0x20000081 = 0xaa;
*(uint8_t*)0x20000082 = 0xaa;
*(uint8_t*)0x20000083 = 0xaa;
*(uint8_t*)0x20000084 = 0xaa;
*(uint8_t*)0x20000085 = 0xaa;
*(uint8_t*)0x20000086 = 0xaa;
*(uint8_t*)0x20000087 = 0xaa;
*(uint8_t*)0x20000088 = 0xaa;
*(uint8_t*)0x20000089 = 0xaa;
*(uint8_t*)0x2000008a = 0xaa;
*(uint8_t*)0x2000008b = 0xbb;
*(uint16_t*)0x2000008c = htobe16(0x800);
STORE_BY_BITMASK(uint8_t, 0x2000008e, 5, 0, 4);
STORE_BY_BITMASK(uint8_t, 0x2000008e, 4, 4, 4);
STORE_BY_BITMASK(uint8_t, 0x2000008f, 0, 0, 2);
STORE_BY_BITMASK(uint8_t, 0x2000008f, 0, 2, 6);
*(uint16_t*)0x20000090 = htobe16(0x5c);
*(uint16_t*)0x20000092 = htobe16(0);
*(uint16_t*)0x20000094 = htobe16(0);
*(uint8_t*)0x20000096 = 0;
*(uint8_t*)0x20000097 = 1;
*(uint16_t*)0x20000098 = 0;
*(uint8_t*)0x2000009a = 0xac;
*(uint8_t*)0x2000009b = 0x14;
*(uint8_t*)0x2000009c = 0x14;
*(uint8_t*)0x2000009d = 0xbb;
*(uint8_t*)0x2000009e = 0xac;
*(uint8_t*)0x2000009f = 0x14;
*(uint8_t*)0x200000a0 = 0x14;
*(uint8_t*)0x200000a1 = 0x11;
*(uint8_t*)0x200000a2 = 5;
*(uint8_t*)0x200000a3 = 4;
*(uint16_t*)0x200000a4 = 0;
*(uint8_t*)0x200000a6 = 0;
*(uint8_t*)0x200000a7 = 0;
*(uint16_t*)0x200000a8 = 0;
STORE_BY_BITMASK(uint8_t, 0x200000aa, 0x10, 0, 4);
STORE_BY_BITMASK(uint8_t, 0x200000aa, 4, 4, 4);
STORE_BY_BITMASK(uint8_t, 0x200000ab, 0, 0, 2);
STORE_BY_BITMASK(uint8_t, 0x200000ab, 0, 2, 6);
*(uint16_t*)0x200000ac = htobe16(0);
*(uint16_t*)0x200000ae = htobe16(0);
*(uint16_t*)0x200000b0 = htobe16(0);
*(uint8_t*)0x200000b2 = 0;
*(uint8_t*)0x200000b3 = 4;
*(uint16_t*)0x200000b4 = htobe16(0);
*(uint8_t*)0x200000b6 = 0xac;
*(uint8_t*)0x200000b7 = 0x14;
*(uint8_t*)0x200000b8 = 0x14;
*(uint8_t*)0x200000b9 = 0xaa;
*(uint8_t*)0x200000ba = 0xac;
*(uint8_t*)0x200000bb = 0x14;
*(uint8_t*)0x200000bc = 0x14;
*(uint8_t*)0x200000bd = 0;
*(uint8_t*)0x200000be = 0x44;
*(uint8_t*)0x200000bf = 0x2c;
*(uint8_t*)0x200000c0 = 0;
STORE_BY_BITMASK(uint8_t, 0x200000c1, 0, 0, 4);
STORE_BY_BITMASK(uint8_t, 0x200000c1, 0, 4, 4);
*(uint32_t*)0x200000c2 = htobe32(0);
*(uint32_t*)0x200000c6 = htobe32(0);
*(uint32_t*)0x200000ca = htobe32(0x7f000001);
*(uint32_t*)0x200000ce = htobe32(0);
*(uint32_t*)0x200000d2 = htobe32(-1);
*(uint32_t*)0x200000d6 = htobe32(0);
*(uint32_t*)0x200000da = htobe32(0xe0000001);
*(uint32_t*)0x200000de = htobe32(0);
*(uint8_t*)0x200000e2 = 0xac;
*(uint8_t*)0x200000e3 = 0x14;
*(uint8_t*)0x200000e4 = 0x14;
*(uint8_t*)0x200000e5 = 0;
*(uint32_t*)0x200000e6 = htobe32(0);
*(uint32_t*)0x20000000 = 0;
*(uint32_t*)0x20000004 = 0;
*(uint32_t*)0x20000008 = 0;
*(uint32_t*)0x2000000c = 0;
*(uint32_t*)0x20000010 = 0xe2d;
*(uint32_t*)0x20000014 = 0;
struct csum_inet csum_1;
csum_inet_init(&csum_1);
csum_inet_update(&csum_1, (const uint8_t*)0x200000a2, 72);
*(uint16_t*)0x200000a4 = csum_inet_digest(&csum_1);
struct csum_inet csum_2;
csum_inet_init(&csum_2);
csum_inet_update(&csum_2, (const uint8_t*)0x2000008e, 20);
*(uint16_t*)0x20000098 = csum_inet_digest(&csum_2);
*(uint64_t*)0x20005e00 = 0x20000440;
*(uint16_t*)0x20000440 = 0;
*(uint8_t*)0x20000442 = 0;
*(uint32_t*)0x20000444 = 0;
*(uint32_t*)0x20005e08 = 0x6e;
*(uint64_t*)0x20005e10 = 0x200016c0;
*(uint64_t*)0x200016c0 = 0x200004c0;
*(uint64_t*)0x200016c8 = 0;
*(uint64_t*)0x20005e18 = 1;
*(uint64_t*)0x20005e20 = 0x20001700;
*(uint64_t*)0x20005e28 = 0;
*(uint32_t*)0x20005e30 = 0;
syscall(__NR_sendmmsg, -1, 0x20005e00, 1, 0);
}
int main()
{
syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
loop();
return 0;
}