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
F102717254: D46824.id.diff
Sat, Nov 16, 7:14 AM
Unknown Object (File)
Wed, Nov 6, 8:35 PM
Unknown Object (File)
Sun, Nov 3, 1:19 PM
Unknown Object (File)
Sat, Nov 2, 11:57 PM
Unknown Object (File)
Wed, Oct 30, 10:43 AM
Unknown Object (File)
Mon, Oct 21, 12:18 AM
Unknown Object (File)
Fri, Oct 18, 7:06 AM
Unknown Object (File)
Oct 2 2024, 10:59 PM

Details

Summary

Sponsored by: Chelsio Communications

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 59658
Build 56545: arc lint + arc unit

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.