xref: /freebsd/tools/test/stress2/misc/syzkaller22.sh (revision a4e5e0106ac7145f56eb39a691e302cabb4635be)
1#!/bin/sh
2
3# panic: Assertion *buflen >= 2 failed at ../../../kern/vfs_cache.c:2837
4# cpuid = 21
5# time = 1598296274
6# KDB: stack backtrace:
7# db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe0149a9e860
8# vpanic() at vpanic+0x182/frame 0xfffffe0149a9e8b0
9# panic() at panic+0x43/frame 0xfffffe0149a9e910
10# vn_fullpath_any_smr() at vn_fullpath_any_smr+0x4df/frame 0xfffffe0149a9e980
11# sys___realpathat() at sys___realpathat+0x20b/frame 0xfffffe0149a9ead0
12# amd64_syscall() at amd64_syscall+0x159/frame 0xfffffe0149a9ebf0
13# fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe0149a9ebf0
14# --- syscall (0, FreeBSD ELF64, nosys), rip = 0x8004294ea, rsp = 0x7fffffffe548, rbp = 0x7fffffffe580 ---
15# KDB: enter: panic
16# [ thread pid 2831 tid 100306 ]
17# Stopped at      kdb_enter+0x37: movq    $0,0x10b4246(%rip)
18# db> x/s version
19# version:        FreeBSD 13.0-CURRENT #0 r364722: Mon Aug 24 21:04:09 CEST 2020
20# pho@t2.osted.lan:/usr/src/sys/amd64/compile/PHO\012
21# db>
22
23[ `uname -p` != "amd64" ] && exit 0
24
25# Obtained from markj (syzkaller).
26# Fixed by r364723.
27
28. ../default.cfg
29kldstat -v | grep -q sctp || kldload sctp.ko
30cat > /tmp/syzkaller22.c <<EOF
31// autogenerated by syzkaller (https://github.com/google/syzkaller)
32
33#define _GNU_SOURCE
34
35#include <pwd.h>
36#include <stdarg.h>
37#include <stdbool.h>
38#include <stdint.h>
39#include <stdio.h>
40#include <stdlib.h>
41#include <string.h>
42#include <sys/endian.h>
43#include <sys/syscall.h>
44#include <unistd.h>
45
46uint64_t r[1] = {0xffffffffffffffff};
47
48int main(void)
49{
50	syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x1012ul, -1, 0ul);
51	intptr_t res = 0;
52	memcpy((void*)0x20000000, "./file0\000", 8);
53	syscall(SYS_open, 0x20000000ul, 0x200645ul, 0ul);
54	memcpy((void*)0x20000000, ".\000", 2);
55	res = syscall(SYS_open, 0x20000000ul, 0ul, 0ul);
56	if (res != -1)
57		r[0] = res;
58	memcpy((void*)0x20000240, "./file0\000", 8);
59	syscall(SYS___realpathat, r[0], 0x20000240ul, 0x20000280ul, 8ul, 0ul);
60	return 0;
61}
62EOF
63mycc -o /tmp/syzkaller22 -Wall -Wextra -O0 /tmp/syzkaller22.c ||
64    exit 1
65
66(cd /tmp; timeout 1m ./syzkaller22)
67
68rm -f /tmp/syzkaller22 /tmp/syzkaller22.c /tmp/syzkaller22.core /tmp/file0
69exit 0
70