mirror of
https://github.com/torvalds/linux.git
synced 2026-12-01 11:03:37 +00:00
This continues the work on getting the selftests to build without
requiring people to first run "make headers" [1].
Now that the system call numbers are in the correct, checked-in locations
in the kernel tree (./tools/include/uapi/asm/unistd*.h), make sure that
the mm selftests include that file (indirectly).
Doing so provides guaranteed definitions at build time, so remove all of
the checks for "ifdef __NR_xxx" in the mm selftests, because they will
always be true (defined).
[1] commit e076eaca59 ("selftests: break the dependency upon local
header files")
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: John Hubbard <[email protected]>
Acked-by: David Hildenbrand <[email protected]>
Cc: Jeff Xu <[email protected]>
Cc: Andrei Vagin <[email protected]>
Cc: Axel Rasmussen <[email protected]>
Cc: Christian Brauner <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Kent Overstreet <[email protected]>
Cc: Liam R. Howlett <[email protected]>
Cc: Muhammad Usama Anjum <[email protected]>
Cc: Peter Xu <[email protected]>
Cc: Rich Felker <[email protected]>
Cc: Shuah Khan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
50 lines
934 B
C
50 lines
934 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#include <syscall.h>
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <asm-generic/unistd.h>
|
|
|
|
static int mlock2_(void *start, size_t len, int flags)
|
|
{
|
|
return syscall(__NR_mlock2, start, len, flags);
|
|
}
|
|
|
|
static FILE *seek_to_smaps_entry(unsigned long addr)
|
|
{
|
|
FILE *file;
|
|
char *line = NULL;
|
|
size_t size = 0;
|
|
unsigned long start, end;
|
|
char perms[5];
|
|
unsigned long offset;
|
|
char dev[32];
|
|
unsigned long inode;
|
|
char path[BUFSIZ];
|
|
|
|
file = fopen("/proc/self/smaps", "r");
|
|
if (!file)
|
|
ksft_exit_fail_msg("fopen smaps: %s\n", strerror(errno));
|
|
|
|
while (getline(&line, &size, file) > 0) {
|
|
if (sscanf(line, "%lx-%lx %s %lx %s %lu %s\n",
|
|
&start, &end, perms, &offset, dev, &inode, path) < 6)
|
|
goto next;
|
|
|
|
if (start <= addr && addr < end)
|
|
goto out;
|
|
|
|
next:
|
|
free(line);
|
|
line = NULL;
|
|
size = 0;
|
|
}
|
|
|
|
fclose(file);
|
|
file = NULL;
|
|
|
|
out:
|
|
free(line);
|
|
return file;
|
|
}
|