[oe-commits] [openembedded-core] 07/35: ltp: cve/meltdown.c: Fix kernel symbol finding

git at git.openembedded.org git at git.openembedded.org
Tue Aug 27 13:05:32 UTC 2019


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit e15fb58c23c9c75b7297b2f655300dab586e1c32
Author: He Zhe <zhe.he at windriver.com>
AuthorDate: Tue Aug 27 12:38:06 2019 +0800

    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
    
    Signed-off-by: He Zhe <zhe.he at windriver.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 ...-cve-meltdown.c-Fix-kernel-symbol-finding.patch | 83 ++++++++++++++++++++++
 meta/recipes-extended/ltp/ltp_20190517.bb          |  1 +
 2 files changed, 84 insertions(+)

diff --git a/meta/recipes-extended/ltp/ltp/0001-cve-meltdown.c-Fix-kernel-symbol-finding.patch b/meta/recipes-extended/ltp/ltp/0001-cve-meltdown.c-Fix-kernel-symbol-finding.patch
new file mode 100644
index 0000000..c639c40
--- /dev/null
+++ b/meta/recipes-extended/ltp/ltp/0001-cve-meltdown.c-Fix-kernel-symbol-finding.patch
@@ -0,0 +1,83 @@
+From c2049b5c874bc071f8185bffb5fd7dcb042d9ec8 Mon Sep 17 00:00:00 2001
+From: He Zhe <zhe.he at 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.
+
+Upstream-Status: Backport                                                        
+[https://github.com/linux-test-project/ltp/commit/c2049b5c874bc071f8185bffb5fd7dcb042d9ec8]
+
+Signed-off-by: He Zhe <zhe.he at windriver.com>
+Signed-off-by: Jan Stancek <jstancek at redhat.com>
+---
+ testcases/cve/meltdown.c | 18 ++++++++++--------
+ 1 file changed, 10 insertions(+), 8 deletions(-)
+
+diff --git a/testcases/cve/meltdown.c b/testcases/cve/meltdown.c
+index f78c38b..863f1a9 100644
+--- a/testcases/cve/meltdown.c
++++ b/testcases/cve/meltdown.c
+@@ -253,9 +253,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;
+ 
+@@ -269,20 +275,13 @@ find_kernel_symbol(const char *name)
+ 	struct utsname utsname;
+ 	unsigned long addr;
+ 
+-	if (access("/proc/kallsyms", F_OK) == -1)
+-		tst_brk(TCONF, "/proc/kallsyms not enabled");
+-
+ 	addr = find_symbol_in_file("/proc/kallsyms", 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;
+ }
+@@ -297,6 +296,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
+
diff --git a/meta/recipes-extended/ltp/ltp_20190517.bb b/meta/recipes-extended/ltp/ltp_20190517.bb
index b0e2f96..76c45f0 100644
--- a/meta/recipes-extended/ltp/ltp_20190517.bb
+++ b/meta/recipes-extended/ltp/ltp_20190517.bb
@@ -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://0001-syscalls-tgkill03-wait-for-defunct-tid-to-get-detach.patch \
            file://0001-ustat02-Fix-EFAULT-in-32bit-compatibility-mode.patch \
+           file://0001-cve-meltdown.c-Fix-kernel-symbol-finding.patch \
            "
 
 S = "${WORKDIR}/git"

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list