* [PATCH v1] can: j1939: j1939_sk_init(): set SOCK_RCU_FREE to call sk_destruct() after RCU is done
@ 2021-06-17 13:06 Oleksij Rempel
2021-06-18 7:15 ` Marc Kleine-Budde
0 siblings, 1 reply; 2+ messages in thread
From: Oleksij Rempel @ 2021-06-17 13:06 UTC (permalink / raw)
To: mkl, David S. Miller, Jakub Kicinski, Oliver Hartkopp,
Robin van der Gracht
Cc: Oleksij Rempel, Thadeu Lima de Souza Cascardo,
syzbot+bdf710cfc41c186fdff3, kernel, linux-can, netdev,
linux-kernel
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@canonical.com>
Reported-by: syzbot+bdf710cfc41c186fdff3@syzkaller.appspotmail.com
Fixes: 25fe97cb7620 ("can: j1939: move j1939_priv_put() into sk_destruct callback")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1] can: j1939: j1939_sk_init(): set SOCK_RCU_FREE to call sk_destruct() after RCU is done
2021-06-17 13:06 [PATCH v1] can: j1939: j1939_sk_init(): set SOCK_RCU_FREE to call sk_destruct() after RCU is done Oleksij Rempel
@ 2021-06-18 7:15 ` Marc Kleine-Budde
0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2021-06-18 7:15 UTC (permalink / raw)
To: Oleksij Rempel
Cc: David S. Miller, Jakub Kicinski, Oliver Hartkopp,
Robin van der Gracht, Thadeu Lima de Souza Cascardo,
syzbot+bdf710cfc41c186fdff3, kernel, linux-can, netdev,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 856 bytes --]
On 17.06.2021 15:06:23, Oleksij Rempel wrote:
> 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@canonical.com>
> Reported-by: syzbot+bdf710cfc41c186fdff3@syzkaller.appspotmail.com
> Fixes: 25fe97cb7620 ("can: j1939: move j1939_priv_put() into sk_destruct callback")
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Applied to linux-can/testing.
Thanks,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-18 7:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 13:06 [PATCH v1] can: j1939: j1939_sk_init(): set SOCK_RCU_FREE to call sk_destruct() after RCU is done Oleksij Rempel
2021-06-18 7:15 ` Marc Kleine-Budde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).