diff options
author | QiuXi <qiuxi1@huawei.com> | 2021-09-08 06:00:32 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2021-09-08 21:50:27 +0300 |
commit | 6fcac87e1f9e5b27805a2a404f4849194bb51de8 (patch) | |
tree | 04cfd6e934914b8f58f1f04da4c1f92b36e9fab7 /fs | |
parent | dbd9d6f8fa9c3e676e491ac65c7fa10a1af8321f (diff) | |
download | linux-6fcac87e1f9e5b27805a2a404f4849194bb51de8.tar.xz |
coredump: fix memleak in dump_vma_snapshot()
dump_vma_snapshot() allocs memory for *vma_meta, when dump_vma_snapshot()
returns -EFAULT, the memory will be leaked, so we free it correctly.
Link: https://lkml.kernel.org/r/20210810020441.62806-1-qiuxi1@huawei.com
Fixes: a07279c9a8cd7 ("binfmt_elf, binfmt_elf_fdpic: use a VMA list snapshot")
Signed-off-by: QiuXi <qiuxi1@huawei.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Jann Horn <jannh@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/coredump.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/coredump.c b/fs/coredump.c index 4b3c75732c97..3224dee44d30 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -1134,8 +1134,10 @@ int dump_vma_snapshot(struct coredump_params *cprm, int *vma_count, mmap_write_unlock(mm); - if (WARN_ON(i != *vma_count)) + if (WARN_ON(i != *vma_count)) { + kvfree(*vma_meta); return -EFAULT; + } *vma_data_size_ptr = vma_data_size; return 0; |