Skip to contentSkip to conversation

bonding: COW before overwriting the destination MAC address

PATCH Applied Changli Gao 2 participants 3 messages Mar 3, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 bonding: COW before overwriting the destination MAC address

When there is a ptype handler holding a clone of this skb, whose destination MAC addresse is overwritten, the owner of this handler may get a corrupted packet.

---
 drivers/net/bonding/bond_main.c |    5 +++++
 1 file changed, 5 insertions(+)
drivers/net/bonding/bond_main.c +5 -0
index 912b416..211be52 100644
@@ -1513,6 +1513,11 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb)
 	    skb->pkt_type == PACKET_HOST) {
 		u16 *dest = (u16 *) eth_hdr(skb)->h_dest;
 
+		if (unlikely(skb_cow_head(skb,
+					  skb->data - skb_mac_header(skb)))) {
+			kfree_skb(skb);
+			return NULL;
+		}
 		memcpy(dest, bond_dev->dev_addr, ETH_ALEN);
 	}
 
#1 lore raw
Quoted 14 lines · Changli Gao

When there is a ptype handler holding a clone of this skb, whose destination MAC addresse is overwritten, the owner of this handler may get a corrupted packet.

---
 drivers/net/bonding/bond_main.c |    5 +++++
 1 file changed, 5 insertions(+)
drivers/net/bonding/bond_main.c +0 -0
index 912b416..211be52 100644
@@ -1513,6 +1513,11 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb)
 	    skb->pkt_type == PACKET_HOST) {

drivers/net/bonding/bond_main.c static struct sk_buff *bond_handle_frame(struct sk_buff *skb) · line 1523

Quoted 10 lines
drivers/net/bonding/bond_main.c +5 -0
 		u16 *dest = (u16 *) eth_hdr(skb)->h_dest;
 
+		if (unlikely(skb_cow_head(skb,
+					  skb->data - skb_mac_header(skb)))) {
+			kfree_skb(skb);
+			return NULL;
+		}
 		memcpy(dest, bond_dev->dev_addr, ETH_ALEN);
 	}
 

This seems buggy.

dest points to old skb head content.

#2 lore raw
Quoted 28 lines · Eric Dumazet
Quoted 14 lines · Changli Gao

When there is a ptype handler holding a clone of this skb, whose destination MAC addresse is overwritten, the owner of this handler may get a corrupted packet.

---
 drivers/net/bonding/bond_main.c |    5 +++++

 1 file changed, 5 insertions(+)
drivers/net/bonding/bond_main.c +0 -0
index 912b416..211be52 100644
@@ -1513,6 +1513,11 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb)
           skb->pkt_type == PACKET_HOST) {

drivers/net/bonding/bond_main.c static struct sk_buff *bond_handle_frame(struct sk_buff *skb) · line 1523

Quoted 10 lines
drivers/net/bonding/bond_main.c +5 -0
               u16 *dest = (u16 *) eth_hdr(skb)->h_dest;
 
+             if (unlikely(skb_cow_head(skb,
+                                       skb->data - skb_mac_header(skb)))) {
+                     kfree_skb(skb);
+                     return NULL;
+             }
               memcpy(dest, bond_dev->dev_addr, ETH_ALEN);
       }
 

This seems buggy.

Quoted 3 lines

dest points to old skb head content.

Oh, thanks. I'll respin it.

Signature · 2 lines
Regards,
Changli Gao([email protected])