From: Andrew Morton <akpm@linux-foundation.org>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Dmitry Vyukov <dvyukov@google.com>,
Oleg Nesterov <oleg@redhat.com>,
Andrea Arcangeli <aarcange@redhat.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCHv3 1/3] mm: Introduce vma_init()
Date: Tue, 24 Jul 2018 13:03:08 -0700 [thread overview]
Message-ID: <20180724130308.bbd46afc3703af4c5e1d6868@linux-foundation.org> (raw)
In-Reply-To: <20180724121139.62570-2-kirill.shutemov@linux.intel.com>
On Tue, 24 Jul 2018 15:11:37 +0300 "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> wrote:
> Not all VMAs allocated with vm_area_alloc(). Some of them allocated on
> stack or in data segment.
>
> The new helper can be use to initialize VMA properly regardless where
> it was allocated.
>
> ...
>
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -452,6 +452,12 @@ struct vm_operations_struct {
> unsigned long addr);
> };
>
> +static inline void vma_init(struct vm_area_struct *vma, struct mm_struct *mm)
> +{
> + vma->vm_mm = mm;
> + INIT_LIST_HEAD(&vma->anon_vma_chain);
> +}
> +
> struct mmu_gather;
> struct inode;
>
> diff --git a/kernel/fork.c b/kernel/fork.c
> index a191c05e757d..1b27babc4c78 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -312,10 +312,8 @@ struct vm_area_struct *vm_area_alloc(struct mm_struct *mm)
> {
> struct vm_area_struct *vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
I'd sleep better if this became a kmem_cache_alloc() and the memset
was moved into vma_init(). A bunch of the vma_init() callers are
already doing the memset and the others risk leaving uninitialized
stack fields in the vma.
>
> - if (vma) {
> - vma->vm_mm = mm;
> - INIT_LIST_HEAD(&vma->anon_vma_chain);
> - }
> + if (vma)
> + vma_init(vma, mm);
> return vma;
> }
next prev parent reply other threads:[~2018-07-24 20:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-24 12:11 [PATCHv3 0/3] Fix crash due to vma_is_anonymous() false-positives Kirill A. Shutemov
2018-07-24 12:11 ` [PATCHv3 1/3] mm: Introduce vma_init() Kirill A. Shutemov
2018-07-24 20:03 ` Andrew Morton [this message]
2018-07-24 20:16 ` Linus Torvalds
2018-07-24 20:41 ` Andrew Morton
2018-07-25 12:39 ` Kirill A. Shutemov
2018-07-25 17:33 ` Linus Torvalds
2018-07-25 19:42 ` Andrew Morton
2018-07-26 15:14 ` Kirill A. Shutemov
2018-07-24 12:11 ` [PATCHv3 2/3] mm: Use vma_init() to initialize VMAs on stack and data segments Kirill A. Shutemov
2018-07-24 12:11 ` [PATCHv3 3/3] mm: Fix vma_is_anonymous() false-positives Kirill A. Shutemov
2018-07-24 17:33 ` [PATCHv3 0/3] Fix crash due to " Linus Torvalds
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=20180724130308.bbd46afc3703af4c5e1d6868@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=aarcange@redhat.com \
--cc=dvyukov@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=oleg@redhat.com \
--cc=torvalds@linux-foundation.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