Page MenuHomeFreeBSD

ifconf(): correct handling of sockaddrs smaller than struct sockaddr.
ClosedPublic

Authored by brooks on Apr 5 2018, 10:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jun 9, 11:29 AM
Unknown Object (File)
Fri, Jun 6, 11:19 AM
Unknown Object (File)
Mon, Jun 2, 10:31 PM
Unknown Object (File)
Fri, May 16, 2:21 PM
Unknown Object (File)
Apr 30 2025, 4:27 AM
Unknown Object (File)
Apr 23 2025, 5:09 AM
Unknown Object (File)
Apr 14 2025, 8:33 AM
Unknown Object (File)
Apr 14 2025, 4:07 AM
Subscribers

Details

Summary

Portable programs that use SIOCGIFCONF (e.g. traceroute) assume that each pseudo
ifreq is of length MAX(sizeof(struct ifreq), sizeof(ifr_name) + ifr_addr.sa_len). For
short sockaddrs we copied too much from the source sockaddr resulting in a heap
leak.

I believe only one such sockaddr exists (struct sockaddr_sco which
is 8 bytes) and it is unclear if such sockaddrs end up on interfaces
in practice. If it did, the result would be an 8 byte heap leak on current architectures.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/net/if.c
3158 ↗(On Diff #41158)

But is it correct to report larger sa_len than it is the expected size of the address family address ?

sys/net/if.c
3158 ↗(On Diff #41158)

I misread the code I was looking at and you are correct that we should not alter the sa_len. I'll fix it.

brooks marked 2 inline comments as done.
  • Preserve the sa_len of short sockaddrs. I misread the traceroute code.

I've updated the commit message to reflect my revised understanding.

This revision is now accepted and ready to land.Apr 6 2018, 4:39 PM
This revision was automatically updated to reflect the committed changes.