Linux CAN drivers development
 help / color / mirror / Atom feed
* [PATCH v2] can: fix skb reference counting in j1939_session_new()
@ 2024-11-05  9:48 Dmitry Antipov
  2024-11-05 16:37 ` Jiri Pirko
  2024-11-29 12:55 ` Oleksij Rempel
  0 siblings, 2 replies; 11+ messages in thread
From: Dmitry Antipov @ 2024-11-05  9:48 UTC (permalink / raw)
  To: Robin van der Gracht, Oleksij Rempel, Oliver Hartkopp,
	Marc Kleine-Budde
  Cc: linux-can, netdev, lvc-project, Dmitry Antipov,
	syzbot+d4e8dc385d9258220c31

Since 'j1939_session_skb_queue()' do an extra 'skb_get()' for each
new skb, I assume that the same should be done for an initial one
in 'j1939_session_new()' just to avoid refcount underflow.

Reported-by: syzbot+d4e8dc385d9258220c31@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d4e8dc385d9258220c31
Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
v2: resend after hitting skb refcount underflow once again when looking
around https://syzkaller.appspot.com/bug?extid=0e6ddb1ef80986bdfe64
---
 net/can/j1939/transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
index 319f47df3330..95f7a7e65a73 100644
--- a/net/can/j1939/transport.c
+++ b/net/can/j1939/transport.c
@@ -1505,7 +1505,7 @@ static struct j1939_session *j1939_session_new(struct j1939_priv *priv,
 	session->state = J1939_SESSION_NEW;
 
 	skb_queue_head_init(&session->skb_queue);
-	skb_queue_tail(&session->skb_queue, skb);
+	skb_queue_tail(&session->skb_queue, skb_get(skb));
 
 	skcb = j1939_skb_to_cb(skb);
 	memcpy(&session->skcb, skcb, sizeof(session->skcb));
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-11-29 13:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-05  9:48 [PATCH v2] can: fix skb reference counting in j1939_session_new() Dmitry Antipov
2024-11-05 16:37 ` Jiri Pirko
2024-11-06  9:43   ` Oleksij Rempel
2024-11-06 11:05     ` Dmitry Antipov
2024-11-29 13:25     ` Oleksij Rempel
2024-11-06 11:03   ` Dmitry Antipov
2024-11-06 14:42     ` Jiri Pirko
2024-11-29 12:55 ` Oleksij Rempel
2024-11-29 12:59   ` Marc Kleine-Budde
2024-11-29 13:05     ` Marc Kleine-Budde
2024-11-29 13:22       ` Oleksij Rempel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox