Commit 60c9d92f authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Linus Torvalds

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@avx2Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2d453e3b
...@@ -1599,6 +1599,8 @@ static int fill_files_note(struct memelfnote *note) ...@@ -1599,6 +1599,8 @@ static int fill_files_note(struct memelfnote *note)
/* *Estimated* file count and total data size needed */ /* *Estimated* file count and total data size needed */
count = current->mm->map_count; count = current->mm->map_count;
if (count > UINT_MAX / 64)
return -EINVAL;
size = count * 64; size = count * 64;
names_ofs = (2 + 3 * count) * sizeof(data[0]); names_ofs = (2 + 3 * count) * sizeof(data[0]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment