Page MenuHomeFreeBSD

audit: Fix logging of IPv6 addresses
ClosedPublic

Authored by gallatin on Apr 18 2023, 12:22 AM.
Tags
None
Referenced Files
F155175117: D39633.diff
Fri, May 1, 11:14 PM
F155174539: D39633.diff
Fri, May 1, 11:07 PM
Unknown Object (File)
Fri, May 1, 10:31 AM
Unknown Object (File)
Tue, Apr 28, 10:38 AM
Unknown Object (File)
Mon, Apr 27, 5:13 PM
Unknown Object (File)
Mon, Apr 27, 2:41 PM
Unknown Object (File)
Sat, Apr 25, 9:35 AM
Unknown Object (File)
Mon, Apr 20, 9:33 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.Sun, Apr 19, 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.