Skip to content

Commit 7aaed57

Browse files
edumazetdavem330
authored andcommitted
phonet: properly unshare skbs in phonet_rcv()
Ivaylo Dimitrov reported a regression caused by commit 7866a62 ("dev: add per net_device packet type chains"). skb->dev becomes NULL and we crash in __netif_receive_skb_core(). Before above commit, different kind of bugs or corruptions could happen without major crash. But the root cause is that phonet_rcv() can queue skb without checking if skb is shared or not. Many thanks to Ivaylo Dimitrov for his help, diagnosis and tests. Reported-by: Ivaylo Dimitrov <[email protected]> Tested-by: Ivaylo Dimitrov <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Cc: Remi Denis-Courmont <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d461873 commit 7aaed57

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/phonet/af_phonet.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,10 @@ static int phonet_rcv(struct sk_buff *skb, struct net_device *dev,
377377
struct sockaddr_pn sa;
378378
u16 len;
379379

380+
skb = skb_share_check(skb, GFP_ATOMIC);
381+
if (!skb)
382+
return NET_RX_DROP;
383+
380384
/* check we have at least a full Phonet header */
381385
if (!pskb_pull(skb, sizeof(struct phonethdr)))
382386
goto out;

0 commit comments

Comments
 (0)