]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix a memory leak when ip_output_send() returns EAGAIN due to send tag issues
authorAndrew Gallatin <gallatin@FreeBSD.org>
Thu, 27 Jan 2022 15:28:15 +0000 (10:28 -0500)
committerAndrew Gallatin <gallatin@FreeBSD.org>
Thu, 27 Jan 2022 15:34:34 +0000 (10:34 -0500)
commit9ba117960e1755a693f9361e4d076630dfe13dba
treed5c4660eef35abc0ca5c01503f4f72c9afcfcc99
parent38da0c96dc1b4698931f65d8d58e864dfc3a600e
Fix a memory leak when ip_output_send() returns EAGAIN due to send tag issues

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 wrapper/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
ktls_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 jbh, rrs, hselasky and markj for their help in
debugging this.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D34054
Reviewed by: hselasky, jhb, rrs
MFC after: 2 weeks
sys/netinet/ip_output.c
sys/netinet6/ip6_output.c