Skip to content

Commit e126dc5

Browse files
CIQ Kernel Automationroxanan1996
authored andcommitted
sctp: avoid NULL dereference when chunk data buffer is missing
jira VULN-160765 cve CVE-2025-40240 commit-author Alexey Simakov <bigalex934@gmail.com> commit 441f064 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: 90017ac ("sctp: Add GSO support") Signed-off-by: Alexey Simakov <bigalex934@gmail.com> Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Link: https://patch.msgid.link/20251021130034.6333-1-bigalex934@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> (cherry picked from commit 441f064) Signed-off-by: CIQ Kernel Automation <ciq_kernel_automation@ciq.com>
1 parent 308d430 commit e126dc5

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

net/sctp/inqueue.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,14 @@ struct sctp_chunk *sctp_inq_pop(struct sctp_inq *queue)
163163
chunk->head_skb = chunk->skb;
164164

165165
/* skbs with "cover letter" */
166-
if (chunk->head_skb && chunk->skb->data_len == chunk->skb->len)
166+
if (chunk->head_skb && chunk->skb->data_len == chunk->skb->len) {
167+
if (WARN_ON(!skb_shinfo(chunk->skb)->frag_list)) {
168+
__SCTP_INC_STATS(dev_net(chunk->skb->dev),
169+
SCTP_MIB_IN_PKT_DISCARDS);
170+
sctp_chunk_free(chunk);
171+
goto next_chunk;
172+
}
167173
chunk->skb = skb_shinfo(chunk->skb)->frag_list;
168-
169-
if (WARN_ON(!chunk->skb)) {
170-
__SCTP_INC_STATS(dev_net(chunk->skb->dev), SCTP_MIB_IN_PKT_DISCARDS);
171-
sctp_chunk_free(chunk);
172-
goto next_chunk;
173174
}
174175
}
175176

0 commit comments

Comments
 (0)