Page MenuHomeFreeBSD

Fix a memory leak when ip_output_send() returns EAGAIN due to send tag issues
ClosedPublic

Authored by gallatin on Jan 26 2022, 9:19 PM.
Tags
None
Referenced Files
F166115025: D34054.id101994.diff
Tue, Aug 11, 8:31 PM
F166091540: D34054.id.diff
Tue, Aug 11, 4:01 PM
F166064714: D34054.id101961.diff
Tue, Aug 11, 11:24 AM
Unknown Object (File)
Sun, Aug 9, 6:57 PM
Unknown Object (File)
Sun, Aug 9, 1:37 PM
Unknown Object (File)
Sun, Aug 9, 1:06 PM
Unknown Object (File)
Fri, Aug 7, 5:21 PM
Unknown Object (File)
Fri, Aug 7, 4:32 PM

Details

Summary

When ip_output_send() returns EAGAIN due to issues with send tags (route change, lagg failover, etc), it must free the mbuf. This is because ip_output_send() was written as a replacement for a direct call to if_output(), and the contract with if_output() has historically been that it owns the mbufs once called. When ip_output_send() failed to free mbufs, it violated this assumption and lead to leaked mbufs.

This was noticed when using NIC TLS in combination with hardware rate-limited connections. When seeing lots of NIC output drops triggered ratelimit send tag changes, we noticed we were leaking tls_sessions, send tags and mbufs. This was due ip_output_send() leaking mbufs which held references to ktls_sessions, which in turn held references to send tags.

Many thanks to @jhb @rrs @hselasky and @markj for helping to debug this at various stages

Diff Detail

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