Skip to content

Commit 3ff2567

Browse files
ZhangShurongtakaswie
authored andcommitted
firewire: net: fix use after free in fwnet_finish_incoming_packet()
The netif_rx() function frees the skb so we can't dereference it to save the skb->len. Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com> Link: https://lore.kernel.org/r/tencent_3B3D24B66ED66A6BB73CC0E63C6A14E45109@qq.com Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
1 parent 06f4543 commit 3ff2567

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/firewire/net.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
479479
struct sk_buff *skb, u16 source_node_id,
480480
bool is_broadcast, u16 ether_type)
481481
{
482-
int status;
482+
int status, len;
483483

484484
switch (ether_type) {
485485
case ETH_P_ARP:
@@ -533,13 +533,15 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
533533
}
534534
skb->protocol = protocol;
535535
}
536+
537+
len = skb->len;
536538
status = netif_rx(skb);
537539
if (status == NET_RX_DROP) {
538540
net->stats.rx_errors++;
539541
net->stats.rx_dropped++;
540542
} else {
541543
net->stats.rx_packets++;
542-
net->stats.rx_bytes += skb->len;
544+
net->stats.rx_bytes += len;
543545
}
544546

545547
return 0;

0 commit comments

Comments
 (0)