| // KMSAN: uninit-value in ebt_stp_mt_check |
| // https://syzkaller.appspot.com/bug?id=34122092087544972a5aa5ea064e5d1c9700f873 |
| // status:fixed |
| // autogenerated by syzkaller (http://github.com/google/syzkaller) |
| |
| #define _GNU_SOURCE |
| #include <endian.h> |
| #include <linux/futex.h> |
| #include <pthread.h> |
| #include <stdint.h> |
| #include <stdlib.h> |
| #include <string.h> |
| #include <sys/syscall.h> |
| #include <unistd.h> |
| |
| struct thread_t { |
| int created, running, call; |
| pthread_t th; |
| }; |
| |
| static struct thread_t threads[16]; |
| static void execute_call(int call); |
| static int running; |
| static int collide; |
| |
| static void* thr(void* arg) |
| { |
| struct thread_t* th = (struct thread_t*)arg; |
| for (;;) { |
| while (!__atomic_load_n(&th->running, __ATOMIC_ACQUIRE)) |
| syscall(SYS_futex, &th->running, FUTEX_WAIT, 0, 0); |
| execute_call(th->call); |
| __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); |
| __atomic_store_n(&th->running, 0, __ATOMIC_RELEASE); |
| syscall(SYS_futex, &th->running, FUTEX_WAKE); |
| } |
| return 0; |
| } |
| |
| static void execute(int num_calls) |
| { |
| int call, thread; |
| running = 0; |
| for (call = 0; call < num_calls; call++) { |
| for (thread = 0; thread < sizeof(threads) / sizeof(threads[0]); thread++) { |
| struct thread_t* th = &threads[thread]; |
| if (!th->created) { |
| th->created = 1; |
| pthread_attr_t attr; |
| pthread_attr_init(&attr); |
| pthread_attr_setstacksize(&attr, 128 << 10); |
| pthread_create(&th->th, &attr, thr, th); |
| } |
| if (!__atomic_load_n(&th->running, __ATOMIC_ACQUIRE)) { |
| th->call = call; |
| __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); |
| __atomic_store_n(&th->running, 1, __ATOMIC_RELEASE); |
| syscall(SYS_futex, &th->running, FUTEX_WAKE); |
| if (collide && call % 2) |
| break; |
| struct timespec ts; |
| ts.tv_sec = 0; |
| ts.tv_nsec = 20 * 1000 * 1000; |
| syscall(SYS_futex, &th->running, FUTEX_WAIT, 1, &ts); |
| if (running) |
| usleep((call == num_calls - 1) ? 10000 : 1000); |
| break; |
| } |
| } |
| } |
| } |
| |
| uint64_t r[1] = {0xffffffffffffffff}; |
| void execute_call(int call) |
| { |
| long res; |
| switch (call) { |
| case 0: |
| res = syscall(__NR_socket, 2, 6, 0); |
| if (res != -1) |
| r[0] = res; |
| break; |
| case 1: |
| memcpy((void*)0x200008c0, "\x62\x72\x6f\x75\x74\x65\x03\xe8\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00", |
| 32); |
| *(uint32_t*)0x200008e0 = 0x20; |
| *(uint32_t*)0x200008e4 = 2; |
| *(uint32_t*)0x200008e8 = 0x2e0; |
| *(uint64_t*)0x200008f0 = 0; |
| *(uint64_t*)0x200008f8 = 0; |
| *(uint64_t*)0x20000900 = 0; |
| *(uint64_t*)0x20000908 = 0; |
| *(uint64_t*)0x20000910 = 0; |
| *(uint64_t*)0x20000918 = 0x20000080; |
| *(uint32_t*)0x20000920 = 0; |
| *(uint64_t*)0x20000928 = 0x20000040; |
| *(uint64_t*)0x20000930 = 0x20000080; |
| *(uint32_t*)0x20000080 = 0; |
| memcpy((void*)0x20000084, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00", |
| 32); |
| *(uint32_t*)0x200000a4 = 0; |
| *(uint32_t*)0x200000a8 = 0xfffffffe; |
| *(uint32_t*)0x200000ac = 2; |
| *(uint32_t*)0x200000b0 = 0x11; |
| *(uint32_t*)0x200000b4 = 0x10; |
| *(uint16_t*)0x200000b8 = htobe16(0x986d); |
| memcpy((void*)0x200000ba, |
| "\x62\x70\x71\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", |
| 16); |
| memcpy((void*)0x200000ca, |
| "\x76\x65\x74\x68\x30\x5f\x74\x6f\x5f\x62\x6f\x6e\x64\x00\x00\x00", |
| 16); |
| memcpy((void*)0x200000da, "veth1_to_bridge", 16); |
| memcpy((void*)0x200000ea, |
| "\x62\x6f\x6e\x64\x5f\x73\x6c\x61\x76\x65\x5f\x30\x00\x00\x00\x00", |
| 16); |
| *(uint8_t*)0x200000fa = 0xaa; |
| *(uint8_t*)0x200000fb = 0xaa; |
| *(uint8_t*)0x200000fc = 0xaa; |
| *(uint8_t*)0x200000fd = 0xaa; |
| *(uint8_t*)0x200000fe = 0xaa; |
| *(uint8_t*)0x200000ff = 0xbb; |
| *(uint8_t*)0x20000100 = -1; |
| *(uint8_t*)0x20000101 = -1; |
| *(uint8_t*)0x20000102 = -1; |
| *(uint8_t*)0x20000103 = 0; |
| *(uint8_t*)0x20000104 = -1; |
| *(uint8_t*)0x20000105 = -1; |
| memcpy((void*)0x20000106, "\x30\x78\xf6\xc9\x62\xdb", 6); |
| *(uint8_t*)0x2000010c = -1; |
| *(uint8_t*)0x2000010d = -1; |
| *(uint8_t*)0x2000010e = -1; |
| *(uint8_t*)0x2000010f = -1; |
| *(uint8_t*)0x20000110 = 0; |
| *(uint8_t*)0x20000111 = -1; |
| *(uint32_t*)0x20000114 = 0xe0; |
| *(uint32_t*)0x20000118 = 0x110; |
| *(uint32_t*)0x2000011c = 0x140; |
| memcpy((void*)0x20000120, "\x73\x74\x70\x00\x00\x00\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00", |
| 32); |
| *(uint32_t*)0x20000140 = 0x48; |
| *(uint8_t*)0x20000148 = 7; |
| *(uint8_t*)0x2000014c = 7; |
| *(uint16_t*)0x2000014e = 0; |
| *(uint16_t*)0x20000150 = 0xfff; |
| *(uint8_t*)0x20000152 = 0xaa; |
| *(uint8_t*)0x20000153 = 0xaa; |
| *(uint8_t*)0x20000154 = 0xaa; |
| *(uint8_t*)0x20000155 = 0xaa; |
| *(uint8_t*)0x20000156 = 0xaa; |
| *(uint8_t*)0x20000157 = 0x19; |
| *(uint8_t*)0x20000158 = 0; |
| *(uint8_t*)0x20000159 = -1; |
| *(uint8_t*)0x2000015a = -1; |
| *(uint8_t*)0x2000015b = -1; |
| *(uint8_t*)0x2000015c = 0; |
| *(uint8_t*)0x2000015d = -1; |
| *(uint32_t*)0x20000160 = 0; |
| *(uint32_t*)0x20000164 = 0x80000001; |
| *(uint16_t*)0x20000168 = 0x6a; |
| *(uint16_t*)0x2000016a = 9; |
| *(uint8_t*)0x2000016c = 1; |
| *(uint8_t*)0x2000016d = 0x80; |
| *(uint8_t*)0x2000016e = 0xc2; |
| *(uint8_t*)0x2000016f = 0; |
| *(uint8_t*)0x20000170 = 0; |
| *(uint8_t*)0x20000171 = 1; |
| *(uint8_t*)0x20000172 = -1; |
| *(uint8_t*)0x20000173 = -1; |
| *(uint8_t*)0x20000174 = 0; |
| *(uint8_t*)0x20000175 = -1; |
| *(uint8_t*)0x20000176 = 0; |
| *(uint8_t*)0x20000177 = -1; |
| *(uint16_t*)0x20000178 = htobe16(0x4e22); |
| *(uint16_t*)0x2000017a = htobe16(0x4e21); |
| *(uint16_t*)0x2000017c = 0x101; |
| *(uint16_t*)0x2000017e = 0; |
| *(uint16_t*)0x20000180 = -1; |
| *(uint16_t*)0x20000182 = 0x3992; |
| *(uint16_t*)0x20000184 = 0xe4; |
| *(uint16_t*)0x20000186 = 0x40; |
| *(uint16_t*)0x20000188 = 0xdfae; |
| *(uint16_t*)0x2000018a = 8; |
| *(uint16_t*)0x2000018c = 9; |
| *(uint16_t*)0x2000018e = 0x40; |
| memcpy((void*)0x20000190, "\x72\x65\x64\x69\x72\x65\x63\x74\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00", |
| 32); |
| *(uint32_t*)0x200001b0 = 8; |
| *(uint32_t*)0x200001b8 = 0xfffffffc; |
| memcpy((void*)0x200001c0, "\x41\x55\x44\x49\x54\x00\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00", |
| 32); |
| *(uint32_t*)0x200001e0 = 8; |
| *(uint8_t*)0x200001e8 = 2; |
| *(uint32_t*)0x200001f0 = 3; |
| *(uint32_t*)0x200001f4 = 0x20; |
| *(uint16_t*)0x200001f8 = htobe16(0xfbff); |
| memcpy((void*)0x200001fa, |
| "\x6c\x6f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", |
| 16); |
| memcpy((void*)0x2000020a, |
| "\x73\x79\x7a\x5f\x74\x75\x6e\x00\x00\x00\x00\x00\x00\x00\x00\x00", |
| 16); |
| memcpy((void*)0x2000021a, |
| "\x76\x65\x74\x68\x31\x5f\x74\x6f\x5f\x62\x6f\x6e\x64\x00\x00\x00", |
| 16); |
| memcpy((void*)0x2000022a, |
| "\x76\x65\x74\x68\x31\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", |
| 16); |
| *(uint8_t*)0x2000023a = 0xaa; |
| *(uint8_t*)0x2000023b = 0xaa; |
| *(uint8_t*)0x2000023c = 0xaa; |
| *(uint8_t*)0x2000023d = 0xaa; |
| *(uint8_t*)0x2000023e = 0xaa; |
| *(uint8_t*)0x2000023f = 0x1f; |
| *(uint8_t*)0x20000240 = -1; |
| *(uint8_t*)0x20000241 = -1; |
| *(uint8_t*)0x20000242 = -1; |
| *(uint8_t*)0x20000243 = -1; |
| *(uint8_t*)0x20000244 = 0; |
| *(uint8_t*)0x20000245 = 0; |
| *(uint8_t*)0x20000246 = 0xaa; |
| *(uint8_t*)0x20000247 = 0xaa; |
| *(uint8_t*)0x20000248 = 0xaa; |
| *(uint8_t*)0x20000249 = 0xaa; |
| *(uint8_t*)0x2000024a = 0xaa; |
| *(uint8_t*)0x2000024b = 0xbb; |
| *(uint8_t*)0x2000024c = -1; |
| *(uint8_t*)0x2000024d = -1; |
| *(uint8_t*)0x2000024e = -1; |
| *(uint8_t*)0x2000024f = 0; |
| *(uint8_t*)0x20000250 = -1; |
| *(uint8_t*)0x20000251 = 0; |
| *(uint32_t*)0x20000254 = 0x70; |
| *(uint32_t*)0x20000258 = 0xd8; |
| *(uint32_t*)0x2000025c = 0x110; |
| memcpy((void*)0x20000260, "\x64\x6e\x61\x74\x00\x00\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00", |
| 32); |
| *(uint32_t*)0x20000280 = 0x10; |
| *(uint8_t*)0x20000288 = 1; |
| *(uint8_t*)0x20000289 = 0x80; |
| *(uint8_t*)0x2000028a = 0xc2; |
| *(uint8_t*)0x2000028b = 0; |
| *(uint8_t*)0x2000028c = 0; |
| *(uint8_t*)0x2000028d = 0xe; |
| *(uint32_t*)0x20000290 = 0xfffffffe; |
| memcpy((void*)0x20000298, "\x43\x4c\x41\x53\x53\x49\x46\x59\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00", |
| 32); |
| *(uint32_t*)0x200002b8 = 8; |
| *(uint32_t*)0x200002c0 = 0x10001; |
| memcpy((void*)0x200002c8, "\x6d\x61\x72\x6b\x00\x00\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00", |
| 32); |
| *(uint32_t*)0x200002e8 = 0x10; |
| *(uint64_t*)0x200002f0 = 0; |
| *(uint32_t*)0x200002f8 = 0xfffffffe; |
| *(uint32_t*)0x20000300 = 0; |
| memcpy((void*)0x20000304, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00", |
| 32); |
| *(uint32_t*)0x20000324 = 2; |
| *(uint32_t*)0x20000328 = 0xfffffffe; |
| *(uint32_t*)0x2000032c = 0; |
| *(uint32_t*)0x20000330 = 0; |
| memcpy((void*)0x20000334, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" |
| "\x00\x00\x00\x00\x00\x00\x00\x00", |
| 32); |
| *(uint32_t*)0x20000354 = 2; |
| *(uint32_t*)0x20000358 = -1; |
| *(uint32_t*)0x2000035c = 0; |
| syscall(__NR_setsockopt, r[0], 0, 0x80, 0x200008c0, 0x358); |
| break; |
| } |
| } |
| |
| void loop() |
| { |
| execute(2); |
| collide = 1; |
| execute(2); |
| } |
| |
| int main() |
| { |
| syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); |
| loop(); |
| return 0; |
| } |