]> git.ipfire.org Git - thirdparty/qemu.git/commit
hw/usb/canokey: Fix buffer overflow for OUT packet
authorHongren Zheng <i@zenithal.me>
Mon, 13 Jan 2025 09:38:56 +0000 (17:38 +0800)
committerMichael Tokarev <mjt@tls.msk.ru>
Wed, 29 Jan 2025 19:29:03 +0000 (22:29 +0300)
commit3b0234c9503628f59384d08f7591474b98a7780d
tree8a6db42ba0767ad3a78f578c486c40c3a296a473
parent09537fbd34736f39b49bce805e04dc6f12d7ce89
hw/usb/canokey: Fix buffer overflow for OUT packet

When USBPacket in OUT direction has larger payload
than the ep_out_buffer (of size 512), a buffer overflow
would occur.

It could be fixed by limiting the size of usb_packet_copy
to be at most buffer size. Further optimization gets rid
of the ep_out_buffer and directly uses ep_out as the target
buffer.

This is reported by a security researcher who artificially
constructed an OUT packet of size 2047. The report has gone
through the QEMU security process, and as this device is for
testing purpose and no deployment of it in virtualization
environment is observed, it is triaged not to be a security bug.

Cc: qemu-stable@nongnu.org
Fixes: d7d34918551dc48 ("hw/usb: Add CanoKey Implementation")
Reported-by: Juan Jose Lopez Jaimez <thatjiaozi@gmail.com>
Signed-off-by: Hongren Zheng <i@zenithal.me>
Message-id: Z4TfMOrZz6IQYl_h@Sun
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 664280abddcb3cacc9c6204706bb739fcc1316f7)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
hw/usb/canokey.c
hw/usb/canokey.h