qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>,
	Aurelien Jarno <aurelien@aurel32.net>,
	Longpeng <longpeng2@huawei.com>,
	Gonglei <arei.gonglei@huawei.com>
Subject: [Qemu-devel] [PULL 4/7] usb/xhci: avoid trigger assertion if guest write wrong epid
Date: Fri,  3 May 2019 08:59:51 +0200	[thread overview]
Message-ID: <20190503065954.17069-5-kraxel@redhat.com> (raw)
In-Reply-To: <20190503065954.17069-1-kraxel@redhat.com>

From: Longpeng <longpeng2@huawei.com>

we found the following core in our environment:
0  0x00007fc6b06c2237 in raise ()
1  0x00007fc6b06c3928 in abort ()
2  0x00007fc6b06bb056 in __assert_fail_base ()
3  0x00007fc6b06bb102 in __assert_fail ()
4  0x0000000000702e36 in xhci_kick_ep (...)
5  0x000000000047897a in memory_region_write_accessor (...)
6  0x000000000047767f in access_with_adjusted_size (...)
7  0x000000000047944d in memory_region_dispatch_write (...)
(mr=mr@entry=0x7fc6a0138df0, addr=addr@entry=156, data=1648892416,
size=size@entry=4, attrs=attrs@entry=...)
8  0x000000000042df17 in address_space_write_continue (...)
10 0x000000000043084d in address_space_rw (...)
11 0x000000000047451b in kvm_cpu_exec (cpu=cpu@entry=0x1ab11b0)
12 0x000000000045dcf5 in qemu_kvm_cpu_thread_fn (arg=0x1ab11b0)
13 0x0000000000870631 in qemu_thread_start (args=args@entry=0x1acfb50)
14 0x00000000008959a7 in thread_entry_for_hotfix (pthread_cb=<optimized out>)
15 0x00007fc6b0a60dd5 in start_thread ()
16 0x00007fc6b078a59d in clone ()

(gdb) f 5
5  0x000000000047897a in memory_region_write_accessor (...)
529	    mr->ops->write(mr->opaque, addr, tmp, size);
(gdb) p /x tmp
$9 = 0x62481a00 <-- last byte 0x00 is @epid

xhci_doorbell_write() already check the upper bound of @slotid an @epid,
it also need to check the lower bound.

Cc: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Longpeng <longpeng2@huawei.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 1556605301-44112-1-git-send-email-longpeng2@huawei.com

