Skip to contentSkip to conversation

cve: Fix kernel symbol finding for meltdown case

PATCH New [email protected] 2 participants 3 messages Aug 21, 2019 – Aug 22, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cve: Fix kernel symbol finding for meltdown case

From: He Zhe <[email protected]>

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.

---
 testcases/cve/meltdown.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/cve/meltdown.c +1 -1
index f78c38b..2d66c1e 100644
@@ -255,7 +255,7 @@ find_symbol_in_file(const char *filename, const char *symname)
 
 	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;
 
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/1 cve: Fix kernel symbol finding for meltdown case

----- Original Message -----

Quoted 5 lines

From: He Zhe <[email protected]>

meltdown case fails as below.
safe_file_ops.c:219: BROK: Expected 3 conversions got 2 at meltdown.c:272

Quoted 7 lines

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.

That explains it, thanks for the patch.

We should also tweak TCONF condition in find_kernel_symbol - no need to re-post for that, I can add that.

Quoted 24 lines
---
 testcases/cve/meltdown.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/cve/meltdown.c +1 -2
index f78c38b..2d66c1e 100644
@@ -255,7 +255,7 @@ find_symbol_in_file(const char *filename, const char
 *symname)
 
 	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;
 
--

2.7.4

#2 lore raw

PATCH v2 1/1 cve: Fix kernel symbol finding for meltdown case

----- Original Message -----

Quoted 14 lines

----- Original Message -----

Quoted 11 lines

From: He Zhe <[email protected]>

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.

Quoted 7 lines
Quoted 2 lines

This patch turns to use FILE_LINES_SCANF to give find_kernel_symbol second chance.

That explains it, thanks for the patch.

We should also tweak TCONF condition in find_kernel_symbol - no need to re-post for that, I can add that.

Pushed, also with tweak for commit 7709d2ae92ea, so we try System.map, even if kallsyms are completely disabled.

Regards,
Jan