|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 2/2] tools/symbols: skip names exceeding the runtime limit
The runtime lookup buffers hold KSYM_NAME_LEN bytes (128), but the
generator accepts longer names. SYSV input prefixes local symbols
with their filename, so an absolute assembly source path can make a
name too long even when the symbol itself is short.
On an Orange Pi 5 debug build this crashed Xen at boot: during the
test_symbols() constructor, symbols_lookup_by_name() expanded the
145-byte name ending in mmu/head.S#identity_mapping_removed into a
128-byte buffer, overwriting the saved frame pointer and return address.
Report and skip names of KSYM_NAME_LEN bytes or more, as Linux does.
Check the complete name in read_symbol(), after adding the filename
prefix. Keep --xensyms maps complete: they are not loaded into Xen.
Fixes: d37d63d4b548 ("symbols: prefix static symbols with their source file
names")
Assisted-by: Codex:GPT-6.1
Signed-off-by: Mykola Kvach <mykola_kvach@xxxxxxxx>
---
Changes in v2:
- Previously patch 1; move it after the KSYM_NAME_LEN conversion.
- Report and skip oversized names instead of failing the build (Jan).
- Move the check from build_initial_tok_table() to read_symbol(), after
adding the filename prefix (Jan).
- Use the NUL-inclusive KSYM_NAME_LEN in the check and diagnostic.
xen/tools/symbols.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/xen/tools/symbols.c b/xen/tools/symbols.c
index 14a045f098..860e9d9224 100644
--- a/xen/tools/symbols.c
+++ b/xen/tools/symbols.c
@@ -178,6 +178,14 @@ static int read_symbol(FILE *in, struct sym_entry *s)
*sym++ = '#';
}
strcpy(sym, str);
+ /* Only the table loaded into Xen is limited, not --xensyms maps. */
+ if (!map_only && s->len - 1 >= KSYM_NAME_LEN) {
+ fprintf(stderr,
+ "Ignoring symbol '%s': too long (%u bytes, maximum
%u)\n",
+ SYMBOL_NAME(s), s->len - 1, KSYM_NAME_LEN - 1);
+ free(s->sym);
+ goto skip_tail;
+ }
if (sort_by_name || map_only)
s->orig_symbol = strdup(SYMBOL_NAME(s));
s->type = stype; /* As s->sym[0] may end up mangled. */
--
2.53.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |