Skip to contentSkip to conversation

insert-sys-cert: fix use of uninitialized pointer with an empty System.map

PATCH In review Leizhen Zhang 1 participant 2 messages Oct 8 – Oct 25 Keys/keyrings

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 insert-sys-cert: fix use of uninitialized pointer with an empty System.map

get_symbol_from_map() only assigns n inside the loop that reads the System.map file. If the file is empty, the loop body never runs and n is then tested while uninitialized, as reported by MemorySanitizer.

Initialize n to NULL.

Fixes c4c361059585 ("KEYS: Reserve an extra certificate symbol for inserting without recompiling")
Assisted-by Claude:claude-opus-5-5 MSan

---
v2:
- Use my real name in the From and Signed-off-by lines. No code changes.

v1: https://lore.kernel.org/r/[email protected]

 scripts/insert-sys-cert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/insert-sys-cert.c +1 -1
index 8902836c23..e0bf0afc1b 100644
@@ -94,7 +94,7 @@ static void get_symbol_from_map(Elf_Ehdr *hdr, FILE *f, char *name,
 				struct sym *s)
 {
 	char l[LINE_SIZE];
-	char *w, *p, *n;
+	char *w, *p, *n = NULL;
 
 	s->size = 0;
 	s->address = 0;
Signature · 1 line
2.34.1
#1 lore raw

Hi David,

Please drop this one. The uninitialized read only happens when insert-sys-cert is handed an empty System.map, which a real kernel build never produces, so it is not something a legitimate input can trigger. I would rather not add churn for it.

Sorry for the noise.

Thanks,
Leizhen