Page MenuHomeFreeBSD

audit: Fix logging of IPv6 addresses
ClosedPublic

Authored by gallatin on Apr 18 2023, 12:22 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, May 17, 10:08 AM
Unknown Object (File)
Sun, May 17, 10:04 AM
Unknown Object (File)
Thu, May 14, 2:33 PM
Unknown Object (File)
Thu, May 14, 12:51 PM
Unknown Object (File)
Thu, May 14, 7:29 AM
Unknown Object (File)
Mon, May 11, 2:43 PM
Unknown Object (File)
Wed, May 6, 11:59 PM
Unknown Object (File)
Sun, May 3, 7:38 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.