Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Disable netlink mmap feature since it creates nondeterminism
  • Loading branch information
rocallahan committed May 21, 2020
1 parent 01dd3e7 commit e62c972
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -897,6 +897,7 @@ set(BASIC_TESTS
munmap_discontinuous
nanosleep
netfilter
netlink_mmap_disable
no_mask_timeslice
nscd
numa
Expand Down
9 changes: 9 additions & 0 deletions src/record_syscall.cc
Expand Up @@ -19,6 +19,7 @@
#include <linux/msdos_fs.h>
#include <linux/msg.h>
#include <linux/net.h>
#include <linux/netlink.h>
#include <linux/perf_event.h>
#include <linux/personality.h>
#include <linux/prctl.h>
Expand Down Expand Up @@ -914,6 +915,14 @@ static bool block_sock_opt(int level, int optname,
return true;
}
break;
case SOL_NETLINK:
switch (optname) {
case NETLINK_RX_RING:
case NETLINK_TX_RING:
syscall_state.emulate_result(-ENOPROTOOPT);
return true;
}
break;
}
return false;
}
Expand Down
29 changes: 29 additions & 0 deletions src/test/netlink_mmap_disable.c
@@ -0,0 +1,29 @@
/* -*- Mode: C; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */

#include "util.h"

int main(void) {
int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
int ret;
unsigned int block_size = 16 * getpagesize();
struct nl_mmap_req req = {
.nm_block_size = block_size,
.nm_block_nr = 64,
.nm_frame_size = 16384,
.nm_frame_nr = 64 * block_size / 16384,
};

if (sock < 0) {
atomic_puts("Can't create netlink socket");
atomic_puts("EXIT-SUCCESS");
return 0;
}

ret = setsockopt(sock, SOL_NETLINK, NETLINK_RX_RING, &req, sizeof(req));
test_assert(ret < 0 && errno == ENOPROTOOPT);
ret = setsockopt(sock, SOL_NETLINK, NETLINK_TX_RING, &req, sizeof(req));
test_assert(ret < 0 && errno == ENOPROTOOPT);

atomic_puts("EXIT-SUCCESS");
return 0;
}
1 change: 1 addition & 0 deletions src/test/util.h
Expand Up @@ -38,6 +38,7 @@
#include <linux/if_tun.h>
#include <linux/limits.h>
#include <linux/mtio.h>
#include <linux/netlink.h>
#include <linux/perf_event.h>
#include <linux/personality.h>
#include <linux/random.h>
Expand Down

0 comments on commit e62c972

Please sign in to comment.