[tor-bugs] #31482 [Core Tor/Tor]: Avoid possible overflow when converting between coarse stamp to approx ms

Tor Bug Tracker & Wiki blackhole at torproject.org
Mon Aug 26 18:07:39 UTC 2019


#31482: Avoid possible overflow when converting between coarse stamp to approx ms
-------------------------------------------------+-------------------------
 Reporter:  teor                                 |          Owner:  teor
     Type:  defect                               |         Status:
                                                 |  needs_revision
 Priority:  Medium                               |      Milestone:  Tor:
                                                 |  0.4.2.x-final
Component:  Core Tor/Tor                         |        Version:  Tor:
                                                 |  0.3.4.1-alpha
 Severity:  Normal                               |     Resolution:
 Keywords:  035-backport, 040-backport,          |  Actual Points:  0.5
  041-backport                                   |
Parent ID:                                       |         Points:  1
 Reviewer:  nickm                                |        Sponsor:
-------------------------------------------------+-------------------------
Changes (by nickm):

 * status:  needs_review => needs_revision


Comment:

 I don't see any problems in the patch as written, but I do support doing
 the TODO items.

 We should also base this on maint-0.3.5 if the bug is there.

 To try to answer your questions:

 >do I need to do any extra tests for monotime_init_internal()

 Maybe it would be good to extract the computation to a new `STATIC`
 function, and then test that new function.  That way we can make sure that
 the stuff calculated by monotime_init_internal() looks the way we expect
 with different inputs.

 >does anyone run our unit tests on iOS?

 I'm not sure; Guardian might?

 I can easily believe that nobody has tried rate-limiting on iOS.

 >how serious is this bug in rate_per_sec_to_rate_per_sec()? Do we actually
 use token bucket rates close to 230? Is my math on that limit correct?

 I think that if it only affects iOS, it's not that bad, but we should
 backport anyway.  I am not 100% sure on your math on the limit; tests
 there would make me more confident.

 >are there any other callers of
 monotime_coarse_stamp_units_to_approx_msec() or
 monotime_msec_to_approx_coarse_stamp_units() that might trigger this bug?

 There's a safe call in relay.c, and that's all I can see outside of the
 unit tests.

 >Do we need to make a similar change to the Windows code?

 I don't think so, though doing a GCD calculation on init wouldn't hurt.

 For windows, the fraction is "nsec per tick", which is unlikely to need a
 very big denominator.

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


More information about the tor-bugs mailing list