Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Burrow, Ryan - 0553 - MITLL" <Ryan.Burrow@ll.mit.edu>
To: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH v2] Bug fix to ELF Loader which rejects valid ELFs
Date: Wed, 19 Aug 2020 14:59:18 +0000 [thread overview]
Message-ID: <7bc774eb946348e3bc3d314fc4d424ba@ll.mit.edu> (raw)
[-- Attachment #1: Type: text/plain, Size: 938 bytes --]
Check was incorrectly being applied to size of elf phdrs, instead
of the number. The ELF standard allows for up to 65535 headers, but
the check was being compared to the number of headers multiplied by
the size of a program header.
---
fs/binfmt_elf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 13d053982dd7..f21896f250d2 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -445,11 +445,11 @@ static struct elf_phdr *load_elf_phdrs(const struct
elfhdr *elf_ex,
goto out;
/* Sanity check the number of program headers... */
- /* ...and their total size. */
- size = sizeof(struct elf_phdr) * elf_ex->e_phnum;
- if (size == 0 || size > 65536 || size > ELF_MIN_ALIGN)
+ if (elf_ex->e_phnum == 0)
goto out;
+ size = array_size(sizeof(*elf_phdata), elf_ex->e_phnum);
+
elf_phdata = kmalloc(size, GFP_KERNEL);
if (!elf_phdata)
goto out;
--
2.17.1
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5529 bytes --]
reply other threads:[~2020-08-19 15:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7bc774eb946348e3bc3d314fc4d424ba@ll.mit.edu \
--to=ryan.burrow@ll.mit.edu \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--subject='Re: [PATCH v2] Bug fix to ELF Loader which rejects valid ELFs' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).