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, Gonglei <arei.gonglei@huawei.com>,
	Longpeng <longpeng2@huawei.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.19 39/66] virtio_pci: fix a NULL pointer reference in vp_del_vqs
Date: Thu,  9 May 2019 20:42:14 +0200	[thread overview]
Message-ID: <20190509181306.101821011@linuxfoundation.org> (raw)
In-Reply-To: <20190509181301.719249738@linuxfoundation.org>

[ Upstream commit 6a8aae68c87349dbbcd46eac380bc43cdb98a13b ]

If the msix_affinity_masks is alloced failed, then we'll
try to free some resources in vp_free_vectors() that may
access it directly.

We met the following stack in our production:
[   29.296767] BUG: unable to handle kernel NULL pointer dereference at  (null)
[   29.311151] IP: [<ffffffffc04fe35a>] vp_free_vectors+0x6a/0x150 [virtio_pci]
[   29.324787] PGD 0
[   29.333224] Oops: 0000 [#1] SMP
[...]
[   29.425175] RIP: 0010:[<ffffffffc04fe35a>]  [<ffffffffc04fe35a>] vp_free_vectors+0x6a/0x150 [virtio_pci]
[   29.441405] RSP: 0018:ffff9a55c2dcfa10  EFLAGS: 00010206
[   29.453491] RAX: 0000000000000000 RBX: ffff9a55c322c400 RCX: 0000000000000000
[   29.467488] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff9a55c322c400
[   29.481461] RBP: ffff9a55c2dcfa20 R08: 0000000000000000 R09: ffffc1b6806ff020
[   29.495427] R10: 0000000000000e95 R11: 0000000000aaaaaa R12: 0000000000000000
[   29.509414] R13: 0000000000010000 R14: ffff9a55bd2d9e98 R15: ffff9a55c322c400
[   29.523407] FS:  00007fdcba69f8c0(0000) GS:ffff9a55c2840000(0000) knlGS:0000000000000000
[   29.538472] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   29.551621] CR2: 0000000000000000 CR3: 000000003ce52000 CR4: 00000000003607a0
[   29.565886] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[   29.580055] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[   29.594122] Call Trace:
[   29.603446]  [<ffffffffc04fe8a2>] vp_request_msix_vectors+0xe2/0x260 [virtio_pci]
[   29.618017]  [<ffffffffc04fedc5>] vp_try_to_find_vqs+0x95/0x3b0 [virtio_pci]
[   29.632152]  [<ffffffffc04ff117>] vp_find_vqs+0x37/0xb0 [virtio_pci]
[   29.645582]  [<ffffffffc057bf63>] init_vq+0x153/0x260 [virtio_blk]
[   29.658831]  [<ffffffffc057c1e8>] virtblk_probe+0xe8/0x87f [virtio_blk]
[...]

Cc: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Longpeng <longpeng2@huawei.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/virtio/virtio_pci_common.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
index 465a6f5142cc5..45b04bc91f248 100644
--- a/drivers/virtio/virtio_pci_common.c
+++ b/drivers/virtio/virtio_pci_common.c
@@ -255,9 +255,11 @@ void vp_del_vqs(struct virtio_device *vdev)
 	for (i = 0; i < vp_dev->msix_used_vectors; ++i)
 		free_irq(pci_irq_vector(vp_dev->pci_dev, i), vp_dev);
 
-	for (i = 0; i < vp_dev->msix_vectors; i++)
-		if (vp_dev->msix_affinity_masks[i])
-			free_cpumask_var(vp_dev->msix_affinity_masks[i]);
+	if (vp_dev->msix_affinity_masks) {
+		for (i = 0; i < vp_dev->msix_vectors; i++)
+			if (vp_dev->msix_affinity_masks[i])
+				free_cpumask_var(vp_dev->msix_affinity_masks[i]);
+	}
 
 	if (vp_dev->msix_enabled) {
 		/* Disable the vector used for configuration */
-- 
2.20.1




  parent reply	other threads:[~2019-05-09 18:48 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-09 18:41 [PATCH 4.19 00/66] 4.19.42-stable review Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 01/66] net: stmmac: Use bfsize1 in ndesc_init_rx_desc Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 02/66] scsi: libsas: fix a race condition when smp task timeout Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 03/66] Drivers: hv: vmbus: Remove the undesired put_cpu_ptr() in hv_synic_cleanup() Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 04/66] ubsan: Fix nasty -Wbuiltin-declaration-mismatch GCC-9 warnings Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 05/66] staging: greybus: power_supply: fix prop-descriptor request size Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 06/66] staging: most: cdev: fix chrdev_region leak in mod_exit Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 07/66] ASoC: tlv320aic3x: fix reset gpio reference counting Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 08/66] ASoC: hdmi-codec: fix S/PDIF DAI Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 09/66] ASoC: stm32: sai: fix iec958 controls indexation Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 10/66] ASoC: stm32: sai: fix exposed capabilities in spdif mode Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 11/66] ASoC:soc-pcm:fix a codec fixup issue in TDM case Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 12/66] ASoC:intel:skl:fix a simultaneous playback & capture issue on hda platform Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 13/66] ASoC: nau8824: fix the issue of the widget with prefix name Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 14/66] ASoC: nau8810: fix the issue of widget with prefixed name Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 15/66] ASoC: samsung: odroid: Fix clock configuration for 44100 sample rate Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 16/66] ASoC: rt5682: recording has no sound after booting Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 17/66] ASoC: wm_adsp: Add locking to wm_adsp2_bus_error Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 18/66] clk: meson-gxbb: round the vdec dividers to closest Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 19/66] ASoC: stm32: dfsdm: manage multiple prepare Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 20/66] ASoC: stm32: dfsdm: fix debugfs warnings on entry creation Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 21/66] ASoC: cs4270: Set auto-increment bit for register writes Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 22/66] ASoC: dapm: Fix NULL pointer dereference in snd_soc_dapm_free_kcontrol Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 23/66] drm/omap: hdmi4_cec: Fix CEC clock handling for PM Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 24/66] IB/hfi1: Eliminate opcode tests on mr deref Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 25/66] IB/hfi1: Fix the allocation of RSM table Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 26/66] MIPS: KGDB: fix kgdb support for SMP platforms Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 27/66] ASoC: tlv320aic32x4: Fix Common Pins Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 28/66] drm/mediatek: Fix an error code in mtk_hdmi_dt_parse_pdata() Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 29/66] perf/x86/intel: Fix handling of wakeup_events for multi-entry PEBS Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 30/66] perf/x86/intel: Initialize TFA MSR Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 31/66] linux/kernel.h: Use parentheses around argument in u64_to_user_ptr() Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 32/66] xtensa: fix initialization of pt_regs::syscall in start_thread Greg Kroah-Hartman
