tor/src/or
David Goulet 77cc97cf0a sched: Don't cast to int32_t the monotime_diff_msec() result
When the KIST schedule() is called, it computes a diff value between the last
scheduler run and the current monotonic time. If tha value is below the run
interval, the libevent even is updated else the event is run.

It turned out that casting to int32_t the returned int64_t value for the very
first scheduler run (which is set to 0) was creating an overflow on the 32 bit
value leading to adding the event with a gigantic usec value. The scheduler
was simply never running for a while.

First of all, a BUG() is added for a diff value < 0 because if the time is
really monotonic, we should never have a now time that is lower than the last
scheduler run time. And we will try to recover with a diff value to 0.

Second, the diff value is changed to int64_t so we avoid this "bootstrap
overflow" and future casting overflow problems.

Fixes #23558

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-18 10:55:54 -04:00
..
addressmap.c Replace accumulated C ;;s with ;s 2017-09-15 16:43:17 -04:00
addressmap.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
bridges.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
bridges.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
channel.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
channel.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
channelpadding.c Merge branch 'ticket17857_squashed' into maint-0.3.1 2017-09-12 10:29:00 -04:00
channelpadding.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
channeltls.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
channeltls.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
circpathbias.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
circpathbias.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
circuitbuild.c Merge branch 'scan-build-032' 2017-09-15 16:40:11 -04:00
circuitbuild.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
circuitlist.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
circuitlist.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
circuitmux_ewma.c Switch to offsetof() 2017-08-03 08:56:35 -04:00
circuitmux_ewma.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
circuitmux.c Merge branch 'scan-build-032' 2017-09-15 16:40:11 -04:00
circuitmux.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
circuitstats.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
circuitstats.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
circuituse.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
circuituse.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
command.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
command.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
config.c Replace accumulated C ;;s with ;s 2017-09-15 16:43:17 -04:00
config.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
confparse.c Delete useless checks in confparse.c 2017-05-02 16:12:30 -04:00
confparse.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
connection_edge.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
connection_edge.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
connection_or.c Refactor control_event_bootstrap_problem 2017-09-14 08:25:27 -05:00
connection_or.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
connection.c Merge branch 'scan-build-032' 2017-09-15 16:40:11 -04:00
connection.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
conscache.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
conscache.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
consdiff.c Request (and try to use) consensus diffs. 2017-05-04 08:37:41 -04:00
consdiff.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
consdiffmgr.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
consdiffmgr.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
control.c Replace accumulated C ;;s with ;s 2017-09-15 16:43:17 -04:00
control.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
cpuworker.c Merge branch 'maint-0.3.1' 2017-07-27 16:30:52 -04:00
cpuworker.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
dircollate.c Switch to offsetof() 2017-08-03 08:56:35 -04:00
dircollate.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
directory.c Merge branch 'scan-build-032' 2017-09-15 16:40:11 -04:00
directory.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
dirserv.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
dirserv.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
dirvote.c Fix warnings about passing uninitialized buffers into functions 2017-09-12 21:32:42 -04:00
dirvote.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
dns_structs.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
dns.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
dns.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
dnsserv.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
dnsserv.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
entrynodes.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
entrynodes.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
ext_orport.c Repair buffer API so everything starts with buf_. 2017-09-05 13:57:51 -04:00
ext_orport.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
fallback_dirs.inc Update fallback directory mirrors in May 2017 2017-05-16 19:02:42 +10:00
fp_pair.c Run the copyright update script. 2017-03-15 16:13:17 -04:00
fp_pair.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
geoip.c New GETINFO target to check if geoip is loaded 2017-08-25 12:25:05 -04:00
geoip.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
hibernate.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
hibernate.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
hs_cache.c prop224: Set stricter expiration time of cached client descriptors. 2017-09-13 14:54:49 -04:00
hs_cache.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
hs_cell.c prop224: Add a function to clear INTRO data 2017-08-24 13:03:28 -04:00
hs_cell.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
hs_circuit.c prop224: Register RP circuit when it opens 2017-08-24 13:03:29 -04:00
hs_circuit.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
hs_circuitmap.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
hs_circuitmap.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
hs_client.c prop224: Fix memleak in client_get_random_intro(). 2017-09-15 12:46:26 +03:00
hs_client.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
hs_common.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
hs_common.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
hs_config.c prop224: Move service version into config object 2017-07-13 16:50:09 -04:00
hs_config.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
hs_descriptor.c test: Fix memory leak in hs_descriptor/decode_bad_signature 2017-09-05 09:26:21 -04:00
hs_descriptor.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
hs_ident.c hs-v3: Cancel active descriptor directory connections before uploading 2017-09-12 01:32:04 +03:00
hs_ident.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
hs_intropoint.c Merge branch 'ticket20657_nickm_bugfixes_squashed' 2017-08-08 20:31:57 -04:00
hs_intropoint.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
hs_ntor.c Explicit length checks in create_rend_cpath(). 2017-07-07 11:12:27 -04:00
hs_ntor.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
hs_service.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
hs_service.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
include.am sched: Groundwork before KIST implementation 2017-09-15 11:40:59 -04:00
keypin.c Run the copyright update script. 2017-03-15 16:13:17 -04:00
keypin.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
main.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
main.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
Makefile.nmake Netflow record collapsing defense. 2017-05-08 13:49:21 -04:00
microdesc.c general formatting / whitespace / typo fixes 2017-07-01 17:56:06 -04:00
microdesc.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
networkstatus.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
networkstatus.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
nodelist.c hs-v3: Rate limit some log statements 2017-09-12 11:03:13 -04:00
nodelist.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
ntmain.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
ntmain.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
onion_fast.c Run the copyright update script. 2017-03-15 16:13:17 -04:00
onion_fast.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
onion_ntor.c Run the copyright update script. 2017-03-15 16:13:17 -04:00
onion_ntor.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
onion_tap.c Rename the hybrid_encrypt/decrypt functions; label them as dangerous 2017-07-24 14:34:53 -04:00
onion_tap.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
onion.c Fix ntohs() that should have been htons() 2017-08-04 12:17:53 -04:00
onion.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
or.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
parsecommon.c Fix warnings about passing uninitialized buffers into functions 2017-09-12 21:32:42 -04:00
parsecommon.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
periodic.c Run the copyright update script. 2017-03-15 16:13:17 -04:00
periodic.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
policies.c Switch to offsetof() 2017-08-03 08:56:35 -04:00
policies.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
proto_cell.c Refactor buffer APIs to put a buf_t first. 2017-09-05 13:57:51 -04:00
proto_cell.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
proto_control0.c Refactor buffer APIs to put a buf_t first. 2017-09-05 13:57:51 -04:00
proto_control0.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
proto_ext_or.c Refactor buffer APIs to put a buf_t first. 2017-09-05 13:57:51 -04:00
proto_ext_or.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
proto_http.c Refactor buffer APIs to put a buf_t first. 2017-09-05 13:57:51 -04:00
proto_http.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
proto_socks.c Repair buffer API so everything starts with buf_. 2017-09-05 13:57:51 -04:00
proto_socks.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
protover.c Dircache protocol version 2 adds support for diffs 2017-05-15 17:53:36 -04:00
protover.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
reasons.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
reasons.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
relay.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
relay.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
rendcache.c prop224: Purge client state on NEWNYM 2017-08-30 09:15:54 -04:00
rendcache.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
rendclient.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
rendclient.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
rendcommon.c Merge branch 'maint-0.3.1' 2017-08-25 11:39:38 -04:00
rendcommon.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
rendmid.c rephist: Remove unused crypto_pk statistics. 2017-07-13 20:24:48 +00:00
rendmid.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
rendservice.c Merge branch 'maint-0.3.1' 2017-09-18 09:42:30 -04:00
rendservice.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
rephist.c Merge branch 'maint-0.3.1' 2017-09-15 14:40:35 -04:00
rephist.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
replaycache.c Run the copyright update script. 2017-03-15 16:13:17 -04:00
replaycache.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
router.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
router.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
routerkeys.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
routerkeys.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
routerlist.c Replace accumulated C ;;s with ;s 2017-09-15 16:43:17 -04:00
routerlist.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
routerparse.c Merge branch 'scan-build-032' 2017-09-15 16:40:11 -04:00
routerparse.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
routerset.c Refactor node lookup APIs to take flags 2017-08-22 19:13:40 -04:00
routerset.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
scheduler_kist.c sched: Don't cast to int32_t the monotime_diff_msec() result 2017-09-18 10:55:54 -04:00
scheduler_vanilla.c sched: Make the scheduler object static 2017-09-15 11:40:59 -04:00
scheduler.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
scheduler.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
shared_random_state.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
shared_random_state.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
shared_random.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
shared_random.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
statefile.c Clear up dead-assignment warnings from scan-build 2017-09-12 21:32:34 -04:00
statefile.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
status.c Run the copyright update script. 2017-03-15 16:13:17 -04:00
status.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
tor_main.c Run the copyright update script. 2017-03-15 16:13:17 -04:00
torcert.c Merge remote-tracking branch 'haxxpop/fuzzing-hsv3' 2017-08-28 13:46:24 -04:00
torcert.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
transports.c Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00
transports.h Run our #else/#endif annotator on our source code. 2017-09-15 16:24:44 -04:00