xref: /freebsd/tools/test/stress2/misc/syzkaller23.sh (revision 8a272653d9fbd9fc37691c9aad6a05089b4ecb4d)
1*8a272653SPeter Holm#!/bin/sh
2*8a272653SPeter Holm
3*8a272653SPeter Holm# panic: Bad link elm 0xfffff80b62eb7500 prev->next != elm
4*8a272653SPeter Holm# cpuid = 2
5*8a272653SPeter Holm# time = 1598546886
6*8a272653SPeter Holm# KDB: stack backtrace:
7*8a272653SPeter Holm# db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe010154a6e0
8*8a272653SPeter Holm# vpanic() at vpanic+0x182/frame 0xfffffe010154a730
9*8a272653SPeter Holm# panic() at panic+0x43/frame 0xfffffe010154a790
10*8a272653SPeter Holm# unp_disconnect() at unp_disconnect+0x279/frame 0xfffffe010154a7c0
11*8a272653SPeter Holm# uipc_disconnect() at uipc_disconnect+0xfd/frame 0xfffffe010154a800
12*8a272653SPeter Holm# soclose() at soclose+0xa2/frame 0xfffffe010154a870
13*8a272653SPeter Holm# _fdrop() at _fdrop+0x1a/frame 0xfffffe010154a890
14*8a272653SPeter Holm# closef() at closef+0x1ea/frame 0xfffffe010154a920
15*8a272653SPeter Holm# fdescfree_fds() at fdescfree_fds+0x8c/frame 0xfffffe010154a980
16*8a272653SPeter Holm# fdescfree() at fdescfree+0x3cd/frame 0xfffffe010154aa50
17*8a272653SPeter Holm# exit1() at exit1+0x487/frame 0xfffffe010154aac0
18*8a272653SPeter Holm# sys_sys_exit() at sys_sys_exit+0xd/frame 0xfffffe010154aad0
19*8a272653SPeter Holm# amd64_syscall() at amd64_syscall+0x159/frame 0xfffffe010154abf0
20*8a272653SPeter Holm# fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe010154abf0
21*8a272653SPeter Holm# --- syscall (1, FreeBSD ELF64, sys_sys_exit), rip = 0x80045376a, rsp = 0x7fffffffe4c8, rbp = 0x7fffffffe4e0 ---
22*8a272653SPeter Holm
23*8a272653SPeter Holm[ `uname -p` != "amd64" ] && exit 0
24*8a272653SPeter Holm
25*8a272653SPeter Holm# Obtained from markj (syzkaller).
26*8a272653SPeter Holm
27*8a272653SPeter Holm. ../default.cfg
28*8a272653SPeter Holmcat > /tmp/syzkaller23.c <<EOF
29*8a272653SPeter Holm// autogenerated by syzkaller (https://github.com/google/syzkaller)
30*8a272653SPeter Holm
31*8a272653SPeter Holm#define _GNU_SOURCE
32*8a272653SPeter Holm
33*8a272653SPeter Holm#include <sys/types.h>
34*8a272653SPeter Holm
35*8a272653SPeter Holm#include <dirent.h>
36*8a272653SPeter Holm#include <errno.h>
37*8a272653SPeter Holm#include <pthread.h>
38*8a272653SPeter Holm#include <pwd.h>
39*8a272653SPeter Holm#include <setjmp.h>
40*8a272653SPeter Holm#include <signal.h>
41*8a272653SPeter Holm#include <stdarg.h>
42*8a272653SPeter Holm#include <stdbool.h>
43*8a272653SPeter Holm#include <stdint.h>
44*8a272653SPeter Holm#include <stdio.h>
45*8a272653SPeter Holm#include <stdlib.h>
46*8a272653SPeter Holm#include <string.h>
47*8a272653SPeter Holm#include <sys/endian.h>
48*8a272653SPeter Holm#include <sys/stat.h>
49*8a272653SPeter Holm#include <sys/syscall.h>
50*8a272653SPeter Holm#include <sys/wait.h>
51*8a272653SPeter Holm#include <time.h>
52*8a272653SPeter Holm#include <unistd.h>
53*8a272653SPeter Holm
54*8a272653SPeter Holmstatic __thread int skip_segv;
55*8a272653SPeter Holmstatic __thread jmp_buf segv_env;
56*8a272653SPeter Holm
57*8a272653SPeter Holmstatic void segv_handler(int sig, siginfo_t* info, void* ctx __unused)
58*8a272653SPeter Holm{
59*8a272653SPeter Holm  uintptr_t addr = (uintptr_t)info->si_addr;
60*8a272653SPeter Holm  const uintptr_t prog_start = 1 << 20;
61*8a272653SPeter Holm  const uintptr_t prog_end = 100 << 20;
62*8a272653SPeter Holm  int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0;
63*8a272653SPeter Holm  int valid = addr < prog_start || addr > prog_end;
64*8a272653SPeter Holm  if (sig == SIGBUS) {
65*8a272653SPeter Holm    valid = 1;
66*8a272653SPeter Holm  }
67*8a272653SPeter Holm  if (skip && valid) {
68*8a272653SPeter Holm    _longjmp(segv_env, 1);
69*8a272653SPeter Holm  }
70*8a272653SPeter Holm  exit(sig);
71*8a272653SPeter Holm}
72*8a272653SPeter Holm
73*8a272653SPeter Holmstatic void install_segv_handler(void)
74*8a272653SPeter Holm{
75*8a272653SPeter Holm  struct sigaction sa;
76*8a272653SPeter Holm  memset(&sa, 0, sizeof(sa));
77*8a272653SPeter Holm  sa.sa_sigaction = segv_handler;
78*8a272653SPeter Holm  sa.sa_flags = SA_NODEFER | SA_SIGINFO;
79*8a272653SPeter Holm  sigaction(SIGSEGV, &sa, NULL);
80*8a272653SPeter Holm  sigaction(SIGBUS, &sa, NULL);
81*8a272653SPeter Holm}
82*8a272653SPeter Holm
83*8a272653SPeter Holm#define NONFAILING(...)                                                        \
84*8a272653SPeter Holm  {                                                                            \
85*8a272653SPeter Holm    __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST);                       \
86*8a272653SPeter Holm    if (_setjmp(segv_env) == 0) {                                              \
87*8a272653SPeter Holm      __VA_ARGS__;                                                             \
88*8a272653SPeter Holm    }                                                                          \
89*8a272653SPeter Holm    __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST);                       \
90*8a272653SPeter Holm  }
91*8a272653SPeter Holm
92*8a272653SPeter Holmstatic void kill_and_wait(int pid, int* status)
93*8a272653SPeter Holm{
94*8a272653SPeter Holm  kill(pid, SIGKILL);
95*8a272653SPeter Holm  while (waitpid(-1, status, 0) != pid) {
96*8a272653SPeter Holm  }
97*8a272653SPeter Holm}
98*8a272653SPeter Holm
99*8a272653SPeter Holmstatic void sleep_ms(uint64_t ms)
100*8a272653SPeter Holm{
101*8a272653SPeter Holm  usleep(ms * 1000);
102*8a272653SPeter Holm}
103*8a272653SPeter Holm
104*8a272653SPeter Holmstatic uint64_t current_time_ms(void)
105*8a272653SPeter Holm{
106*8a272653SPeter Holm  struct timespec ts;
107*8a272653SPeter Holm  if (clock_gettime(CLOCK_MONOTONIC, &ts))
108*8a272653SPeter Holm    exit(1);
109*8a272653SPeter Holm  return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
110*8a272653SPeter Holm}
111*8a272653SPeter Holm
112*8a272653SPeter Holmstatic void use_temporary_dir(void)
113*8a272653SPeter Holm{
114*8a272653SPeter Holm  char tmpdir_template[] = "./syzkaller.XXXXXX";
115*8a272653SPeter Holm  char* tmpdir = mkdtemp(tmpdir_template);
116*8a272653SPeter Holm  if (!tmpdir)
117*8a272653SPeter Holm    exit(1);
118*8a272653SPeter Holm  if (chmod(tmpdir, 0777))
119*8a272653SPeter Holm    exit(1);
120*8a272653SPeter Holm  if (chdir(tmpdir))
121*8a272653SPeter Holm    exit(1);
122*8a272653SPeter Holm}
123*8a272653SPeter Holm
124*8a272653SPeter Holmstatic void remove_dir(const char* dir)
125*8a272653SPeter Holm{
126*8a272653SPeter Holm  DIR* dp = opendir(dir);
127*8a272653SPeter Holm  if (dp == NULL)
128*8a272653SPeter Holm    exit(1);
129*8a272653SPeter Holm  struct dirent* ep = 0;
130*8a272653SPeter Holm  while ((ep = readdir(dp))) {
131*8a272653SPeter Holm    if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0)
132*8a272653SPeter Holm      continue;
133*8a272653SPeter Holm    char filename[FILENAME_MAX];
134*8a272653SPeter Holm    snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name);
135*8a272653SPeter Holm    struct stat st;
136*8a272653SPeter Holm    if (lstat(filename, &st))
137*8a272653SPeter Holm      exit(1);
138*8a272653SPeter Holm    if (S_ISDIR(st.st_mode)) {
139*8a272653SPeter Holm      remove_dir(filename);
140*8a272653SPeter Holm      continue;
141*8a272653SPeter Holm    }
142*8a272653SPeter Holm    if (unlink(filename))
143*8a272653SPeter Holm      exit(1);
144*8a272653SPeter Holm  }
145*8a272653SPeter Holm  closedir(dp);
146*8a272653SPeter Holm  if (rmdir(dir))
147*8a272653SPeter Holm    exit(1);
148*8a272653SPeter Holm}
149*8a272653SPeter Holm
150*8a272653SPeter Holmstatic void thread_start(void* (*fn)(void*), void* arg)
151*8a272653SPeter Holm{
152*8a272653SPeter Holm  pthread_t th;
153*8a272653SPeter Holm  pthread_attr_t attr;
154*8a272653SPeter Holm  pthread_attr_init(&attr);
155*8a272653SPeter Holm  pthread_attr_setstacksize(&attr, 128 << 10);
156*8a272653SPeter Holm  int i = 0;
157*8a272653SPeter Holm  for (; i < 100; i++) {
158*8a272653SPeter Holm    if (pthread_create(&th, &attr, fn, arg) == 0) {
159*8a272653SPeter Holm      pthread_attr_destroy(&attr);
160*8a272653SPeter Holm      return;
161*8a272653SPeter Holm    }
162*8a272653SPeter Holm    if (errno == EAGAIN) {
163*8a272653SPeter Holm      usleep(50);
164*8a272653SPeter Holm      continue;
165*8a272653SPeter Holm    }
166*8a272653SPeter Holm    break;
167*8a272653SPeter Holm  }
168*8a272653SPeter Holm  exit(1);
169*8a272653SPeter Holm}
170*8a272653SPeter Holm
171*8a272653SPeter Holmtypedef struct {
172*8a272653SPeter Holm  pthread_mutex_t mu;
173*8a272653SPeter Holm  pthread_cond_t cv;
174*8a272653SPeter Holm  int state;
175*8a272653SPeter Holm} event_t;
176*8a272653SPeter Holm
177*8a272653SPeter Holmstatic void event_init(event_t* ev)
178*8a272653SPeter Holm{
179*8a272653SPeter Holm  if (pthread_mutex_init(&ev->mu, 0))
180*8a272653SPeter Holm    exit(1);
181*8a272653SPeter Holm  if (pthread_cond_init(&ev->cv, 0))
182*8a272653SPeter Holm    exit(1);
183*8a272653SPeter Holm  ev->state = 0;
184*8a272653SPeter Holm}
185*8a272653SPeter Holm
186*8a272653SPeter Holmstatic void event_reset(event_t* ev)
187*8a272653SPeter Holm{
188*8a272653SPeter Holm  ev->state = 0;
189*8a272653SPeter Holm}
190*8a272653SPeter Holm
191*8a272653SPeter Holmstatic void event_set(event_t* ev)
192*8a272653SPeter Holm{
193*8a272653SPeter Holm  pthread_mutex_lock(&ev->mu);
194*8a272653SPeter Holm  if (ev->state)
195*8a272653SPeter Holm    exit(1);
196*8a272653SPeter Holm  ev->state = 1;
197*8a272653SPeter Holm  pthread_mutex_unlock(&ev->mu);
198*8a272653SPeter Holm  pthread_cond_broadcast(&ev->cv);
199*8a272653SPeter Holm}
200*8a272653SPeter Holm
201*8a272653SPeter Holmstatic void event_wait(event_t* ev)
202*8a272653SPeter Holm{
203*8a272653SPeter Holm  pthread_mutex_lock(&ev->mu);
204*8a272653SPeter Holm  while (!ev->state)
205*8a272653SPeter Holm    pthread_cond_wait(&ev->cv, &ev->mu);
206*8a272653SPeter Holm  pthread_mutex_unlock(&ev->mu);
207*8a272653SPeter Holm}
208*8a272653SPeter Holm
209*8a272653SPeter Holmstatic int event_isset(event_t* ev)
210*8a272653SPeter Holm{
211*8a272653SPeter Holm  pthread_mutex_lock(&ev->mu);
212*8a272653SPeter Holm  int res = ev->state;
213*8a272653SPeter Holm  pthread_mutex_unlock(&ev->mu);
214*8a272653SPeter Holm  return res;
215*8a272653SPeter Holm}
216*8a272653SPeter Holm
217*8a272653SPeter Holmstatic int event_timedwait(event_t* ev, uint64_t timeout)
218*8a272653SPeter Holm{
219*8a272653SPeter Holm  uint64_t start = current_time_ms();
220*8a272653SPeter Holm  uint64_t now = start;
221*8a272653SPeter Holm  pthread_mutex_lock(&ev->mu);
222*8a272653SPeter Holm  for (;;) {
223*8a272653SPeter Holm    if (ev->state)
224*8a272653SPeter Holm      break;
225*8a272653SPeter Holm    uint64_t remain = timeout - (now - start);
226*8a272653SPeter Holm    struct timespec ts;
227*8a272653SPeter Holm    ts.tv_sec = remain / 1000;
228*8a272653SPeter Holm    ts.tv_nsec = (remain % 1000) * 1000 * 1000;
229*8a272653SPeter Holm    pthread_cond_timedwait(&ev->cv, &ev->mu, &ts);
230*8a272653SPeter Holm    now = current_time_ms();
231*8a272653SPeter Holm    if (now - start > timeout)
232*8a272653SPeter Holm      break;
233*8a272653SPeter Holm  }
234*8a272653SPeter Holm  int res = ev->state;
235*8a272653SPeter Holm  pthread_mutex_unlock(&ev->mu);
236*8a272653SPeter Holm  return res;
237*8a272653SPeter Holm}
238*8a272653SPeter Holm
239*8a272653SPeter Holmstruct thread_t {
240*8a272653SPeter Holm  int created, call;
241*8a272653SPeter Holm  event_t ready, done;
242*8a272653SPeter Holm};
243*8a272653SPeter Holm
244*8a272653SPeter Holmstatic struct thread_t threads[16];
245*8a272653SPeter Holmstatic void execute_call(int call);
246*8a272653SPeter Holmstatic int running;
247*8a272653SPeter Holm
248*8a272653SPeter Holmstatic void* thr(void* arg)
249*8a272653SPeter Holm{
250*8a272653SPeter Holm  struct thread_t* th = (struct thread_t*)arg;
251*8a272653SPeter Holm  for (;;) {
252*8a272653SPeter Holm    event_wait(&th->ready);
253*8a272653SPeter Holm    event_reset(&th->ready);
254*8a272653SPeter Holm    execute_call(th->call);
255*8a272653SPeter Holm    __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED);
256*8a272653SPeter Holm    event_set(&th->done);
257*8a272653SPeter Holm  }
258*8a272653SPeter Holm  return 0;
259*8a272653SPeter Holm}
260*8a272653SPeter Holm
261*8a272653SPeter Holmstatic void execute_one(void)
262*8a272653SPeter Holm{
263*8a272653SPeter Holm  int i, call, thread;
264*8a272653SPeter Holm  int collide = 0;
265*8a272653SPeter Holmagain:
266*8a272653SPeter Holm  for (call = 0; call < 5; call++) {
267*8a272653SPeter Holm    for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0]));
268*8a272653SPeter Holm         thread++) {
269*8a272653SPeter Holm      struct thread_t* th = &threads[thread];
270*8a272653SPeter Holm      if (!th->created) {
271*8a272653SPeter Holm        th->created = 1;
272*8a272653SPeter Holm        event_init(&th->ready);
273*8a272653SPeter Holm        event_init(&th->done);
274*8a272653SPeter Holm        event_set(&th->done);
275*8a272653SPeter Holm        thread_start(thr, th);
276*8a272653SPeter Holm      }
277*8a272653SPeter Holm      if (!event_isset(&th->done))
278*8a272653SPeter Holm        continue;
279*8a272653SPeter Holm      event_reset(&th->done);
280*8a272653SPeter Holm      th->call = call;
281*8a272653SPeter Holm      __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED);
282*8a272653SPeter Holm      event_set(&th->ready);
283*8a272653SPeter Holm      if (collide && (call % 2) == 0)
284*8a272653SPeter Holm        break;
285*8a272653SPeter Holm      event_timedwait(&th->done, 45);
286*8a272653SPeter Holm      break;
287*8a272653SPeter Holm    }
288*8a272653SPeter Holm  }
289*8a272653SPeter Holm  for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++)
290*8a272653SPeter Holm    sleep_ms(1);
291*8a272653SPeter Holm  if (!collide) {
292*8a272653SPeter Holm    collide = 1;
293*8a272653SPeter Holm    goto again;
294*8a272653SPeter Holm  }
295*8a272653SPeter Holm}
296*8a272653SPeter Holm
297*8a272653SPeter Holmstatic void execute_one(void);
298*8a272653SPeter Holm
299*8a272653SPeter Holm#define WAIT_FLAGS 0
300*8a272653SPeter Holm
301*8a272653SPeter Holmstatic void loop(void)
302*8a272653SPeter Holm{
303*8a272653SPeter Holm  int iter = 0;
304*8a272653SPeter Holm  for (;; iter++) {
305*8a272653SPeter Holm    char cwdbuf[32];
306*8a272653SPeter Holm    sprintf(cwdbuf, "./%d", iter);
307*8a272653SPeter Holm    if (mkdir(cwdbuf, 0777))
308*8a272653SPeter Holm      exit(1);
309*8a272653SPeter Holm    int pid = fork();
310*8a272653SPeter Holm    if (pid < 0)
311*8a272653SPeter Holm      exit(1);
312*8a272653SPeter Holm    if (pid == 0) {
313*8a272653SPeter Holm      if (chdir(cwdbuf))
314*8a272653SPeter Holm        exit(1);
315*8a272653SPeter Holm      execute_one();
316*8a272653SPeter Holm      exit(0);
317*8a272653SPeter Holm    }
318*8a272653SPeter Holm    int status = 0;
319*8a272653SPeter Holm    uint64_t start = current_time_ms();
320*8a272653SPeter Holm    for (;;) {
321*8a272653SPeter Holm      if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid)
322*8a272653SPeter Holm        break;
323*8a272653SPeter Holm      sleep_ms(1);
324*8a272653SPeter Holm      if (current_time_ms() - start < 5 * 1000)
325*8a272653SPeter Holm        continue;
326*8a272653SPeter Holm      kill_and_wait(pid, &status);
327*8a272653SPeter Holm      break;
328*8a272653SPeter Holm    }
329*8a272653SPeter Holm    remove_dir(cwdbuf);
330*8a272653SPeter Holm  }
331*8a272653SPeter Holm}
332*8a272653SPeter Holm
333*8a272653SPeter Holmuint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff};
334*8a272653SPeter Holm
335*8a272653SPeter Holmvoid execute_call(int call)
336*8a272653SPeter Holm{
337*8a272653SPeter Holm  intptr_t res = 0;
338*8a272653SPeter Holm  switch (call) {
339*8a272653SPeter Holm  case 0:
340*8a272653SPeter Holm    NONFAILING(memcpy((void*)0x20000000, ".\000", 2));
341*8a272653SPeter Holm    res = syscall(SYS_open, 0x20000000ul, 0ul, 0ul);
342*8a272653SPeter Holm    if (res != -1)
343*8a272653SPeter Holm      r[0] = res;
344*8a272653SPeter Holm    break;
345*8a272653SPeter Holm  case 1:
346*8a272653SPeter Holm    res = syscall(SYS_socketpair, 1ul, 2ul, 0, 0x20000100ul);
347*8a272653SPeter Holm    if (res != -1)
348*8a272653SPeter Holm      NONFAILING(r[1] = *(uint32_t*)0x20000100);
349*8a272653SPeter Holm    break;
350*8a272653SPeter Holm  case 2:
351*8a272653SPeter Holm    NONFAILING(memcpy(
352*8a272653SPeter Holm        (void*)0x20000180,
353*8a272653SPeter Holm        "\x0a\x01\x2e\x2f\x66\x69\x6c\x65\x30\x00\x46\xd3\xc5\xea\xb2\xf9\xd0"
354*8a272653SPeter Holm        "\x81\x73\xef\x4a\xd0\xe9\x00\x9b\x10\xb2\x6d\x40\xab\xf3\x06\x35\x55"
355*8a272653SPeter Holm        "\x92\x6b\xa7\x48\x51\xed\xf1\x47\x2a\x1c\x57\xda\x98\x4d\x23\x4f\x6d"
356*8a272653SPeter Holm        "\x63\x57\x71\x99\x01\x97\x42\xef\xe9\xd6\x91\x78\x55\x43\x7f\x80\x8b"
357*8a272653SPeter Holm        "\xf3\xfa\x29\xeb\x62\xeb\x2f\x4b\xb5\xcd\x3f\xd7\x4f\x78\x35\xfb\xd3"
358*8a272653SPeter Holm        "\x24\xe3\xc4\x10\x31\x53\xdd\xe7\x9a\x1c\x23\x36\x48\xe4\x7a\xf8\x3a"
359*8a272653SPeter Holm        "\x7e\xd0\x1f\x89\xf7\xb6\xee\xff\x69\x1d\xad\x02\x57\x01\xf2\x52\x93"
360*8a272653SPeter Holm        "\x3e\x6b\xda\x65\x2a\xc7\x6c\x27\xf9\x0a\xd4\x3b\x05\x00\x00\x00\x1b"
361*8a272653SPeter Holm        "\x1c\x89\xc9\x3b\x41\x9c\x7b\x4f\x31\xbb\x6a\x5c\x17\xed\x78\xf1\x64"
362*8a272653SPeter Holm        "\xc4\xa3\x17\x5c\x7a\x8c\x02\x75\x00\xaf\x61\xac\x90\x22\x86\x15\x67"
363*8a272653SPeter Holm        "\x90\x03\x17\x8c\x55\xf6\xb9\x3a\xf8\x6c\xab\xcb\xf1\x74\x09\xc0\xbc"
364*8a272653SPeter Holm        "\xf4\x5b\x76\x33\x8f\x9a\x76\xf3\x6e",
365*8a272653SPeter Holm        196));
366*8a272653SPeter Holm    syscall(SYS_bindat, r[0], r[1], 0x20000180ul, 0xaul);
367*8a272653SPeter Holm    break;
368*8a272653SPeter Holm  case 3:
369*8a272653SPeter Holm    NONFAILING(*(uint8_t*)0x20000040 = 0xa);
370*8a272653SPeter Holm    NONFAILING(*(uint8_t*)0x20000041 = 1);
371*8a272653SPeter Holm    NONFAILING(memcpy((void*)0x20000042, "./file0\000", 8));
372*8a272653SPeter Holm    syscall(SYS_connectat, r[0], r[1], 0x20000040ul, 0xaul);
373*8a272653SPeter Holm    break;
374*8a272653SPeter Holm  case 4:
375*8a272653SPeter Holm    NONFAILING(*(uint8_t*)0x20000000 = 0xa);
376*8a272653SPeter Holm    NONFAILING(*(uint8_t*)0x20000001 = 1);
377*8a272653SPeter Holm    NONFAILING(memcpy((void*)0x20000002, "./file0\000", 8));
378*8a272653SPeter Holm    syscall(SYS_connect, r[1], 0x20000000ul, 0xaul);
379*8a272653SPeter Holm    break;
380*8a272653SPeter Holm  }
381*8a272653SPeter Holm}
382*8a272653SPeter Holmint main(void)
383*8a272653SPeter Holm{
384*8a272653SPeter Holm  syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x1012ul, -1, 0ul);
385*8a272653SPeter Holm  install_segv_handler();
386*8a272653SPeter Holm  use_temporary_dir();
387*8a272653SPeter Holm  loop();
388*8a272653SPeter Holm  return 0;
389*8a272653SPeter Holm}
390*8a272653SPeter HolmEOF
391*8a272653SPeter Holmmycc -o /tmp/syzkaller23 -Wall -Wextra -O0 /tmp/syzkaller23.c -lpthread ||
392*8a272653SPeter Holm    exit 1
393*8a272653SPeter Holm
394*8a272653SPeter Holmfor i in `jot 256`; do
395*8a272653SPeter Holm	(cd /tmp; timeout 3m ./syzkaller23) &
396*8a272653SPeter Holmdone
397*8a272653SPeter Holmwait
398*8a272653SPeter Holm
399*8a272653SPeter Holmrm -rf /tmp/syzkaller23 /tmp/syzkaller23.c /tmp/syzkaller.*
400*8a272653SPeter Holmexit 0
401