net/sctp: use-after-free in sctp_hash_transport
From: Andrey Konovalov
Date: Mon Feb 27 2017 - 11:14:18 EST
Hi,
I've got the following error report while fuzzing the kernel with syzkaller.
On commit e5d56efc97f8240d0b5d66c03949382b6d7e5570 (Feb 26).
A reproducer and .config are attached.
===============================
[ ERR: suspicious RCU usage. ]
4.10.0+ #54 Not tainted
-------------------------------
./include/linux/rhashtable.h:602 suspicious rcu_dereference_check() usage!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 0
1 lock held by a.out/4189:
#0: (sk_lock-AF_INET6){+.+.+.}, at: [<ffffffff84510c78>]
sctp_setsockopt+0x318/0x5f10
stack backtrace:
CPU: 1 PID: 4189 Comm: a.out Not tainted 4.10.0+ #54
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:15
dump_stack+0x292/0x398 lib/dump_stack.c:51
lockdep_rcu_suspicious+0x139/0x180 kernel/locking/lockdep.c:4452
__rhashtable_lookup ./include/linux/rhashtable.h:602
rhltable_lookup ./include/linux/rhashtable.h:690
sctp_hash_transport+0x826/0xcc0 net/sctp/input.c:887
sctp_assoc_add_peer+0xd0b/0x1470 net/sctp/associola.c:716
__sctp_connect+0x26d/0xdb0 net/sctp/socket.c:1184
__sctp_setsockopt_connectx+0x197/0x200 net/sctp/socket.c:1338
sctp_setsockopt_connectx net/sctp/socket.c:1370
sctp_setsockopt+0x15fa/0x5f10 net/sctp/socket.c:3936
sock_common_setsockopt+0x95/0xd0 net/core/sock.c:2725
SYSC_setsockopt net/socket.c:1786
SyS_setsockopt+0x270/0x3a0 net/socket.c:1765
entry_SYSCALL_64_fastpath+0x1f/0xc2 arch/x86/entry/entry_64.S:204
RIP: 0033:0x7f3e27a55b79
RSP: 002b:00007f3e2296fd98 EFLAGS: 00000206 ORIG_RAX: 0000000000000036
RAX: ffffffffffffffda RBX: 00007f3e229709c0 RCX: 00007f3e27a55b79
RDX: 000000000000006e RSI: 0000000000000084 RDI: 0000000000000003
RBP: 00007f3e27f21220 R08: 0000000000000010 R09: 0000000000000000
R10: 0000000020004000 R11: 0000000000000206 R12: 0000000000000000
R13: 00007f3e229709c0 R14: 00007f3e2834c040 R15: 0000000000000003
==================================================================
BUG: KASAN: use-after-free in sctp_hash_transport+0x855/0xcc0 at addr
ffff8800671e1f8c
Read of size 4 by task a.out/4189
CPU: 1 PID: 4189 Comm: a.out Not tainted 4.10.0+ #54
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:15
dump_stack+0x292/0x398 lib/dump_stack.c:51
kasan_object_err+0x1c/0x70 mm/kasan/report.c:162
print_address_description mm/kasan/report.c:200
kasan_report_error mm/kasan/report.c:289
kasan_report.part.1+0x20e/0x4e0 mm/kasan/report.c:311
kasan_report mm/kasan/report.c:331
__asan_report_load4_noabort+0x29/0x30 mm/kasan/report.c:331
rht_key_hashfn ./include/linux/rhashtable.h:254
__rhashtable_lookup ./include/linux/rhashtable.h:604
rhltable_lookup ./include/linux/rhashtable.h:690
sctp_hash_transport+0x855/0xcc0 net/sctp/input.c:887
sctp_assoc_add_peer+0xd0b/0x1470 net/sctp/associola.c:716
__sctp_connect+0x26d/0xdb0 net/sctp/socket.c:1184
__sctp_setsockopt_connectx+0x197/0x200 net/sctp/socket.c:1338
sctp_setsockopt_connectx net/sctp/socket.c:1370
sctp_setsockopt+0x15fa/0x5f10 net/sctp/socket.c:3936
sock_common_setsockopt+0x95/0xd0 net/core/sock.c:2725
SYSC_setsockopt net/socket.c:1786
SyS_setsockopt+0x270/0x3a0 net/socket.c:1765
entry_SYSCALL_64_fastpath+0x1f/0xc2 arch/x86/entry/entry_64.S:204
RIP: 0033:0x7f3e27a55b79
RSP: 002b:00007f3e2296fd98 EFLAGS: 00000206 ORIG_RAX: 0000000000000036
RAX: ffffffffffffffda RBX: 00007f3e229709c0 RCX: 00007f3e27a55b79
RDX: 000000000000006e RSI: 0000000000000084 RDI: 0000000000000003
RBP: 00007f3e27f21220 R08: 0000000000000010 R09: 0000000000000000
R10: 0000000020004000 R11: 0000000000000206 R12: 0000000000000000
R13: 00007f3e229709c0 R14: 00007f3e2834c040 R15: 0000000000000003
Object at ffff8800671e1f80, in cache kmalloc-1024 size: 1024
Allocated:
PID = 1
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
save_stack+0x43/0xd0 mm/kasan/kasan.c:502
set_track mm/kasan/kasan.c:514
kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:605
__kmalloc+0xa0/0x2d0 mm/slub.c:3745
kmalloc ./include/linux/slab.h:495
kzalloc ./include/linux/slab.h:663
bucket_table_alloc+0x618/0x930 lib/rhashtable.c:224
rhashtable_init+0x5f8/0xc60 lib/rhashtable.c:1006
rhltable_init+0x53/0xa0 lib/rhashtable.c:1037
sctp_transport_hashtable_init+0x1c/0x20 net/sctp/input.c:865
sctp_init+0x62c/0x88f net/sctp/protocol.c:1486
do_one_initcall+0xf3/0x390 init/main.c:788
do_initcall_level init/main.c:854
do_initcalls init/main.c:862
do_basic_setup init/main.c:880
kernel_init_freeable+0x5cc/0x6a6 init/main.c:1031
kernel_init+0x13/0x180 init/main.c:955
ret_from_fork+0x31/0x40 arch/x86/entry/entry_64.S:430
Freed:
PID = 0
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
save_stack+0x43/0xd0 mm/kasan/kasan.c:502
set_track mm/kasan/kasan.c:514
kasan_slab_free+0x73/0xc0 mm/kasan/kasan.c:578
slab_free_hook mm/slub.c:1357
slab_free_freelist_hook mm/slub.c:1379
slab_free mm/slub.c:2961
kfree+0xe8/0x2b0 mm/slub.c:3882
kvfree+0x36/0x60 mm/util.c:335
bucket_table_free+0xd7/0x260 lib/rhashtable.c:152
bucket_table_free_rcu+0x16/0x20 lib/rhashtable.c:157
__rcu_reclaim kernel/rcu/rcu.h:118
rcu_do_batch.isra.64+0x94c/0xcc0 kernel/rcu/tree.c:2877
invoke_rcu_callbacks kernel/rcu/tree.c:3140
__rcu_process_callbacks kernel/rcu/tree.c:3107
rcu_process_callbacks+0x2cc/0xb90 kernel/rcu/tree.c:3124
__do_softirq+0x2fb/0xb7d kernel/softirq.c:284
Memory state around the buggy address:
ffff8800671e1e80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8800671e1f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8800671e1f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8800671e2000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8800671e2080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
...
...
...
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN
Modules linked in:
CPU: 1 PID: 4189 Comm: a.out Tainted: G B 4.10.0+ #54
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
task: ffff880069111600 task.stack: ffff880068638000
RIP: 0010:rht_bucket_nested+0x18e/0x560 lib/rhashtable.c:1126
RSP: 0018:ffff88006863eda8 EFLAGS: 00010246
RAX: dffffc0000000000 RBX: 000000006be18a80 RCX: 1ffff1000d0c7dbf
RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffffffff85a5ee80
RBP: ffff88006863ee60 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: dffffc0000000000 R12: 0000000000000001
R13: ffff8800671e1f84 R14: ffff8800671e1f80 R15: dffffc0000000000
FS: 00007f3e22970700(0000) GS:ffff88006cb00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f3e2216ef38 CR3: 0000000065589000 CR4: 00000000000006e0
Call Trace:
rht_bucket ./include/linux/rhashtable.h:404
__rhashtable_lookup ./include/linux/rhashtable.h:605
rhltable_lookup ./include/linux/rhashtable.h:690
sctp_hash_transport+0xaa9/0xcc0 net/sctp/input.c:887
sctp_assoc_add_peer+0xd0b/0x1470 net/sctp/associola.c:716
__sctp_connect+0x26d/0xdb0 net/sctp/socket.c:1184
__sctp_setsockopt_connectx+0x197/0x200 net/sctp/socket.c:1338
sctp_setsockopt_connectx net/sctp/socket.c:1370
sctp_setsockopt+0x15fa/0x5f10 net/sctp/socket.c:3936
sock_common_setsockopt+0x95/0xd0 net/core/sock.c:2725
SYSC_setsockopt net/socket.c:1786
SyS_setsockopt+0x270/0x3a0 net/socket.c:1765
entry_SYSCALL_64_fastpath+0x1f/0xc2 arch/x86/entry/entry_64.S:204
RIP: 0033:0x7f3e27a55b79
RSP: 002b:00007f3e2296fd98 EFLAGS: 00000206 ORIG_RAX: 0000000000000036
RAX: ffffffffffffffda RBX: 00007f3e229709c0 RCX: 00007f3e27a55b79
RDX: 000000000000006e RSI: 0000000000000084 RDI: 0000000000000003
RBP: 00007f3e27f21220 R08: 0000000000000010 R09: 0000000000000000
R10: 0000000020004000 R11: 0000000000000206 R12: 0000000000000000
R13: 00007f3e229709c0 R14: 00007f3e2834c040 R15: 0000000000000003
Code: 34 14 97 03 00 0f 84 a4 01 00 00 e8 9d e2 4b ff 8b 85 70 ff ff
ff 4d 8d 24 c4 48 b8 00 00 00 00 00 fc ff df 4c 89 e2 48 c1 ea 03 <80>
3c 02 00 0f 85 b1 03 00 00 4c 89 ea 48 b8 00 00 00 00 00 fc
RIP: rht_bucket_nested+0x18e/0x560 RSP: ffff88006863eda8
---[ end trace 9d36cf16fcdf072c ]--
Attachment:
.config
Description: Binary data
// autogenerated by syzkaller (http://github.com/google/syzkaller)
#ifndef __NR_mmap
#define __NR_mmap 9
#endif
#ifndef __NR_socketpair
#define __NR_socketpair 53
#endif
#ifndef __NR_socket
#define __NR_socket 41
#endif
#ifndef __NR_getsockopt
#define __NR_getsockopt 55
#endif
#ifndef __NR_setsockopt
#define __NR_setsockopt 54
#endif
#ifndef __NR_connect
#define __NR_connect 42
#endif
#ifndef __NR_ioctl
#define __NR_ioctl 16
#endif
#define _GNU_SOURCE
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <linux/capability.h>
#include <linux/if.h>
#include <linux/if_tun.h>
#include <linux/kvm.h>
#include <linux/sched.h>
#include <net/if_arp.h>
#include <assert.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
#include <pthread.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
const int kFailStatus = 67;
const int kErrorStatus = 68;
const int kRetryStatus = 69;
__attribute__((noreturn)) void doexit(int status)
{
volatile unsigned i;
syscall(__NR_exit_group, status);
for (i = 0;; i++) {
}
}
__attribute__((noreturn)) void fail(const char* msg, ...)
{
int e = errno;
fflush(stdout);
va_list args;
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
fprintf(stderr, " (errno %d)\n", e);
doexit(e == ENOMEM ? kRetryStatus : kFailStatus);
}
__attribute__((noreturn)) void exitf(const char* msg, ...)
{
int e = errno;
fflush(stdout);
va_list args;
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
fprintf(stderr, " (errno %d)\n", e);
doexit(kRetryStatus);
}
static int flag_debug;
void debug(const char* msg, ...)
{
if (!flag_debug)
return;
va_list args;
va_start(args, msg);
vfprintf(stdout, msg, args);
va_end(args);
fflush(stdout);
}
__thread int skip_segv;
__thread jmp_buf segv_env;
static void segv_handler(int sig, siginfo_t* info, void* uctx)
{
uintptr_t addr = (uintptr_t)info->si_addr;
const uintptr_t prog_start = 1 << 20;
const uintptr_t prog_end = 100 << 20;
if (__atomic_load_n(&skip_segv, __ATOMIC_RELAXED) &&
(addr < prog_start || addr > prog_end)) {
debug("SIGSEGV on %p, skipping\n", addr);
_longjmp(segv_env, 1);
}
debug("SIGSEGV on %p, exiting\n", addr);
doexit(sig);
for (;;) {
}
}
static void install_segv_handler()
{
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_sigaction = segv_handler;
sa.sa_flags = SA_NODEFER | SA_SIGINFO;
sigaction(SIGSEGV, &sa, NULL);
sigaction(SIGBUS, &sa, NULL);
}
#define NONFAILING(...) \
{ \
__atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \
if (_setjmp(segv_env) == 0) { \
__VA_ARGS__; \
} \
__atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \
}
#define BITMASK_LEN(type, bf_len) (type)((1ull << (bf_len)) - 1)
#define BITMASK_LEN_OFF(type, bf_off, bf_len) \
(type)(BITMASK_LEN(type, (bf_len)) << (bf_off))
#define STORE_BY_BITMASK(type, addr, val, bf_off, bf_len) \
if ((bf_off) == 0 && (bf_len) == 0) { \
*(type*)(addr) = (type)(val); \
} else { \
type new_val = *(type*)(addr); \
new_val &= ~BITMASK_LEN_OFF(type, (bf_off), (bf_len)); \
new_val |= ((type)(val)&BITMASK_LEN(type, (bf_len))) << (bf_off); \
*(type*)(addr) = new_val; \
}
static uintptr_t execute_syscall(int nr, uintptr_t a0, uintptr_t a1,
uintptr_t a2, uintptr_t a3,
uintptr_t a4, uintptr_t a5,
uintptr_t a6, uintptr_t a7,
uintptr_t a8)
{
switch (nr) {
default:
return syscall(nr, a0, a1, a2, a3, a4, a5);
}
}
static void setup_main_process()
{
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = SIG_IGN;
syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8);
syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8);
install_segv_handler();
char tmpdir_template[] = "./syzkaller.XXXXXX";
char* tmpdir = mkdtemp(tmpdir_template);
if (!tmpdir)
fail("failed to mkdtemp");
if (chmod(tmpdir, 0777))
fail("failed to chmod");
if (chdir(tmpdir))
fail("failed to chdir");
}
static void loop();
static void sandbox_common()
{
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
setpgrp();
setsid();
struct rlimit rlim;
rlim.rlim_cur = rlim.rlim_max = 128 << 20;
setrlimit(RLIMIT_AS, &rlim);
rlim.rlim_cur = rlim.rlim_max = 1 << 20;
setrlimit(RLIMIT_FSIZE, &rlim);
rlim.rlim_cur = rlim.rlim_max = 1 << 20;
setrlimit(RLIMIT_STACK, &rlim);
rlim.rlim_cur = rlim.rlim_max = 0;
setrlimit(RLIMIT_CORE, &rlim);
unshare(CLONE_NEWNS);
unshare(CLONE_NEWIPC);
unshare(CLONE_IO);
}
static int do_sandbox_none(int executor_pid, bool enable_tun)
{
int pid = fork();
if (pid)
return pid;
sandbox_common();
loop();
doexit(1);
}
static void remove_dir(const char* dir)
{
DIR* dp;
struct dirent* ep;
int iter = 0;
retry:
dp = opendir(dir);
if (dp == NULL) {
if (errno == EMFILE) {
exitf("opendir(%s) failed due to NOFILE, exiting");
}
exitf("opendir(%s) failed", dir);
}
while ((ep = readdir(dp))) {
if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0)
continue;
char filename[FILENAME_MAX];
snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name);
struct stat st;
if (lstat(filename, &st))
exitf("lstat(%s) failed", filename);
if (S_ISDIR(st.st_mode)) {
remove_dir(filename);
continue;
}
int i;
for (i = 0;; i++) {
debug("unlink(%s)\n", filename);
if (unlink(filename) == 0)
break;
if (errno == EROFS) {
debug("ignoring EROFS\n");
break;
}
if (errno != EBUSY || i > 100)
exitf("unlink(%s) failed", filename);
debug("umount(%s)\n", filename);
if (umount2(filename, MNT_DETACH))
exitf("umount(%s) failed", filename);
}
}
closedir(dp);
int i;
for (i = 0;; i++) {
debug("rmdir(%s)\n", dir);
if (rmdir(dir) == 0)
break;
if (i < 100) {
if (errno == EROFS) {
debug("ignoring EROFS\n");
break;
}
if (errno == EBUSY) {
debug("umount(%s)\n", dir);
if (umount2(dir, MNT_DETACH))
exitf("umount(%s) failed", dir);
continue;
}
if (errno == ENOTEMPTY) {
if (iter < 100) {
iter++;
goto retry;
}
}
}
exitf("rmdir(%s) failed", dir);
}
}
static uint64_t current_time_ms()
{
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts))
fail("clock_gettime failed");
return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
}
static void test();
void loop()
{
int iter;
for (iter = 0;; iter++) {
char cwdbuf[256];
sprintf(cwdbuf, "./%d", iter);
if (mkdir(cwdbuf, 0777))
fail("failed to mkdir");
int pid = fork();
if (pid < 0)
fail("clone failed");
if (pid == 0) {
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
setpgrp();
if (chdir(cwdbuf))
fail("failed to chdir");
test();
doexit(0);
}
int status = 0;
uint64_t start = current_time_ms();
for (;;) {
int res = waitpid(-1, &status, __WALL | WNOHANG);
if (res == pid)
break;
usleep(1000);
if (current_time_ms() - start > 5 * 1000) {
kill(-pid, SIGKILL);
kill(pid, SIGKILL);
while (waitpid(-1, &status, __WALL) != pid) {
}
break;
}
}
remove_dir(cwdbuf);
}
}
long r[41];
void* thr(void* arg)
{
switch ((long)arg) {
case 0:
r[0] =
execute_syscall(__NR_mmap, 0x20000000ul, 0xa000ul, 0x3ul,
0x32ul, 0xfffffffffffffffful, 0x0ul, 0, 0, 0);
break;
case 1:
r[1] = execute_syscall(__NR_socketpair, 0x2ul, 0x2ul, 0x0ul,
0x2000a000ul, 0, 0, 0, 0, 0);
break;
case 2:
r[2] = execute_syscall(__NR_socket, 0xaul, 0x1ul, 0x84ul, 0, 0, 0,
0, 0, 0);
break;
case 3:
r[3] =
execute_syscall(__NR_mmap, 0x2000a000ul, 0x1000ul, 0x3ul,
0x32ul, 0xfffffffffffffffful, 0x0ul, 0, 0, 0);
break;
case 4:
NONFAILING(*(uint32_t*)0x20005ffc = (uint32_t)0x4);
r[5] = execute_syscall(__NR_getsockopt, r[2], 0x84ul, 0x20ul,
0x2000affcul, 0x20005ffcul, 0, 0, 0, 0);
break;
case 5:
NONFAILING(*(uint32_t*)0x20003000 = (uint32_t)0x4);
r[7] = execute_syscall(__NR_getsockopt, r[2], 0x84ul, 0x8ul,
0x2000bffcul, 0x20003000ul, 0, 0, 0, 0);
break;
case 6:
NONFAILING(*(uint32_t*)0x20001ffc = (uint32_t)0xffffffff);
r[9] = execute_syscall(__NR_setsockopt, r[2], 0x84ul, 0xcul,
0x20001ffcul, 0x4ul, 0, 0, 0, 0);
break;
case 7:
r[10] =
execute_syscall(__NR_mmap, 0x2000a000ul, 0x1000ul, 0x3ul,
0x32ul, 0xfffffffffffffffful, 0x0ul, 0, 0, 0);
break;
case 8:
NONFAILING(*(uint32_t*)0x2000a000 = (uint32_t)0x8001);
r[12] = execute_syscall(__NR_setsockopt, r[2], 0x84ul, 0x7ul,
0x2000a000ul, 0x4ul, 0, 0, 0, 0);
break;
case 9:
NONFAILING(*(uint16_t*)0x2000cff6 = (uint16_t)0x2);
NONFAILING(memcpy((void*)0x2000cff8,
"\x2e\x2f\x66\x69\x6c\x65\x30\x00", 8));
r[15] = execute_syscall(__NR_connect, r[2], 0x2000cff6ul, 0xaul, 0,
0, 0, 0, 0, 0);
break;
case 10:
NONFAILING(*(uint16_t*)0x20004000 = (uint16_t)0x2);
NONFAILING(*(uint16_t*)0x20004002 = (uint16_t)0x224e);
NONFAILING(*(uint32_t*)0x20004004 = (uint32_t)0x100007f);
NONFAILING(*(uint8_t*)0x20004008 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x20004009 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x2000400a = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x2000400b = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x2000400c = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x2000400d = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x2000400e = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x2000400f = (uint8_t)0x0);
r[27] = execute_syscall(__NR_setsockopt, r[2], 0x84ul, 0x6eul,
0x20004000ul, 0x10ul, 0, 0, 0, 0);
break;
case 11:
NONFAILING(*(uint16_t*)0x2000d000 = (uint16_t)0x2);
NONFAILING(*(uint16_t*)0x2000d002 = (uint16_t)0x204e);
NONFAILING(*(uint32_t*)0x2000d004 = (uint32_t)0x0);
NONFAILING(*(uint8_t*)0x2000d008 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x2000d009 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x2000d00a = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x2000d00b = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x2000d00c = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x2000d00d = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x2000d00e = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x2000d00f = (uint8_t)0x0);
r[39] = execute_syscall(__NR_setsockopt, r[2], 0x84ul, 0x6bul,
0x2000d000ul, 0x10ul, 0, 0, 0, 0);
break;
case 12:
r[40] = execute_syscall(__NR_ioctl, r[2], 0x541bul, 0x20006ffcul, 0,
0, 0, 0, 0, 0);
break;
}
return 0;
}
void test()
{
long i;
pthread_t th[26];
memset(r, -1, sizeof(r));
srand(getpid());
for (i = 0; i < 13; i++) {
pthread_create(&th[i], 0, thr, (void*)i);
usleep(10000);
}
for (i = 0; i < 13; i++) {
pthread_create(&th[13 + i], 0, thr, (void*)i);
if (rand() % 2)
usleep(rand() % 10000);
}
usleep(100000);
}
int main()
{
int i;
for (i = 0; i < 8; i++) {
if (fork() == 0) {
setup_main_process();
int pid = do_sandbox_none(i, false);
int status = 0;
while (waitpid(pid, &status, __WALL) != pid) {
}
return 0;
}
}
sleep(1000000);
return 0;
}