elf: fix NT_FILE integer overflow

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/60c9d92f887f4606d363fece7a36c92664dc64c6
Commit:     60c9d92f887f4606d363fece7a36c92664dc64c6
Parent:     2d453e3b41c80d1a2c02b02d672f5dcd73f95a12
Refname:    refs/heads/master
Author:     Alexey Dobriyan <[email protected]>
AuthorDate: Tue Feb 6 15:39:13 2018 -0800
Committer:  Linus Torvalds <[email protected]>
CommitDate: Tue Feb 6 18:32:45 2018 -0800

    elf: fix NT_FILE integer overflow
    
    If vm.max_map_count bumped above 2^26 (67+ mil) and system has enough RAM
    to allocate all the VMAs (~12.8 GB on Fedora 27 with 200-byte VMAs), then
    it should be possible to overflow 32-bit "size", pass paranoia check,
    allocate very little vmalloc space and oops while writing into vmalloc
    guard page...
    
    But I didn't test this, only coredump of regular process.
    
    Link: http://lkml.kernel.org/r/20180112203427.GA9109@avx2
    Signed-off-by: Alexey Dobriyan <[email protected]>
    Signed-off-by: Andrew Morton <[email protected]>
    Signed-off-by: Linus Torvalds <[email protected]>
---
 fs/binfmt_elf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 83732fef510d..bdb201230bae 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1599,6 +1599,8 @@ static int fill_files_note(struct memelfnote *note)
 
 	/* *Estimated* file count and total data size needed */
 	count = current->mm->map_count;
+	if (count > UINT_MAX / 64)
+		return -EINVAL;
 	size = count * 64;
 
 	names_ofs = (2 + 3 * count) * sizeof(data[0]);
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.