Skip to content

Commit 9460e79

Browse files
pvts-matPlaidCat
authored andcommitted
sctp: avoid NULL dereference when chunk data buffer is missing
jira VULN-176137 cve CVE-2025-40240 commit-author Alexey Simakov <bigalex934@gmail.com> commit 441f064 upstream-diff Same change as in upstream, except for ciqcbr7_9's SCTP_INC_STATS_BH macro instead of upstream's __SCTP_INC_STATS. It's the same macro, renamed on upstream in 13415e4 ("net: snmp: kill STATS_BH macros") 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: Marcin Wcisło <marcin.wcislo@conclusive.pl>
1 parent 66fc3f0 commit 9460e79

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
@@ -185,13 +185,14 @@ struct sctp_chunk *sctp_inq_pop(struct sctp_inq *queue)
185185
chunk->head_skb = chunk->skb;
186186

187187
/* skbs with "cover letter" */
188-
if (chunk->head_skb && chunk->skb->data_len == chunk->skb->len)
188+
if (chunk->head_skb && chunk->skb->data_len == chunk->skb->len) {
189+
if (WARN_ON(!skb_shinfo(chunk->skb)->frag_list)) {
190+
SCTP_INC_STATS_BH(dev_net(chunk->skb->dev),
191+
SCTP_MIB_IN_PKT_DISCARDS);
192+
sctp_chunk_free(chunk);
193+
goto next_chunk;
194+
}
189195
chunk->skb = skb_shinfo(chunk->skb)->frag_list;
190-
191-
if (WARN_ON(!chunk->skb)) {
192-
SCTP_INC_STATS_BH(dev_net(chunk->skb->dev), SCTP_MIB_IN_PKT_DISCARDS);
193-
sctp_chunk_free(chunk);
194-
goto next_chunk;
195196
}
196197
}
197198

0 commit comments

Comments
 (0)