linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Jong Hyun Park <park.jonghyun@yonsei.ac.kr>,
	Tianyu Lan <Tianyu.Lan@microsoft.com>,
	Michael Kelley <mikelley@microsoft.com>,
	Borislav Petkov <bp@alien8.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.19 70/79] x86/hyper-v: Fix overflow bug in fill_gva_list()
Date: Fri, 20 Sep 2019 00:03:55 +0200	[thread overview]
Message-ID: <20190919214813.934615543@linuxfoundation.org> (raw)
In-Reply-To: <20190919214807.612593061@linuxfoundation.org>

From: Tianyu Lan <Tianyu.Lan@microsoft.com>

[ Upstream commit 4030b4c585c41eeefec7bd20ce3d0e100a0f2e4d ]

When the 'start' parameter is >=  0xFF000000 on 32-bit
systems, or >= 0xFFFFFFFF'FF000000 on 64-bit systems,
fill_gva_list() gets into an infinite loop.

With such inputs, 'cur' overflows after adding HV_TLB_FLUSH_UNIT
and always compares as less than end.  Memory is filled with
guest virtual addresses until the system crashes.

Fix this by never incrementing 'cur' to be larger than 'end'.

Reported-by: Jong Hyun Park <park.jonghyun@yonsei.ac.kr>
Signed-off-by: Tianyu Lan <Tianyu.Lan@microsoft.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 2ffd9e33ce4a ("x86/hyper-v: Use hypercall for remote TLB flush")
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/x86/hyperv/mmu.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
index ef5f29f913d7b..2f34d52753526 100644
--- a/arch/x86/hyperv/mmu.c
+++ b/arch/x86/hyperv/mmu.c
@@ -37,12 +37,14 @@ static inline int fill_gva_list(u64 gva_list[], int offset,
 		 * Lower 12 bits encode the number of additional
 		 * pages to flush (in addition to the 'cur' page).
 		 */
-		if (diff >= HV_TLB_FLUSH_UNIT)
+		if (diff >= HV_TLB_FLUSH_UNIT) {
 			gva_list[gva_n] |= ~PAGE_MASK;
-		else if (diff)
+			cur += HV_TLB_FLUSH_UNIT;
+		}  else if (diff) {
 			gva_list[gva_n] |= (diff - 1) >> PAGE_SHIFT;
+			cur = end;
+		}
 
-		cur += HV_TLB_FLUSH_UNIT;
 		gva_n++;
 
 	} while (cur < end);
-- 
2.20.1




  parent reply	other threads:[~2019-09-19 22:14 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-19 22:02 [PATCH 4.19 00/79] 4.19.75-stable review Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 01/79] netfilter: nf_flow_table: set default timeout after successful insertion Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 02/79] HID: wacom: generic: read HID_DG_CONTACTMAX from any feature report Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 03/79] RDMA/restrack: Release task struct which was hold by CM_ID object Greg Kroah-Hartman
