From: Lorenzo Stoakes <lstoakes@gmail.com>
To: "Liam R. Howlett" <Liam.Howlett@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Jann Horn <jannh@google.com>, Vlastimil Babka <vbabka@suse.cz>,
Suren Baghdasaryan <surenb@google.com>,
Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH v3 3/3] mmap: Add clarifying comment to vma_merge() code
Date: Fri, 29 Sep 2023 23:30:01 +0100 [thread overview]
Message-ID: <1c7c1869-ef9c-487f-9c8e-08a51d9f8efe@lucifer.local> (raw)
In-Reply-To: <20230929183041.2835469-4-Liam.Howlett@oracle.com>
On Fri, Sep 29, 2023 at 02:30:41PM -0400, Liam R. Howlett wrote:
> When tracing through the code in vma_merge(), it was not completely
> clear why the error return to a dup_anon_vma() call would not overwrite
> a previous attempt to the same function. This commit adds a comment
> specifying why it is safe.
>
> Suggested-by: Jann Horn <jannh@google.com>
> Link: https://lore.kernel.org/linux-mm/CAG48ez3iDwFPR=Ed1BfrNuyUJPMK_=StjxhUsCkL6po1s7bONg@mail.gmail.com/
> Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> ---
> mm/mmap.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index f9f0a5fe4db4..9967acbd070f 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -943,6 +943,11 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm,
> vma_start_write(curr);
> remove = curr;
> remove2 = next;
> + /*
> + * Note that the dup_anon_vma below cannot overwrite err
> + * since the first caller would do nothing unless next
> + * has an anon_vma.
> + */
> if (!next->anon_vma)
> err = dup_anon_vma(prev, curr, &anon_dup);
> }
> --
> 2.40.1
>
Nice comment! It causes me to sick up a bit in my mouth that this is a thing,
but it's good to have it documented.
Reviewed-by: Lorenzo Stoakes <lstoakes@gmail.com>
next prev parent reply other threads:[~2023-09-29 22:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-29 18:30 [PATCH v3 0/3] Fixes for vma_merge() error path Liam R. Howlett
2023-09-29 18:30 ` [PATCH v3 1/3] mmap: Fix vma_iterator in error path of vma_merge() Liam R. Howlett
2023-09-29 22:21 ` Lorenzo Stoakes
2023-10-02 7:09 ` Vlastimil Babka
2023-09-29 18:30 ` [PATCH v3 2/3] mmap: Fix error paths with dup_anon_vma() Liam R. Howlett
2023-09-29 22:28 ` Lorenzo Stoakes
2023-10-02 7:26 ` Vlastimil Babka
2023-10-02 7:43 ` Lorenzo Stoakes
2023-10-03 14:45 ` Liam R. Howlett
2023-10-02 7:11 ` Vlastimil Babka
2023-10-03 16:21 ` Suren Baghdasaryan
2023-10-03 18:51 ` Liam R. Howlett
2023-10-03 19:40 ` Suren Baghdasaryan
2023-10-06 21:08 ` Andrew Morton
2023-10-06 21:32 ` Suren Baghdasaryan
2023-09-29 18:30 ` [PATCH v3 3/3] mmap: Add clarifying comment to vma_merge() code Liam R. Howlett
2023-09-29 22:30 ` Lorenzo Stoakes [this message]
2023-10-02 7:11 ` Vlastimil Babka
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=1c7c1869-ef9c-487f-9c8e-08a51d9f8efe@lucifer.local \
--to=lstoakes@gmail.com \
--cc=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=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/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