* [PATCH] virtio_pci: fix a NULL pointer reference in vp_del_vqs
@ 2019-03-09 7:17 Longpeng(Mike)
2019-03-09 7:21 ` Gonglei (Arei)
0 siblings, 1 reply; 2+ messages in thread
From: Longpeng(Mike) @ 2019-03-09 7:17 UTC (permalink / raw)
To: mst, jasowang; +Cc: virtualization, linux-kernel, Longpeng, Gonglei
From: Longpeng <longpeng2@huawei.com>
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>
---
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 d0584c0..7a0398b 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 */
--
1.8.3.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: [PATCH] virtio_pci: fix a NULL pointer reference in vp_del_vqs
2019-03-09 7:17 [PATCH] virtio_pci: fix a NULL pointer reference in vp_del_vqs Longpeng(Mike)
@ 2019-03-09 7:21 ` Gonglei (Arei)
0 siblings, 0 replies; 2+ messages in thread
From: Gonglei (Arei) @ 2019-03-09 7:21 UTC (permalink / raw)
To: longpeng, mst, jasowang; +Cc: virtualization, linux-kernel
> -----Original Message-----
> From: longpeng
> Sent: Saturday, March 09, 2019 3:18 PM
> To: mst@redhat.com; jasowang@redhat.com
> Cc: virtualization@lists.linux-foundation.org; linux-kernel@vger.kernel.org;
> longpeng <longpeng2@huawei.com>; Gonglei (Arei)
> <arei.gonglei@huawei.com>
> Subject: [PATCH] virtio_pci: fix a NULL pointer reference in vp_del_vqs
>
> From: Longpeng <longpeng2@huawei.com>
>
> 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>
> ---
> drivers/virtio/virtio_pci_common.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
Thanks,
-Gonglei
> diff --git a/drivers/virtio/virtio_pci_common.c
> b/drivers/virtio/virtio_pci_common.c
> index d0584c0..7a0398b 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 */
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-03-09 7:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-09 7:17 [PATCH] virtio_pci: fix a NULL pointer reference in vp_del_vqs Longpeng(Mike)
2019-03-09 7:21 ` Gonglei (Arei)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®