Page MenuHomeFreeBSD

if_geneve: Fix mbuf leak on ip_ecn_egress
ClosedPublic

Authored by pouria on Mon, Jul 20, 8:46 PM.
Tags
None
Referenced Files
F164275600: D58361.diff
Thu, Jul 30, 7:15 AM
F164255161: D58361.id182311.diff
Thu, Jul 30, 3:47 AM
Unknown Object (File)
Tue, Jul 28, 1:58 AM
Unknown Object (File)
Mon, Jul 27, 10:50 PM
Unknown Object (File)
Mon, Jul 27, 6:24 AM
Unknown Object (File)
Mon, Jul 27, 4:12 AM
Unknown Object (File)
Sun, Jul 26, 11:15 PM
Unknown Object (File)
Sun, Jul 26, 9:17 PM

Details

Summary

Free mbuf and increase IFCOUNTER_IERRORS if ip_ecn_egress() under
geneve_input_inherit() decides to drop the packet.

Reported by: Chris Jarrett-Davies of the OpenAI Codex Security Team

Diff Detail

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

Event Timeline

sys/net/if_geneve.c
3132

The m_pullup() call above may free the old mbuf. In that case, since *m0 hasn't been updated, geneve_udp_input() will free the mbuf again in this error path.

IMO it is easiest to just

m_freem(m);
*m0 = NULL;
return (ENOBUFS);
sys/net/if_geneve.c
3127–3130

how about this one?

sys/net/if_geneve.c
3127–3130

That's fine too.

markj added inline comments.
sys/net/if_geneve.c
3180–3181

Now you can remove this assignment.

This revision is now accepted and ready to land.Mon, Jul 20, 9:17 PM
pouria marked 3 inline comments as done.

Address @markj comment, remove redundant *m0 = m assignment

This revision now requires review to proceed.Mon, Jul 20, 9:21 PM
This revision is now accepted and ready to land.Mon, Jul 20, 9:22 PM
This revision was automatically updated to reflect the committed changes.
sys/net/if_geneve.c
2844

BTW, there is a leak in this error path too, though I suspect this might not be triggerable in practice.