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)
Mar 18 2024, 9:02 AM
Unknown Object (File)
Jan 28 2024, 1:54 AM
Unknown Object (File)
Jan 13 2024, 3:33 AM
Unknown Object (File)
Dec 23 2023, 12:22 AM
Unknown Object (File)
Sep 11 2023, 11:33 PM
Unknown Object (File)
Jul 12 2023, 3:59 PM
Unknown Object (File)
Jun 30 2023, 7:45 AM
Unknown Object (File)
May 14 2023, 6:23 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.