Page MenuHomeFreeBSD

audit: Fix logging of IPv6 addresses
ClosedPublic

Authored by gallatin on Apr 18 2023, 12:22 AM.
Tags
None
Referenced Files
F174512300: D39633.diff
Sat, Oct 3, 8:11 PM
Unknown Object (File)
Tue, Sep 29, 8:56 PM
Unknown Object (File)
Tue, Sep 29, 8:57 AM
Unknown Object (File)
Tue, Sep 29, 7:27 AM
Unknown Object (File)
Sun, Sep 27, 11:01 PM
Unknown Object (File)
Fri, Sep 25, 9:46 PM
Unknown Object (File)
Fri, Sep 18, 3:12 PM
Unknown Object (File)
Thu, Sep 17, 3:16 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.