[PATCH net 0/4] sctp: fix I-FORWARD-TSN handling with user message interleaving

From: Tim Budding

Date: Sat Oct 24 2026 - 08:09:08 EST


With user message interleaving (RFC 8260), fragments of messages on
different streams can be interleaved in TSN space. When a PR-SCTP
message is abandoned, the sender reports it in an I-FORWARD-TSN, which
carries a New Cumulative TSN and the stream, U bit and MID of the
skipped messages. The receiver still uses the New Cumulative TSN as if
it delimited messages, which loses or corrupts unrelated messages:

TSN stream MID
0 0 0 B 64KB reliable message on stream 0
...
5 0 0
6 1 0 BE PR-SCTP message on stream 1, lost, abandoned
7 0 0
...
I-FORWARD-TSN new_cum=6 skip=[sid=1 mid=0]

The receiver frees the stream 0 fragments with TSNs 0-5 together with
the abandoned message. They have already been acked and are not
retransmitted, so the stream 0 message is never delivered and the
stream stays blocked.

Patch 1 frees reassembly fragments per I-FORWARD-TSN skip entry (stream,
U bit and MID) instead of by TSN. Patch 2 aborts an unordered partial
delivery when the message being delivered is the skipped one, instead
of merging it with the next unordered message on the stream. Patch 3
stops treating an I-FORWARD-TSN as an association reset when its New
Cumulative TSN is the highest TSN seen, which aborted partial delivery
on all streams and could abort the association. Patch 2 comes first
because the code that patch 3 removes also aborted that unordered
partial delivery in the leading edge case.

Patch 4 adds a selftest. Its ordered, unordered, leading_edge and uo_pd
tests fail without the corresponding fix and pass with it; its reset
test checks that an SSN/TSN association reset still works.

Tested with the new selftest, sctp_vrf.sh and the lksctp-tools
functional tests, also on a kernel with KASAN, lockdep and kmemleak
enabled. W=1 and sparse show no new warnings.

The first bug showed up as message loss in real use, and I found its
cause by AI-assisted code inspection. An AI assistant found the other
two while I was fixing it. The assistant also helped write the patches,
the selftest and these messages; I have reviewed and tested all of it.

Tim Budding (4):
sctp: purge abandoned I-DATA fragments by stream and MID, not by TSN
sctp: abort unordered partial delivery when its message is skipped
sctp: don't treat an I-FORWARD-TSN as an association reset
selftests: net: add SCTP I-FORWARD-TSN tests with message interleaving

net/sctp/stream.c | 2 +
net/sctp/stream_interleave.c | 34 +-
tools/testing/selftests/net/.gitignore | 1 +
tools/testing/selftests/net/Makefile | 2 +
tools/testing/selftests/net/sctp_ifwdtsn.c | 538 ++++++++++++++++++++
tools/testing/selftests/net/sctp_ifwdtsn.sh | 141 +++++
6 files changed, 696 insertions(+), 22 deletions(-)
create mode 100644 tools/testing/selftests/net/sctp_ifwdtsn.c
create mode 100755 tools/testing/selftests/net/sctp_ifwdtsn.sh


base-commit: 7076f684d5132e6a6145e1da2fa74771ecd052e5
--
2.34.1