Skip to contentSkip to conversation

net: imx: limit buffer descriptor count

PATCH Applied P J P 3 participants 8 messages Sep 22, 2016 – Feb 2, 2017 Arm i.MX and Layerscape

lore
Share & tools
lore

P J P

author
#0 lore raw

PATCH v2 1/1 net: imx: limit buffer descriptor count

From: Prasad J Pandit <[email protected]>

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.

---
 hw/net/imx_fec.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Update per
-> https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg05284.html

hw/net/imx_fec.c +4 -2
index e60e338..547fa99 100644
@@ -94,6 +94,8 @@ static const VMStateDescription vmstate_imx_fec = {
 #define PHY_INT_PARFAULT            (1 << 2)
 #define PHY_INT_AUTONEG_PAGE        (1 << 1)
 
+#define IMX_MAX_DESC                1024
+
 static void imx_fec_update(IMXFECState *s);
 
 /*
@@ -264,12 +266,12 @@ static void imx_fec_update(IMXFECState *s)
 
 static void imx_fec_do_tx(IMXFECState *s)
 {
-    int frame_size = 0;
+    int frame_size = 0, descnt = 0;
     uint8_t frame[FEC_MAX_FRAME_SIZE];
     uint8_t *ptr = frame;
     uint32_t addr = s->tx_descriptor;
 
-    while (1) {
+    while (descnt++ < IMX_MAX_DESC) {
         IMXFECBufDesc bd;
         int len;
 
Signature · 1 line
2.5.5
Reviewed-by on v2 1/1
#1 lore raw
Quoted 36 lines · P J P

From: Prasad J Pandit <[email protected]>

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.

---
 hw/net/imx_fec.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Update per
-> https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg05284.html

hw/net/imx_fec.c +2 -1
index e60e338..547fa99 100644
@@ -94,6 +94,8 @@ static const VMStateDescription vmstate_imx_fec = {
 #define PHY_INT_PARFAULT            (1 << 2)
 #define PHY_INT_AUTONEG_PAGE        (1 << 1)
 
+#define IMX_MAX_DESC                1024
+
 static void imx_fec_update(IMXFECState *s);
 
 /*
@@ -264,12 +266,12 @@ static void imx_fec_update(IMXFECState *s)
 
 static void imx_fec_do_tx(IMXFECState *s)
 {
-    int frame_size = 0;

hw/net/imx_fec.c static void imx_fec_update(IMXFECState *s) · line 277

Quoted 10 lines
hw/net/imx_fec.c +2 -1
+    int frame_size = 0, descnt = 0;
     uint8_t frame[FEC_MAX_FRAME_SIZE];
     uint8_t *ptr = frame;
     uint32_t addr = s->tx_descriptor;
 
-    while (1) {
+    while (descnt++ < IMX_MAX_DESC) {
         IMXFECBufDesc bd;
         int len;
 
Applied
#2 lore raw
Quoted 42 lines · Paolo Bonzini
Quoted 40 lines · P J P

From: Prasad J Pandit <[email protected]>

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.

---
  hw/net/imx_fec.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)

Update per
-> https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg05284.html

hw/net/imx_fec.c +3 -1
index e60e338..547fa99 100644
@@ -94,6 +94,8 @@ static const VMStateDescription vmstate_imx_fec = {
  #define PHY_INT_PARFAULT            (1 << 2)
  #define PHY_INT_AUTONEG_PAGE        (1 << 1)
 
+#define IMX_MAX_DESC                1024
+
  static void imx_fec_update(IMXFECState *s);
 
  /*
@@ -264,12 +266,12 @@ static void imx_fec_update(IMXFECState *s)
 
  static void imx_fec_do_tx(IMXFECState *s)
  {
-    int frame_size = 0;
+    int frame_size = 0, descnt = 0;
      uint8_t frame[FEC_MAX_FRAME_SIZE];
      uint8_t *ptr = frame;
      uint32_t addr = s->tx_descriptor;
 
Quoted 7 lines

hw/net/imx_fec.c static void imx_fec_update(IMXFECState *s) · line 277

Quoted 6 lines
hw/net/imx_fec.c +1 -1
-    while (1) {
+    while (descnt++ < IMX_MAX_DESC) {
          IMXFECBufDesc bd;
          int len;
 

Applied, thanks.

#3 lore raw
Quoted 49 lines · Jason Wang
Quoted 37 lines · Paolo Bonzini
Quoted 35 lines · P J P

From: Prasad J Pandit <[email protected]>

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.

---
  hw/net/imx_fec.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)

Update per
->
https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg05284.html

hw/net/imx_fec.c +2 -1
index e60e338..547fa99 100644
@@ -94,6 +94,8 @@ static const VMStateDescription vmstate_imx_fec = {
  #define PHY_INT_PARFAULT            (1 << 2)
  #define PHY_INT_AUTONEG_PAGE        (1 << 1)
  +#define IMX_MAX_DESC                1024
+
  static void imx_fec_update(IMXFECState *s);
    /*
@@ -264,12 +266,12 @@ static void imx_fec_update(IMXFECState *s)
    static void imx_fec_do_tx(IMXFECState *s)
  {
-    int frame_size = 0;
+    int frame_size = 0, descnt = 0;
      uint8_t frame[FEC_MAX_FRAME_SIZE];
Quoted 8 lines

hw/net/imx_fec.c static void imx_fec_update(IMXFECState *s) · line 277

Quoted 7 lines
hw/net/imx_fec.c +1 -0
      uint8_t *ptr = frame;
      uint32_t addr = s->tx_descriptor;
  -    while (1) {
+    while (descnt++ < IMX_MAX_DESC) {
          IMXFECBufDesc bd;
          int len;
 
Quoted 2 lines

Applied, thanks.

Actually the patch does not apply cleanly. Please fix and repost.

Thanks

author
#4 lore raw

Hello Jason,

+-- On Fri, 23 Sep 2016, Jason Wang wrote --+
| Actually the patch does not apply cleanly. Please fix and repost.

The 'net: imx:...' patch is for v2.6 series. I missed to indicate that in
Patch v2. Could you please try it with v2.6?

Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F

author
#5 lore raw

Hello Jason,

+-- On Mon, 26 Sep 2016, P J P wrote --+
| +-- On Fri, 23 Sep 2016, Jason Wang wrote --+
| | Actually the patch does not apply cleanly. Please fix and repost.
| 
|   The 'net: imx:...' patch is for v2.6 series. I missed to indicate that in 
| Patch v2. Could you please try it with v2.6?

This patch still isn't merged upstream it seems. Could you please check?

Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F

author
#6 lore raw
+-- On Thu, 26 Jan 2017, P J P wrote --+
| +-- On Mon, 26 Sep 2016, P J P wrote --+
| | +-- On Fri, 23 Sep 2016, Jason Wang wrote --+
| | | Actually the patch does not apply cleanly. Please fix and repost.
| | 
| |   The 'net: imx:...' patch is for v2.6 series. I missed to indicate that 
| | in Patch v2. Could you please try it with v2.6?
| 
| This patch still isn't merged upstream it seems. Could you please check?

@Jason:..ping!?
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F