stable.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, Igor Mammedov <imammedo@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>
Subject: [PATCH 3.19 101/101] kvm: avoid page allocation failure in kvm_set_memory_region()
Date: Fri, 17 Apr 2015 15:29:29 +0200	[thread overview]
Message-ID: <20150417132518.710599666@linuxfoundation.org> (raw)
In-Reply-To: <20150417132514.379828774@linuxfoundation.org>

3.19-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Igor Mammedov <imammedo@redhat.com>

commit 744961341d472db6272ed9b42319a90f5a2aa7c4 upstream.

KVM guest can fail to startup with following trace on host:

qemu-system-x86: page allocation failure: order:4, mode:0x40d0
Call Trace:
  dump_stack+0x47/0x67
  warn_alloc_failed+0xee/0x150
  __alloc_pages_direct_compact+0x14a/0x150
  __alloc_pages_nodemask+0x776/0xb80
  alloc_kmem_pages+0x3a/0x110
  kmalloc_order+0x13/0x50
  kmemdup+0x1b/0x40
  __kvm_set_memory_region+0x24a/0x9f0 [kvm]
  kvm_set_ioapic+0x130/0x130 [kvm]
  kvm_set_memory_region+0x21/0x40 [kvm]
  kvm_vm_ioctl+0x43f/0x750 [kvm]

Failure happens when attempting to allocate pages for
'struct kvm_memslots', however it doesn't have to be
present in physically contiguous (kmalloc-ed) address
space, change allocation to kvm_kvzalloc() so that
it will be vmalloc-ed when its size is more then a page.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 virt/kvm/kvm_main.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -466,7 +466,7 @@ static struct kvm *kvm_create_vm(unsigne
 	BUILD_BUG_ON(KVM_MEM_SLOTS_NUM > SHRT_MAX);
 
 	r = -ENOMEM;
-	kvm->memslots = kzalloc(sizeof(struct kvm_memslots), GFP_KERNEL);
+	kvm->memslots = kvm_kvzalloc(sizeof(struct kvm_memslots));
 	if (!kvm->memslots)
 		goto out_err_no_srcu;
 
@@ -517,7 +517,7 @@ out_err_no_srcu:
 out_err_no_disable:
 	for (i = 0; i < KVM_NR_BUSES; i++)
 		kfree(kvm->buses[i]);
-	kfree(kvm->memslots);
+	kvfree(kvm->memslots);
 	kvm_arch_free_vm(kvm);
 	return ERR_PTR(r);
 }
@@ -573,7 +573,7 @@ static void kvm_free_physmem(struct kvm
 	kvm_for_each_memslot(memslot, slots)
 		kvm_free_physmem_slot(kvm, memslot, NULL);
 
-	kfree(kvm->memslots);
+	kvfree(kvm->memslots);
 }
 
 static void kvm_destroy_devices(struct kvm *kvm)
@@ -865,10 +865,10 @@ int __kvm_set_memory_region(struct kvm *
 			goto out_free;
 	}
 
-	slots = kmemdup(kvm->memslots, sizeof(struct kvm_memslots),
-			GFP_KERNEL);
+	slots = kvm_kvzalloc(sizeof(struct kvm_memslots));
 	if (!slots)
 		goto out_free;
