Skip to content

Commit 9181a6b

Browse files
committed
Merge branch 'mac802154'
Phoebe Buckheister says: ==================== Recent llsec code introduced a memory leak on decryption failures during rx. This fixes said leak, and optimizes the receive loops for monitor and wpan devices to only deliver skbs to devices that are actually up. Also changes a dev_kfree_skb to kfree_skb when an invalid packet is dropped before being pushed into the stack. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents d5c4858 + 2d3b5b0 commit 9181a6b

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

net/mac802154/monitor.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ void mac802154_monitors_rx(struct mac802154_priv *priv, struct sk_buff *skb)
7070

7171
rcu_read_lock();
7272
list_for_each_entry_rcu(sdata, &priv->slaves, list) {
73-
if (sdata->type != IEEE802154_DEV_MONITOR)
73+
if (sdata->type != IEEE802154_DEV_MONITOR ||
74+
!netif_running(sdata->dev))
7475
continue;
7576

7677
skb2 = skb_clone(skb, GFP_ATOMIC);

net/mac802154/rx.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,23 @@ mac802154_subif_rx(struct ieee802154_dev *hw, struct sk_buff *skb, u8 lqi)
6464

6565
if (skb->len < 2) {
6666
pr_debug("got invalid frame\n");
67-
goto out;
67+
goto fail;
6868
}
6969
crc = crc_ccitt(0, skb->data, skb->len);
7070
if (crc) {
7171
pr_debug("CRC mismatch\n");
72-
goto out;
72+
goto fail;
7373
}
7474
skb_trim(skb, skb->len - 2); /* CRC */
7575
}
7676

7777
mac802154_monitors_rx(priv, skb);
7878
mac802154_wpans_rx(priv, skb);
79-
out:
80-
dev_kfree_skb(skb);
79+
80+
return;
81+
82+
fail:
83+
kfree_skb(skb);
8184
}
8285

8386
static void mac802154_rx_worker(struct work_struct *work)

net/mac802154/wpan.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ mac802154_subif_frame(struct mac802154_sub_if_data *sdata, struct sk_buff *skb,
472472
rc = mac802154_llsec_decrypt(&sdata->sec, skb);
473473
if (rc) {
474474
pr_debug("decryption failed: %i\n", rc);
475+
kfree_skb(skb);
475476
return NET_RX_DROP;
476477
}
477478

@@ -566,7 +567,6 @@ static int mac802154_parse_frame_start(struct sk_buff *skb,
566567
void mac802154_wpans_rx(struct mac802154_priv *priv, struct sk_buff *skb)
567568
{
568569
int ret;
569-
struct sk_buff *sskb;
570570
struct mac802154_sub_if_data *sdata;
571571
struct ieee802154_hdr hdr;
572572

@@ -578,12 +578,16 @@ void mac802154_wpans_rx(struct mac802154_priv *priv, struct sk_buff *skb)
578578

579579
rcu_read_lock();
580580
list_for_each_entry_rcu(sdata, &priv->slaves, list) {
581-
if (sdata->type != IEEE802154_DEV_WPAN)
581+
if (sdata->type != IEEE802154_DEV_WPAN ||
582+
!netif_running(sdata->dev))
582583
continue;
583584

584-
sskb = skb_clone(skb, GFP_ATOMIC);
585-
if (sskb)
586-
mac802154_subif_frame(sdata, sskb, &hdr);
585+
mac802154_subif_frame(sdata, skb, &hdr);
586+
skb = NULL;
587+
break;
587588
}
588589
rcu_read_unlock();
590+
591+
if (skb)
592+
kfree_skb(skb);
589593
}

0 commit comments

Comments
 (0)