mac802154: avoid extra skb references in RX queues
Subsystems (4)
PATCH 1/1 mac802154: avoid extra skb references in RX queues
From: Xuanqiang Luo <[email protected]>
__ieee802154_rx_handle_packet() passes each cloned skb to ieee802154_subif_frame() and does not release it after the call. The callee consumes the skb on every path: it either frees it, hands it to the networking stack, or stores it in a queued RX descriptor.
The beacon and MAC command paths nevertheless call skb_get() before storing the skb. The worker drops only that additional reference, leaving the original clone reference without an owner and leaking every queued skb.
kmemleak report:
unreferenced object 0xffff0000c1fcd480 (size 232):
comm "softirq", pid 0, jiffies 4295683396 hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 60 fd d4 00 00 ff ff 00 00 00 00 00 00 00 00 .`..............
backtrace (crc ee03f6a1):
kmemleak_alloc+0xcc/0xf8
kmem_cache_alloc_noprof+0x240/0x418
skb_clone+0x60/0xe0
ieee802154_rx+0x19c/0x280 [mac802154]
ieee802154_tasklet_handler+0xa8/0xb8 [mac802154]
tasklet_action_common+0x148/0x528
tasklet_action+0x38/0x50
handle_softirqs+0x10c/0x450
__do_softirq+0x1c/0x28Transfer the existing skb reference to the descriptor instead of taking another one.
--- net/mac802154/rx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/mac802154/rx.c +2 -2
@@ -287,7 +287,7 @@ ieee802154_subif_frame(struct ieee802154_sub_if_data *sdata,if (!mac_pkt) goto fail; - mac_pkt->skb =skb_get (skb); + mac_pkt->skb = skb; mac_pkt->sdata = sdata; mac_pkt->page = sdata->local->scan_page; mac_pkt->channel = sdata->local->scan_channel;
@@ -304,7 +304,7 @@ ieee802154_subif_frame(struct ieee802154_sub_if_data *sdata,if (!mac_pkt) goto fail; - mac_pkt->skb =skb_get (skb); + mac_pkt->skb = skb; mac_pkt->sdata = sdata;netdev_hold (sdata->dev, &mac_pkt->dev_tracker,GFP_ATOMIC );spin_lock (&sdata->local->rx_lock);
Signature · 1 line
2.43.0
Quoted 11 lines · Xuanqiang Luo
From: Xuanqiang Luo <[email protected]>
__ieee802154_rx_handle_packet()passes each cloned skb toieee802154_subif_frame()and does not release it after the call. The callee consumes the skb on every path: it either frees it, hands it to the networking stack, or stores it in a queued RX descriptor.The beacon and MAC command paths nevertheless call
skb_get()before storing the skb. The worker drops only that additional reference, leaving the original clone reference without an owner and leaking every queued skb.