mirror of
https://git.yoctoproject.org/poky
synced 2026-05-31 12:49:46 +00:00
ltp: cve/meltdown.c: Fix kernel symbol finding
Backport a patch to fix the following error. safe_file_ops.c:219: BROK: Expected 3 conversions got 2 at meltdown.c:272 (From OE-Core rev: 372a211657bfddd7f32f30043ec06198f8c27101) Signed-off-by: He Zhe <zhe.he@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -0,0 +1,81 @@
|
|||||||
|
From fbeda82f440a0098be42dd668cbc47212a86ab48 Mon Sep 17 00:00:00 2001
|
||||||
|
From: He Zhe <zhe.he@windriver.com>
|
||||||
|
Date: Wed, 21 Aug 2019 16:27:24 +0800
|
||||||
|
Subject: [PATCH] cve/meltdown.c: Fix kernel symbol finding
|
||||||
|
|
||||||
|
meltdown case fails as below.
|
||||||
|
safe_file_ops.c:219: BROK: Expected 3 conversions got 2 at meltdown.c:272
|
||||||
|
|
||||||
|
find_kernel_symbol is defined to try twice with each of /proc/kallsyms and
|
||||||
|
/boot/System.map-%s. Currently if the symbol is not found in /proc/kallsyms,
|
||||||
|
when kernel option CONFIG_KALLSYMS_ALL is disabled, it would stop the case
|
||||||
|
immediately due to SAFE_FILE_LINES_SCANF.
|
||||||
|
|
||||||
|
This patch turns to use FILE_LINES_SCANF to give find_kernel_symbol second
|
||||||
|
chance.
|
||||||
|
|
||||||
|
[jstancek] Fix also condition introduced in 7709d2ae92ea, even if
|
||||||
|
/proc/kallsyms is disabled, we still want to try System.map.
|
||||||
|
|
||||||
|
Signed-off-by: He Zhe <zhe.he@windriver.com>
|
||||||
|
Signed-off-by: Jan Stancek <jstancek@redhat.com>
|
||||||
|
|
||||||
|
Upstream-Status: Backport
|
||||||
|
[https://github.com/linux-test-project/ltp/commit/c2049b5c874bc071f8185bffb5fd7dcb042d9ec8]
|
||||||
|
|
||||||
|
Remove the hunk for upstream 7709d2ae92ea ("cve/meltdown.c: abort the test if kallsyms was not enabled")
|
||||||
|
that has been covered by this patch.
|
||||||
|
|
||||||
|
Signed-off-by: He Zhe <zhe.he@windriver.com>
|
||||||
|
---
|
||||||
|
testcases/cve/meltdown.c | 13 ++++++++++---
|
||||||
|
1 file changed, 10 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/testcases/cve/meltdown.c b/testcases/cve/meltdown.c
|
||||||
|
index a53ea9b..22651a6 100644
|
||||||
|
--- a/testcases/cve/meltdown.c
|
||||||
|
+++ b/testcases/cve/meltdown.c
|
||||||
|
@@ -267,9 +267,15 @@ find_symbol_in_file(const char *filename, const char *symname)
|
||||||
|
int ret, read;
|
||||||
|
char fmt[strlen(symname) + 64];
|
||||||
|
|
||||||
|
+ tst_res(TINFO, "Looking for %s in %s", symname, filename);
|
||||||
|
+ if (access(filename, F_OK) == -1) {
|
||||||
|
+ tst_res(TINFO, "%s not available", filename);
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
sprintf(fmt, "%%lx %%c %s%%c", symname);
|
||||||
|
|
||||||
|
- ret = SAFE_FILE_LINES_SCANF(filename, fmt, &addr, &type, &read);
|
||||||
|
+ ret = FILE_LINES_SCANF(filename, fmt, &addr, &type, &read);
|
||||||
|
if (ret)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
@@ -287,13 +293,11 @@ find_kernel_symbol(const char *name)
|
||||||
|
if (addr)
|
||||||
|
return addr;
|
||||||
|
|
||||||
|
- tst_res(TINFO, "not found '%s' in /proc/kallsyms", name);
|
||||||
|
if (uname(&utsname) < 0)
|
||||||
|
tst_brk(TBROK | TERRNO, "uname");
|
||||||
|
|
||||||
|
sprintf(systemmap, "/boot/System.map-%s", utsname.release);
|
||||||
|
|
||||||
|
- tst_res(TINFO, "looking in '%s'\n", systemmap);
|
||||||
|
addr = find_symbol_in_file(systemmap, name);
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
@@ -308,6 +312,9 @@ static void setup(void)
|
||||||
|
saved_cmdline_addr = find_kernel_symbol("saved_command_line");
|
||||||
|
tst_res(TINFO, "&saved_command_line == 0x%lx", saved_cmdline_addr);
|
||||||
|
|
||||||
|
+ if (!saved_cmdline_addr)
|
||||||
|
+ tst_brk(TCONF, "saved_command_line not found");
|
||||||
|
+
|
||||||
|
spec_fd = SAFE_OPEN("/proc/cmdline", O_RDONLY);
|
||||||
|
|
||||||
|
memset(target_array, 1, sizeof(target_array));
|
||||||
|
--
|
||||||
|
2.7.4
|
||||||
|
|
||||||
@@ -45,6 +45,7 @@ SRC_URI = "git://github.com/linux-test-project/ltp.git \
|
|||||||
file://0002-check-for-RES_USE_INET6-during-configure.patch \
|
file://0002-check-for-RES_USE_INET6-during-configure.patch \
|
||||||
file://0001-syscalls-tgkill03-wait-for-defunct-tid-to-get-detach.patch \
|
file://0001-syscalls-tgkill03-wait-for-defunct-tid-to-get-detach.patch \
|
||||||
file://0001-ustat02-Fix-EFAULT-in-32bit-compatibility-mode.patch \
|
file://0001-ustat02-Fix-EFAULT-in-32bit-compatibility-mode.patch \
|
||||||
|
file://0001-cve-meltdown.c-Fix-kernel-symbol-finding.patch \
|
||||||
"
|
"
|
||||||
|
|
||||||
S = "${WORKDIR}/git"
|
S = "${WORKDIR}/git"
|
||||||
|
|||||||
Reference in New Issue
Block a user