[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-8.2.1 39/54] load_elf: fix iterator's type for elf file processi
From: |
Michael Tokarev |
Subject: |
[Stable-8.2.1 39/54] load_elf: fix iterator's type for elf file processing |
Date: |
Tue, 23 Jan 2024 18:46:40 +0300 |
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>
(cherry picked from commit 410c2a4d75f52f6a2fe978eda5a9b6f854afe5ea)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h
index 0a5c258fe6..9c35d1b9da 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.39.2
- [Stable-8.2.1 v2 00/54] Patch Round-up for stable 8.2.1, freeze on 2024-01-27, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 39/54] load_elf: fix iterator's type for elf file processing,
Michael Tokarev <=
- [Stable-8.2.1 40/54] target/i386: Do not re-compute new pc with CF_PCREL, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 41/54] target/i386: fix incorrect EIP in PC-relative translation blocks, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 42/54] target/i386: pcrel: store low bits of physical address in data[0], Michael Tokarev, 2024/01/23
- [Stable-8.2.1 43/54] backends/cryptodev: Do not ignore throttle/backends Errors, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 46/54] hw/pflash: implement update buffer for block writes, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 53/54] s390x/pci: refresh fh before disabling aif, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 47/54] migration/rdma: define htonll/ntohll only if not predefined, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 44/54] hw/pflash: refactor pflash_data_write(), Michael Tokarev, 2024/01/23
- [Stable-8.2.1 52/54] s390x/pci: avoid double enable/disable of aif, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 45/54] hw/pflash: use ldn_{be,le}_p and stn_{be,le}_p, Michael Tokarev, 2024/01/23