Hi all,
This series fixes two buffer overflows in Xen's symbol handling.
Thanks to Jan for the review of v1.
Patch 1 makes KSYM_NAME_LEN include the terminating NUL, following
Linux's convention. The runtime lookup buffers stay at 128 bytes.
The token expansion buffer grows to 129 bytes to hold the type,
a 127-byte name and the NUL.
Patch 2 reports and skips names longer than 127 bytes in read_symbol(),
including the filename prefix added to local SYSV symbols. This avoids
generating a table that can overflow the runtime lookup buffers. A long
absolute source path caused this overflow during the boot self-tests
on an Orange Pi 5 debug build. Human-readable --xensyms maps keep names
longer than this limit.
Changes in v2:
- Reorder the patches so the name-length check uses the final
KSYM_NAME_LEN convention from the start.
- Patch 1 (v1 patch 2): make KSYM_NAME_LEN include the NUL and update
its users. The token buffer is KSYM_NAME_LEN + 1, with the extra byte
for the type, as discussed with Jan.
- Patch 2 (v1 patch 1): report and skip oversized names instead of
failing the build, and move the check to read_symbol(), as suggested
by Jan.
Testing:
- Built the host generator with GCC 15.2.0 and tested it under ASan/UBSan.
- Checked BSD and SYSV input at the 127/128-byte boundary, --xensyms,
--sort-by-name and --error-dup.
- Reproduced the token overflow with 64 identical 127-byte names of
type T; the fixed generator processes the same input without errors.
Best regards,
Mykola
Mykola Kvach (2):
symbols: make KSYM_NAME_LEN include the trailing NUL
tools/symbols: skip names exceeding the runtime limit
xen/arch/x86/platform_hypercall.c | 2 +-
xen/common/symbols.c | 6 +++---
xen/common/vsprintf.c | 2 +-
xen/include/xen/symbols.h | 3 ++-
xen/tools/symbols.c | 11 ++++++++++-
5 files changed, 17 insertions(+), 7 deletions(-)
--
2.53.0