]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
sctp: keep chunk->transport in step with the list it is queued on
authorBaul Lee <baul.lee@xbow.com>
Wed, 29 Jul 2026 16:00:28 +0000 (01:00 +0900)
committerJakub Kicinski <kuba@kernel.org>
Mon, 3 Aug 2026 21:23:05 +0000 (14:23 -0700)
commit9f2cf069a9a72a2d6b97ca8b4c70e714aac99749
tree1a55701441dae8851d5c368f0bcd23942caf4fc6
parent0e125ecfe20c077625cf0be8d750d5c3abc0dce9
sctp: keep chunk->transport in step with the list it is queued on

__sctp_outq_flush_rtx() moves a gap-acked chunk onto another transport's
transmitted list without updating chunk->transport:

if (chunk->tsn_gap_acked) {
list_move_tail(&chunk->transmitted_list,
       &transport->transmitted);
continue;
}

The chunk then sits on a live transport's list while chunk->transport still
names a different one.  If that transport is removed - sctp_assoc_rm_peer()
from an ASCONF Delete-IP - sctp_transport_free() RCU-frees it and the chunk
is left with a dangling pointer.  sctp_assoc_rm_peer() scrubs
peer->transmitted and asoc->outqueue.out_chunk_list, but the chunk is on
neither.

The pointer is not followed while tsn_gap_acked is set.  A SACK that
reneges on the TSN clears the flag, and the next SACK reaches

tchunk->transport->flight_size -= sctp_data_size(tchunk);

inside the freed transport.  KASAN reports a slab-use-after-free read in
sctp_check_transmitted(), freed from sctp_assoc_rm_peer().  Both the
removal and the SACKs come from the association peer.

Set chunk->transport at the move.  The ordinary resend path needs nothing:
it reaches its list_move_tail() only after sctp_packet_append_chunk()
returned SCTP_XMIT_OK, and __sctp_packet_append_chunk() has rebound the
chunk by then.

Discovered by XBOW, triaged by Baul Lee <baul.lee@xbow.com>

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Baul Lee <baul.lee@xbow.com>
Acked-by: Xin Long <lucien.xin@gmail.com>
Link: https://patch.msgid.link/20260729160028.54546-1-baul.lee@xbow.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/sctp/outqueue.c