Skip to content

Commit 2c4541e

Browse files
kiryltorvalds
authored andcommitted
mm: use vma_init() to initialize VMAs on stack and data segments
Make sure to initialize all VMAs properly, not only those which come from vm_area_cachep. Link: http://lkml.kernel.org/r/20180724121139.62570-3-kirill.shutemov@linux.intel.com Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 027232d commit 2c4541e

File tree

10 files changed

+17
-7
lines changed

10 files changed

+17
-7
lines changed

arch/arm/kernel/process.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ static struct vm_area_struct gate_vma = {
338338

339339
static int __init gate_vma_init(void)
340340
{
341+
vma_init(&gate_vma, NULL);
341342
gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
342343
return 0;
343344
}

arch/arm/mach-rpc/ecard.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ static void ecard_init_pgtables(struct mm_struct *mm)
237237

238238
memcpy(dst_pgd, src_pgd, sizeof(pgd_t) * (EASI_SIZE / PGDIR_SIZE));
239239

240+
vma_init(&vma, mm);
240241
vma.vm_flags = VM_EXEC;
241-
vma.vm_mm = mm;
242242

243243
flush_tlb_range(&vma, IO_START, IO_START + IO_SIZE);
244244
flush_tlb_range(&vma, EASI_START, EASI_START + EASI_SIZE);

arch/arm64/include/asm/tlb.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ static inline void __tlb_remove_table(void *_table)
3737

3838
static inline void tlb_flush(struct mmu_gather *tlb)
3939
{
40-
struct vm_area_struct vma = { .vm_mm = tlb->mm, };
40+
struct vm_area_struct vma;
41+
42+
vma_init(&vma, tlb->mm);
4143

4244
/*
4345
* The ASID allocator will either invalidate the ASID or mark

arch/arm64/mm/hugetlbpage.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,13 @@ static pte_t get_clear_flush(struct mm_struct *mm,
108108
unsigned long pgsize,
109109
unsigned long ncontig)
110110
{
111-
struct vm_area_struct vma = { .vm_mm = mm };
111+
struct vm_area_struct vma;
112112
pte_t orig_pte = huge_ptep_get(ptep);
113113
bool valid = pte_valid(orig_pte);
114114
unsigned long i, saddr = addr;
115115

116+
vma_init(&vma, mm);
117+
116118
for (i = 0; i < ncontig; i++, addr += pgsize, ptep++) {
117119
pte_t pte = ptep_get_and_clear(mm, addr, ptep);
118120

@@ -145,9 +147,10 @@ static void clear_flush(struct mm_struct *mm,
145147
unsigned long pgsize,
146148
unsigned long ncontig)
147149
{
148-
struct vm_area_struct vma = { .vm_mm = mm };
150+
struct vm_area_struct vma;
149151
unsigned long i, saddr = addr;
150152

153+
vma_init(&vma, mm);
151154
for (i = 0; i < ncontig; i++, addr += pgsize, ptep++)
152155
pte_clear(mm, addr, ptep);
153156

arch/ia64/include/asm/tlb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ ia64_tlb_flush_mmu_tlbonly(struct mmu_gather *tlb, unsigned long start, unsigned
120120
*/
121121
struct vm_area_struct vma;
122122

123-
vma.vm_mm = tlb->mm;
123+
vma_init(&vma, tlb->mm);
124124
/* flush the address range from the tlb: */
125125
flush_tlb_range(&vma, start, end);
126126
/* now flush the virt. page-table area mapping the address range: */

arch/ia64/mm/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static struct vm_area_struct gate_vma;
273273

274274
static int __init gate_vma_init(void)
275275
{
276-
gate_vma.vm_mm = NULL;
276+
vma_init(&gate_vma, NULL);
277277
gate_vma.vm_start = FIXADDR_USER_START;
278278
gate_vma.vm_end = FIXADDR_USER_END;
279279
gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;

arch/x86/um/mem_32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static int __init gate_vma_init(void)
1616
if (!FIXADDR_USER_START)
1717
return 0;
1818

19-
gate_vma.vm_mm = NULL;
19+
vma_init(&gate_vma, NULL);
2020
gate_vma.vm_start = FIXADDR_USER_START;
2121
gate_vma.vm_end = FIXADDR_USER_END;
2222
gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;

fs/hugetlbfs/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
411411
bool truncate_op = (lend == LLONG_MAX);
412412

413413
memset(&pseudo_vma, 0, sizeof(struct vm_area_struct));
414+
vma_init(&pseudo_vma, current->mm);
414415
pseudo_vma.vm_flags = (VM_HUGETLB | VM_MAYSHARE | VM_SHARED);
415416
pagevec_init(&pvec);
416417
next = start;
@@ -595,6 +596,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
595596
* as input to create an allocation policy.
596597
*/
597598
memset(&pseudo_vma, 0, sizeof(struct vm_area_struct));
599+
vma_init(&pseudo_vma, mm);
598600
pseudo_vma.vm_flags = (VM_HUGETLB | VM_MAYSHARE | VM_SHARED);
599601
pseudo_vma.vm_file = file;
600602

mm/mempolicy.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,6 +2505,7 @@ void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol)
25052505

25062506
/* Create pseudo-vma that contains just the policy */
25072507
memset(&pvma, 0, sizeof(struct vm_area_struct));
2508+
vma_init(&pvma, NULL);
25082509
pvma.vm_end = TASK_SIZE; /* policy covers entire file */
25092510
mpol_set_shared_policy(sp, &pvma, new); /* adds ref */
25102511

mm/shmem.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,7 @@ static void shmem_pseudo_vma_init(struct vm_area_struct *vma,
14211421
{
14221422
/* Create a pseudo vma that just contains the policy */
14231423
memset(vma, 0, sizeof(*vma));
1424+
vma_init(vma, NULL);
14241425
/* Bias interleave by inode number to distribute better across nodes */
14251426
vma->vm_pgoff = index + info->vfs_inode.i_ino;
14261427
vma->vm_policy = mpol_shared_policy_lookup(&info->policy, index);

0 commit comments

Comments
 (0)