Skip to content

Commit

Permalink
can: j1939: j1939_can_recv(): add priv refcounting
Browse files Browse the repository at this point in the history
j1939_can_recv() can be called in parallel with socket release. In this
case sk_release and sk_destruct can be done earlier than
j1939_can_recv() is processed.

Reported-by: syzbot+ca172a0ac477ac90f045@syzkaller.appspotmail.com
Reported-by: syzbot+07ca5bce8530070a5650@syzkaller.appspotmail.com
Reported-by: syzbot+a47537d3964ef6c874e1@syzkaller.appspotmail.com
Fixes: 9d71dd0 ("can: add support of SAE J1939 protocol")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
  • Loading branch information
Oleksij Rempel authored and Marc Kleine-Budde committed Nov 13, 2019
1 parent 8d7a5f0 commit ddeeb7d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/can/j1939/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static void j1939_can_recv(struct sk_buff *iskb, void *data)
if (!skb)
return;

j1939_priv_get(priv);
can_skb_set_owner(skb, iskb->sk);

/* get a pointer to the header of the skb
Expand Down Expand Up @@ -104,6 +105,7 @@ static void j1939_can_recv(struct sk_buff *iskb, void *data)
j1939_simple_recv(priv, skb);
j1939_sk_recv(priv, skb);
done:
j1939_priv_put(priv);
kfree_skb(skb);
}

Expand Down

0 comments on commit ddeeb7d

Please sign in to comment.