1 Star 0 Fork 123

zhouli57/src-qemu

forked from src-openEuler/qemu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
hw-usb-core-fix-buffer-overflow.patch 1.45 KB
一键复制 编辑 原始数据 按行查看 历史
hw-usb-core-fix-buffer-overflow
From 18ad0451f113ffc3a2ff59c059d189cca1e42842 Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Wed, 19 Aug 2020 17:04:04 +0800
Subject: [PATCH] hw/usb/core.c fix buffer overflow
Store calculated setup_len in a local variable, verify it,
and only write it to the struct (USBDevice->setup_len) in case it passed the
sanity checks.
This prevents other code (do_token_{in,out} function specifically)
from working with invalid USBDevice->setup_len values and overruning
the USBDevice->setup_buf[] buffer.
Store
Fixes: CVE-2020-14364
Signed-off-by: Gred Hoffman <kraxel@redhat.com>
---
hw/usb/core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/usb/core.c b/hw/usb/core.c
index 5abd128b..12342f13 100644
--- a/hw/usb/core.c
+++ b/hw/usb/core.c
@@ -144,6 +144,8 @@ static void do_token_setup(USBDevice *s, USBPacket *p)
"usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n",
s->setup_len, sizeof(s->data_buf));
p->status = USB_RET_STALL;
+ s->setup_len = 0;
+ s->setup_state = SETUP_STATE_ACK;
return;
}
@@ -277,6 +279,8 @@ static void do_parameter(USBDevice *s, USBPacket *p)
"usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n",
s->setup_len, sizeof(s->data_buf));
p->status = USB_RET_STALL;
+ s->setup_len = 0;
+ s->setup_state = SETUP_STATE_ACK;
return;
}
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhouli57/src-qemu.git
git@gitee.com:zhouli57/src-qemu.git
zhouli57
src-qemu
src-qemu
master

搜索帮助