]> www.infradead.org Git - users/jedix/linux-maple.git/commit
vma: detect infinite loop in vma tree
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 31 Oct 2024 19:36:08 +0000 (15:36 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 1 Nov 2024 04:29:34 +0000 (21:29 -0700)
commit6df819a5c168ea51228e491d18fedd9cfbd38946
treeadbc213d2d69c92e952a1fd558c573cf4951c7e2
parent9fe3d10835bf7879bc31f3800d1ad8533770c71e
vma: detect infinite loop in vma tree

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.

The variance of +10 is to allow for the debugging output to be more useful
for nearly correct counts.  In the event of more than 10 over the
map_count, the count will be set to -1 for easier identification of a
potential infinite loop.

Note that the mmap lock is held to ensure a consistent tree state during
the validation process.

Link: https://lkml.kernel.org/r/20241031193608.1965366-1-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Jann Horn <jannh@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vma.c