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


Groups > linux.kernel > #1709892

Re: [PATCH 4.4 18/58] mm, mprotect: flush TLB if potentially racing with a parallel reclaim leaving stale TLB entries

From Ben Hutchings <ben.hutchings@codethink.co.uk>
Newsgroups linux.kernel
Subject Re: [PATCH 4.4 18/58] mm, mprotect: flush TLB if potentially racing with a parallel reclaim leaving stale TLB entries
Date 2017-08-11 19:50 +0200
Message-ID <udmel-6sy-13@gated-at.bofh.it> (permalink)
References <ucF9n-3gT-3@gated-at.bofh.it> <ucF9q-3gT-69@gated-at.bofh.it>
Organization Codethink Ltd.

Show all headers | View raw


On Wed, 2017-08-09 at 12:41 -0700, Greg Kroah-Hartman wrote:
> 4.4-stable review patch.  If anyone has any objections, please let me know.
> 
> ------------------
> 
> From: Mel Gorman <mgorman@suse.de>
> 
> commit 3ea277194daaeaa84ce75180ec7c7a2075027a68 upstream.
[...]
> +/*
> + * Reclaim unmaps pages under the PTL but do not flush the TLB prior to
> + * releasing the PTL if TLB flushes are batched. It's possible for a parallel
> + * operation such as mprotect or munmap to race between reclaim unmapping
> + * the page and flushing the page. If this race occurs, it potentially allows
> + * access to data via a stale TLB entry. Tracking all mm's that have TLB
> + * batching in flight would be expensive during reclaim so instead track
> + * whether TLB batching occurred in the past and if so then do a flush here
> + * if required. This will cost one additional flush per reclaim cycle paid
> + * by the first operation at risk such as mprotect and mumap.
> + *
> + * This must be called under the PTL so that an access to tlb_flush_batched
> + * that is potentially a "reclaim vs mprotect/munmap/etc" race will synchronise
> + * via the PTL.

What about USE_SPLIT_PTE_PTLOCKS?  I don't see how you can use "the PTL"
to synchronise access to a per-mm flag.

Ben.

> + */
> +void flush_tlb_batched_pending(struct mm_struct *mm)
> +{
> +	if (mm->tlb_flush_batched) {
> +		flush_tlb_mm(mm);
> +
> +		/*
> +		 * Do not allow the compiler to re-order the clearing of
> +		 * tlb_flush_batched before the tlb is flushed.
> +		 */
> +		barrier();
> +		mm->tlb_flush_batched = false;
> +	}
> +}
>  #else
>  static void set_tlb_ubc_flush_pending(struct mm_struct *mm,
>  		struct page *page, bool writable)
> 
> 

-- 
Ben Hutchings
Software Developer, Codethink Ltd.

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


Thread

