Skip to content

Commit 7a832b0

Browse files
jtstrsgregkh
authored andcommitted
sctp: avoid NULL dereference when chunk data buffer is missing
[ Upstream 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 <[email protected]> Acked-by: Marcelo Ricardo Leitner <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent d72f6e2 commit 7a832b0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

net/sctp/inqueue.c

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

171171
/* skbs with "cover letter" */
172-
if (chunk->head_skb && chunk->skb->data_len == chunk->skb->len)
172+
if (chunk->head_skb && chunk->skb->data_len == chunk->skb->len) {
173+
if (WARN_ON(!skb_shinfo(chunk->skb)->frag_list)) {
174+
__SCTP_INC_STATS(dev_net(chunk->skb->dev),
175+
SCTP_MIB_IN_PKT_DISCARDS);
176+
sctp_chunk_free(chunk);
177+
goto next_chunk;
178+
}
173179
chunk->skb = skb_shinfo(chunk->skb)->frag_list;
174-
175-
if (WARN_ON(!chunk->skb)) {
176-
__SCTP_INC_STATS(dev_net(chunk->skb->dev), SCTP_MIB_IN_PKT_DISCARDS);
177-
sctp_chunk_free(chunk);
178-
goto next_chunk;
179180
}
180181
}
181182

0 commit comments

Comments
 (0)