mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-16 14:54:25 +00:00
This reverts commita5c6bc5900. The general approach described in commite076eaca59("selftests: break the dependency upon local header files") was taken one step too far here: it should not have been extended to include the syscall numbers. This is because doing so would require per-arch support in tools/include/uapi, and no such support exists. This revert fixes two separate reports of test failures, from Dave Hansen[1], and Li Wang[2]. An excerpt of Dave's report: Before this commit (a5c6bc5900) things are fine. But after, I get: running PKEY tests for unsupported CPU/OS An excerpt of Li's report: I just found that mlock2_() return a wrong value in mlock2-test [1] https://lore.kernel.org/dc585017-6740-4cab-a536-b12b37a7582d@intel.com [2] https://lore.kernel.org/CAEemH2eW=UMu9+turT2jRie7+6ewUazXmA6kL+VBo3cGDGU6RA@mail.gmail.com Link: https://lkml.kernel.org/r/20250214033850.235171-1-jhubbard@nvidia.com Fixes:a5c6bc5900("selftests/mm: remove local __NR_* definitions") Signed-off-by: John Hubbard <jhubbard@nvidia.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Li Wang <liwang@redhat.com> Cc: David Hildenbrand <david@redhat.com> Cc: Jeff Xu <jeffxu@chromium.org> Cc: Andrei Vagin <avagin@google.com> Cc: Axel Rasmussen <axelrasmussen@google.com> Cc: Christian Brauner <brauner@kernel.org> Cc: Kees Cook <kees@kernel.org> Cc: Kent Overstreet <kent.overstreet@linux.dev> Cc: Liam R. Howlett <Liam.Howlett@oracle.com> Cc: Muhammad Usama Anjum <usama.anjum@collabora.com> Cc: Peter Xu <peterx@redhat.com> Cc: Rich Felker <dalias@libc.org> Cc: Shuah Khan <shuah@kernel.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
49 lines
902 B
C
49 lines
902 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#include <syscall.h>
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.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;
|
|
}
|