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 7090D176AA1; Thu, 12 Dec 2024 17:04:32 +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=1734023072; cv=none; b=YipUYV/gG5Kt/mDdU/bjeU2WeOQbJsMK2IRltifJ3Q8iEffM3qZeicTrsEPSHskur5cEagz+D2TSyqRlmolJltg/d+8Xy2ks11w4ClAiamGHX9esEuaQVRfuNX6qDNX7u0Ft8fdlxa4onn/yAc2EcBlSpvRC5eEoIIMqr7V3iw4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734023072; c=relaxed/simple; bh=gTh58Kze4jEof2mmLAfgRxQaJ+2jWMaGAlGjMfti7t0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qd/XbvlrB6abui6RPqshwTRfNpoDGZLdhOqcurN2XHZMNE4yq0ktDsxfKfup/mYwoadCEUg56ma0UfM7m3Xypex/6NPgH/7RvnIOeG8vLkqgnNqJbps3Li3re6vobztOuXg5/RYLv59po9Va534jkuQJVhxOAUm190sQNCfHW+s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=stMipUg8; 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="stMipUg8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA98EC4CECE; Thu, 12 Dec 2024 17:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1734023072; bh=gTh58Kze4jEof2mmLAfgRxQaJ+2jWMaGAlGjMfti7t0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=stMipUg8MKrTNhjDkv8qys0w9lP9a8ydpnOhojmJd5PMZ8g/TYn2h6ZGVGY9FO+YQ XluGlMaj3DFTNP749cLfb61+wlbKR/K7DOa/3gniFPvScOW4SBnBCjOpx5wRSlDfk2 DqIVKAOEZ77XtT1vhJqNbkQDLR53+jMVkNQv7IPA= 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 5.15 413/565] can: j1939: j1939_session_new(): fix skb reference counting Date: Thu, 12 Dec 2024 16:00:08 +0100 Message-ID: <20241212144327.982974356@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241212144311.432886635@linuxfoundation.org> References: <20241212144311.432886635@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 5.15-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