xref: /freebsd/tools/test/stress2/misc/syzkaller20.sh (revision e0c4386e)
1#!/bin/sh
2
3# Fatal trap 12: page fault while in kernel mode
4# cpuid = 0; apic id = 00
5# fault virtual address   = 0x70
6# fault code              = supervisor read data, page not present
7# instruction pointer     = 0x20:0xffffffff80dec3cf
8# stack pointer           = 0x28:0xfffffe013c9384d0
9# frame pointer           = 0x28:0xfffffe013c938510
10# code segment            = base 0x0, limit 0xfffff, type 0x1b
11#                         = DPL 0, pres 1, long 1, def32 0, gran 1
12# processor eflags        = interrupt enabled, resume, IOPL = 0
13# current process         = 58092 (syzkaller20)
14# trap number             = 12
15# panic: page fault
16# cpuid = 0
17# time = 1596109014
18# KDB: stack backtrace:
19# db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe013c938180
20# vpanic() at vpanic+0x182/frame 0xfffffe013c9381d0
21# panic() at panic+0x43/frame 0xfffffe013c938230
22# trap_fatal() at trap_fatal+0x387/frame 0xfffffe013c938290
23# trap_pfault() at trap_pfault+0x99/frame 0xfffffe013c9382f0
24# trap() at trap+0x2a5/frame 0xfffffe013c938400
25# calltrap() at calltrap+0x8/frame 0xfffffe013c938400
26# --- trap 0xc, rip = 0xffffffff80dec3cf, rsp = 0xfffffe013c9384d0, rbp = 0xfffffe013c938510 ---
27# in6_setscope() at in6_setscope+0x5f/frame 0xfffffe013c938510
28# ip6_output() at ip6_output+0x103c/frame 0xfffffe013c938750
29# udp6_send() at udp6_send+0x79b/frame 0xfffffe013c938900
30# sosend_dgram() at sosend_dgram+0x34e/frame 0xfffffe013c938960
31# sosend() at sosend+0x66/frame 0xfffffe013c938990
32# kern_sendit() at kern_sendit+0x246/frame 0xfffffe013c938a30
33# sendit() at sendit+0x1d8/frame 0xfffffe013c938a80
34# sys_sendto() at sys_sendto+0x4d/frame 0xfffffe013c938ad0
35# amd64_syscall() at amd64_syscall+0x159/frame 0xfffffe013c938bf0
36# fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe013c938bf0
37# --- syscall (0, FreeBSD ELF64, nosys), rip = 0x80045513a, rsp = 0x7fffffffe568, rbp = 0x7fffffffe580 ---
38# KDB: enter: panic
39# [ thread pid 58092 tid 100337 ]
40# Stopped at      kdb_enter+0x37: movq    $0,0x10b8de6(%rip)
41# db> x/s version
42# version:        FreeBSD 13.0-CURRENT #0 r363687: Thu Jul 30 08:55:21 CEST 2020
43# pho@t2.osted.lan:/usr/src/sys/amd64/compile/PHO
44# db>
45
46[ `uname -p` != "amd64" ] && exit 0
47
48. ../default.cfg
49cat > /tmp/syzkaller20.c <<EOF
50// autogenerated by syzkaller (https://github.com/google/syzkaller)
51
52#define _GNU_SOURCE
53
54#include <pwd.h>
55#include <stdarg.h>
56#include <stdbool.h>
57#include <stdint.h>
58#include <stdio.h>
59#include <stdlib.h>
60#include <string.h>
61#include <sys/endian.h>
62#include <sys/syscall.h>
63#include <unistd.h>
64
65uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff};
66
67int main(void)
68{
69  syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x1012ul, -1, 0ul);
70  intptr_t res = 0;
71  res = syscall(SYS_socket, 0x1cul, 1ul, 0);
72  if (res != -1)
73    r[0] = res;
74  res = syscall(SYS_socket, 0x1cul, 2ul, 0x88);
75  if (res != -1)
76    r[1] = res;
77  syscall(SYS_dup2, r[1], r[0]);
78  *(uint8_t*)0x20000000 = 0x1c;
79  *(uint8_t*)0x20000001 = 0x1c;
80  *(uint16_t*)0x20000002 = htobe16(0x4e21);
81  *(uint32_t*)0x20000004 = 0;
82  *(uint64_t*)0x20000008 = htobe64(0);
83  *(uint64_t*)0x20000010 = htobe64(1);
84  *(uint32_t*)0x20000018 = 0;
85  syscall(SYS_bind, r[0], 0x20000000ul, 0x1cul);
86  *(uint8_t*)0x200002c0 = 0x1c;
87  *(uint8_t*)0x200002c1 = 0x1c;
88  *(uint16_t*)0x200002c2 = htobe16(0x4e23);
89  *(uint32_t*)0x200002c4 = 0;
90  memcpy((void*)0x200002c8,
91         "\xff\x71\x4e\x39\x01\x68\x0f\x3c\xd3\x1d\xb7\x61\x2c\x26\x8b\xac",
92         16);
93  *(uint32_t*)0x200002d8 = 0;
94  syscall(SYS_sendto, r[0], 0ul, 0ul, 0ul, 0x200002c0ul, 0x1cul);
95  return 0;
96}
97EOF
98mycc -o /tmp/syzkaller20 -Wall -Wextra -O2 /tmp/syzkaller20.c -lpthread ||
99    exit 1
100
101(cd ../testcases/swap; ./swap -t 1m -i 20 -h > /dev/null 2>&1) &
102(cd /tmp; ./syzkaller20) &
103sleep 60
104pkill -9 syzkaller20 swap
105while pgrep -q swap; do pkill swap; done
106wait
107
108rm -f /tmp/syzkaller20 /tmp/syzkaller20.c /tmp/syzkaller20.core
109exit 0
110