aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-03-14 15:10:10 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2019-03-14 15:10:10 -0700
commitf261c4e529dac5608a604d3dd3ae1cd2adf23c89 (patch)
tree5e73077db2d1bd0011531941c2cb4cd65aeab78a /tools
parentMerge tag 'acpi-5.1-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm (diff)
parentinclude/linux/swap.h: use offsetof() instead of custom __swapoffset macro (diff)
downloadlinux-dev-f261c4e529dac5608a604d3dd3ae1cd2adf23c89.tar.xz
linux-dev-f261c4e529dac5608a604d3dd3ae1cd2adf23c89.zip
Merge branch 'akpm' (patches from Andrew)
Merge misc patches from Andrew Morton: - a little bit more MM - a few fixups [ The "little bit more MM" is actually just one of the three patches Andrew sent for mm/filemap.c, I'm still mulling over two more of them from Josef Bacik - Linus ] * emailed patches from Andrew Morton <akpm@linux-foundation.org>: include/linux/swap.h: use offsetof() instead of custom __swapoffset macro tools/testing/selftests/proc/proc-pid-vm.c: test with vsyscall in mind zram: default to lzo-rle instead of lzo filemap: pass vm_fault to the mmap ra helpers
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/proc/proc-pid-vm.c49
1 files changed, 46 insertions, 3 deletions
diff --git a/tools/testing/selftests/proc/proc-pid-vm.c b/tools/testing/selftests/proc/proc-pid-vm.c
index bbe8150d18aa..7202bbac976e 100644
--- a/tools/testing/selftests/proc/proc-pid-vm.c
+++ b/tools/testing/selftests/proc/proc-pid-vm.c
@@ -29,6 +29,7 @@
#include <errno.h>
#include <sched.h>
#include <signal.h>
+#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
@@ -36,11 +37,14 @@
#include <sys/mount.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/uio.h>
#include <linux/kdev_t.h>
+#include <sys/time.h>
+#include <sys/resource.h>
static inline long sys_execveat(int dirfd, const char *pathname, char **argv, char **envp, int flags)
{
@@ -205,12 +209,44 @@ static int make_exe(const uint8_t *payload, size_t len)
}
#endif
+static bool g_vsyscall = false;
+
+static const char str_vsyscall[] =
+"ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]\n";
+
#ifdef __x86_64__
+/*
+ * vsyscall page can't be unmapped, probe it with memory load.
+ */
+static void vsyscall(void)
+{
+ pid_t pid;
+ int wstatus;
+
+ pid = fork();
+ if (pid < 0) {
+ fprintf(stderr, "fork, errno %d\n", errno);
+ exit(1);
+ }
+ if (pid == 0) {
+ struct rlimit rlim = {0, 0};
+ (void)setrlimit(RLIMIT_CORE, &rlim);
+ *(volatile int *)0xffffffffff600000UL;
+ exit(0);
+ }
+ wait(&wstatus);
+ if (WIFEXITED(wstatus)) {
+ g_vsyscall = true;
+ }
+}
+
int main(void)
{
int pipefd[2];
int exec_fd;
+ vsyscall();
+
atexit(ate);
make_private_tmp();
@@ -261,9 +297,9 @@ int main(void)
snprintf(buf0 + MAPS_OFFSET, sizeof(buf0) - MAPS_OFFSET,
"/tmp/#%llu (deleted)\n", (unsigned long long)st.st_ino);
-
/* Test /proc/$PID/maps */
{
+ const size_t len = strlen(buf0) + (g_vsyscall ? strlen(str_vsyscall) : 0);
char buf[256];
ssize_t rv;
int fd;
@@ -274,13 +310,16 @@ int main(void)
return 1;
}
rv = read(fd, buf, sizeof(buf));
- assert(rv == strlen(buf0));
+ assert(rv == len);
assert(memcmp(buf, buf0, strlen(buf0)) == 0);
+ if (g_vsyscall) {
+ assert(memcmp(buf + strlen(buf0), str_vsyscall, strlen(str_vsyscall)) == 0);
+ }
}
/* Test /proc/$PID/smaps */
{
- char buf[1024];
+ char buf[4096];
ssize_t rv;
int fd;
@@ -319,6 +358,10 @@ int main(void)
for (i = 0; i < sizeof(S)/sizeof(S[0]); i++) {
assert(memmem(buf, rv, S[i], strlen(S[i])));
}
+
+ if (g_vsyscall) {
+ assert(memmem(buf, rv, str_vsyscall, strlen(str_vsyscall)));
+ }
}
/* Test /proc/$PID/smaps_rollup */