+	memcpy(slots, kvm->memslots, sizeof(struct kvm_memslots));
 
 	if ((change == KVM_MR_DELETE) || (change == KVM_MR_MOVE)) {
 		slot = id_to_memslot(slots, mem->slot);
@@ -911,7 +911,7 @@ int __kvm_set_memory_region(struct kvm *
 	kvm_arch_commit_memory_region(kvm, mem, &old, change);
 
 	kvm_free_physmem_slot(kvm, &old, &new);
-	kfree(old_memslots);
+	kvfree(old_memslots);
 
 	/*
 	 * IOMMU mapping:  New slots need to be mapped.  Old slots need to be
@@ -930,7 +930,7 @@ int __kvm_set_memory_region(struct kvm *
 	return 0;
 
 out_slots:
-	kfree(slots);
+	kvfree(slots);
 out_free:
 	kvm_free_physmem_slot(kvm, &new, &old);
 out:



  parent reply	other threads:[~2015-04-17 13:29 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-17 13:27 [PATCH 3.19 000/101] 3.19.5-stable review Greg Kroah-Hartman
2015-04-17 13:27 ` [PATCH 3.19 001/101] ALSA: hda - Add dock support for Thinkpad T450s (17aa:5036) Greg Kroah-Hartman
2015-04-17 13:27 ` [PATCH 3.19 002/101] ALSA: hda - Add one more node in the EAPD supporting candidate list Greg Kroah-Hartman
2015-04-17 13:27 ` [PATCH 3.19 003/101] ALSA: usb - Creative USB X-Fi Pro SB1095 volume knob support Greg Kroah-Hartman
2015-04-17 13:27 ` [PATCH 3.19 004/101] ALSA: bebob: fix to processing in big-endian machine for sending cue Greg Kroah-Hartman
2015-04-17 13:27 ` [PATCH 3.19 005/101] ALSA: hda/realtek - Make more stable to get pin sense for ALC283 Greg Kroah-Hartman
2015-04-17 13:27 ` [PATCH 3.19 006/101] ALSA: hda - Fix headphone pin config for Lifebook T731 Greg Kroah-Hartman
2015-04-17 13:27 ` [PATCH 3.19 007/101] PCI/AER: Avoid info leak in __print_tlp_header() Greg Kroah-Hartman
2015-04-17 13:27 ` [PATCH 3.19 008/101] PCI: cpcihp: Add missing curly braces in cpci_configure_slot() Greg Kroah-Hartman
2015-04-17 13:27 ` [PATCH 3.19 009/101] Revert "sparc/PCI: Clip bridge windows to fit in upstream windows" Greg Kroah-Hartman
2015-04-17 13:27 ` [PATCH 3.19 010/101] PCI: Dont look for ACPI hotplug parameters if ACPI is disabled Greg Kroah-Hartman
2015-04-17 13:27 ` [PATCH 3.19 011/101] PCI: spear: Drop __initdata from spear13xx_pcie_driver Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 012/101] ARC: SA_SIGINFO ucontext regs off-by-one Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 013/101] ARC: signal handling robustify Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 014/101] ARM: sunxi: Have ARCH_SUNXI select RESET_CONTROLLER for clock driver usage Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 015/101] selinux: fix sel_write_enforce broken return value Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 016/101] blk-mq: fix use of incorrect goto label in blk_mq_init_queue error path Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 017/101] blkmq: Fix NULL pointer deref when all reserved tags in Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 018/101] Fix bug in blk_rq_merge_ok Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 019/101] block: fix blk_stack_limits() regression due to lcm() change Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 020/101] drm: Fixup racy refcounting in plane_force_disable Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 021/101] drm/edid: set ELD for firmware and debugfs override EDIDs Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 023/101] drm/radeon/dpm: fix 120hz handling harder Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 027/101] drm/i915/vlv: save/restore the power context base reg Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 028/101] drm/i915/vlv: remove wait for previous GFX clk disable request Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 030/101] drm/i915: Align initial plane backing objects correctly Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 031/101] btrfs: simplify insert_orphan_item Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 032/101] IB/uverbs: Prevent integer overflow in ib_umem_get address arithmetic Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 033/101] iwlwifi: dvm: run INIT firmware again upon .start() Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 034/101] x86/xen: prepare p2m list for memory hotplug Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 035/101] xen/balloon: before adding hotplugged memory, set frames to invalid Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 036/101] nfsd: return correct openowner when there is a race to put one in the hash Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 037/101] nfsd: return correct lockowner when there is a race on hash insert Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 038/101] sunrpc: make debugfs file creation failure non-fatal Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 039/101] powerpc: fix memory corruption by pnv_alloc_idle_core_states Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 040/101] powerpc: Re-enable dynticks Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 041/101] nbd: fix possible memory leak Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 042/101] mac80211: fix RX A-MPDU session reorder timer deletion Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 043/101] mm: fix anon_vma->degree underflow in anon_vma endless growing prevention Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 044/101] mm/memory hotplug: postpone the reset of obsolete pgdat Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 045/101] mm/page_alloc.c: call kernel_map_pages in unset_migrateype_isolate Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 046/101] sched: Fix RLIMIT_RTTIME when PI-boosting to RT Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 047/101] cpufreq: Schedule work for the first-online CPU on resume Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 048/101] writeback: add missing INITIAL_JIFFIES init in global_update_bandwidth() Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 049/101] writeback: fix possible underflow in write bandwidth calculation Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 050/101] libata: Update Crucial/Micron blacklist Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 051/101] libata: Blacklist queued TRIM on Samsung SSD 850 Pro Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 053/101] USB: keyspan_pda: add new device id Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 054/101] USB: ftdi_sio: Added custom PID for Synapse Wireless product Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 055/101] USB: ftdi_sio: Use jtag quirk for SNAP Connect E10 Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 056/101] Defer processing of REQ_PREEMPT requests for blocked devices Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 057/101] iio: inv_mpu6050: Clear timestamps fifo while resetting hardware fifo Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 058/101] iio: core: Fix double free Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 059/101] iio: bmc150: change sampling frequency Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 060/101] iio: adc: vf610: use ADC clock within specification Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 061/101] iio: imu: Use iio_trigger_get for indio_dev->trig assignment Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 062/101] dmaengine: edma: fix memory leak when terminating running transfers Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 063/101] dmaengine: omap-dma: Fix memory leak when terminating running transfer Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 064/101] ath9k: fix tracking of enabled AP beacons Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 065/101] x86/reboot: Add ASRock Q1900DC-ITX mainboard reboot quirk Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 066/101] can: flexcan: fix bus-off error state handling Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 067/101] can: flexcan: Deferred on Regulator return EPROBE_DEFER Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 068/101] firmware: dmi_scan: Prevent dmi_num integer overflow Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 069/101] cpuidle: remove state_count field from struct cpuidle_device Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 070/101] cpuidle: ACPI: do not overwrite name and description of C0 Greg Kroah-Hartman
2015-04-17 13:28 ` [PATCH 3.19 071/101] usb: xhci: handle Config Error Change (CEC) in xhci driver Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 072/101] usb: xhci: apply XHCI_AVOID_BEI quirk to all Intel xHCI controllers Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 073/101] tty: serial: fsl_lpuart: specify transmit FIFO size Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 074/101] tty: serial: fsl_lpuart: clear receive flag on FIFO flush Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 075/101] n_tty: Fix read buffer overwrite when no newline Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 076/101] cifs: smb2_clone_range() - exit on unhandled error Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 077/101] cifs: fix use-after-free bug in find_writable_file Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 078/101] brcmfmac: disable MBSS feature for BCM43362 Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 079/101] iommu/vt-d: Detach domain *only* from attached iommus Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 080/101] rtlwifi: Fix IOMMU mapping leak in AP mode Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 081/101] drivers/of: Add empty ranges quirk for PA-Semi Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 082/101] Revert "PM / hibernate: avoid unsafe pages in e820 reserved regions" Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 083/101] Revert "libceph: use memalloc flags for net IO" Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 084/101] be2iscsi: Fix kernel panic when device initialization fails Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 085/101] ocfs2: _really_ sync the right range Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 086/101] ioctx_alloc(): fix vma (and file) leak on failure Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 087/101] iscsi target: fix oops when adding reject pdu Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 088/101] [media] sh_veu: v4l2_dev wasnt set Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 089/101] [media] media: s5p-mfc: fix mmap support for 64bit arch Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 090/101] [media] cx23885: fix querycap Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 091/101] [media] soc-camera: Fix devm_kfree() in soc_of_bind() Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 092/101] [media] vb2: Fix dma_dir setting for dma-contig mem type Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 093/101] [media] vb2: fix UNBALANCED warnings when calling vb2_thread_stop() Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 096/101] IB/mlx4: Saturate RoCE port PMA counters in case of overflow Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 097/101] timers/tick/broadcast-hrtimer: Fix suspicious RCU usage in idle loop Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 098/101] ext4: fix indirect punch hole corruption Greg Kroah-Hartman
2015-04-17 13:29 ` [PATCH 3.19 099/101] xfs: ensure truncate forces zeroed blocks to disk Greg Kroah-Hartman
2015-04-17 13:29 ` Greg Kroah-Hartman [this message]
2015-04-17 17:34 ` [PATCH 3.19 000/101] 3.19.5-stable review Shuah Khan
2015-04-17 19:43   ` Greg Kroah-Hartman
2015-04-17 20:03 ` Guenter Roeck
2015-04-18 18:59   ` Greg Kroah-Hartman

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=20150417132518.710599666@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=imammedo@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=stable@vger.kernel.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).