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 3AB8032779A; Mon, 27 Oct 2025 19:13:54 +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=1761592434; cv=none; b=haxJimcT07vKyReU4cxuPs+bmELlqSkOr08w4CrcmdpJu07Gn3pE69UiLRjkjLDfgVEn24Jl/iLRYg2wnS0VAMh65nzyQO8CIYdThyxiBcnhEUawZ1MrdsQ59L9Luj44YJY9Md/3cQL23OgtgKDwiwKj9e3zLuuYp+CTdusCK7M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761592434; c=relaxed/simple; bh=F/oLs21nW6I6BEzu4jh97xCQUtkngYYE4RZbgDjKWwk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f6j52TwpUxImA+23QCoEuzkpgI+ZoWd0aVCpxPzSNwIitXO5fUUYmrCIMAO6en0sVwNMXgE16POFHhBvKSH4K+ORbELzekxqgVe4zG/v3YTp59EIh4YdFZJeCjvpc8y1c2foio4PaaMx5o0c9dbcFUGrJkdlusdf96+w74F2pQc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qWlb6HKo; 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="qWlb6HKo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C20D3C4CEFD; Mon, 27 Oct 2025 19:13:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761592434; bh=F/oLs21nW6I6BEzu4jh97xCQUtkngYYE4RZbgDjKWwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qWlb6HKo7Iep0+LfIgkvJVS8E1CVeHxRTEjMKa8622LNHO5AqrRgfORFEO9Ay5sVb LCOYuI8OhvsWiuHr3cmvRQUYVq6abcsjYOHWKwnKl/kRF5hWfOy7yIPRhXqn1xpp6M ROrJKQX0ff6lS8gRd9j6Xat+hhC21ZB2RkZZQjrE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexey Simakov , Marcelo Ricardo Leitner , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 086/157] sctp: avoid NULL dereference when chunk data buffer is missing Date: Mon, 27 Oct 2025 19:35:47 +0100 Message-ID: <20251027183503.580527368@linuxfoundation.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251027183501.227243846@linuxfoundation.org> References: <20251027183501.227243846@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev 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: Alexey Simakov [ Upstream commit 441f0647f7673e0e64d4910ef61a5fb8f16bfb82 ] chunk->skb pointer is dereferenced in the if-block where it's supposed to be NULL only. chunk->skb can only be NULL if chunk->head_skb is not. Check for frag_list instead and do it just before replacing chunk->skb. We're sure that otherwise chunk->skb is non-NULL because of outer if() condition. Fixes: 90017accff61 ("sctp: Add GSO support") Signed-off-by: Alexey Simakov Acked-by: Marcelo Ricardo Leitner Link: https://patch.msgid.link/20251021130034.6333-1-bigalex934@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sctp/inqueue.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/net/sctp/inqueue.c b/net/sctp/inqueue.c index 5c16521818058..f5a7d5a387555 100644 --- a/net/sctp/inqueue.c +++ b/net/sctp/inqueue.c @@ -169,13 +169,14 @@ struct sctp_chunk *sctp_inq_pop(struct sctp_inq *queue) chunk->head_skb = chunk->skb; /* skbs with "cover letter" */ - if (chunk->head_skb && chunk->skb->data_len == chunk->skb->len) + if (chunk->head_skb && chunk->skb->data_len == chunk->skb->len) { + if (WARN_ON(!skb_shinfo(chunk->skb)->frag_list)) { + __SCTP_INC_STATS(dev_net(chunk->skb->dev), + SCTP_MIB_IN_PKT_DISCARDS); + sctp_chunk_free(chunk); + goto next_chunk; + } chunk->skb = skb_shinfo(chunk->skb)->frag_list; - - if (WARN_ON(!chunk->skb)) { - __SCTP_INC_STATS(dev_net(chunk->skb->dev), SCTP_MIB_IN_PKT_DISCARDS); - sctp_chunk_free(chunk); - goto next_chunk; } } -- 2.51.0