Skip to content

Commit 89bbe78

Browse files
committed
Merge branch 'sctp-fix-a-null-pointer-dereference-in-sctp_sched_dequeue_common'
Xin Long says: ==================== sctp: fix a NULL pointer dereference in sctp_sched_dequeue_common This issue was triggered with SCTP_PR_SCTP_PRIO in sctp, and caused by not checking and fixing stream->out_curr after removing a chunk from this stream. Patch 1 removes an unnecessary check and makes the real fix easier to add in Patch 2. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 1c075b1 + 2f201ae commit 89bbe78

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

net/sctp/outqueue.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ static int sctp_prsctp_prune_unsent(struct sctp_association *asoc,
384384
{
385385
struct sctp_outq *q = &asoc->outqueue;
386386
struct sctp_chunk *chk, *temp;
387+
struct sctp_stream_out *sout;
387388

388389
q->sched->unsched_all(&asoc->stream);
389390

@@ -398,12 +399,14 @@ static int sctp_prsctp_prune_unsent(struct sctp_association *asoc,
398399
sctp_sched_dequeue_common(q, chk);
399400
asoc->sent_cnt_removable--;
400401
asoc->abandoned_unsent[SCTP_PR_INDEX(PRIO)]++;
401-
if (chk->sinfo.sinfo_stream < asoc->stream.outcnt) {
402-
struct sctp_stream_out *streamout =
403-
SCTP_SO(&asoc->stream, chk->sinfo.sinfo_stream);
404402

405-
streamout->ext->abandoned_unsent[SCTP_PR_INDEX(PRIO)]++;
406-
}
403+
sout = SCTP_SO(&asoc->stream, chk->sinfo.sinfo_stream);
404+
sout->ext->abandoned_unsent[SCTP_PR_INDEX(PRIO)]++;
405+
406+
/* clear out_curr if all frag chunks are pruned */
407+
if (asoc->stream.out_curr == sout &&
408+
list_is_last(&chk->frag_list, &chk->msg->chunks))
409+
asoc->stream.out_curr = NULL;
407410

408411
msg_len -= chk->skb->truesize + sizeof(struct sctp_chunk);
409412
sctp_chunk_free(chk);

0 commit comments

Comments
 (0)