From owner-svn-src-user@freebsd.org  Tue Aug 25 05:15:41 2020
Return-Path: <owner-svn-src-user@freebsd.org>
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 769763BE4EB
 for <svn-src-user@mailman.nyi.freebsd.org>;
 Tue, 25 Aug 2020 05:15:41 +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)
 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 "Let's Encrypt Authority X3" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 4BbHJF2Z3Zz3bGw;
 Tue, 25 Aug 2020 05:15:41 +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 3B29B24771;
 Tue, 25 Aug 2020 05:15:41 +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 07P5FfTg051760;
 Tue, 25 Aug 2020 05:15:41 GMT (envelope-from pho@FreeBSD.org)
Received: (from pho@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id 07P5Ffba051759;
 Tue, 25 Aug 2020 05:15:41 GMT (envelope-from pho@FreeBSD.org)
Message-Id: <202008250515.07P5Ffba051759@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org
 using -f
From: Peter Holm <pho@FreeBSD.org>
Date: Tue, 25 Aug 2020 05:15:41 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
Subject: svn commit: r364752 - 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: 364752
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 &quot; user&quot;
 src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-user>,
 <mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user/>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-user>,
 <mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Tue, 25 Aug 2020 05:15:41 -0000

Author: pho
Date: Tue Aug 25 05:15:40 2020
New Revision: 364752
URL: https://svnweb.freebsd.org/changeset/base/364752

Log:
  Added a syzkaller reproducer.

Added:
  user/pho/stress2/misc/syzkaller22.sh   (contents, props changed)

Added: user/pho/stress2/misc/syzkaller22.sh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/pho/stress2/misc/syzkaller22.sh	Tue Aug 25 05:15:40 2020	(r364752)
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+# panic: Assertion *buflen >= 2 failed at ../../../kern/vfs_cache.c:2837
+# cpuid = 21
+# time = 1598296274
+# KDB: stack backtrace:
+# db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe0149a9e860
+# vpanic() at vpanic+0x182/frame 0xfffffe0149a9e8b0
+# panic() at panic+0x43/frame 0xfffffe0149a9e910
+# vn_fullpath_any_smr() at vn_fullpath_any_smr+0x4df/frame 0xfffffe0149a9e980
+# sys___realpathat() at sys___realpathat+0x20b/frame 0xfffffe0149a9ead0
+# amd64_syscall() at amd64_syscall+0x159/frame 0xfffffe0149a9ebf0
+# fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe0149a9ebf0
+# --- syscall (0, FreeBSD ELF64, nosys), rip = 0x8004294ea, rsp = 0x7fffffffe548, rbp = 0x7fffffffe580 ---
+# KDB: enter: panic
+# [ thread pid 2831 tid 100306 ]
+# Stopped at      kdb_enter+0x37: movq    $0,0x10b4246(%rip)
+# db> x/s version
+# version:        FreeBSD 13.0-CURRENT #0 r364722: Mon Aug 24 21:04:09 CEST 2020
+# pho@t2.osted.lan:/usr/src/sys/amd64/compile/PHO\012
+# db>
+
+# $FreeBSD$
+
+[ `uname -p` != "amd64" ] && exit 0
+
+# Obtained from markj (syzkaller).
+# Fixed by r364723.
+
+. ../default.cfg
+kldstat -v | grep -q sctp || kldload sctp.ko
+cat > /tmp/syzkaller22.c <<EOF
+// autogenerated by syzkaller (https://github.com/google/syzkaller)
+
+#define _GNU_SOURCE
+
+#include <pwd.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/endian.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+uint64_t r[1] = {0xffffffffffffffff};
+
+int main(void)
+{
+	syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x1012ul, -1, 0ul);
+	intptr_t res = 0;
+	memcpy((void*)0x20000000, "./file0\000", 8);
+	syscall(SYS_open, 0x20000000ul, 0x200645ul, 0ul);
+	memcpy((void*)0x20000000, ".\000", 2);
+	res = syscall(SYS_open, 0x20000000ul, 0ul, 0ul);
+	if (res != -1)
+		r[0] = res;
+	memcpy((void*)0x20000240, "./file0\000", 8);
+	syscall(SYS___realpathat, r[0], 0x20000240ul, 0x20000280ul, 8ul, 0ul);
+	return 0;
+}
+EOF
+mycc -o /tmp/syzkaller22 -Wall -Wextra -O0 /tmp/syzkaller22.c ||
+    exit 1
+
+(cd /tmp; timeout 1m ./syzkaller22)
+
+rm -f /tmp/syzkaller22 /tmp/syzkaller22.c /tmp/syzkaller22.core /tmp/file0
+exit 0