[tor-bugs] #18362 [Core Tor/Tor]: Tor could use a generic 'handle' implementation.

Tor Bug Tracker & Wiki blackhole at torproject.org
Mon Apr 18 22:46:30 UTC 2016


#18362: Tor could use a generic 'handle' implementation.
-------------------------------------------------+-------------------------
 Reporter:  nickm                                |          Owner:  nickm
     Type:  enhancement                          |         Status:
 Priority:  High                                 |  needs_revision
Component:  Core Tor/Tor                         |      Milestone:  Tor:
 Severity:  Normal                               |  0.2.9.x-final
 Keywords:  modularity, TorCoreTeam201604, tor-  |        Version:
  modularity                                     |     Resolution:
Parent ID:                                       |  Actual Points:
 Reviewer:  dgoulet                              |         Points:  small
                                                 |        Sponsor:
                                                 |  SponsorS-can
-------------------------------------------------+-------------------------

Comment (by cypherpunks):

 Replying to [comment:12 dgoulet]:
 > Some review comments:
 >
 > * In `_handle_new`, I don't think the two lines below need to be in the
 critical section. How I understand it, the mutex is used to protect the
 `head` object (handle_head) but the following doesn't do memory access on
 it.
 >
 > {{{
 >     name ## _handle_t *new_ref = tor_malloc_zero(sizeof(*new_ref));
 >     new_ref->head = head;
 > }}}
 You overlooked the more obvious blunder: The locking is too lax, the
 creation of the head is not exclusive and, as a result, simultaneous calls
 to *_new() can allocate multiple heads.
 The key aspect the implementer should realise is that the object and the
 head are *both* shared resources, so access to them should be exclusive.

 And now you realise that the lock cannot be (only, or at all, it depends)
 inside the head, for you need to hold the lock before creating the head!

 More comments later.

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


More information about the tor-bugs mailing list