Page MenuHomeFreeBSD

tcp_output: Clear FIN if tcp_m_copym truncates output length
ClosedPublic

Authored by jhb on Sep 27 2024, 9:34 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 19, 5:37 PM
Unknown Object (File)
Wed, Dec 11, 8:02 PM
Unknown Object (File)
Sun, Dec 1, 4:57 AM
Unknown Object (File)
Nov 22 2024, 5:33 AM
Unknown Object (File)
Nov 22 2024, 2:26 AM
Unknown Object (File)
Nov 19 2024, 7:09 AM
Unknown Object (File)
Nov 16 2024, 7:14 AM
Unknown Object (File)
Nov 6 2024, 8:35 PM

Diff Detail

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

Event Timeline

jhb requested review of this revision.Sep 27 2024, 9:34 PM

I tripped over this while doing some internal testing of NIC TLS where I used a hack in tcp_m_copym() that forces truncations in the middle of TLS trailers and I tripped over an assertion that a truncated TLS record can't be transmitted with FIN. Other places in tcp_output() that truncate the length clear TH_FIN as well. Possibly the change to clear tso could also go inside this check, but that would be a larger diff.

rscheff added subscribers: tuexen, cc, rrs, rscheff.

Good find! While there is probably zero difference as the compiler optimizes this, keeping "old_len" instead would only require the clearing of TH_FIN, and not another assignment though, which seems more alike to similar other checks... @tuexen @cc and @rrs may want to have a look too...

This revision is now accepted and ready to land.Sep 29 2024, 12:51 PM

Good find! While there is probably zero difference as the compiler optimizes this, keeping "old_len" instead would only require the clearing of TH_FIN, and not another assignment though, which seems more alike to similar other checks... @tuexen @cc and @rrs may want to have a look too...

I agree with Richard. Something like:

uint32_t old_len;
...
old_len = len;
m->m_next = tcp_m_copym(mb, moff,
    &len, if_hw_tsomaxsegcount,
    if_hw_tsomaxsegsize, msb, hw_tls);
if (old_len != len)
	 flags &= ~TH_FIN;

But I leave it up to you.

This revision now requires review to proceed.Sep 30 2024, 5:30 PM
This revision is now accepted and ready to land.Sep 30 2024, 5:42 PM
cc requested changes to this revision.Oct 1 2024, 1:57 PM
cc added inline comments.
sys/netinet/tcp_output.c
1081

Shall use int32_t, the same type as len. Although we generally think uint32_t is not harmful, but I think we shall stick with the simple rule when comparing int32_t with uint32_t.

This revision now requires changes to proceed.Oct 1 2024, 1:57 PM

I think this change also applies to the bbr and rack stacks.

I can fix the type mismatch during commit. I have not looked to see if other stacks are affected.

In D46824#1068981, @jhb wrote:

I can fix the type mismatch during commit. I have not looked to see if other stacks are affected.

Fixing the type mismatch would be good. I think other stacks are not affected, since I think they
do not send a FIN before any outstanding data is ACKed and nothing is buffered anymore.

This revision was not accepted when it landed; it landed in state Needs Revision.Oct 2 2024, 7:14 PM
This revision was automatically updated to reflect the committed changes.
In D46824#1068981, @jhb wrote:

I can fix the type mismatch during commit. I have not looked to see if other stacks are affected.

Fixing the type mismatch would be good. I think other stacks are not affected, since I think they
do not send a FIN before any outstanding data is ACKed and nothing is buffered anymore.

Sounds good to me.