Skip to contentSkip to conversation

mac80211: fix mesh forwarding

PATCH In review Johannes Berg 3 participants 4 messages Dec 22, 2010 – Dec 30, 2010 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

PATCH 1/1 mac80211: fix mesh forwarding

From: Johannes Berg <[email protected]>

Under memory pressure, the mac80211 mesh code may helpfully print a message that it failed to clone a mesh frame and then will proceed to crash trying to use it anyway. Fix that.

---
 net/mac80211/rx.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/mac80211/rx.c +4 -1
@@ -1831,9 +1831,11 @@ ieee80211_rx_h_mesh_fwding(struct ieee80
 
 			fwd_skb = skb_copy(skb, GFP_ATOMIC);
 
-			if (!fwd_skb && net_ratelimit())
+			if (!fwd_skb && net_ratelimit()) {
 				printk(KERN_DEBUG "%s: failed to clone mesh frame\n",
 						   sdata->name);
+				goto out;
+			}
 
 			fwd_hdr =  (struct ieee80211_hdr *) fwd_skb->data;
 			memcpy(fwd_hdr->addr2, sdata->vif.addr, ETH_ALEN);
@@ -1871,6 +1873,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80
 		}
 	}
 
+ out:
 	if (is_multicast_ether_addr(hdr->addr1) ||
 	    sdata->dev->flags & IFF_PROMISC)
 		return RX_CONTINUE;
Acked-by on v1 1/1
#1 lore raw

Johannes,

Had I encountered this I would have changed the "failed to clone mesh frame" message to "I'm about to crash". Your fix is better.

Thanks!

Quoted 9 lines · Johannes Berg

From: Johannes Berg <[email protected]>

Under memory pressure, the mac80211 mesh code
may helpfully print a message that it failed
to clone a mesh frame and then will proceed
to crash trying to use it anyway. Fix that.

Quoted 34 lines

---
 net/mac80211/rx.c |    5 ++++-

 1 file changed, 4 insertions(+), 1 deletion(-)
net/mac80211/rx.c  2010-12-22 10:06:08.000000000 +0100 renamed from net/mac80211/rx.c     2010-12-22 10:05:58.000000000 +0100 +4 -1
@@ -1831,9 +1831,11 @@ ieee80211_rx_h_mesh_fwding(struct ieee80
 
                        fwd_skb = skb_copy(skb, GFP_ATOMIC);
 
-                       if (!fwd_skb && net_ratelimit())
+                       if (!fwd_skb && net_ratelimit()) {
                                printk(KERN_DEBUG "%s: failed to clone mesh frame\n",
                                                   sdata->name);
+                               goto out;
+                       }
 
                        fwd_hdr =  (struct ieee80211_hdr *) fwd_skb->data;
                        memcpy(fwd_hdr->addr2, sdata->vif.addr, ETH_ALEN);
@@ -1871,6 +1873,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80
                }
        }
 
+ out:

       if (is_multicast_ether_addr(hdr->addr1) ||
           sdata->dev->flags & IFF_PROMISC)
               return RX_CONTINUE;

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Signature · 3 lines
Javier Cardona
cozybit Inc.
http://www.cozybit.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

PATCH 1/1 mac80211: fix mesh forwarding when ratelimited too

Commit b51aff057c9d0ef6c529dc25fd9f775faf7b6c63 said:

Under memory pressure, the mac80211 mesh code
may helpfully print a message that it failed
to clone a mesh frame and then will proceed
to crash trying to use it anyway. Fix that.

Avoid the reference whenever the frame copy is unsuccessful regardless of the debug message being suppressed or printed.

---
I chose a seperate if vs nesting the ratelimit check to avoid shifting the printk further to the right.

net/mac80211/rx.c +2 -2
index b01e467..e98668f 100644
@@ -1788,11 +1788,11 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
 
 			fwd_skb = skb_copy(skb, GFP_ATOMIC);
 
-			if (!fwd_skb && net_ratelimit()) {
+			if (!fwd_skb && net_ratelimit())
 				printk(KERN_DEBUG "%s: failed to clone mesh frame\n",
 						   sdata->name);
+			if (!fwd_skb)
 				goto out;
-			}
 
 			fwd_hdr =  (struct ieee80211_hdr *) fwd_skb->data;
 			memcpy(fwd_hdr->addr2, sdata->vif.addr, ETH_ALEN);
author maintainer
#4 lore raw

Re: [PATCH] mac80211: fix mesh forwarding when ratelimited too

Quoted 21 lines · Milton Miller

Commit b51aff057c9d0ef6c529dc25fd9f775faf7b6c63 said:

Under memory pressure, the mac80211 mesh code
may helpfully print a message that it failed
to clone a mesh frame and then will proceed
to crash trying to use it anyway. Fix that.

Avoid the reference whenever the frame copy is unsuccessful regardless of the debug message being suppressed or printed.

---
I chose a seperate if vs nesting the ratelimit check to avoid shifting the printk further to the right.

net/mac80211/rx.c +0 -0
index b01e467..e98668f 100644

net/mac80211/rx.c ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) · line 1795

Quoted 10 lines
net/mac80211/rx.c +2 -2
@@ -1788,11 +1788,11 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
 
 			fwd_skb = skb_copy(skb, GFP_ATOMIC);
 
-			if (!fwd_skb && net_ratelimit()) {
+			if (!fwd_skb && net_ratelimit())
 				printk(KERN_DEBUG "%s: failed to clone mesh frame\n",
 						   sdata->name);
+			if (!fwd_skb)
 				goto out;
-			}

Oops, good catch! Thanks.

johannes