From nobody Wed Jun 21 09:10:43 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QmHm33Lx3z4fkg0; Wed, 21 Jun 2023 09:10:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QmHm32vB5z3FcB; Wed, 21 Jun 2023 09:10:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687338643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jmruN4Iz9OfcaYM426NTXT82KRuma2nKgR7Mm2KinCI=; b=Fg1+8LeK1PfDcTOJ+rRWz2Wnk6fIKDtrBzjePWkOmNQsEwRAxCwqQiRLGzXAn9dqWpZD9m Ig11aEk70Hrbl18KR24SrEfboIF+qZL3pG7xOhsImkZKfkN9zOuDGu1bTZNzpv5FyjMDQI 7xjVW7Ph38k9pPckl20P83F/FLgz1YjHiSEkeq2wp+yUR7UXmAY7sxaMGQrWzEfg4dMY0F aGB+ijzJZo7E7/o85XvpOgkl35OLSoYn4zfp1wnW4+JnCCdcKQUwrgneyRASHWvvYUOMNR 9G5tElYGRI+fbb+tE1qsmk7vfAIuiayInw0E5VzHsvqa5eGO7aQhJuk3dKvL3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687338643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jmruN4Iz9OfcaYM426NTXT82KRuma2nKgR7Mm2KinCI=; b=Ce729Ui2Di6gpt5xkqJB2j3N3Bhs3DgHvN+mid5uDBiPd7B1GY2AFRZOCq8FGaadFC3lGJ VgYbMwS5bkNO3yVXAqFntehGO8XbA+BSqsddmpBkKdhentdkBdXdUMxsoEZhKSbe1LObwf nmT9UIrq8zbDZmyvXVJ19DNvlDX3CCh76aauPOmETkEc/F1OXq/vSk4B+rW+KMdc/eFxR8 cvW4tXTNV5q/13BJYi9ZFZWx47W93USaViQFkyEsM1NgpHfuNVHfddBX1nlVNuebuMMTWR fF1ktiKWNtyvwtt53m+s7VR0FvmocJeiqJDCKD0MrIzwv6KV7OX8EaQTY6CXvg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687338643; a=rsa-sha256; cv=none; b=FfXmdEtkgwx1Z9ieGHk2IWk8lEYn5m08xHk1rijbHElKMispUtgmrPiQbM304xVQTlR6G4 jAM63F2aH+bygWghdWJEk0R8zS106+o1Q8ApMiVX3c/yIyIIrlXkjt+WKPnbh3hzZheHsm vtu/VHAAm0mM89dOXSI4g2byT/2X8Wrjyjx6MG01oYTW32vdRf3cbdhoGXs8exrYJoRlop IdMFgJz/t6GJ1jdrllBFfxtfYK8cp64WUklldSDJiSt6PXHFXIxnDsGNHW9p+hfEodjmLK qrbY5zfGqmAj/UUqF+3huO7ZXZ5s9BGBbvQJh0NZse2Rs30fYxV56ixtaG6RtQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QmHm31zVZzZdX; Wed, 21 Jun 2023 09:10:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 35L9AhD8005989; Wed, 21 Jun 2023 09:10:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35L9AhdB005988; Wed, 21 Jun 2023 09:10:43 GMT (envelope-from git) Date: Wed, 21 Jun 2023 09:10:43 GMT Message-Id: <202306210910.35L9AhdB005988@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Peter Holm Subject: git: 83c701af5340 - main - stress2: Added two syzkaller reproducers List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pho X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 83c701af5340d2aa0a665498ad5a54f025c74c4c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by pho: URL: https://cgit.FreeBSD.org/src/commit/?id=83c701af5340d2aa0a665498ad5a54f025c74c4c commit 83c701af5340d2aa0a665498ad5a54f025c74c4c Author: Peter Holm AuthorDate: 2023-06-21 09:10:13 +0000 Commit: Peter Holm CommitDate: 2023-06-21 09:10:13 +0000 stress2: Added two syzkaller reproducers --- tools/test/stress2/misc/all.exclude | 2 + tools/test/stress2/misc/syzkaller66.sh | 156 +++++++++++++++++++++++++++++++++ tools/test/stress2/misc/syzkaller67.sh | 99 +++++++++++++++++++++ 3 files changed, 257 insertions(+) diff --git a/tools/test/stress2/misc/all.exclude b/tools/test/stress2/misc/all.exclude index 36ff8790a4c8..2560b22149d5 100644 --- a/tools/test/stress2/misc/all.exclude +++ b/tools/test/stress2/misc/all.exclude @@ -69,6 +69,8 @@ syzkaller31.sh panic: Bad tailq NEXT(0xfffffe01a0899430->tqh_last) != NULL 2022 syzkaller55.sh panic: Counter goes negative 20220525 syzkaller59.sh Page fault 20220625 syzkaller65.sh panic: in_pcblookup_hash_locked: invalid local address 20230318 +syzkaller66.sh panic: in_pcbconnect: inp is already connected 20230621 +syzkaller67.sh panic: ASan: Invalid access, 8-byte read at ... 20230621 truss3.sh WiP 20200915 # Test not to run for other reasons: diff --git a/tools/test/stress2/misc/syzkaller66.sh b/tools/test/stress2/misc/syzkaller66.sh new file mode 100755 index 000000000000..8d1e9afe6f6c --- /dev/null +++ b/tools/test/stress2/misc/syzkaller66.sh @@ -0,0 +1,156 @@ +#!/bin/sh + +# panic: in_pcbconnect: inp is already connected +# cpuid = 2 +# time = 1687326262 +# KDB: stack backtrace: +# db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe016e604b60 +# vpanic() at vpanic+0x150/frame 0xfffffe016e604bb0 +# panic() at panic+0x43/frame 0xfffffe016e604c10 +# in_pcbconnect_setup() at in_pcbconnect_setup/frame 0xfffffe016e604c60 +# tcp_connect() at tcp_connect+0xa3/frame 0xfffffe016e604ca0 +# tcp_usr_connect() at tcp_usr_connect+0xf3/frame 0xfffffe016e604d10 +# soconnectat() at soconnectat+0xaf/frame 0xfffffe016e604d60 +# kern_connectat() at kern_connectat+0xe1/frame 0xfffffe016e604dc0 +# sys_connect() at sys_connect+0x75/frame 0xfffffe016e604e00 +# amd64_syscall() at amd64_syscall+0x157/frame 0xfffffe016e604f30 +# fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe016e604f30 +# --- syscall (0, FreeBSD ELF64, syscall), rip = 0x823c81a6a, rsp = 0x8210ed3c8, rbp = 0x8210ed3e0 --- +# KDB: enter: panic +# [ thread pid 46907 tid 100356 ] +# Stopped at kdb_enter+0x32: movq $0,0xddf693(%rip) +# db> x/s version +# version: FreeBSD 14.0-CURRENT #0 main-n263725-1efa7dbc0798e: Wed Jun 21 09:13:50 CEST 2023 +# pho@mercat1.netperf.freebsd.org:/usr/src/sys/amd64/compile/PHO-KASAN\012 +# db> + +[ `uname -p` != "amd64" ] && exit 0 +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg +prog=$(basename "$0" .sh) +cat > /tmp/$prog.c < + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void kill_and_wait(int pid, int* status) +{ + kill(pid, SIGKILL); + while (waitpid(-1, status, 0) != pid) { + } +} + +static void sleep_ms(uint64_t ms) +{ + usleep(ms * 1000); +} + +static uint64_t current_time_ms(void) +{ + struct timespec ts; + if (clock_gettime(CLOCK_MONOTONIC, &ts)) + exit(1); + return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; +} + +static void execute_one(void); + +#define WAIT_FLAGS 0 + +static void loop(void) +{ + int iter __unused = 0; + for (;; iter++) { + int pid = fork(); + if (pid < 0) + exit(1); + if (pid == 0) { + execute_one(); + exit(0); + } + int status = 0; + uint64_t start = current_time_ms(); + for (;;) { + if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) + break; + sleep_ms(1); + if (current_time_ms() - start < 5000) + continue; + kill_and_wait(pid, &status); + break; + } + } +} + +uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff}; + +void execute_one(void) +{ + intptr_t res = 0; + res = syscall(SYS_socket, 2ul, 1ul, 0); + if (res != -1) + r[0] = res; + *(uint8_t*)0x200001c0 = 0x10; + *(uint8_t*)0x200001c1 = 2; + *(uint16_t*)0x200001c2 = htobe16(0x4e22); + *(uint32_t*)0x200001c4 = htobe32(0x7f000001); + memset((void*)0x200001c8, 0, 8); + syscall(SYS_bind, r[0], 0x200001c0ul, 0x10ul); + syscall(SYS_listen, r[0], 0); + res = syscall(SYS_socket, 2ul, 1ul, 0); + if (res != -1) + r[1] = res; + *(uint8_t*)0x200000c0 = 0x10; + *(uint8_t*)0x200000c1 = 2; + *(uint16_t*)0x200000c2 = htobe16(0x4e22); + *(uint32_t*)0x200000c4 = htobe32(0x7f000001); + memset((void*)0x200000c8, 0, 8); + syscall(SYS_connect, r[1], 0x200000c0ul, 0x10ul); + *(uint64_t*)0x20002580 = 0; + *(uint32_t*)0x20002588 = 0; + *(uint64_t*)0x20002590 = 0; + *(uint64_t*)0x20002598 = 0; + *(uint64_t*)0x200025a0 = 0; + *(uint64_t*)0x200025a8 = 0; + *(uint32_t*)0x200025b0 = 0; + syscall(SYS_sendmsg, r[1], 0x20002580ul, 0x20104ul); + syscall(SYS_shutdown, r[1], 1ul); + *(uint8_t*)0x200000c0 = 0x10; + *(uint8_t*)0x200000c1 = 2; + *(uint16_t*)0x200000c2 = htobe16(0x4e22); + *(uint32_t*)0x200000c4 = htobe32(0x7f000001); + memset((void*)0x200000c8, 0, 8); + syscall(SYS_connect, r[1], 0x200000c0ul, 0x10ul); +} +int main(void) +{ + syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x1012ul, -1, 0ul); + loop(); + return 0; +} +EOF +mycc -o /tmp/$prog -Wall -Wextra -O0 /tmp/$prog.c || exit 1 + +(cd /tmp; timeout 2m ./$prog) + +rm -rf /tmp/$prog /tmp/$prog.c /tmp/syzkaller.* +exit 0 diff --git a/tools/test/stress2/misc/syzkaller67.sh b/tools/test/stress2/misc/syzkaller67.sh new file mode 100755 index 000000000000..d5dc340442ae --- /dev/null +++ b/tools/test/stress2/misc/syzkaller67.sh @@ -0,0 +1,99 @@ +#!/bin/sh + +# panic: ASan: Invalid access, 8-byte read at 0xfffffe01fece46f8, StackMiddle(f2) +# cpuid = 4 +# time = 1687335671 +# KDB: stack backtrace: +# db_trace_self_wrapper() at db_trace_self_wrapper+0xa5/frame 0xfffffe01fece42f0 +# kdb_backtrace() at kdb_backtrace+0xc7/frame 0xfffffe01fece4450 +# vpanic() at vpanic+0x1d7/frame 0xfffffe01fece4510 +# panic() at panic+0xb5/frame 0xfffffe01fece45e0 +# kasan_report() at kasan_report+0xdc/frame 0xfffffe01fece46b0 +# __cap_rights_is_set() at __cap_rights_is_set+0x186/frame 0xfffffe01fece47d0 +# fget_fcntl() at fget_fcntl+0xd7/frame 0xfffffe01fece48d0 +# kern_fcntl() at kern_fcntl+0x602/frame 0xfffffe01fece4c10 +# kern_fcntl_freebsd() at kern_fcntl_freebsd+0x244/frame 0xfffffe01fece4d30 +# ia32_syscall() at ia32_syscall+0x32a/frame 0xfffffe01fece4f30 +# int0x80_syscall_common() at int0x80_syscall_common+0x9c/frame 0xffffdb38 +# KDB: enter: panic +# [ thread pid 4224 tid 100231 ] +# Stopped at kdb_enter+0x34: movq $0,0x1e3f7c1(%rip) +# db> x/s version +# version: FreeBSD 14.0-CURRENT #0 main-n263725-1efa7dbc0798e: Wed Jun 21 09:13:50 CEST 2023 +# pho@mercat1.netperf.freebsd.org:/usr/src/sys/amd64/compile/PHO-KASAN +# db> + +uname -p | grep -Eq "amd64|i386" || exit 0 +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg +prog=$(basename "$0" .sh) +cat > /tmp/$prog.c < +#include +#include +#include +#include +#include +#include +#include +#include +#include + +uint64_t r[5] = {0x0, 0x0, 0x0, 0x0, 0x0}; + +int main(void) +{ + syscall(SYS_mmap, 0x10000000, 0x1000000, 7, 0x1012, -1, 0); + intptr_t res = 0; + syscall(SYS_munmap, 0x10ffa000, 0x3000); + syscall(SYS_mmap, 0x10ffd000, 0x1000, 4, 0x1010, -1, 0); + syscall(SYS_mmap, 0x10ffc000, 0x1000, 0, 0x1010, -1, 0); + syscall(SYS_mmap, 0x10ffc000, 0x1000, 0, 0x1010, -1, 0); + syscall(SYS_mprotect, 0x10ffe000, 0x2000, 7); + syscall(SYS_mprotect, 0x10ffd000, 0x3000, 0); + syscall(SYS_fork); + res = syscall(SYS_fork); + if (res != -1) + r[0] = res; + syscall(SYS_fork); + res = syscall(SYS_fork); + if (res != -1) + r[1] = res; + syscall(SYS_sigqueue, (intptr_t)r[1], 0x2b, 0); + res = syscall(SYS_fork); + if (res != -1) + r[2] = res; + syscall(SYS_sigqueue, (intptr_t)r[2], 0x2b, 0); + syscall(SYS_vfork); + syscall(SYS_fcntl, -1, 5, 0); + syscall(SYS_sigqueue, 0, 0x2b, 0); + syscall(SYS_getpgrp, (intptr_t)r[0]); + syscall(SYS_fork); + res = syscall(SYS_fork); + if (res != -1) + r[3] = res; + syscall(SYS_sigqueue, (intptr_t)r[3], 0x2b, 0); + syscall(SYS_getpid); + syscall(SYS_mmap, 0x10ffc000, 0x1000, 3, 0x10, -1, 7); + syscall(SYS_mmap, 0x10ffc000, 0x1000, 3, 0x10, -1, 7); + res = syscall(SYS_fork); + if (res != -1) + r[4] = res; + syscall(SYS_sigqueue, (intptr_t)r[4], 0xc, 0); + return 0; +} +EOF +mycc -o /tmp/$prog -Wall -Wextra -O0 -m32 /tmp/$prog.c || exit 1 + +(cd /tmp; timeout 2m ./$prog) + +rm -rf /tmp/$prog /tmp/$prog.c /tmp/syzkaller.* +exit 0