From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3AF7226553; Thu, 12 Dec 2024 16:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734020675; cv=none; b=O+FXkWW2OzBE2oM4smr3IMmuXqBrc/IxEllUt+xUMACNLSGHICocJZuftgLBGAyhtfhRTDjBqfukKzowYbDIE64RuLfLRUs0q2xDHrtSUgHoDenzq++6cdku8P2p7QkEp1tB1p31GXLWdv62fkB0DkuivqLjcLqJOeWiPJOmFkY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734020675; c=relaxed/simple; bh=qP1qwzXW6ckn0ApKGJb9VgX94ybwVi3v9nPoXzvsEF4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J2x6MH0z07k95tsWL8WbNvxOo5KU+jN07/+hzpzPRYpyw0mkiADCd6R2Jei7tPVkDPqcuJTyBnVxrI/34jPCQKWnZBzzLLBp0RZcPbpwrKZ7qrN6+o/EIF5uIh/Wej01vDDxslA7OPRWXUI5+mmMhmTZF2cTjg+wpzYDLAYTfIE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=d/d31QWO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="d/d31QWO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2B4EC4CECE; Thu, 12 Dec 2024 16:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1734020675; bh=qP1qwzXW6ckn0ApKGJb9VgX94ybwVi3v9nPoXzvsEF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d/d31QWOaBLJY16rTfX9WbFdn7CF8jaTGXBqOlBm6KeTqlEyznfJypKfPsdcGs3Mx ZH2YNl3i0NAwAYvwlbMTuLFwjTApaLc1U9OBXBaHXPtccbjRm7bxRRpiAoA6OaAUa8 8pkWNhgpAZAlc3u+VFlwSkgNmETA4OUuF/5If8II= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+d4e8dc385d9258220c31@syzkaller.appspotmail.com, Dmitry Antipov , Oleksij Rempel , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 6.1 531/772] can: j1939: j1939_session_new(): fix skb reference counting Date: Thu, 12 Dec 2024 15:57:56 +0100 Message-ID: <20241212144411.915141310@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241212144349.797589255@linuxfoundation.org> References: <20241212144349.797589255@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dmitry Antipov [ Upstream commit a8c695005bfe6569acd73d777ca298ddddd66105 ] Since j1939_session_skb_queue() does an extra skb_get() for each new skb, do the same for the initial one in j1939_session_new() 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 Tested-by: Oleksij Rempel Acked-by: Oleksij Rempel Link: https://patch.msgid.link/20241105094823.2403806-1-dmantipov@yandex.ru [mkl: clean up commit message] Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- 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 5d2097e5ca3a8..a58f6f5dfcf8e 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.43.0