All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ksm: Revert "use GET_KSM_PAGE_NOLOCK to get ksm page in remove_rmap_item_from_tree()"
@ 2021-05-10  5:59 ` Hugh Dickins
  0 siblings, 0 replies; 6+ messages in thread
From: Hugh Dickins @ 2021-05-10  5:59 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Hugh Dickins, Miaohe Lin, linux-kernel, linux-mm

This reverts commit 3e96b6a2e9ad929a3230a22f4d64a74671a0720b.
General Protection Fault in rmap_walk_ksm() under memory pressure:
remove_rmap_item_from_tree() needs to take page lock, of course.

Signed-off-by: Hugh Dickins <hughd@google.com>
---

 mm/ksm.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- 5.13-rc1/mm/ksm.c	2021-05-09 17:03:44.010422188 -0700
+++ linux/mm/ksm.c	2021-05-09 22:12:39.403008350 -0700
@@ -776,11 +776,12 @@ static void remove_rmap_item_from_tree(s
 		struct page *page;
 
 		stable_node = rmap_item->head;
-		page = get_ksm_page(stable_node, GET_KSM_PAGE_NOLOCK);
+		page = get_ksm_page(stable_node, GET_KSM_PAGE_LOCK);
 		if (!page)
 			goto out;
 
 		hlist_del(&rmap_item->hlist);
+		unlock_page(page);
 		put_page(page);
 
 		if (!hlist_empty(&stable_node->hlist))

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

end of thread, other threads:[~2021-05-11  1:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10  5:59 [PATCH] ksm: Revert "use GET_KSM_PAGE_NOLOCK to get ksm page in remove_rmap_item_from_tree()" Hugh Dickins
2021-05-10  5:59 ` Hugh Dickins
2021-05-10  6:57 ` Miaohe Lin
2021-05-10 23:42   ` Hugh Dickins
2021-05-10 23:42     ` Hugh Dickins
2021-05-11  1:40     ` Miaohe Lin

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.