From owner-svn-src-user@freebsd.org Wed May 13 06:45:34 2020 Return-Path: Delivered-To: svn-src-user@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 110BE2EB943 for ; Wed, 13 May 2020 06:45:34 +0000 (UTC) (envelope-from pho@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49MQCx6k9yz4cKb; Wed, 13 May 2020 06:45:33 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E22A91D599; Wed, 13 May 2020 06:45:33 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 04D6jXsM081901; Wed, 13 May 2020 06:45:33 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04D6jX4g081900; Wed, 13 May 2020 06:45:33 GMT (envelope-from pho@FreeBSD.org) Message-Id: <202005130645.04D6jX4g081900@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Wed, 13 May 2020 06:45:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r361004 - user/pho/stress2/misc X-SVN-Group: user X-SVN-Commit-Author: pho X-SVN-Commit-Paths: user/pho/stress2/misc X-SVN-Commit-Revision: 361004 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 May 2020 06:45:34 -0000 Author: pho Date: Wed May 13 06:45:33 2020 New Revision: 361004 URL: https://svnweb.freebsd.org/changeset/base/361004 Log: Added a syzkaller reproducer. Added: user/pho/stress2/misc/syzkaller12.sh (contents, props changed) Added: user/pho/stress2/misc/syzkaller12.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/syzkaller12.sh Wed May 13 06:45:33 2020 (r361004) @@ -0,0 +1,177 @@ +#!/bin/sh + +# Fatal trap 12: page fault while in kernel mode +# cpuid = 21; apic id = 29 +# fault virtual address = 0x5eb9977d +# fault code = supervisor read data, page not present +# instruction pointer = 0x20:0xffffffff80d8f181 +# stack pointer = 0x28:0xfffffe0126709300 +# frame pointer = 0x28:0xfffffe0126709750 +# code segment = base 0x0, limit 0xfffff, type 0x1b +# = DPL 0, pres 1, long 1, def32 0, gran 1 +# processor eflags = interrupt enabled, resume, IOPL = 0 +# current process = 12 (swi1: netisr 0) +# trap number = 12 +# panic: page fault +# cpuid = 21 +# time = 1589220309 +# KDB: stack backtrace: +# db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe0126708fb0 +# vpanic() at vpanic+0x182/frame 0xfffffe0126709000 +# panic() at panic+0x43/frame 0xfffffe0126709060 +# trap_fatal() at trap_fatal+0x387/frame 0xfffffe01267090c0 +# trap_pfault() at trap_pfault+0x99/frame 0xfffffe0126709120 +# trap() at trap+0x2a5/frame 0xfffffe0126709230 +# calltrap() at calltrap+0x8/frame 0xfffffe0126709230 +# --- trap 0xc, rip = 0xffffffff80d8f181, rsp = 0xfffffe0126709300, rbp = 0xfffffe0126709750 --- +# sctp_process_control() at sctp_process_control+0x1351/frame 0xfffffe0126709750 +# sctp_common_input_processing() at sctp_common_input_processing+0x4f1/frame 0xfffffe01267098c0 +# sctp6_input_with_port() at sctp6_input_with_port+0x22c/frame 0xfffffe01267099b0 +# sctp6_input() at sctp6_input+0xb/frame 0xfffffe01267099c0 +# ip6_input() at ip6_input+0xe89/frame 0xfffffe0126709aa0 +# swi_net() at swi_net+0x1a1/frame 0xfffffe0126709b20 +# ithread_loop() at ithread_loop+0x279/frame 0xfffffe0126709bb0 +# fork_exit() at fork_exit+0x80/frame 0xfffffe0126709bf0 +# fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe0126709bf0 +# --- trap 0, rip = 0, rsp = 0, rbp = 0 --- +# KDB: enter: panic +# [ thread pid 12 tid 100083 ] +# Stopped at kdb_enter+0x37: movq $0,0x10ca9a6(%rip) +# db> + +# $FreeBSD$ + +# Reproduced on r360902 +# Fixed by r360942 + +[ `uname -p` = "i386" ] && exit 0 + +. ../default.cfg +cat > /tmp/syzkaller12.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; + for (iter = 0;; 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 < 5 * 1000) + continue; + kill_and_wait(pid, &status); + break; + } + } +} + +uint64_t r[1] = {0xffffffffffffffff}; + +void execute_one(void) +{ + intptr_t res = 0; + res = syscall(SYS_socket, 0x1cul, 1ul, 0x84); + if (res != -1) + r[0] = res; + *(uint8_t*)0x20000000 = 0x1c; + *(uint8_t*)0x20000001 = 0x1c; + *(uint16_t*)0x20000002 = htobe16(0x4e22); + *(uint32_t*)0x20000004 = 0; + *(uint8_t*)0x20000008 = 0; + *(uint8_t*)0x20000009 = 0; + *(uint8_t*)0x2000000a = 0; + *(uint8_t*)0x2000000b = 0; + *(uint8_t*)0x2000000c = 0; + *(uint8_t*)0x2000000d = 0; + *(uint8_t*)0x2000000e = 0; + *(uint8_t*)0x2000000f = 0; + *(uint8_t*)0x20000010 = 0; + *(uint8_t*)0x20000011 = 0; + *(uint8_t*)0x20000012 = 0; + *(uint8_t*)0x20000013 = 0; + *(uint8_t*)0x20000014 = 0; + *(uint8_t*)0x20000015 = 0; + *(uint8_t*)0x20000016 = 0; + *(uint8_t*)0x20000017 = 0; + *(uint32_t*)0x20000018 = 0; + syscall(SYS_bind, r[0], 0x20000000ul, 0x1cul); + *(uint8_t*)0x20000180 = 0x5f; + *(uint8_t*)0x20000181 = 0x1c; + *(uint16_t*)0x20000182 = htobe16(0x4e22); + *(uint32_t*)0x20000184 = 0; + *(uint64_t*)0x20000188 = htobe64(0); + *(uint64_t*)0x20000190 = htobe64(1); + *(uint32_t*)0x20000198 = 0; + syscall(SYS_connect, r[0], 0x20000180ul, 0x1cul); +} +int main(void) +{ + syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x1012ul, -1, 0ul); + loop(); + return 0; +} +// https://syzkaller.a +EOF +mycc -o /tmp/syzkaller12 -Wall -Wextra -O2 /tmp/syzkaller12.c -lpthread || + exit 1 + +(cd /tmp; ./syzkaller12) & +sleep 60 +pkill -9 syzkaller12 +wait + +rm -f /tmp/syzkaller12 /tmp/syzkaller12.c /tmp/syzkaller12.core +exit 0