linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vma: Detect infinite loop in vma tree
@ 2024-10-31 17:01 Liam R. Howlett
  2024-10-31 17:04 ` Liam R. Howlett
  2024-10-31 17:06 ` Vlastimil Babka
  0 siblings, 2 replies; 6+ messages in thread
From: Liam R. Howlett @ 2024-10-31 17:01 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, linux-kernel, Liam R. Howlett, Lorenzo Stoakes,
	Vlastimil Babka, Jann Horn

From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>

There have been no reported infinite loops in the tree, but checking the
detection of an infinite loop during validation is simple enough.  Add
the detection to the validate_mm() function so that error reports are
clear and don't just report stalls.

This does not protect against internal maple tree issues, but it does
detect too many vmas being returned from the tree.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Jann Horn <jannh@google.com>
---
 mm/vma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/vma.c b/mm/vma.c
index 68138e8c153e..60ed8cc187ad 100644
--- a/mm/vma.c
+++ b/mm/vma.c
@@ -615,7 +615,8 @@ void validate_mm(struct mm_struct *mm)
 			anon_vma_unlock_read(anon_vma);
 		}
 #endif
-		i++;
+		if (++i > mm->map_count)
+			break;
 	}
 	if (i != mm->map_count) {
 		pr_emerg("map_count %d vma iterator %d\n", mm->map_count, i);
-- 
2.43.0



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

end of thread, other threads:[~2024-10-31 17:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-31 17:01 [PATCH] vma: Detect infinite loop in vma tree Liam R. Howlett
2024-10-31 17:04 ` Liam R. Howlett
2024-10-31 17:06 ` Vlastimil Babka
2024-10-31 17:13   ` Liam R. Howlett
2024-10-31 17:21     ` Lorenzo Stoakes
2024-10-31 17:30       ` Liam R. Howlett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox