Skip to content

Commit df132ef

Browse files
lxindavem330
authored andcommitted
sctp: clear the transport of some out_chunk_list chunks in sctp_assoc_rm_peer
If a transport is removed by asconf but there still are some chunks with this transport queuing on out_chunk_list, later an use-after-free issue will be caused when accessing this transport from these chunks in sctp_outq_flush(). This is an old bug, we fix it by clearing the transport of these chunks in out_chunk_list when removing a transport in sctp_assoc_rm_peer(). Reported-by: [email protected] Signed-off-by: Xin Long <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2b0ab72 commit df132ef

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

net/sctp/associola.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,9 @@ void sctp_assoc_set_primary(struct sctp_association *asoc,
499499
void sctp_assoc_rm_peer(struct sctp_association *asoc,
500500
struct sctp_transport *peer)
501501
{
502-
struct list_head *pos;
503-
struct sctp_transport *transport;
502+
struct sctp_transport *transport;
503+
struct list_head *pos;
504+
struct sctp_chunk *ch;
504505

505506
pr_debug("%s: association:%p addr:%pISpc\n",
506507
__func__, asoc, &peer->ipaddr.sa);
@@ -564,7 +565,6 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc,
564565
*/
565566
if (!list_empty(&peer->transmitted)) {
566567
struct sctp_transport *active = asoc->peer.active_path;
567-
struct sctp_chunk *ch;
568568

569569
/* Reset the transport of each chunk on this list */
570570
list_for_each_entry(ch, &peer->transmitted,
@@ -586,6 +586,10 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc,
586586
sctp_transport_hold(active);
587587
}
588588

589+
list_for_each_entry(ch, &asoc->outqueue.out_chunk_list, list)
590+
if (ch->transport == peer)
591+
ch->transport = NULL;
592+
589593
asoc->peer.transport_count--;
590594

591595
sctp_transport_free(peer);

0 commit comments

Comments
 (0)