lkml.org 
[lkml]   [2017]   [Jun]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC v4 14/20] mm/spf: protect madvise vs speculative pf
Date
This patch protects  madvise's effect against the speculative page
fault handler.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
---
mm/madvise.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/mm/madvise.c b/mm/madvise.c
index 25b78ee4fc2c..d1fa6a7ee604 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -172,7 +172,9 @@ static long madvise_behavior(struct vm_area_struct *vma,
/*
* vm_flags is protected by the mmap_sem held in write mode.
*/
+ write_seqcount_begin(&vma->vm_sequence);
vma->vm_flags = new_flags;
+ write_seqcount_end(&vma->vm_sequence);
out:
return error;
}
@@ -439,9 +441,11 @@ static void madvise_free_page_range(struct mmu_gather *tlb,
.private = tlb,
};

+ write_seqcount_begin(&vma->vm_sequence);
tlb_start_vma(tlb, vma);
walk_page_range(addr, end, &free_walk);
tlb_end_vma(tlb, vma);
+ write_seqcount_end(&vma->vm_sequence);
}

static int madvise_free_single_vma(struct vm_area_struct *vma,
--
2.7.4
\
 
 \ /
  Last update: 2017-06-12 01:49    [W:5.063 / U:0.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site