mirror of
https://github.com/qemu/qemu.git
synced 2025-08-10 12:46:22 +00:00
net: imx: limit buffer descriptor count
i.MX Fast Ethernet Controller uses buffer descriptors to manage data flow to/fro receive & transmit queues. While transmitting packets, it could continue to read buffer descriptors if a buffer descriptor has length of zero and has crafted values in bd.flags. Set an upper limit to number of buffer descriptors. Reported-by: Li Qiang <liqiang6-s@360.cn> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
parent
a935cc3132
commit
81f17e0d43
@ -55,6 +55,8 @@
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define IMX_MAX_DESC 1024
|
||||||
|
|
||||||
static const char *imx_default_reg_name(IMXFECState *s, uint32_t index)
|
static const char *imx_default_reg_name(IMXFECState *s, uint32_t index)
|
||||||
{
|
{
|
||||||
static char tmp[20];
|
static char tmp[20];
|
||||||
@ -402,12 +404,12 @@ static void imx_eth_update(IMXFECState *s)
|
|||||||
|
|
||||||
static void imx_fec_do_tx(IMXFECState *s)
|
static void imx_fec_do_tx(IMXFECState *s)
|
||||||
{
|
{
|
||||||
int frame_size = 0;
|
int frame_size = 0, descnt = 0;
|
||||||
uint8_t frame[ENET_MAX_FRAME_SIZE];
|
uint8_t frame[ENET_MAX_FRAME_SIZE];
|
||||||
uint8_t *ptr = frame;
|
uint8_t *ptr = frame;
|
||||||
uint32_t addr = s->tx_descriptor;
|
uint32_t addr = s->tx_descriptor;
|
||||||
|
|
||||||
while (1) {
|
while (descnt++ < IMX_MAX_DESC) {
|
||||||
IMXFECBufDesc bd;
|
IMXFECBufDesc bd;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
@ -453,12 +455,12 @@ static void imx_fec_do_tx(IMXFECState *s)
|
|||||||
|
|
||||||
static void imx_enet_do_tx(IMXFECState *s)
|
static void imx_enet_do_tx(IMXFECState *s)
|
||||||
{
|
{
|
||||||
int frame_size = 0;
|
int frame_size = 0, descnt = 0;
|
||||||
uint8_t frame[ENET_MAX_FRAME_SIZE];
|
uint8_t frame[ENET_MAX_FRAME_SIZE];
|
||||||
uint8_t *ptr = frame;
|
uint8_t *ptr = frame;
|
||||||
uint32_t addr = s->tx_descriptor;
|
uint32_t addr = s->tx_descriptor;
|
||||||
|
|
||||||
while (1) {
|
while (descnt++ < IMX_MAX_DESC) {
|
||||||
IMXENETBufDesc bd;
|
IMXENETBufDesc bd;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user