2019-05-09 18:55   ` Max Filippov
2019-05-10  6:24     ` Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 33/66] ASoC: rockchip: pdm: fix regmap_ops hang issue Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 34/66] drm/amd/display: fix cursor black issue Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 35/66] ASoC: cs35l35: Disable regulators on driver removal Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 36/66] objtool: Add rewind_stack_do_exit() to the noreturn list Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 37/66] slab: fix a crash by reading /proc/slab_allocators Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 38/66] drm/sun4i: tcon top: Fix NULL/invalid pointer dereference in sun8i_tcon_top_un/bind Greg Kroah-Hartman
2019-05-09 18:42 ` Greg Kroah-Hartman [this message]
2019-05-09 18:42 ` [PATCH 4.19 40/66] RDMA/vmw_pvrdma: Fix memory leak on pvrdma_pci_remove Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 41/66] RDMA/hns: Fix bug that caused srq creation to fail Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 42/66] scsi: csiostor: fix missing data copy in csio_scsi_err_handler() Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 43/66] drm/mediatek: fix possible object reference leak Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 44/66] ASoC: Intel: kbl: fix wrong number of channels Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 45/66] virtio-blk: limit number of hw queues by nr_cpu_ids Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 46/66] nvme-fc: correct csn initialization and increments on error Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 47/66] platform/x86: pmc_atom: Drop __initconst on dmi table Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 48/66] perf/core: Fix perf_event_disable_inatomic() race Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 49/66] iommu/amd: Set exclusion range correctly Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 50/66] genirq: Prevent use-after-free and work list corruption Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 51/66] usb: dwc3: Fix default lpm_nyet_threshold value Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 52/66] USB: serial: f81232: fix interrupt worker not stop Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 53/66] USB: cdc-acm: fix unthrottle races Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 54/66] usb-storage: Set virt_boundary_mask to avoid SG overflows Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 55/66] intel_th: pci: Add Comet Lake support Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 56/66] cpufreq: armada-37xx: fix frequency calculation for opp Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 57/66] soc: sunxi: Fix missing dependency on REGMAP_MMIO Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 58/66] scsi: lpfc: change snprintf to scnprintf for possible overflow Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 59/66] scsi: qla2xxx: Fix incorrect region-size setting in optrom SYSFS routines Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 60/66] scsi: qla2xxx: Fix device staying in blocked state Greg Kroah-Hartman
2019-05-09 20:28   ` [EXT] " Quoc Tran
2019-05-10  5:37     ` Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 61/66] Bluetooth: hidp: fix buffer overflow Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 62/66] Bluetooth: Align minimum encryption key size for LE and BR/EDR connections Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 63/66] UAS: fix alignment of scatter/gather segments Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 64/66] ASoC: Intel: avoid Oops if DMA setup fails Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 65/66] locking/futex: Allow low-level atomic operations to return -EAGAIN Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 66/66] arm64: futex: Bound number of LDXR/STXR loops in FUTEX_WAKE_OP Greg Kroah-Hartman
2019-05-10  0:07 ` [PATCH 4.19 00/66] 4.19.42-stable review kernelci.org bot
2019-05-10  6:34 ` Naresh Kamboju
2019-05-10 10:16 ` Jon Hunter
2019-05-10 13:35 ` Guenter Roeck
2019-05-10 21:25 ` shuah
2019-05-11 11:19 ` Pavel Machek

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=20190509181306.101821011@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=arei.gonglei@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longpeng2@huawei.com \
    --cc=mst@redhat.com \
    --cc=sashal@kernel.org \
    --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).