[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 5/5] util/grub-module-verifierXX.c: Add e_shoff check in get_s
From: |
Alec Brown |
Subject: |
[PATCH v3 5/5] util/grub-module-verifierXX.c: Add e_shoff check in get_shdr() |
Date: |
Wed, 20 Apr 2022 22:23:17 -0400 |
In util/grub-module-verifierXX.c, the function get_shdr() is used to obtain the
section header at a given index but isn't checking that there is an offset for
the section header table. To validate that there is, we can check that e_shoff
isn't 0.
Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
---
util/grub-module-verifierXX.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c
index 4e6cf133f..cf3ff0dfa 100644
--- a/util/grub-module-verifierXX.c
+++ b/util/grub-module-verifierXX.c
@@ -134,6 +134,9 @@ grub_target_to_host_real (const struct
grub_module_verifier_arch *arch, grub_uin
static Elf_Shdr *
get_shdr (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e, Elf_Word
index)
{
+ if (grub_target_to_host (e->e_shoff) == 0)
+ grub_util_error ("Invalid section header offset");
+
return (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff) +
index * grub_target_to_host16 (e->e_shentsize));
}
--
2.27.0
- [PATCH v3 0/5] Fix coverity bugs and add checks for elf values in grub-core, Alec Brown, 2022/04/20
- [PATCH v3 4/5] elf: Validate number of elf program header table entries, Alec Brown, 2022/04/20
- [PATCH v3 2/5] elf: Validate number of elf section header table entries, Alec Brown, 2022/04/20
- [PATCH v3 5/5] util/grub-module-verifierXX.c: Add e_shoff check in get_shdr(),
Alec Brown <=
- [PATCH v3 3/5] elf: Validate elf section header table index for section name string table, Alec Brown, 2022/04/20
- [PATCH v3 1/5] grub-core/loader/i386/bsdXX.c: Avoid downcasting (char *) to (Elf_Shdr *), Alec Brown, 2022/04/20
- Re: [PATCH v3 0/5] Fix coverity bugs and add checks for elf values in grub-core, Darren Kenny, 2022/04/27