[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3f4af429-1f60-40c3-bd7f-c8c5950ac6ed@redhat.com>
Date: Thu, 31 Oct 2024 22:42:54 +0100
From: David Hildenbrand <david@...hat.com>
To: "Liam R. Howlett" <Liam.Howlett@...cle.com>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
Vlastimil Babka <vbabka@...e.cz>, Jann Horn <jannh@...gle.com>
Subject: Re: [PATCH v2] vma: Detect infinite loop in vma tree
On 31.10.24 20:36, Liam R. Howlett wrote:
> From: "Liam R. Howlett" <Liam.Howlett@...cle.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.
>
> 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.
>
> Signed-off-by: Liam R. Howlett <Liam.Howlett@...cle.com>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
> Cc: Vlastimil Babka <vbabka@...e.cz>
> Cc: Jann Horn <jannh@...gle.com>
> ---
> mm/vma.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/mm/vma.c b/mm/vma.c
> index 68138e8c153e..283e6bc4884f 100644
> --- a/mm/vma.c
> +++ b/mm/vma.c
> @@ -615,7 +615,10 @@ void validate_mm(struct mm_struct *mm)
> anon_vma_unlock_read(anon_vma);
> }
> #endif
> - i++;
> + if (++i > mm->map_count + 10) {
> + i = -1;
> + break;
> + }
> }
> if (i != mm->map_count) {
> pr_emerg("map_count %d vma iterator %d\n", mm->map_count, i);
Reviewed-by: David Hildenbrand <david@...hat.com>
--
Cheers,
David / dhildenb
Powered by blists - more mailing lists