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 D9EC621576E; Mon, 27 Oct 2025 19:18:11 +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=1761592691; cv=none; b=mHve+UnIyD2g9De8KvAY1QV078NQdYQ/kEh68ubNuka0DnkAz0JFm5TZlYbcpRvEaXOU/Z1vFb2gZFz4gorElz3bZzkHNEo+8if+sbUfAG9fxX4bok2JAzFotk6u82EnGjZVMdAcQT1AwYv5HfvNb8zwwVxmPEIor1S1faYkGH8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761592691; c=relaxed/simple; bh=unPXXErYCYVlXDbSozXfvzt7ZnMMNqhAUh/sVYhZYfM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mNAiI6u84USIUbSbRQFppDPFOYH2M+aIf4rKUqZzOkRQaN4RPPNO7ENGZBqaRUFmAkdUMUSBCM0Cog9ZQpsyP4heCjM8O/GNTF5oAXlzsFTw1TUAti0MkNydaSh4Qg6ydg767DdW5sLlL1Bhpb8+Udo7xgxxpmBZYQA371scGaE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vpqosT6s; 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="vpqosT6s" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E0B5C4CEF1; Mon, 27 Oct 2025 19:18:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761592691; bh=unPXXErYCYVlXDbSozXfvzt7ZnMMNqhAUh/sVYhZYfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vpqosT6sKDEc3g1Fx1XwRbIF+wie9JYoTkDDfyezZOLM4D259xFzqFtQcXJak0dG3 upQlmEddALp9IMOlZ25XfiiRojsaGGDvLolFmV8g88yAOJrEoke0YWSK5zWOgC3w6U 9Otm+xJp9hzJXUkA5NpLKJXVJ0DJ58w4Qs8KMn/Q= 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.6 30/84] sctp: avoid NULL dereference when chunk data buffer is missing Date: Mon, 27 Oct 2025 19:36:19 +0100 Message-ID: <20251027183439.620608332@linuxfoundation.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251027183438.817309828@linuxfoundation.org> References: <20251027183438.817309828@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.6-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