[ kraxel: fixed typo in subject line ]

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/hcd-xhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index ec28bee31963..d8472b4fea7f 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -3137,7 +3137,7 @@ static void xhci_doorbell_write(void *ptr, hwaddr reg,
         streamid = (val >> 16) & 0xffff;
         if (reg > xhci->numslots) {
             DPRINTF("xhci: bad doorbell %d\n", (int)reg);
-        } else if (epid > 31) {
+        } else if (epid == 0 || epid > 31) {
             DPRINTF("xhci: bad doorbell %d write: 0x%x\n",
                     (int)reg, (uint32_t)val);
         } else {
-- 
2.18.1

WARNING: multiple messages have this Message-ID (diff)
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Longpeng <longpeng2@huawei.com>,
	Gonglei <arei.gonglei@huawei.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Aurelien Jarno <aurelien@aurel32.net>
Subject: [Qemu-devel] [PULL 4/7] usb/xhci: avoid trigger assertion if guest write wrong epid
Date: Fri,  3 May 2019 08:59:51 +0200	[thread overview]
Message-ID: <20190503065954.17069-5-kraxel@redhat.com> (raw)
Message-ID: <20190503065951.Yk_l2vuIHl7apzQ8DvNAWeIe4LIEtAMoHz11fbxmnRA@z> (raw)
In-Reply-To: <20190503065954.17069-1-kraxel@redhat.com>

From: Longpeng <longpeng2@huawei.com>

we found the following core in our environment:
0  0x00007fc6b06c2237 in raise ()
1  0x00007fc6b06c3928 in abort ()
2  0x00007fc6b06bb056 in __assert_fail_base ()
3  0x00007fc6b06bb102 in __assert_fail ()
4  0x0000000000702e36 in xhci_kick_ep (...)
5  0x000000000047897a in memory_region_write_accessor (...)
6  0x000000000047767f in access_with_adjusted_size (...)
7  0x000000000047944d in memory_region_dispatch_write (...)
(mr=mr@entry=0x7fc6a0138df0, addr=addr@entry=156, data=1648892416,
size=size@entry=4, attrs=attrs@entry=...)
8  0x000000000042df17 in address_space_write_continue (...)
10 0x000000000043084d in address_space_rw (...)
11 0x000000000047451b in kvm_cpu_exec (cpu=cpu@entry=0x1ab11b0)
12 0x000000000045dcf5 in qemu_kvm_cpu_thread_fn (arg=0x1ab11b0)
13 0x0000000000870631 in qemu_thread_start (args=args@entry=0x1acfb50)
14 0x00000000008959a7 in thread_entry_for_hotfix (pthread_cb=<optimized out>)
15 0x00007fc6b0a60dd5 in start_thread ()
16 0x00007fc6b078a59d in clone ()

(gdb) f 5
5  0x000000000047897a in memory_region_write_accessor (...)
529	    mr->ops->write(mr->opaque, addr, tmp, size);
(gdb) p /x tmp
$9 = 0x62481a00 <-- last byte 0x00 is @epid

xhci_doorbell_write() already check the upper bound of @slotid an @epid,
it also need to check the lower bound.

Cc: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Longpeng <longpeng2@huawei.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 1556605301-44112-1-git-send-email-longpeng2@huawei.com

[ kraxel: fixed typo in subject line ]

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/hcd-xhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index ec28bee31963..d8472b4fea7f 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -3137,7 +3137,7 @@ static void xhci_doorbell_write(void *ptr, hwaddr reg,
         streamid = (val >> 16) & 0xffff;
         if (reg > xhci->numslots) {
             DPRINTF("xhci: bad doorbell %d\n", (int)reg);
-        } else if (epid > 31) {
+        } else if (epid == 0 || epid > 31) {
             DPRINTF("xhci: bad doorbell %d write: 0x%x\n",
                     (int)reg, (uint32_t)val);
         } else {
-- 
2.18.1



  parent reply	other threads:[~2019-05-03  7:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-03  6:59 [Qemu-devel] [PULL 0/7] Usb 20190503 v2 patches Gerd Hoffmann
2019-05-03  6:59 ` Gerd Hoffmann
2019-05-03  6:59 ` [Qemu-devel] [PULL 1/7] usb-mtp: fix string length for filename when writing metadata Gerd Hoffmann
2019-05-03  6:59   ` Gerd Hoffmann
2019-05-03  6:59 ` [Qemu-devel] [PULL 2/7] usb-mtp: fix alignment of access of ObjectInfo filename field Gerd Hoffmann
2019-05-03  6:59   ` Gerd Hoffmann
2019-05-03  6:59 ` [Qemu-devel] [PULL 3/7] usb-mtp: change default to success for usb_mtp_update_object Gerd Hoffmann
2019-05-03  6:59   ` Gerd Hoffmann
2019-05-03  6:59 ` Gerd Hoffmann [this message]
2019-05-03  6:59   ` [Qemu-devel] [PULL 4/7] usb/xhci: avoid trigger assertion if guest write wrong epid Gerd Hoffmann
2019-05-03  6:59 ` [Qemu-devel] [PULL 5/7] hw/usb/hcd-ohci: Do not use PCI functions with sysbus devices in ohci_die() Gerd Hoffmann
2019-05-03  6:59   ` Gerd Hoffmann
2019-05-03  6:59 ` [Qemu-devel] [PULL 6/7] hw/usb/hcd-ohci: Move PCI-related code into a separate file Gerd Hoffmann
2019-05-03  6:59   ` Gerd Hoffmann
2019-05-03  6:59 ` [Qemu-devel] [PULL 7/7] hw/usb: avoid format truncation warning when formatting port name Gerd Hoffmann
2019-05-03  6:59   ` Gerd Hoffmann
2021-01-18 11:31   ` Philippe Mathieu-Daudé
2021-01-18 11:35     ` Daniel P. Berrangé
2021-01-18 11:40       ` Philippe Mathieu-Daudé
2019-05-03 13:56 ` [Qemu-devel] [PULL 0/7] Usb 20190503 v2 patches Peter Maydell
2019-05-03 13:56   ` Peter Maydell
  -- strict thread matches above, loose matches on Subject: below --
2019-05-02  7:35 [Qemu-devel] [PULL 0/7] Usb 20190502 patches Gerd Hoffmann
2019-05-02  7:35 ` [Qemu-devel] [PULL 4/7] usb/xhci: avoid trigger assertion if guest write wrong epid Gerd Hoffmann
2019-05-02  7:35   ` Gerd Hoffmann

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=20190503065954.17069-5-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=aurelien@aurel32.net \
    --cc=longpeng2@huawei.com \
    --cc=qemu-devel@nongnu.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).