Page MenuHomeFreeBSD

tcp: improve MAC error handling for SYN segments
ClosedPublic

Authored by tuexen on Sep 23 2024, 8:46 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 10, 7:17 AM
Unknown Object (File)
Tue, Nov 5, 5:41 AM
Unknown Object (File)
Tue, Nov 5, 3:50 AM
Unknown Object (File)
Sat, Nov 2, 11:32 PM
Unknown Object (File)
Thu, Oct 31, 11:50 PM
Unknown Object (File)
Tue, Oct 29, 3:55 AM
Unknown Object (File)
Fri, Oct 25, 8:21 AM
Unknown Object (File)
Wed, Oct 23, 7:17 AM
Subscribers

Details

Summary

Don't leak a maclabel when SYN segments are processed which results in an error due to MD5 signature handling.
Tweak the #idef MAC to allow additional upcoming changes.
This patch depends on D46701 to avoid double frees.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

cy added inline comments.
sys/netinet/tcp_syncache.c
1766

I'm not sure if I'm missing something here but if this evaluates true when MAC is undefined it results in what is essentially a NOOP. Should this be moved to inside #ifdef MAC?

1770

ditto

tuexen added inline comments.
sys/netinet/tcp_syncache.c
1766

You are right. But upcoming changes there will add two more statements in to block:

  • Calling crfree(cred) if cred != NULL.
  • Calling m_free(ipopts) if ipopts != NULL`.

Both of these will not be protected by #if MAC.

That is what I wanted to point out in the Summary by stating: "Tweak the #idef MAC to allow additional upcoming changes."

sys/netinet/tcp_syncache.c
1766

The parentheses are redundant.

1766

I don't really see the value of submitting this as a separate patch. It's fine, but as Cy says, it's a no-op that could be included together with some functional change.

tuexen marked an inline comment as done.

Remove parentheses, which are not necessary, as suggested by Mark.

tuexen added inline comments.
sys/netinet/tcp_syncache.c
1766

Removed.

1766

I'm bundling moving the #ifdef MAC with fixing the maclabel leak. Please note that I'm changing the condition from sc == &scs to sc == NULL || sc == &scs.
If you prefer to not bundle the #ifdef MAC change with this commit, I can bundle it with the next one, where it is necessary. Whatever you prefer. The final code (after fixing all three leaks) will be the same.

markj added inline comments.
sys/netinet/tcp_syncache.c
1375

It's not necessary now, but I'd consider initializing this to NULL, to avoid any surprises if a new goto is introduced.

1766

I see now, the coffee is still kicking in.

tuexen marked 2 inline comments as done.

Initialize maclabel to NULL, which is not need right now, but avoids using an uninitialized variable in case someone adds a goto in the future before mac_syncache_init() is called. This was suggested by Mark.

tuexen added inline comments.
sys/netinet/tcp_syncache.c
1375

Done. Then we are on the safe side.

tuexen marked an inline comment as done.
This revision was not accepted when it landed; it landed in state Needs Review.Sep 26 2024, 6:12 AM
This revision was automatically updated to reflect the committed changes.