xref: /freebsd/tools/test/stress2/misc/syzkaller9.sh (revision ebacd8013fe5f7fdf9f6a5b286f6680dd2891036)
1#!/bin/sh
2
3# Fatal trap 12: page fault while in kernel mode
4# cpuid = 0; apic id = 00
5# fault virtual address	= 0x18
6# fault code		= supervisor read data, page not present
7# instruction pointer	= 0x20:0xffffffff80ffe995
8# stack pointer	        = 0x28:0xfffffe0015e1d6f0
9# frame pointer	        = 0x28:0xfffffe0015e1d720
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		= 744 (syz-executor7538254)
14# trap number		= 12
15# panic: page fault
16# cpuid = 0
17# time = 1575776142
18# KDB: stack backtrace:
19# db_trace_self_wrapper() at db_trace_self_wrapper+0x47/frame 0xfffffe0015e1d2f0
20# vpanic() at vpanic+0x1c7/frame 0xfffffe0015e1d360
21# panic() at panic+0x43/frame 0xfffffe0015e1d3c0
22# trap_fatal() at trap_fatal+0x4cc/frame 0xfffffe0015e1d440
23# trap_pfault() at trap_pfault+0xdc/frame 0xfffffe0015e1d4e0
24# trap() at trap+0x441/frame 0xfffffe0015e1d620
25# calltrap() at calltrap+0x8/frame 0xfffffe0015e1d620
26# --- trap 0xc, rip = 0xffffffff80ffe995, rsp = 0xfffffe0015e1d6f0, rbp = 0xfffffe0015e1d720 ---
27# __mtx_assert() at __mtx_assert+0x85/frame 0xfffffe0015e1d720
28# uipc_send() at uipc_send+0xeec/frame 0xfffffe0015e1d810
29# sosend_generic() at sosend_generic+0x707/frame 0xfffffe0015e1d8d0
30# sosend() at sosend+0xc6/frame 0xfffffe0015e1d940
31# kern_sendit() at kern_sendit+0x32d/frame 0xfffffe0015e1d9f0
32# sendit() at sendit+0x226/frame 0xfffffe0015e1da50
33# sys_sendmsg() at sys_sendmsg+0x8b/frame 0xfffffe0015e1dab0
34# amd64_syscall() at amd64_syscall+0x46d/frame 0xfffffe0015e1dbf0
35# fast_syscall_common() at fast_syscall_common+0x101/frame 0xfffffe0015e1dbf0
36# --- syscall (0, FreeBSD ELF64, nosys), rip = 0x41c3ea, rsp = 0x7fffffffeb98, rbp = 0x7fffffffebf0 ---
37
38# Reproduced on r359818
39# Fixed by r359893
40
41[ `uname -p` = "i386" ] && exit 0
42
43. ../default.cfg
44cat > /tmp/syzkaller9.c <<EOF
45// http://syzkaller.backtrace.io:8080/report?id=03a08d05681c3e7f38ab6ab3f0d025105c3dcea3
46// autogenerated by syzkaller (https://github.com/google/syzkaller)
47
48#define _GNU_SOURCE
49
50#include <pwd.h>
51#include <stdarg.h>
52#include <stdbool.h>
53#include <stdint.h>
54#include <stdio.h>
55#include <stdlib.h>
56#include <string.h>
57#include <sys/endian.h>
58#include <sys/syscall.h>
59#include <unistd.h>
60
61uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff};
62
63int main(void)
64{
65  syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x1012ul, -1, 0ul);
66  intptr_t res = 0;
67  res = syscall(SYS_socket, 1ul, 5ul, 0ul);
68  if (res != -1)
69    r[0] = res;
70  memcpy((void*)0x20000000, "\x1d\x01\x2e\x2f\x66\x69\x6c\x65\x30\x00", 10);
71  syscall(SYS_bind, r[0], 0x20000000ul, 0xaul);
72  syscall(SYS_listen, r[0], 0);
73  res = syscall(SYS_socket, 1ul, 5ul, 0ul);
74  if (res != -1)
75    r[1] = res;
76  *(uint64_t*)0x20002640 = 0x20000000;
77  *(uint8_t*)0x20000000 = 0xa;
78  *(uint8_t*)0x20000001 = 1;
79  memcpy((void*)0x20000002, "./file0\000", 8);
80  *(uint32_t*)0x20002648 = 0xa;
81  *(uint64_t*)0x20002650 = 0;
82  *(uint64_t*)0x20002658 = 0;
83  *(uint64_t*)0x20002660 = 0x20002580;
84  memcpy((void*)0x20002580,
85         "\x10\x00\x00\x00\xff\xff\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00",
86         16);
87  *(uint64_t*)0x20002668 = 0x10;
88  *(uint32_t*)0x20002670 = 0;
89  syscall(SYS_sendmsg, r[1], 0x20002640ul, 0ul);
90  return 0;
91}
92EOF
93mycc -o /tmp/syzkaller9 -Wall -Wextra -O2 /tmp/syzkaller9.c -lpthread ||
94    exit 1
95
96(cd /tmp; ./syzkaller9) &
97sleep 60
98pkill -9 syzkaller9
99wait
100
101rm -f /tmp/syzkaller9 /tmp/syzkaller9.c /tmp/syzkaller9.core /tmp/file0
102exit 0
103