Page MenuHomeFreeBSD

audit: Fix logging of IPv6 addresses
ClosedPublic

Authored by gallatin on Apr 18 2023, 12:22 AM.
Tags
None
Referenced Files
F159758271: D39633.id120517.diff
Wed, Jun 17, 10:32 PM
Unknown Object (File)
Wed, Jun 17, 1:55 AM
Unknown Object (File)
Mon, Jun 8, 7:00 PM
Unknown Object (File)
Thu, Jun 4, 8:57 AM
Unknown Object (File)
May 17 2026, 10:08 AM
Unknown Object (File)
May 17 2026, 10:04 AM
Unknown Object (File)
May 14 2026, 2:33 PM
Unknown Object (File)
May 14 2026, 12:51 PM
Subscribers

Details

Summary

Our audit logging was not logging the IP/port information for IPv6 accept() syscalls. It turns out there were 2 problems

  1. kaudit_to_bsm: Log IPv6 as well as IPv4 and unix addrs
  2. au_to_sock_inet128: Treat ports the same way as au_to_sock_inet32(). Just pushing a uint16 causes byte ordering problems on little endian systems.

Diff Detail

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

Event Timeline

a few years late to the party here but have you tested this?

Yes I see the problem.. ADD_U_INT16 calls be16enc(), which assumes the input value is in host byte order and converts it to big-endian. However, sin6_port is already stored in network byte order (big-endian). On a little-endian system (like x86 or ARM), the CPU interprets those bytes as a byte-swapped integer, and then be16enc swaps them again. We just need a memcpy here.

This revision is now accepted and ready to land.Apr 19 2026, 5:35 AM

I will open a PR to fix au_to_sock_inet128() upstream as well. Thanks for catching this

a few years late to the party here but have you tested this?

I had totally forgotten about this. Yes, I tested it years ago..

This revision was automatically updated to reflect the committed changes.