提交 d7f05365 编写于 作者: M Michael S. Tsirkin 提交者: Jason Wang

cadence_gem: fix buffer overflow

gem_transmit copies a packet from guest into an tx_packet[2048]
array on stack, with size limited by descriptor length set by guest.  If
guest is malicious and specifies a descriptor length that is too large,
and should packet size exceed array size, this results in a buffer
overflow.
Reported-by: N刘令 <liuling-it@360.cn>
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: NJason Wang <jasowang@redhat.com>
上级 244381ec
...@@ -867,6 +867,14 @@ static void gem_transmit(CadenceGEMState *s) ...@@ -867,6 +867,14 @@ static void gem_transmit(CadenceGEMState *s)
break; break;
} }
if (tx_desc_get_length(desc) > sizeof(tx_packet) - (p - tx_packet)) {
DB_PRINT("TX descriptor @ 0x%x too large: size 0x%x space 0x%x\n",
(unsigned)packet_desc_addr,
(unsigned)tx_desc_get_length(desc),
sizeof(tx_packet) - (p - tx_packet));
break;
}
/* Gather this fragment of the packet from "dma memory" to our contig. /* Gather this fragment of the packet from "dma memory" to our contig.
* buffer. * buffer.
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册