Page MenuHomeFreeBSD

tcp: improve SEG.ACK validation in SYN-RECEIVED
ClosedPublic

Authored by tuexen on Oct 6 2025, 2:42 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 6, 1:47 PM
Unknown Object (File)
Sun, Nov 2, 7:13 AM
Unknown Object (File)
Sat, Nov 1, 8:19 AM
Unknown Object (File)
Wed, Oct 29, 6:55 AM
Unknown Object (File)
Wed, Oct 29, 6:54 AM
Unknown Object (File)
Wed, Oct 29, 6:53 AM
Unknown Object (File)
Wed, Oct 29, 6:44 AM
Unknown Object (File)
Tue, Oct 28, 11:29 PM

Details

Summary

According to the fifth step in SEGMENT ARRIVES, send a RST segment in response to an ACK segment which fails the SEG.ACK check, but leave the endpoint state unchanged.
FreeBSD handles this correctly when entering the SYN-RECEIVED state via the SYN-SENT state, but not in the SYN-cache code, which handles the SYN-RECEIVED state via the LISTEN state.
This also fixes a panic reported by Alexander Leidinger.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

tuexen requested review of this revision.Oct 6 2025, 2:42 PM
tuexen retitled this revision from tcp: improve SEG.ACK check in SYN-RECEIVED to tcp: improve SEG.ACK validation in SYN-RECEIVED.Oct 6 2025, 2:48 PM
jtl added inline comments.
sys/netinet/tcp_syncache.c
1287

Is there a reason to free() while holding the lock? The conditional right before this one drops the lock before calling free().

1318

At this point, I think you can either delete this or turn it into an assert that sc == &scs. (I think you can now only reach this from the syncookie portion of the code and not from the syncache code.)

This revision is now accepted and ready to land.Oct 6 2025, 3:25 PM
tuexen marked an inline comment as done.

Address one of Jonathan's comments.

This revision now requires review to proceed.Oct 6 2025, 3:53 PM
sys/netinet/tcp_syncache.c
1287

This is one of the things I want to do consistently. In several other places it calls free in the if statement, at the end it checks if s is not NULL. I plan to do it in a consistent way in all places. Doing it after releasing the lock is better, I agree. I can do that right now.

1318

Yes, this is also one of the cleanup steps. Right now my plan is to remove the synchache_free() call, move the free(s, M_TCPLOG) up to the remaining three places and finally remove the three instances of goto failed by using return (0) directly.
I guess this makes the code clearer.

This revision is now accepted and ready to land.Oct 6 2025, 6:24 PM

I can confirm that this fixes the crash I've seen. Instead of crashing after a few minutes, it now is still humming happily with 16 minutes of uptime.

sys/netinet/tcp_syncache.c
1289

';' in front and after the comment...

I can confirm that this fixes the crash I've seen. Instead of crashing after a few minutes, it now is still humming happily with 16 minutes of uptime.

Thanks for testing and reporting.

sys/netinet/tcp_syncache.c
1289

Fix. Not sure why these come up. I guess my editor has changed its behavior.