All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ltp: cve/meltdown.c: Fix kernel symbol finding
@ 2019-08-27  4:38 zhe.he
  2019-08-27 15:56 ` Richard Purdie
  0 siblings, 1 reply; 3+ messages in thread
From: zhe.he @ 2019-08-27  4:38 UTC (permalink / raw)
  To: openembedded-core

From: He Zhe <zhe.he@windriver.com>

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@windriver.com>
---
 ...-cve-meltdown.c-Fix-kernel-symbol-finding.patch | 83 ++++++++++++++++++++++
 meta/recipes-extended/ltp/ltp_20190517.bb          |  1 +
 2 files changed, 84 insertions(+)
 create mode 100644 meta/recipes-extended/ltp/ltp/0001-cve-meltdown.c-Fix-kernel-symbol-finding.patch

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@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@windriver.com>
+Signed-off-by: Jan Stancek <jstancek@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"
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ltp: cve/meltdown.c: Fix kernel symbol finding
  2019-08-27  4:38 [PATCH] ltp: cve/meltdown.c: Fix kernel symbol finding zhe.he
@ 2019-08-27 15:56 ` Richard Purdie
  2019-08-28  6:23   ` He Zhe
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Purdie @ 2019-08-27 15:56 UTC (permalink / raw)
  To: zhe.he, openembedded-core

On Tue, 2019-08-27 at 12:38 +0800, zhe.he@windriver.com wrote:
> From: He Zhe <zhe.he@windriver.com>
> 
> 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@windriver.com>
> ---
>  ...-cve-meltdown.c-Fix-kernel-symbol-finding.patch | 83
> ++++++++++++++++++++++
>  meta/recipes-extended/ltp/ltp_20190517.bb          |  1 +
>  2 files changed, 84 insertions(+)
>  create mode 100644 meta/recipes-extended/ltp/ltp/0001-cve-
> meltdown.c-Fix-kernel-symbol-finding.patch

Patch doesn't apply, how was this tested?

https://autobuilder.yoctoproject.org/typhoon/#/builders/65/builds/981/steps/8/logs/step1b

Cheers,

Richard



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ltp: cve/meltdown.c: Fix kernel symbol finding
  2019-08-27 15:56 ` Richard Purdie
@ 2019-08-28  6:23   ` He Zhe
  0 siblings, 0 replies; 3+ messages in thread
From: He Zhe @ 2019-08-28  6:23 UTC (permalink / raw)
  To: Richard Purdie, openembedded-core



On 8/27/19 11:56 PM, Richard Purdie wrote:
> On Tue, 2019-08-27 at 12:38 +0800, zhe.he@windriver.com wrote:
>> From: He Zhe <zhe.he@windriver.com>
>>
>> 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@windriver.com>
>> ---
>>  ...-cve-meltdown.c-Fix-kernel-symbol-finding.patch | 83
>> ++++++++++++++++++++++
>>  meta/recipes-extended/ltp/ltp_20190517.bb          |  1 +
>>  2 files changed, 84 insertions(+)
>>  create mode 100644 meta/recipes-extended/ltp/ltp/0001-cve-
>> meltdown.c-Fix-kernel-symbol-finding.patch
> Patch doesn't apply, how was this tested?

Sorry, my test environment messed up with upstream ltp.
v2 will be sent.

Zhe

>
> https://autobuilder.yoctoproject.org/typhoon/#/builders/65/builds/981/steps/8/logs/step1b
>
> Cheers,
>
> Richard
>
>



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-28  6:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27  4:38 [PATCH] ltp: cve/meltdown.c: Fix kernel symbol finding zhe.he
2019-08-27 15:56 ` Richard Purdie
2019-08-28  6:23   ` He Zhe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.