aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Filippov <[email protected]>2024-08-25 20:27:45 -0700
committerKees Cook <[email protected]>2024-08-26 13:00:38 -0700
commitc6a09e342f8e6d3cac7f7c5c14085236aca284b9 (patch)
treed037b146459fbe78c2c13dc8bda2605fcb4ad6f1
parentf50733b45d865f91db90919f8311e2127ce5a0cb (diff)
binfmt_elf_fdpic: fix AUXV size calculation when ELF_HWCAP2 is defined
create_elf_fdpic_tables() does not correctly account the space for the AUX vector when an architecture has ELF_HWCAP2 defined. Prior to the commit 10e29251be0e ("binfmt_elf_fdpic: fix /proc/<pid>/auxv") it resulted in the last entry of the AUX vector being set to zero, but with that change it results in a kernel BUG. Fix that by adding one to the number of AUXV entries (nitems) when ELF_HWCAP2 is defined. Fixes: 10e29251be0e ("binfmt_elf_fdpic: fix /proc/<pid>/auxv") Cc: [email protected] Reported-by: Greg Ungerer <[email protected]> Closes: https://lore.kernel.org/lkml/[email protected]/ Signed-off-by: Max Filippov <[email protected]> Tested-by: Greg Ungerer <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
-rw-r--r--fs/binfmt_elf_fdpic.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index 28a3439f163a..4fe5bb9f1b1f 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -589,6 +589,9 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
if (bprm->have_execfd)
nitems++;
+#ifdef ELF_HWCAP2
+ nitems++;
+#endif
csp = sp;
sp -= nitems * 2 * sizeof(unsigned long);