From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Vlastimil Babka <vbabka@suse.cz>, Jann Horn <jannh@google.com>
Subject: Re: [PATCH v2] vma: Detect infinite loop in vma tree
Date: Thu, 31 Oct 2024 17:21:25 -0400 [thread overview]
Message-ID: <nitzqi2v37ojb2ron7bjwushyxwjw7yq753z42un7eotzs3vpm@6kr5xblggaz6> (raw)
In-Reply-To: <20241031134815.81766b263e87f74a3e31471e@linux-foundation.org>
* Andrew Morton <akpm@linux-foundation.org> [241031 16:48]:
> On Thu, 31 Oct 2024 15:36:08 -0400 "Liam R. Howlett" <Liam.Howlett@oracle.com> wrote:
>
> > 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.
> >
> > 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.
> >
> > ...
> >
> > +++ 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);
>
> It might be helpful to tell readers what's going on here?
Sounds good. I guess I should have waited longer for a v2.
>
> --- a/mm/vma.c~vma-detect-infinite-loop-in-vma-tree-fix
> +++ a/mm/vma.c
> @@ -615,6 +615,7 @@ void validate_mm(struct mm_struct *mm)
> anon_vma_unlock_read(anon_vma);
> }
> #endif
> + /* Check for a infinite loop */
> if (++i > mm->map_count + 10) {
> i = -1;
> break;
> _
>
next prev parent reply other threads:[~2024-10-31 21:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-31 19:36 Liam R. Howlett
2024-10-31 20:48 ` Andrew Morton
2024-10-31 21:21 ` Liam R. Howlett [this message]
2024-10-31 21:42 ` David Hildenbrand
2024-10-31 21:44 ` Vlastimil Babka
2024-11-01 10:54 ` Lorenzo Stoakes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=nitzqi2v37ojb2ron7bjwushyxwjw7yq753z42un7eotzs3vpm@6kr5xblggaz6 \
--to=liam.howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox