From: Kees Cook <kees@kernel.org>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: "Liam R . Howlett" <Liam.Howlett@oracle.com>,
Vlastimil Babka <vbabka@suse.cz>, Jann Horn <jannh@google.com>,
Pedro Falcato <pfalcato@suse.de>,
David Hildenbrand <david@redhat.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Suren Baghdasaryan <surenb@google.com>,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] mm: perform VMA allocation, freeing, duplication in mm
Date: Thu, 24 Apr 2025 20:15:26 -0700 [thread overview]
Message-ID: <51903B43-2BFC-4BA6-9D74-63F79CF890B7@kernel.org> (raw)
In-Reply-To: <0f848d59f3eea3dd0c0cdc3920644222c40cffe6.1745528282.git.lorenzo.stoakes@oracle.com>
On April 24, 2025 2:15:27 PM PDT, Lorenzo Stoakes <lorenzo.stoakes@oracle.com> wrote:
>+static void vm_area_init_from(const struct vm_area_struct *src,
>+ struct vm_area_struct *dest)
>+{
>+ dest->vm_mm = src->vm_mm;
>+ dest->vm_ops = src->vm_ops;
>+ dest->vm_start = src->vm_start;
>+ dest->vm_end = src->vm_end;
>+ dest->anon_vma = src->anon_vma;
>+ dest->vm_pgoff = src->vm_pgoff;
>+ dest->vm_file = src->vm_file;
>+ dest->vm_private_data = src->vm_private_data;
>+ vm_flags_init(dest, src->vm_flags);
>+ memcpy(&dest->vm_page_prot, &src->vm_page_prot,
>+ sizeof(dest->vm_page_prot));
>+ /*
>+ * src->shared.rb may be modified concurrently when called from
>+ * dup_mmap(), but the clone will reinitialize it.
>+ */
>+ data_race(memcpy(&dest->shared, &src->shared, sizeof(dest->shared)));
>+ memcpy(&dest->vm_userfaultfd_ctx, &src->vm_userfaultfd_ctx,
>+ sizeof(dest->vm_userfaultfd_ctx));
>+#ifdef CONFIG_ANON_VMA_NAME
>+ dest->anon_name = src->anon_name;
>+#endif
>+#ifdef CONFIG_SWAP
>+ memcpy(&dest->swap_readahead_info, &src->swap_readahead_info,
>+ sizeof(dest->swap_readahead_info));
>+#endif
>+#ifdef CONFIG_NUMA
>+ dest->vm_policy = src->vm_policy;
>+#endif
>+}
I know you're doing a big cut/paste here, but why in the world is this function written this way? Why not just:
*dest = *src;
And then do any one-off cleanups?
--
Kees Cook
next prev parent reply other threads:[~2025-04-25 3:15 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-24 21:15 [PATCH 0/4] move all VMA allocation, freeing and duplication logic to mm Lorenzo Stoakes
2025-04-24 21:15 ` [PATCH 1/4] mm: abstract initial stack setup to mm subsystem Lorenzo Stoakes
2025-04-24 21:30 ` David Hildenbrand
2025-04-25 0:55 ` Suren Baghdasaryan
2025-04-25 10:10 ` Lorenzo Stoakes
2025-04-25 10:11 ` Lorenzo Stoakes
2025-04-24 21:15 ` [PATCH 2/4] mm: perform VMA allocation, freeing, duplication in mm Lorenzo Stoakes
2025-04-24 21:22 ` David Hildenbrand
2025-04-25 1:22 ` Suren Baghdasaryan
2025-04-25 1:37 ` Suren Baghdasaryan
2025-04-25 10:10 ` Lorenzo Stoakes
2025-04-25 11:04 ` Lorenzo Stoakes
2025-04-25 10:09 ` Lorenzo Stoakes
2025-04-25 10:26 ` Liam R. Howlett
2025-04-25 10:31 ` Lorenzo Stoakes
2025-04-25 10:45 ` Lorenzo Stoakes
2025-04-25 11:00 ` Liam R. Howlett
2025-04-25 11:03 ` Lorenzo Stoakes
2025-04-25 10:17 ` Lorenzo Stoakes
2025-04-25 3:15 ` Kees Cook [this message]
2025-04-25 10:40 ` Lorenzo Stoakes
2025-04-25 10:53 ` Pedro Falcato
2025-04-25 13:54 ` Liam R. Howlett
2025-04-25 15:32 ` Suren Baghdasaryan
2025-04-25 15:34 ` Suren Baghdasaryan
2025-04-25 17:12 ` Kees Cook
2025-04-25 17:26 ` Suren Baghdasaryan
2025-04-24 21:15 ` [PATCH 3/4] mm: move dup_mmap() to mm Lorenzo Stoakes
2025-04-25 9:13 ` Pedro Falcato
2025-04-25 10:18 ` Lorenzo Stoakes
2025-04-24 21:15 ` [PATCH 4/4] mm: move vm_area_alloc,dup,free() functions to vma.c 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=51903B43-2BFC-4BA6-9D74-63F79CF890B7@kernel.org \
--to=kees@kernel.org \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=david@redhat.com \
--cc=jack@suse.cz \
--cc=jannh@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=pfalcato@suse.de \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=viro@zeniv.linux.org.uk \
/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