Skip to content

AROSTCP: what a segment that is not the peer's may change - #2448

Merged
Kalamatee merged 4 commits into
aros-development-team:masterfrom
JJDSNT:review/arostcp-syn-options
Nov 30, 2026
Merged

Kalamatee merged 4 commits into
aros-development-team:masterfrom
JJDSNT:review/arostcp-syn-options

Conversation

@JJDSNT

@JJDSNT JJDSNT commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

What a segment that is not the peer's may change on a connection: nothing. Three fixes in tcp_input(), one commit each, and the test; the revision bump is in the last one: 5.53, kernel v0.92.

Scope

  1. A SYN agrees on options only where it may open a connection (RFC 9293 §3.7.1). tcp_dooptions() took the options of any SYN over before anything else of the segment was looked at. One on an established connection, whatever its sequence number, changed its MSS, its window scale and ts_recent; with a timestamp newer than the peer's, PAWS then dropped all the peer sent. Someone who cannot see the connection needs only its addresses and ports.
  2. TS.Recent only from a segment that reaches the last ACK sent (RFC 7323 §5.3, R2 before R3). A segment wholly before the window is kept for its ACK or RST, but its timestamp was recorded too, with the same result. The condition is FreeBSD's.
  3. A challenge ACK for a SYN before the window too (RFC 5961 §4.2, "irrespective of the sequence number"). AROSTCP: TCP hardening (group 6a) #2078 gave one to a SYN in the window; one before it lost its SYN in the trimming and was dropped without an answer, so that a peer that restarted learned nothing of the old connection. Checked before the timestamps and the trimming, as in FreeBSD. TIME_WAIT is not changed here.

Not changed: in SYN_SENT the options are still taken before the ACK is checked, as in FreeBSD.

Validation

New CUnit test, cunit-net-tcpsynopt: segments made with a raw socket over loopback, IPv4 and IPv6. The connection's numbers are not known to it: it sends sequence numbers and timestamps half the space apart, all four combinations on one connection, so that one of them is always the one that matters.

master this
linux-x86_64 hosted, six runs 10 to 12 of 14 fail, every run 14 of 14 pass, every run
m68k, emulated A3000 10 of 14 fail, three runs 14 of 14 pass, four runs

On the master the number varies in the SYN-with-ACK cases, whose ACK number is not the connection's.

  • All suites: all 71 cunit-net-* programs on hosted, two tap.device units, dual stack: 443 tests, 0 failures.
  • On the wire (aros-matter benches, hosted): rst_probe 7 of 7 cases, listen_probe, tsval_probe and loss_probe as on master.
  • m68k: transport.prot has 134 bytes more of text (50801 to 50935).
  • Bisect: each commit builds on its own, without warnings. cppcheck and flawfinder: nothing new.

One more run of the A3000 with this did not get through its startup in 240 s, the test not begun; it has not happened again in the four that followed, and its cause is not known.

Not tested: real hardware. The m68k system was master 83004d5 with this transport.prot.

tcp_dooptions() took the options of any SYN over, before anything else of
the segment was looked at: one on an established connection, of any
sequence number, changed its MSS, its window scale and ts_recent. With a
timestamp newer than the peer's, PAWS then dropped all the peer sent. The
segment itself was answered with a challenge ACK (RFC 5961 section 4), too
late.

They count now only in a state in which a SYN may open the connection
(RFC 9293 section 3.7.1).
A segment wholly before the window is kept for its ACK or RST, but its
timestamp was recorded too: SEG.SEQ <= Last.ACK.sent was the only
condition. RFC 7323 section 5.3 rejects one outside the window (R2) before
it takes the timestamp (R3). Any such segment with a newer timestamp made
PAWS drop what the peer sent next.

The segment must now reach the last ACK sent, as in FreeBSD's tcp_input().
RFC 5961 section 4.2 has a SYN in a synchronized state answered with a
challenge ACK irrespective of its sequence number. One before the window
lost its SYN in the trimming, and was dropped without an answer: a peer
that restarted, whose new SYN came to be there, learned nothing of the old
connection and repeated the SYN until it gave up.

The SYN is now checked before the timestamps and the trimming, as FreeBSD
does. TIME_WAIT stays as it was.
Segments made with a raw socket over loopback, IPv4 and IPv6, on a
connection that has its handshake behind it: SYNs without options, with
timestamps and with an MSS, ACKs outside the window with timestamps, and
the challenge ACKs a SYN gets in ESTABLISHED, CLOSE_WAIT and FIN_WAIT_2.
Before: at least ten of the fourteen tests fail; now none.
@Kalamatee
Kalamatee merged commit d62cf1f into aros-development-team:master Nov 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants