[tor-bugs] #17949 [Core Tor/Tor]: Make loopback address search more accurate

Tor Bug Tracker & Wiki blackhole at torproject.org
Mon Jul 23 13:59:22 UTC 2018


#17949: Make loopback address search more accurate
-------------------------------------------------+-------------------------
 Reporter:  teor                                 |          Owner:  rl1987
     Type:  enhancement                          |         Status:
                                                 |  needs_revision
 Priority:  Medium                               |      Milestone:  Tor:
                                                 |  0.3.5.x-final
Component:  Core Tor/Tor                         |        Version:
 Severity:  Normal                               |     Resolution:
 Keywords:  easy, tor-client, tor-relay,         |  Actual Points:
  loopback, weird-configuration, 035-triaged-    |
  in-20180711                                    |
Parent ID:  #17991                               |         Points:
 Reviewer:  teor                                 |        Sponsor:
-------------------------------------------------+-------------------------

Comment (by rl1987):

 In `get_interface_addresses_ioctl`, we call `ioctl(.,SIOCGIFCONF,.)` to
 get `ifconf` struct, which has a pointer to `struct ifreq`:
 {{{
 struct ifreq {
 #define IFHWADDRLEN     6
         union
         {
                 char    ifrn_name[IFNAMSIZ];            /* if name, e.g.
 "en0" */
         } ifr_ifrn;

         union {
                 struct  sockaddr ifru_addr;
                 struct  sockaddr ifru_dstaddr;
                 struct  sockaddr ifru_broadaddr;
                 struct  sockaddr ifru_netmask;
                 struct  sockaddr ifru_hwaddr;
                 short   ifru_flags;
                 int     ifru_ivalue;
                 int     ifru_mtu;
                 struct  ifmap ifru_map;
                 char    ifru_slave[IFNAMSIZ];   /* Just fits the size */
                 char    ifru_newname[IFNAMSIZ];
                 void __user *   ifru_data;
                 struct  if_settings ifru_settings;
         } ifr_ifru;
 };
 }}}

 See:
 https://github.com/freebsd/freebsd/blob/master/sys/net/if.h
 https://github.com/aosm/xnu/blob/master/bsd/net/if.h
 https://github.com/torvalds/linux/blob/master/include/uapi/linux/if.h

 Note that both `ifru_addr` and `ifru_flags` are members of the same union,
 meaning they share the same memory and only one is to be set at a time.
 Yet `ifreq_to_smartlist()` reads both fields from the same instance of
 above struct.

 To properly benefit from a `ifru_flags` here, we need to rework how we're
 using `ioctl()`. One `ioctl()` syscall is not enough!

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/17949#comment:52>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list