Set SOCK_RCU_FREE to let RCU to call sk_destruct() on completion. Without this patch, we will run in to j1939_can_recv() after priv was freed by j1939_sk_release()->j1939_sk_sock_destruct() Reported-by: Thadeu Lima de Souza Cascardo <cascardo@xxxxxxxxxxxxx> Reported-by: syzbot+bdf710cfc41c186fdff3@xxxxxxxxxxxxxxxxxxxxxxxxx Fixes: 25fe97cb7620 ("can: j1939: move j1939_priv_put() into sk_destruct callback") Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx> --- net/can/j1939/socket.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c index 56aa66147d5a..c7c1b4d4c0fb 100644 --- a/net/can/j1939/socket.c +++ b/net/can/j1939/socket.c @@ -398,6 +398,9 @@ static int j1939_sk_init(struct sock *sk) atomic_set(&jsk->skb_pending, 0); spin_lock_init(&jsk->sk_session_queue_lock); INIT_LIST_HEAD(&jsk->sk_session_queue); + + sock_set_flag(sk, SOCK_RCU_FREE); + /* j1939_sk_sock_destruct() depends on SOCK_RCU_FREE flag */ sk->sk_destruct = j1939_sk_sock_destruct; sk->sk_protocol = CAN_J1939; -- 2.29.2