diff options
author | Taylor Yu <catalyst@torproject.org> | 2018-05-04 17:16:06 -0500 |
---|---|---|
committer | Taylor Yu <catalyst@torproject.org> | 2018-05-08 17:59:03 -0500 |
commit | de343b4e421c0c651eaac1d52d23c3c792bee73a (patch) | |
tree | 7507ded322eda3141794f23457b93331c3931218 /src/or/networkstatus.c | |
parent | d6948bc7764dca7644b331aaf37453b328239e6d (diff) | |
download | tor-de343b4e421c0c651eaac1d52d23c3c792bee73a.tar.gz tor-de343b4e421c0c651eaac1d52d23c3c792bee73a.zip |
Improve tolerance for dirauths with skewed clocks
Previously, an authority with a clock more than 60 seconds ahead could
cause a client with a correct clock to warn that the client's clock
was behind. Now the clocks of a majority of directory authorities
have to be ahead of the client before this warning will occur.
Relax the early-consensus check so that a client's clock must be 60
seconds behind the earliest time that a given sufficiently-signed
consensus could possibly be available.
Add a new unit test that calls warn_early_consensus() directly.
Fixes bug 25756; bugfix on 0.2.2.25-alpha.
Diffstat (limited to 'src/or/networkstatus.c')
-rw-r--r-- | src/or/networkstatus.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index d1c2171198..51b2f4af15 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -1777,10 +1777,18 @@ warn_early_consensus(const networkstatus_t *c, const char *flavor, long delta = now - c->valid_after; char *flavormsg = NULL; -/** If a consensus appears more than this many seconds before its declared - * valid-after time, declare that our clock is skewed. */ +/** If a consensus appears more than this many seconds before it could + * possibly be a sufficiently-signed consensus, declare that our clock + * is skewed. */ #define EARLY_CONSENSUS_NOTICE_SKEW 60 - if (now >= c->valid_after - EARLY_CONSENSUS_NOTICE_SKEW) + + /* We assume that if a majority of dirauths have accurate clocks, + * the earliest that a dirauth with a skewed clock could possibly + * publish a sufficiently-signed consensus is (valid_after - + * dist_seconds). Before that time, the skewed dirauth would be + * unable to obtain enough authority signatures for the consensus to + * be valid. */ + if (now >= c->valid_after - c->dist_seconds - EARLY_CONSENSUS_NOTICE_SKEW) return; format_iso_time(tbuf, c->valid_after); |