Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1632220

[RFC v3 16/17] mm: protect madvise vs speculative pf

From Laurent Dufour <ldufour@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject [RFC v3 16/17] mm: protect madvise vs speculative pf
Date 2017-04-27 18:00 +0200
Message-ID <tATZN-2FN-47@gated-at.bofh.it> (permalink)
References <tATZL-2FN-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


This is an attempt to protect madvise's effect against the speculative
page fault handler.

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

diff --git a/mm/madvise.c b/mm/madvise.c
index 0e3828eae9f8..f91b64564571 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -132,8 +132,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:
 	if (error == -ENOMEM)
 		error = -EAGAIN;
@@ -403,9 +404,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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC v3 00/17] Speculative page faults Laurent Dufour <ldufour@linux.vnet.ibm.com> - 2017-04-27 18:00 +0200
  [RFC v3 03/17] mm: Introduce pte_spinlock Laurent Dufour <ldufour@linux.vnet.ibm.com> - 2017-04-27 18:00 +0200
    Re: [RFC v3 03/17] mm: Introduce pte_spinlock Matthew Wilcox <willy@infradead.org> - 2017-04-30 06:50 +0200
      Re: [RFC v3 03/17] mm: Introduce pte_spinlock Laurent Dufour <ldufour@linux.vnet.ibm.com> - 2017-05-03 15:10 +0200
  [RFC v3 13/17] mm/spf Protect vm_policy's changes against speculative pf Laurent Dufour <ldufour@linux.vnet.ibm.com> - 2017-04-27 18:00 +0200
  [RFC v3 04/17] mm: VMA sequence count Laurent Dufour <ldufour@linux.vnet.ibm.com> - 2017-04-27 18:00 +0200
  [RFC v3 02/17] mm: Prepare for FAULT_FLAG_SPECULATIVE Laurent Dufour <ldufour@linux.vnet.ibm.com> - 2017-04-27 18:00 +0200
  [RFC v3 12/17] mm/spf: Protect changes to vm_flags Laurent Dufour <ldufour@linux.vnet.ibm.com> - 2017-04-27 18:00 +0200
  [RFC v3 14/17] x86/mm: Update the handle_speculative_fault's path Laurent Dufour <ldufour@linux.vnet.ibm.com> - 2017-04-27 18:00 +0200
  [RFC v3 06/17] mm: Provide speculative fault infrastructure Laurent Dufour <ldufour@linux.vnet.ibm.com> - 2017-04-27 18:00 +0200
  [RFC v3 16/17] mm: protect madvise vs speculative pf Laurent Dufour <ldufour@linux.vnet.ibm.com> - 2017-04-27 18:00 +0200
  [RFC v3 09/17] mm/spf: Fix fe.sequence init in __handle_mm_fault() Laurent Dufour <ldufour@linux.vnet.ibm.com> - 2017-04-27 18:00 +0200
  [RFC v3 08/17] mm/spf: Try spin lock in speculative path Laurent Dufour <ldufour@linux.vnet.ibm.com> - 2017-04-27 18:00 +0200

csiph-web