[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 21/21] load_elf: fix iterator's type for elf file processing
From: |
Peter Maydell |
Subject: |
[PULL 21/21] load_elf: fix iterator's type for elf file processing |
Date: |
Tue, 16 Jan 2024 15:12:28 +0000 |
From: Anastasia Belova <abelova@astralinux.ru>
j is used while loading an ELF file to byteswap segments'
data. If data is larger than 2GB an overflow may happen.
So j should be elf_word.
This commit fixes a minor bug: it's unlikely anybody is trying to
load ELF files with 2GB+ segments for wrong-endianness targets,
but if they did, it wouldn't work correctly.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Cc: qemu-stable@nongnu.org
Fixes: 7ef295ea5b ("loader: Add data swap option to load-elf")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
include/hw/elf_ops.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h
index 0a5c258fe68..9c35d1b9da6 100644
--- a/include/hw/elf_ops.h
+++ b/include/hw/elf_ops.h
@@ -500,7 +500,7 @@ static ssize_t glue(load_elf, SZ)(const char *name, int fd,
}
if (data_swab) {
- int j;
+ elf_word j;
for (j = 0; j < file_size; j += (1 << data_swab)) {
uint8_t *dp = data + j;
switch (data_swab) {
--
2.34.1
- [PULL 06/21] tests/qtest: Add STM32L4x5 EXTI QTest testcase, (continued)
- [PULL 06/21] tests/qtest: Add STM32L4x5 EXTI QTest testcase, Peter Maydell, 2024/01/16
- [PULL 18/21] tests/qtest: Adding PCS Module test to GMAC Qtest, Peter Maydell, 2024/01/16
- [PULL 19/21] hw/timer: fix systick trace message, Peter Maydell, 2024/01/16
- [PULL 10/21] hw/misc: Add Nuvoton's PCI Mailbox Module, Peter Maydell, 2024/01/16
- [PULL 14/21] hw/arm: Add GMAC devices to NPCM7XX SoC, Peter Maydell, 2024/01/16
- [PULL 13/21] hw/net: Add NPCMXXX GMAC device, Peter Maydell, 2024/01/16
- [PULL 11/21] hw/arm: Add PCI mailbox module to Nuvoton SoC, Peter Maydell, 2024/01/16
- [PULL 15/21] tests/qtest: Creating qtest for GMAC Module, Peter Maydell, 2024/01/16
- [PULL 16/21] hw/net: GMAC Rx Implementation, Peter Maydell, 2024/01/16
- [PULL 17/21] hw/net: GMAC Tx Implementation, Peter Maydell, 2024/01/16
- [PULL 21/21] load_elf: fix iterator's type for elf file processing,
Peter Maydell <=
- [PULL 20/21] hw/arm/virt: Consolidate valid CPU types, Peter Maydell, 2024/01/16