[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210617130623.12705-1-o.rempel@pengutronix.de>
Date: Thu, 17 Jun 2021 15:06:23 +0200
From: Oleksij Rempel <o.rempel@...gutronix.de>
To: mkl@...gutronix.de, "David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Oliver Hartkopp <socketcan@...tkopp.net>,
Robin van der Gracht <robin@...tonic.nl>
Cc: Oleksij Rempel <o.rempel@...gutronix.de>,
Thadeu Lima de Souza Cascardo <cascardo@...onical.com>,
syzbot+bdf710cfc41c186fdff3@...kaller.appspotmail.com,
kernel@...gutronix.de, linux-can@...r.kernel.org,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v1] can: j1939: j1939_sk_init(): set SOCK_RCU_FREE to call sk_destruct() after RCU is done
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@...onical.com>
Reported-by: syzbot+bdf710cfc41c186fdff3@...kaller.appspotmail.com
Fixes: 25fe97cb7620 ("can: j1939: move j1939_priv_put() into sk_destruct callback")
Signed-off-by: Oleksij Rempel <o.rempel@...gutronix.de>
---
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
Powered by blists - more mailing lists