]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
binfmt_elf_fdpic: fix AUXV size calculation when ELF_HWCAP2 is defined
authorMax Filippov <jcmvbkbc@gmail.com>
Mon, 26 Aug 2024 03:27:45 +0000 (20:27 -0700)
committerKees Cook <kees@kernel.org>
Mon, 26 Aug 2024 20:00:38 +0000 (13:00 -0700)
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: stable@vger.kernel.org
Reported-by: Greg Ungerer <gerg@kernel.org>
Closes: https://lore.kernel.org/lkml/5b51975f-6d0b-413c-8b38-39a6a45e8821@westnet.com.au/
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Tested-by: Greg Ungerer <gerg@kernel.org>
Link: https://lore.kernel.org/r/20240826032745.3423812-1-jcmvbkbc@gmail.com
Signed-off-by: Kees Cook <kees@kernel.org>
fs/binfmt_elf_fdpic.c

index 28a3439f163abc891e0923599992e2a09a91cd30..4fe5bb9f1b1f5e0be6e8d1ef5b20492935b90633 100644 (file)
@@ -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);