mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
net: sctp: fix skb leak in sctp_inq_free()
[ Upstream commit 4e45170d9acc2d5ae8f545bf3f2f67504a361338 ]
In case of GSO, 'chunk->skb' pointer may point to an entry from
fraglist created in 'sctp_packet_gso_append()'. To avoid freeing
random fraglist entry (and so undefined behavior and/or memory
leak), introduce 'sctp_inq_chunk_free()' helper to ensure that
'chunk->skb' is set to 'chunk->head_skb' (i.e. fraglist head)
before calling 'sctp_chunk_free()', and use the aforementioned
helper in 'sctp_inq_pop()' as well.
Reported-by: syzbot+8bb053b5d63595ab47db@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?id=0d8351bbe54fd04a492c2daab0164138db008042
Fixes: 90017accff ("sctp: Add GSO support")
Suggested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Acked-by: Xin Long <lucien.xin@gmail.com>
Link: https://lore.kernel.org/r/20240214082224.10168-1-dmantipov@yandex.ru
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
2c66293a45
commit
0b60c07253
@@ -38,6 +38,14 @@ void sctp_inq_init(struct sctp_inq *queue)
|
|||||||
INIT_WORK(&queue->immediate, NULL);
|
INIT_WORK(&queue->immediate, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Properly release the chunk which is being worked on. */
|
||||||
|
static inline void sctp_inq_chunk_free(struct sctp_chunk *chunk)
|
||||||
|
{
|
||||||
|
if (chunk->head_skb)
|
||||||
|
chunk->skb = chunk->head_skb;
|
||||||
|
sctp_chunk_free(chunk);
|
||||||
|
}
|
||||||
|
|
||||||
/* Release the memory associated with an SCTP inqueue. */
|
/* Release the memory associated with an SCTP inqueue. */
|
||||||
void sctp_inq_free(struct sctp_inq *queue)
|
void sctp_inq_free(struct sctp_inq *queue)
|
||||||
{
|
{
|
||||||
@@ -53,7 +61,7 @@ void sctp_inq_free(struct sctp_inq *queue)
|
|||||||
* free it as well.
|
* free it as well.
|
||||||
*/
|
*/
|
||||||
if (queue->in_progress) {
|
if (queue->in_progress) {
|
||||||
sctp_chunk_free(queue->in_progress);
|
sctp_inq_chunk_free(queue->in_progress);
|
||||||
queue->in_progress = NULL;
|
queue->in_progress = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,9 +138,7 @@ struct sctp_chunk *sctp_inq_pop(struct sctp_inq *queue)
|
|||||||
goto new_skb;
|
goto new_skb;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chunk->head_skb)
|
sctp_inq_chunk_free(chunk);
|
||||||
chunk->skb = chunk->head_skb;
|
|
||||||
sctp_chunk_free(chunk);
|
|
||||||
chunk = queue->in_progress = NULL;
|
chunk = queue->in_progress = NULL;
|
||||||
} else {
|
} else {
|
||||||
/* Nothing to do. Next chunk in the packet, please. */
|
/* Nothing to do. Next chunk in the packet, please. */
|
||||||
|
|||||||
Reference in New Issue
Block a user