[tor-bugs] #5112 [Tor Client]: Tor fails to bind to socket, SOCK_CLOEXEC unsupported on 2.6.18 kernel

Tor Bug Tracker & Wiki torproject-admin at torproject.org
Tue Feb 14 15:37:21 UTC 2012


#5112: Tor fails to bind to socket, SOCK_CLOEXEC unsupported on 2.6.18 kernel
------------------------+---------------------------------------------------
 Reporter:  fob         |          Owner:  nickm              
     Type:  defect      |         Status:  needs_review       
 Priority:  normal      |      Milestone:  Tor: 0.2.3.x-final 
Component:  Tor Client  |        Version:  Tor: 0.2.3.12-alpha
 Keywords:              |         Parent:                     
   Points:              |   Actualpoints:                     
------------------------+---------------------------------------------------
Changes (by nickm):

  * status:  accepted => needs_review


Comment:

 There's a likely fix for this in branch "bug5112" of my public repository.
 Needs testing and review.

 From the commit message:
 {{{

     Since 0.2.3.1-alpha, we've supported the Linux extensions to socket(),
     open(), socketpair(), and accept() that enable us to create an fd and
     make it close-on-exec with a single syscall.  This not only saves us a
     syscall (big deal), but makes us less vulnerable to race conditions
     where we open a socket and then exec before we can make it
     close-on-exec.

     But these extensions are not supported on all Linuxes: They were added
     between 2.6.23 or so and 2.6.28 or so.  If you were to build your Tor
     against a recent Linux's kernel headers, and then run it with a older
     kernel, you would find yourselve unable to open sockets.  Ouch!

     The solution here is that, when one of these syscalls fails with
     EINVAL, we should try again in the portable way.  This adds an extra
     syscall in the case where we built with new headers and are running
     with old ones, but it will at least allow Tor to work.
 }}}

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


More information about the tor-bugs mailing list