All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] mm: fix use-after-free bug when mm->mmap is reused after being freed
@ 2022-02-15 20:19 Suren Baghdasaryan
  2022-02-15 20:26 ` Rik van Riel
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: Suren Baghdasaryan @ 2022-02-15 20:19 UTC (permalink / raw)
  To: akpm
  Cc: mhocko, mhocko, shy828301, rientjes, willy, hannes, guro, riel,
	minchan, kirill, aarcange, brauner, christian, hch, oleg, david,
	jannh, shakeelb, luto, christian.brauner, fweimer, jengelh,
	timmurray, linux-mm, linux-kernel, kernel-team, surenb,
	syzbot+2ccf63a4bd07cf39cab0

After exit_mmap frees all vmas in the mm, mm->mmap needs to be reset,
otherwise it points to a vma that was freed and when reused leads to
a use-after-free bug.

Reported-by: syzbot+2ccf63a4bd07cf39cab0@syzkaller.appspotmail.com
Suggested-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
---
 mm/mmap.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/mmap.c b/mm/mmap.c
index 1e8fdb0b51ed..d445c1b9d606 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -3186,6 +3186,7 @@ void exit_mmap(struct mm_struct *mm)
 		vma = remove_vma(vma);
 		cond_resched();
 	}
+	mm->mmap = NULL;
 	mmap_write_unlock(mm);
 	vm_unacct_memory(nr_accounted);
 }
-- 
2.35.1.265.g69c8d7142f-goog


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2022-03-11  1:35 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-15 20:19 [PATCH 1/1] mm: fix use-after-free bug when mm->mmap is reused after being freed Suren Baghdasaryan
2022-02-15 20:26 ` Rik van Riel
2022-02-15 20:37 ` Andrew Morton
2022-02-15 20:45   ` Suren Baghdasaryan
2022-02-15 20:46     ` Suren Baghdasaryan
2022-02-15 20:51       ` Andrew Morton
2022-02-15 20:42 ` Yang Shi
2022-02-16  7:54 ` Michal Hocko
2022-02-17 19:51   ` Suren Baghdasaryan
2022-02-17 20:50     ` Andrew Morton
2022-02-18  8:11       ` Michal Hocko
2022-02-18  8:10     ` Michal Hocko
2022-02-25  4:18 ` Andrew Morton
2022-02-25  4:23   ` Matthew Wilcox
2022-02-25  5:50     ` Suren Baghdasaryan
2022-03-10 15:55       ` Liam Howlett
2022-03-10 16:28         ` Suren Baghdasaryan
2022-03-10 22:22           ` Liam Howlett
2022-03-10 23:31             ` Suren Baghdasaryan
2022-03-11  1:34               ` Liam Howlett
2022-02-25 10:17   ` Michal Hocko
2022-02-26  1:04     ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.