mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* + coredump-fix-memleak-in-dump_vma_snapshot.patch added to -mm tree
@ 2021-08-11  4:28 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2021-08-11  4:28 UTC (permalink / raw)
  To: mm-commits, viro, jannh, gregkh, qiuxi1


The patch titled
     Subject: coredump: fix memleak in dump_vma_snapshot()
has been added to the -mm tree.  Its filename is
     coredump-fix-memleak-in-dump_vma_snapshot.patch

This patch should soon appear at
    https://ozlabs.org/~akpm/mmots/broken-out/coredump-fix-memleak-in-dump_vma_snapshot.patch
and later at
    https://ozlabs.org/~akpm/mmotm/broken-out/coredump-fix-memleak-in-dump_vma_snapshot.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: QiuXi <qiuxi1@huawei.com>
Subject: 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>
---

 fs/coredump.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/fs/coredump.c~coredump-fix-memleak-in-dump_vma_snapshot
+++ a/fs/coredump.c
@@ -1134,8 +1134,10 @@ int dump_vma_snapshot(struct coredump_pa
 
 	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;
_

Patches currently in -mm which might be from qiuxi1@huawei.com are

coredump-fix-memleak-in-dump_vma_snapshot.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-11  4:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11  4:28 + coredump-fix-memleak-in-dump_vma_snapshot.patch added to -mm tree akpm

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).