2019-09-21 20:22   ` Pavel Machek
2019-09-22  8:30     ` Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 04/79] Input: elan_i2c - remove Lenovo Legion Y7000 PnpID Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 05/79] powerpc/mm/radix: Use the right page size for vmemmap mapping Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 06/79] USB: usbcore: Fix slab-out-of-bounds bug during device reset Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 07/79] media: tm6000: double free if usb disconnect while streaming Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 08/79] phy: renesas: rcar-gen3-usb2: Disable clearing VBUS in over-current Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 09/79] ip6_gre: fix a dst leak in ip6erspan_tunnel_xmit Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 10/79] udp: correct reuseport selection with connected sockets Greg Kroah-Hartman
2019-09-21 20:32   ` Pavel Machek
2019-09-19 22:02 ` [PATCH 4.19 11/79] xen-netfront: do not assume sk_buff_head list is empty in error handling Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 12/79] net_sched: let qdisc_put() accept NULL pointer Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 13/79] KVM: coalesced_mmio: add bounds checking Greg Kroah-Hartman
2019-09-19 22:02 ` [PATCH 4.19 14/79] firmware: google: check if size is valid when decoding VPD data Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 15/79] serial: sprd: correct the wrong sequence of arguments Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 16/79] tty/serial: atmel: reschedule TX after RX was started Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 17/79] mwifiex: Fix three heap overflow at parsing element in cfg80211_ap_settings Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 18/79] nl80211: Fix possible Spectre-v1 for CQM RSSI thresholds Greg Kroah-Hartman
2019-09-20 11:28   ` Pavel Machek
2019-09-19 22:03 ` [PATCH 4.19 19/79] ieee802154: hwsim: Fix error handle path in hwsim_init_module Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 20/79] ieee802154: hwsim: unregister hw while hwsim_subscribe_all_others fails Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 21/79] ARM: dts: am57xx: Disable voltage switching for SD card Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 22/79] ARM: OMAP2+: Fix missing SYSC_HAS_RESET_STATUS for dra7 epwmss Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 23/79] bus: ti-sysc: Fix using configured sysc mask value Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 24/79] s390/bpf: fix lcgr instruction encoding Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 25/79] ARM: OMAP2+: Fix omap4 errata warning on other SoCs Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 26/79] ARM: dts: dra74x: Fix iodelay configuration for mmc3 Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 27/79] ARM: OMAP1: ams-delta-fiq: Fix missing irq_ack Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 28/79] bus: ti-sysc: Simplify cleanup upon failures in sysc_probe() Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 29/79] s390/bpf: use 32-bit index for tail calls Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 30/79] selftests/bpf: fix "bind{4, 6} deny specific IP & port" on s390 Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 31/79] tools: bpftool: close prog FD before exit on showing a single program Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 32/79] fpga: altera-ps-spi: Fix getting of optional confd gpio Greg Kroah-Hartman
2019-09-21 20:46   ` Pavel Machek
2019-09-23  1:33     ` Phil Reid
2019-09-19 22:03 ` [PATCH 4.19 33/79] netfilter: ebtables: Fix argument order to ADD_COUNTER Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 34/79] netfilter: nft_flow_offload: missing netlink attribute policy Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 35/79] netfilter: xt_nfacct: Fix alignment mismatch in xt_nfacct_match_info Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 36/79] NFSv4: Fix return values for nfs4_file_open() Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 37/79] NFSv4: Fix return value in nfs_finish_open() Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 38/79] NFS: Fix initialisation of I/O result struct in nfs_pgio_rpcsetup Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 39/79] Kconfig: Fix the reference to the IDT77105 Phy driver in the description of ATM_NICSTAR_USE_IDT77105 Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 40/79] xdp: unpin xdp umem pages in error path Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 41/79] qed: Add cleanup in qed_slowpath_start() Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 42/79] ARM: 8874/1: mm: only adjust sections of valid mm structures Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 43/79] batman-adv: Only read OGM2 tvlv_len after buffer len check Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 44/79] bpf: allow narrow loads of some sk_reuseport_md fields with offset > 0 Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 45/79] r8152: Set memory to all 0xFFs on failed reg reads Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 46/79] x86/apic: Fix arch_dynirq_lower_bound() bug for DT enabled machines Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 47/79] netfilter: xt_physdev: Fix spurious error message in physdev_mt_check Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 48/79] netfilter: nf_conntrack_ftp: Fix debug output Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 49/79] NFSv2: Fix eof handling Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 50/79] NFSv2: Fix write regression Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 51/79] kallsyms: Dont let kallsyms_lookup_size_offset() fail on retrieving the first symbol Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 52/79] cifs: set domainName when a domain-key is used in multiuser Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 53/79] cifs: Use kzfree() to zero out the password Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 54/79] usb: host: xhci-tegra: Set DMA mask correctly Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 55/79] ARM: 8901/1: add a criteria for pfn_valid of arm Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 56/79] ibmvnic: Do not process reset during or after device removal Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 57/79] sky2: Disable MSI on yet another ASUS boards (P6Xxxx) Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 58/79] i2c: designware: Synchronize IRQs when unregistering slave client Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 59/79] perf/x86/intel: Restrict period on Nehalem Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 60/79] perf/x86/amd/ibs: Fix sample bias for dispatched micro-ops Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 61/79] amd-xgbe: Fix error path in xgbe_mod_init() Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 62/79] tools/power x86_energy_perf_policy: Fix "uninitialized variable" warnings at -O2 Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 63/79] tools/power x86_energy_perf_policy: Fix argument parsing Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 64/79] tools/power turbostat: fix buffer overrun Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 65/79] net: aquantia: fix out of memory condition on rx side Greg Kroah-Hartman
2019-09-20 11:20   ` Pavel Machek
2019-09-19 22:03 ` [PATCH 4.19 66/79] net: seeq: Fix the function used to release some memory in an error handling path Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 67/79] dmaengine: ti: dma-crossbar: Fix a memory leak bug Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 68/79] dmaengine: ti: omap-dma: Add cleanup in omap_dma_probe() Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 69/79] x86/uaccess: Dont leak the AC flags into __get_user() argument evaluation Greg Kroah-Hartman
2019-09-19 22:03 ` Greg Kroah-Hartman [this message]
2019-09-19 22:03 ` [PATCH 4.19 71/79] keys: Fix missing null pointer check in request_key_auth_describe() Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 72/79] iommu/amd: Flush old domains in kdump kernel Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 73/79] iommu/amd: Fix race in increase_address_space() Greg Kroah-Hartman
2019-09-19 22:03 ` [PATCH 4.19 74/79] PCI: kirin: Fix section mismatch warning Greg Kroah-Hartman
2019-09-19 22:04 ` [PATCH 4.19 75/79] ovl: fix regression caused by overlapping layers detection Greg Kroah-Hartman
2019-09-19 22:04 ` [PATCH 4.19 76/79] floppy: fix usercopy direction Greg Kroah-Hartman
2019-09-19 22:04 ` [PATCH 4.19 77/79] binfmt_elf: move brk out of mmap when doing direct loader exec Greg Kroah-Hartman
2019-09-19 22:04 ` [PATCH 4.19 78/79] arm64: kpti: Whitelist Cortex-A CPUs that dont implement the CSV3 field Greg Kroah-Hartman
2019-09-19 22:04 ` [PATCH 4.19 79/79] media: technisat-usb2: break out of loop at end of buffer Greg Kroah-Hartman
2019-09-20  3:39 ` [PATCH 4.19 00/79] 4.19.75-stable review kernelci.org bot
2019-09-20  8:51 ` Naresh Kamboju
2019-09-20 13:48 ` Jon Hunter
2019-09-20 18:37 ` Guenter Roeck
2019-09-20 21:21 ` shuah

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=20190919214813.934615543@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=Tianyu.Lan@microsoft.com \
    --cc=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikelley@microsoft.com \
    --cc=mingo@kernel.org \
    --cc=park.jonghyun@yonsei.ac.kr \
    --cc=peterz@infradead.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --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;
as well as URLs for NNTP newsgroup(s).