[PATCH 4.4 00/58] 4.4.81-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 02/58] libata: array underflow in ata_find_dev() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 12/58] target: Avoid mappedlun symlink creation during lun shutdown Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 29/58] openvswitch: fix potential out of bound access in parse_ct Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 51/58] virtio_blk: fix panic in initialization error path Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 55/58] signal: protect SIGNAL_UNKILLABLE from unintentional clearing. Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 49/58] scsi: qla2xxx: Get mutex lock before checking optrom_state Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 15/58] iscsi-target: Fix initial login PDU asynchronous socket close OOPs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
    Re: [PATCH 4.4 15/58] iscsi-target: Fix initial login PDU  asynchronous socket close OOPs Ben Hutchings <ben.hutchings@codethink.co.uk> - 2017-08-11 18:20 +0200
  [PATCH 4.4 33/58] dccp: fix a memleak that dccp_ipv6 doesnt put reqsk properly Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 45/58] net: phy: dp83867: fix irq generation Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 53/58] mm, slab: make sure that KMALLOC_MAX_SIZE will fit into MAX_ORDER Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 57/58] ipv4: Should use consistent conditional judgement for ip fragment in __ip_append_data and ip_finish_output Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 18/58] mm, mprotect: flush TLB if potentially racing with a parallel reclaim leaving stale TLB entries Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
    Re: [PATCH 4.4 18/58] mm, mprotect: flush TLB if potentially racing  with a parallel reclaim leaving stale TLB entries Ben Hutchings <ben.hutchings@codethink.co.uk> - 2017-08-11 19:50 +0200
      Re: [PATCH 4.4 18/58] mm, mprotect: flush TLB if potentially racing  with a parallel reclaim leaving stale TLB entries Nadav Amit <nadav.amit@gmail.com> - 2017-08-13 08:30 +0200
        Re: [PATCH 4.4 18/58] mm, mprotect: flush TLB if potentially racing  with a parallel reclaim leaving stale TLB entries Ben Hutchings <ben.hutchings@codethink.co.uk> - 2017-08-15 15:40 +0200
          Re: [PATCH 4.4 18/58] mm, mprotect: flush TLB if potentially racing  with a parallel reclaim leaving stale TLB entries Nadav Amit <nadav.amit@gmail.com> - 2017-08-15 18:40 +0200
      Re: [PATCH 4.4 18/58] mm, mprotect: flush TLB if potentially racing  with a parallel reclaim leaving stale TLB entries Mel Gorman <mgorman@suse.de> - 2017-08-14 10:10 +0200
  [PATCH 4.4 23/58] ipv4: ipv6: initialize treq->txhash in cookie_v[46]_check() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 52/58] ARM: 8632/1: ftrace: fix syscall name matching Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 04/58] ALSA: hda - Fix speaker output from VAIO VPCL14M1R Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 37/58] sctp: fix the check for _sctp_walk_params and _sctp_walk_errors Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 48/58] phy state machine: failsafe leave invalid RUNNING state Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 28/58] mcs7780: Fix initialization when CONFIG_VMAP_STACK is enabled Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 03/58] workqueue: restore WQ_UNBOUND/max_active==1 to be ordered Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 42/58] sparc64: Prevent perf from running during super critical sections Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
    Re: [PATCH 4.4 42/58] sparc64: Prevent perf from running during  super critical sections Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-10 18:30 +0200
  [PATCH 4.4 46/58] tg3: Fix race condition in tg3_get_stats64(). Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 21:50 +0200
  [PATCH 4.4 31/58] ipv6: Dont increase IPSTATS_MIB_FRAGFAILS twice in ip6_fragment() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:00 +0200
  [PATCH 4.4 27/58] rtnetlink: allocate more memory for dev_set_mac_address() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:00 +0200
  [PATCH 4.4 10/58] ARM: dts: armada-38x: Fix irq type for pca955 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:00 +0200
  [PATCH 4.4 20/58] f2fs: sanity check checkpoint segno and blkoff Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:00 +0200
  [PATCH 4.4 21/58] drm: rcar-du: fix backport bug Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:00 +0200
  [PATCH 4.4 38/58] net/mlx5: Fix command bad flow on command entry allocation failure Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:00 +0200
  [PATCH 4.4 35/58] dccp: fix a memleak for dccp_feat_init err process Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:00 +0200
  [PATCH 4.4 34/58] dccp: fix a memleak that dccp_ipv4 doesnt put reqsk properly Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:00 +0200
  [PATCH 4.4 24/58] net: Zero terminate ifr_name in dev_ifname(). Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:00 +0200
  [PATCH 4.4 14/58] iscsi-target: Fix early sk_data_ready LOGIN_FLAGS_READY race Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:00 +0200
  [PATCH 4.4 09/58] ext4: fix overflow caused by missing cast in ext4_resize_fs() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:00 +0200
  [PATCH 4.4 22/58] [media] saa7164: fix double fetch PCIe access condition Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:00 +0200
  [PATCH 4.4 26/58] ipv4: initialize fib_trie prior to register_netdev_notifier call. Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:00 +0200
  [PATCH 4.4 05/58] ASoC: do not close shared backend dailink Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:00 +0200
  [PATCH 4.4 25/58] ipv6: avoid overflow of offset in ip6_find_1stfragopt Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:00 +0200
  Re: [PATCH 4.4 00/58] 4.4.81-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2017-08-10 02:10 +0200
  Re: [PATCH 4.4 00/58] 4.4.81-stable review Guenter Roeck <linux@roeck-us.net> - 2017-08-10 02:40 +0200
    Re: [PATCH 4.4 00/58] 4.4.81-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-10 18:20 +0200
      Re: [PATCH 4.4 00/58] 4.4.81-stable review Guenter Roeck <linux@roeck-us.net> - 2017-08-10 19:40 +0200
    Re: [PATCH 4.4 00/58] 4.4.81-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-10 18:30 +0200
  Re: [PATCH 4.4 00/58] 4.4.81-stable review Guenter Roeck <linux@roeck-us.net> - 2017-08-10 03:00 +0200
    Re: [PATCH 4.4 00/58] 4.4.81-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-10 18:20 +0200

csiph-web