aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/execvp-0.c15
-rwxr-xr-xtests/malloc-07
-rwxr-xr-xtests/malloc-1.sh4
-rw-r--r--tests/malloc.at1
-rw-r--r--tests/malloc_mmap_tst.c26
6 files changed, 56 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3627344..943ce3b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -18,6 +18,7 @@ check_PROGRAMS = \
chown-0 \
creat-0 \
creat64-0 \
+ execvp-0 \
faccessat-0 \
fchmodat-0 \
fchownat-0 \
@@ -72,6 +73,7 @@ check_PROGRAMS = \
\
getcwd-gnulib_tst \
libsigsegv_tst \
+ malloc_mmap_tst \
pipe-fork_tst \
pipe-fork_static_tst \
sb_printf_tst \
@@ -81,6 +83,7 @@ check_PROGRAMS = \
dist_check_SCRIPTS = \
$(wildcard $(srcdir)/*-[0-9]*.sh) \
+ malloc-0 \
script-0 \
trace-0
diff --git a/tests/execvp-0.c b/tests/execvp-0.c
new file mode 100644
index 0000000..6cfce13
--- /dev/null
+++ b/tests/execvp-0.c
@@ -0,0 +1,15 @@
+/*
+ * A simple wrapper for execvp. Useful when most host programs don't match
+ * the ABI of the active libsandbox.so (e.g. 64bit vs 32bit).
+ */
+
+#include "tests.h"
+
+int main(int argc, char *argv[])
+{
+ if (argc < 2) {
+ printf("usage: execvp <path> [argv0 [argvN] ...]\n");
+ return 0;
+ }
+ return execvp(argv[1], argv + 2);
+}
diff --git a/tests/malloc-0 b/tests/malloc-0
new file mode 100755
index 0000000..9a4190b
--- /dev/null
+++ b/tests/malloc-0
@@ -0,0 +1,7 @@
+#!/bin/sh
+# make sure `timeout` is available.
+if timeout --help >/dev/null ; then
+ exit 0
+else
+ exit 77
+fi
diff --git a/tests/malloc-1.sh b/tests/malloc-1.sh
new file mode 100755
index 0000000..2b5623d
--- /dev/null
+++ b/tests/malloc-1.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+# Since the malloc binary is in the target ABI, make sure the exec is
+# launched from the same ABI so the same libsandbox.so is used.
+timeout -s KILL 10 execvp-0 malloc_mmap_tst malloc_mmap_tst
diff --git a/tests/malloc.at b/tests/malloc.at
new file mode 100644
index 0000000..081d7d2
--- /dev/null
+++ b/tests/malloc.at
@@ -0,0 +1 @@
+SB_CHECK(1)
diff --git a/tests/malloc_mmap_tst.c b/tests/malloc_mmap_tst.c
new file mode 100644
index 0000000..a1a15e1
--- /dev/null
+++ b/tests/malloc_mmap_tst.c
@@ -0,0 +1,26 @@
+/* Make sure programs that override mmap don't mess us up. #290249 */
+
+#include "headers.h"
+
+/* A few basic stubs that do nothing. */
+void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
+{
+ errno = ENOMEM;
+ return MAP_FAILED;
+}
+int munmap(void *addr, size_t length)
+{
+ errno = ENOMEM;
+ return -1;
+}
+
+int main(int argc, char *argv[])
+{
+ /* Don't loop forever. */
+ alarm(10);
+
+ /* Make sure we do an operation to trigger the sandbox. */
+ open("/dev/null", 0);
+
+ return 0;
+}