Re: [syzbot] [can?] memory leak in j1939_netdev_start

Edward Adam Davis
2024-01-24T01:29:45Z

please test memory leak in j1939_netdev_start

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c
index 14c431663233..1d1f1348eeca 100644
--- a/net/can/j1939/socket.c
+++ b/net/can/j1939/socket.c
@@ -141,6 +141,7 @@ static void j1939_sk_queue_drop_all(struct j1939_priv *priv,
sk_session_queue_entry) {
list_del_init(&session->sk_session_queue_entry);
session->err = err;
+ printk("s: %p, %s\n", session, __func__);
j1939_session_put(session);
}
spin_unlock_bh(&jsk->sk_session_queue_lock);
diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
index fe3df23a2595..4e5f6037db46 100644
--- a/net/can/j1939/transport.c
+++ b/net/can/j1939/transport.c
@@ -283,6 +283,7 @@ static void j1939_session_destroy(struct j1939_session *session)
}
__j1939_session_drop(session);
j1939_priv_put(session->priv);
+ printk("free session: %p, %s\n", session, __func__);
kfree(session);
}

@@ -1552,6 +1553,8 @@ j1939_session *j1939_session_fresh_new(struct j1939_priv *priv,
/* alloc data area */
skb_put(skb, size);
/* skb is recounted in j1939_session_new() */
+ printk("s: %p, skb: %p, size: %d, csk: %d, %s\n",
+ session, skb, size, sizeof(struct can_skb_priv), __func__);
return session;
}

@@ -1758,6 +1761,7 @@ static void j1939_xtp_rx_rts(struct j1939_priv *priv, struct sk_buff *skb,
j1939_tp_set_rxtimeout(session, 1250);
}

+ printk("s: %p, %s\n", session, __func__);
j1939_session_put(session);
}

@@ -2005,6 +2009,8 @@ struct j1939_session *j1939_tp_send(struct j1939_priv *priv,
if (!session)
return ERR_PTR(-ENOMEM);

+ printk("s: %p, size: %d, %s\n", session, size, __func__);
+
/* skb is recounted in j1939_session_new() */
sock_hold(skb->sk);
session->sk = skb->sk;