Commit Graph

27178 Commits

Author SHA1 Message Date
David Goulet
7b102d53e3 Merge branch 'tor-gitlab/mr/265' into maint-0.4.5 2021-01-21 12:27:27 -05:00
David Goulet
7692f443d4 config: Remove Bridge <-> ClientTransportPlugin validation
This validation was only done if DisableNetwork was off because we would use
the global list of transports/bridges and DisableNetwork would not populate
it.

This was a problem for any user using DisableNetwork which includes Tor
Browser and thus leading to the Bug() warning.

Without a more in depth refactoring, we can't do this validation without the
global list.

The previous commit makes it that any connection to a bridge without a
transport won't happen thus we keep the security feature of not connecting to
a bridge without its corresponding transport.

Related to #40106

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-01-20 15:56:19 -05:00
David Goulet
09c6d03246 bridge: Don't initiate connection without a transport
Don't pick the bridge as the guard or launch descriptor fetch if no transport
is found.

Fixes #40106

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-01-20 15:55:50 -05:00
Alexander Færøy
c38c36e5f1 Limit the number of items in the consdiffmgr on Windows.
This patch limits the number of items in the consensus diff cache to 64
on the Windows platform. Hopefully, this will allow us to investigate a
smarter fix while avoiding the situation reported in tor#24857 where
Windows relay operators report Tor using 100% CPU.

See: tor#24857
2021-01-20 16:33:17 +00:00
Nick Mathewson
9a0a91dc23 Merge branch 'maint-0.4.5' 2021-01-19 15:21:07 -05:00
Nick Mathewson
18654b629f Merge remote-tracking branch 'tor-gitlab/mr/266' into maint-0.4.5 2021-01-19 15:20:54 -05:00
Nick Mathewson
b0af4ddc7c Merge branch 'maint-0.4.5' 2021-01-19 13:20:43 -05:00
Nick Mathewson
27ee12836d Merge remote-tracking branch 'tor-gitlab/mr/261' into maint-0.4.5 2021-01-19 13:20:31 -05:00
David Goulet
9321ddf3a1 config: Prioritize port with explicit address
When selecting the first advertised port, we always prefer the one with an
explicit address.

Closes #40246

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-01-19 13:07:49 -05:00
David Goulet
938623004b relay: Keep all ORPorts that are on different ports
We used to actually discard ORPorts that were the same port and same family
but they could have different address.

Instead, we need to keep all different ORPorts so we can bind a listener on
each of them. We will publish only one of these in our descriptor though.

Related to #40246

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-01-19 13:07:49 -05:00
Nick Mathewson
b7f886beb4 Merge remote-tracking branch 'tor-gitlab/mr/163' into maint-0.4.3 2021-01-19 12:53:44 -05:00
Nick Mathewson
faf7b550e7 Merge remote-tracking branch 'tor-gitlab/mr/143' into maint-0.3.5 2021-01-19 12:53:30 -05:00
Nick Mathewson
5f53e013cd Merge branch 'maint-0.4.5' 2021-01-19 12:49:31 -05:00
Nick Mathewson
6c1bc570cf Merge branch 'maint-0.4.4' into maint-0.4.5 2021-01-19 12:49:31 -05:00
Nick Mathewson
4c82c2d1d4 Merge branch 'maint-0.4.3' into maint-0.4.4 2021-01-19 12:49:22 -05:00
Nick Mathewson
a22bfe04bc Merge branch 'maint-0.3.5' into maint-0.4.3 2021-01-19 12:45:07 -05:00
Alexander Færøy
13cf964453 Remove unnecessary non-fatal assertion.
This patch removes a call to `tor_assert_nonfatal()` if
`extend_info_from_node()` returns NULL. This is unnecessary as we
already handle the case where `info` is NULL in the next `if (!info) {
... }` block in the code.

See: tor#32666.
2021-01-19 17:08:01 +00:00
Nick Mathewson
4961645254 Merge branch 'maint-0.4.5' 2021-01-19 12:02:28 -05:00
David Goulet
691c717187 Revert "IPv6 sybil: consider addresses in the same /64 to be equal."
This reverts commit d07f17f676.

We don't want to consider an entire routable IPv6 network as sybil if more
than 2 relays happen to be on it. For path selection it is very important but
not for selecting relays in the consensus.

Fixes #40243
2021-01-15 12:57:57 -05:00
David Goulet
f0c29f0883 relay: Don't BUG() if we can't find authority descriptor
We can end up trying to find our address from an authority while we don't have
yet its descriptor.

In this case, don't BUG() and just come back later.

Closes #40231

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-01-14 10:02:03 -05:00
David Goulet
743a5ef2b3 relay: Don't flag that we published if descriptor build fails
In case building the descriptor would fail, we could still flag that we did in
fact publish the descriptors leading to no more attempt at publishing it which
in turn makes the relay silent for some hours and not try to rebuild the
descriptor later.

This has been spotted with #40231 because the operator used a localhost
address for the ORPort and "AssumeReachable 1" leading to this code path where
the descriptor failed to build but all conditions to "can I publish" were met.

Related to #40231

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-01-14 09:42:56 -05:00
Nick Mathewson
fa8ecf8820 Better fix for #40241 (--enable-all-bugs-are-fatal and fallthrough)
This one should work on GCC _and_ on Clang.  The previous version
made Clang happier by not having unreachable "fallthrough"
statements, but made GCC sad because GCC didn't think that the
unconditional failures were really unconditional, and therefore
_wanted_ a FALLTHROUGH.

This patch adds a FALLTHROUGH_UNLESS_ALL_BUGS_ARE_FATAL macro that
seems to please both GCC and Clang in this case: ordinarily it is a
FALLTHROUGH, but when ALL_BUGS_ARE_FATAL is defined, it's an
abort().

Fixes bug 40241 again.  Bugfix on earlier fix for 40241, which was
merged into maint-0.3.5 and forward, and released in 0.4.5.3-rc.
2021-01-13 09:54:43 -05:00
George Kadianakis
cd1468d56b Merge branch 'maint-0.4.5' 2021-01-13 16:01:41 +02:00
George Kadianakis
c931eae981 Merge branch 'mr/252' into maint-0.4.5 2021-01-13 16:01:11 +02:00
Nick Mathewson
4d6d3b3c05 Remove BUG() when checking TOO_MANY_OUTDATED_DIRSERVERS.
Fixes bug #40234; bugfix on 0.3.2.5-alpha.
2021-01-13 16:00:54 +02:00
George Kadianakis
cc30c09f7c Merge branch 'mr/236' 2021-01-13 15:23:54 +02:00
Nick Mathewson
fb3704b459 New consensus method to find bwweightscale & maxunmeasuredbw correctly.
Our original code for parsing these parameters out of our list of
parameters pre-dated us having the
dirvote_get_intermediate_param_value() function... and it was buggy.
Specifically, it would reject any " ... K=V ..." value
where there were additional unconverted characters after the V, and
use the default value instead,

We haven't run into this yet because we've never voted for
bwweightscale to be anything besides the default 10000, or
maxunmeasuredbw to be anything besides the default 20.

This requires a new consensus method because it is a change in how
consensuses are computed.

Fixes bug 19011; bugfix on 0.2.2.10-alpha.
2021-01-13 15:23:27 +02:00
Nick Mathewson
01be7cc535 Bump to 0.4.5.3-rc-dev 2021-01-12 16:08:07 -05:00
George Kadianakis
42e95c8d85 Merge branch 'maint-0.4.5' 2021-01-12 18:05:32 +02:00
David Goulet
9b59ede8d3 Merge branch 'ticket40237_044_01' into ticket40237_045_01 2021-01-12 10:55:21 -05:00
David Goulet
b3652f2104 Merge branch 'ticket40237_043_01' into ticket40237_044_01 2021-01-12 10:54:31 -05:00
David Goulet
0485c7ddba tests: Fix unit tests after merge of #40237 2021-01-12 10:50:01 -05:00
David Goulet
60da5d6222 Merge branch 'ticket40237_035_01' into ticket40237_043_01 2021-01-12 10:46:25 -05:00
David Goulet
04b0263974 hs-v3: Require reasonably live consensus
Some days before this commit, the network experienced a DDoS on the directory
authorities that prevented them to generate a consensus for more than 5 hours
straight.

That in turn entirely disabled onion service v3, client and service side, due
to the subsystem requiring a live consensus to function properly.

We know require a reasonably live consensus which means that the HSv3
subsystem will to its job for using the best consensus tor can find. If the
entire network is using an old consensus, than this should be alright.

If the service happens to use a live consensus while a client is not, it
should still work because the client will use the current SRV it sees which
might be the previous SRV for the service for which it still publish
descriptors for.

If the service is using an old one and somehow can't get a new one while
clients are on a new one, then reachability issues might arise. However, this
is a situation we already have at the moment since the service will simply not
work if it doesn't have a live consensus while a client has one.

Fixes #40237

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-01-12 09:46:35 -05:00
Nick Mathewson
ca6ccd372f Reject obsolete router/extrainfo descs more quietly.
Thanks to proposal 315 / ticket #30132, more fields are now
required in these documents.  But ancient Tors that try to upload
obsolete documents were causing the authorities to log warnings
about missing fields, and to do so very spammily.

We now detect the missing fields before tokenizing, and log at
debug.  This is a bit of ugliness, but it's probably a safer choice
than making _all_ unparseable-desc warnings into debug-level logs.

I'm looking at identity-ed25519 in extrainfos and proto in
routerdescs because they were (I believe) the latest-added fields in
Tor's history: any Tor that lacks them will also lack the other
newly required fields.

Fixes bug #40238; bugfix on 0.4.5.1-alpha.
2021-01-11 14:50:40 -05:00
Nick Mathewson
9c268b66ba Merge branch 'maint-0.4.5' 2021-01-11 14:46:13 -05:00
Nick Mathewson
5a822b462a Merge branch 'maint-0.4.3' into maint-0.4.4 2021-01-11 14:37:29 -05:00
Nick Mathewson
d1f4741606 Merge branch 'maint-0.4.4' into maint-0.4.5 2021-01-11 14:37:29 -05:00
Nick Mathewson
4b39f46a61 Merge branch 'maint-0.3.5' into maint-0.4.3 2021-01-11 14:37:28 -05:00
Nick Mathewson
ccdbbae4ec Fix warnings in current debian-hardened CI.
We're getting "fallback annotation annotation in unreachable code"
warnings when we build with ALL_BUGS_ARE_FATAL. This patch fixes
that.

Fixes bug 40241.  Bugfix on 0.3.5.4-alpha.
2021-01-11 14:25:56 -05:00
Nick Mathewson
edc9fda4f5 Increment version to 0.4.5.3-rc 2021-01-11 12:48:00 -05:00
Roger Dingledine
ee0a27293e fix typos and whitespace 2021-01-10 13:29:50 -05:00
Neel Chauhan
3d993d4d85 Do not require a valid torrc for 2021-01-06 10:41:27 -08:00
Neel Chauhan
1811bded77 Downgrade the severity of a few rendezvous circuit-related warnings. 2020-12-24 11:32:03 -08:00
David Goulet
e7da681034 Merge branch 'maint-0.4.5' 2020-12-21 14:55:44 -05:00
David Goulet
aae9a05a01 relay: Log address suggested by directory authorities
If we get an address suggestion from a directory authority and we have no
address configured or discovered, log it at notice level so the operator can
learn what address will be used by Tor.

Fixes #40201

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-12-21 14:41:52 -05:00
Nick Mathewson
ad00da663e Merge branch 'mr_240_squashed' into maint-0.4.5 2020-12-21 13:25:52 -05:00
Nick Mathewson
cce7d1edaf Merge branch 'mr_240_squashed' 2020-12-21 13:23:42 -05:00
David Goulet
f4cbcde2da test: Fix memleak in test/load_stats_file
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-12-21 13:18:20 -05:00
Karsten Loesing
5dd6304f36 Fix timestamp parser in new load_stats_file.
The previous parser only considered stats files _starting_ with the
timestamp tag, not stats files having the timestamp tag in a later
position. While this applies to all current stats files, a future
stats file might look differently. Better to fix the function now than
be surprised in another 9 years from now.

This commit also adds a test case for such future stats, and it fixes
stats file paths in newly added unit tests.
2020-12-21 13:18:20 -05:00
David Goulet
c934fced31 relay: Report the entire content of a stats file
It turns out that 9 years ago, we stopped appending data into stats file and
rather overwrite everytime we have new stats (see commit
a6a127c833)

The load_stats_file() function was still thinking that we could have the same
line many times in the file which turns out to be false since 9 years ago.
However, that did not cause problem until IPv6 connection stats came along
which introduced a new line in conn-stats: "ipv6-conn-bi-direct ...".

Before, that file contained a single line starting with the tag
"conn-bi-direct".  That very tag appears also in the IPv6 tag (see above) so
the load_stats_file() function would consider that the IPv6 line as the last
tag to be appeneded to the file and fail to report the line above (for IPv4).
It would actually truncate the IPv6 line and report it (removing the "ipv6-"
part).

In other words, "conn-bi-direct" was not reported and instead
"ipv6-conn-bi-direct" was used without the "ipv6-" part.

This commit refactors the entire function so that now it looks for a
"timestamp tag" to validate and then if everything is fine, returns the entire
content of the file. The refactor simplifies the function, adds logging in
case of failures and modernize it in terms of coding standard.

Unit tests are also added that makes sure the loaded content matches the
entire file if timestamp validation passes.

Fixes #40226

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-12-21 13:18:20 -05:00
Alexander Færøy
db5f7b4250 Merge remote-tracking branch 'tor-gitlab/mr/211' 2020-12-18 14:22:23 +00:00
Alexander Færøy
b645fbdb54 Merge remote-tracking branch 'tor-gitlab/mr/207' 2020-12-18 14:19:24 +00:00
David Goulet
5527aef56f Merge branch 'maint-0.4.5' 2020-12-17 08:25:29 -05:00
David Goulet
d45354d5ea Merge branch 'tor-gitlab/mr/243' into maint-0.4.5 2020-12-17 08:25:18 -05:00
George Kadianakis
d89974c5c6 Fix Keccak undefined behavior on exotic platforms.
Bug reported and diagnosed in:
    https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=975977

Fixes bug #40210.
2020-12-17 13:49:17 +02:00
Alexander Færøy
0bd4cd8101 Merge remote-tracking branch 'tor-gitlab/mr/230' 2020-12-16 20:55:03 +00:00
Alexander Færøy
66597b9291 Merge branch 'maint-0.4.5' 2020-12-16 20:39:01 +00:00
Alexander Færøy
5a2d01ae57 Merge branch 'tor-gitlab/mr/234' into maint-0.4.5 2020-12-16 20:38:23 +00:00
David Goulet
ee6ad0e592 config: Catch missing Bridge for ClientTransportPlugin
When making sure we have a Bridge line with a ClientTransportPlugin, we
now check in the managed proxy list and so we can catch any missing
ClientTransportPlugin for a Bridge line.

Fixes #40106

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-12-16 20:37:57 +00:00
David Goulet
1430d5ff63 Merge branch 'maint-0.4.5' 2020-12-15 11:58:22 -05:00
David Goulet
4a77aa6e82 Merge branch 'tor-gitlab/mr/239' into maint-0.4.5 2020-12-15 11:58:13 -05:00
George Kadianakis
c731a4efec Merge remote-tracking branch 'tor-gitlab/mr/205' into maint-0.4.5 2020-12-15 16:28:49 +02:00
George Kadianakis
c05ae61f26 Merge remote-tracking branch 'tor-gitlab/mr/205' 2020-12-15 16:28:04 +02:00
Nick Mathewson
c4fe66e342 Socks5: handle truncated client requests correctly
Previously, our code would send back an error if the socks5 request
parser said anything but DONE.  But there are other non-error cases,
like TRUNCATED: we shouldn't send back errors for them.

This patch lowers the responsibility for setting the error message
into the parsing code, since the actual type of the error message
will depend on what problem was encountered.

Fixes bug 40190; bugfix on 0.3.5.1-alpha.
2020-12-14 10:14:03 -05:00
George Kadianakis
04b271af9f Merge remote-tracking branch 'tor-gitlab/mr/232' 2020-12-11 15:56:13 +02:00
Nick Mathewson
ce1c3c6898 Fix a typo in coverage builds.
We should be using TOR_STATIC_LDFLAGS, not TOR_STATIC_LDFALGS.

Bug not in any released version of Tor.
2020-12-09 13:31:34 -05:00
Nick Mathewson
2bfb76b927 Merge branch 'mr_224_squashed' 2020-12-09 10:03:45 -05:00
Alexander Færøy
ed3f46a385 Announce URL to bridge status page when starting Tor as a bridge relay.
This patch makes Tor announce the relay specific bridge status page URL
when Tor is starting up before bootstrap occours.

See: tor#30477
2020-12-09 10:03:11 -05:00
Daniel Pinto
bd0046c9ec Avoid sandbox bug warning when unglobbing patterns #40094
Adds a more user-friendly error message when the configuration is
reloaded and a new %include is added that makes its unglobbing
access files/folders not allowed by the seccomp sandbox.
2020-12-08 15:00:43 -05:00
Nick Mathewson
baef0843a4 Fix a couple of documentation comments related to #40094 2020-12-08 14:59:28 -05:00
David Goulet
6e83a52077 Merge branch 'maint-0.4.5' 2020-12-08 14:51:43 -05:00
David Goulet
e74f168bb4 relay: Avoid log reachability test for bandwidth test circuit
Fixes #40205

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-12-08 14:51:31 -05:00
Neel Chauhan
8a2910461b Reinstate add_onion_helper_add_service() test, validate auth clients before adding them 2020-12-08 11:24:27 -08:00
Neel Chauhan
65d60a16d9 Remove unused NULL check in hs_service_add_ephemeral(), mention we take ownership of auth_clients_v3 2020-12-08 10:47:05 -08:00
George Kadianakis
f280c171e2 Merge branch 'mr/233' 2020-12-08 16:54:18 +02:00
Nick Mathewson
558aaf1c32 Command-line arguments: be better at detecting absent optional args.
Previously, "--list-fingerprint --quiet" was an error.  Now, the
handler for optional arguments to "--list-fingerprint" can tell that
"--quiet" is a flag, not an argument.

This only affects flags that take an _optional_ argument, so you can
still put your torrc file in a location starting with "-".

Closes #40223.
2020-12-08 16:53:57 +02:00
David Goulet
2d0a7f2e89 Merge branch 'maint-0.4.5' 2020-12-08 09:15:06 -05:00
David Goulet
c618c4f279 configure: Fix the --enable-static-tor switch
The "-static" compile flag was set globally which means that all autoconf test
were attempting to be built statically and lead to failures of detecting
OpenSSL libraries and others.

This commit adds this flag only to the "tor" binary build.

There is also a fix on where to find libevent.a since it is using libtool, it
is in .libs/.

At this commit, there are still warnings being emitted that informs the user
that the built binary must still be linked dynamically with glibc.

Fixes #40111

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-12-08 09:14:49 -05:00
Nick Mathewson
a09eb66cc7 Merge remote-tracking branch 'tor-gitlab/mr/219' 2020-12-08 08:19:37 -05:00
Neel Chauhan
599af15159 Fix formatting in comment in parse_port_config() 2020-12-03 20:50:18 -08:00
Neel Chauhan
7d54734900 More logic corrections 2020-12-03 17:40:55 -08:00
Nick Mathewson
6c602026e8 Detect extra bytes in HAProxy inbuf when transitioning to OR handshake
This shouldn't be possible, but let's add it for defense-in-depth.

Closes #40017.
2020-12-02 10:07:26 -05:00
Daniel Pinto
328f38a59f Use atomic ops to access lock_owner in WIN32 tor_mutex_t #17927 2020-11-30 02:54:13 +00:00
Samanta Navarro
2a06b7c3b8 Support Python 3.8 in hs_build_address.py
The Python code is such a nice addition to the documentation and the C
code for better understanding of onion v3 address generation. Straight
to the point and easy to understand.

Unfortunately it did not work with my distribution's Python version. I
have adjusted the code to support Python 3.8 (tested with 3.8.6) and
to still be compatible with Python 2.
2020-11-28 11:38:43 +00:00
Alexander Færøy
7640631539 Fix build on 32-bit Windows.
Currently Tor fails with the following error:

    src/test/test_stats.c: In function ‘test_rephist_v3_onions’:
    src/test/test_stats.c:527:22: error: overflow in implicit constant conversion [-Werror=overflow]
       update_approx_time(10101010101);

This patch changes the constant passed to update_approx_time() to avoid
the overflow in the implicit conversion.

See: tor#40199
2020-11-25 17:16:24 +00:00
Neel Chauhan
be6db23d1d Some test and logic corrections 2020-11-24 20:47:31 -08:00
David Goulet
fd80979786 Merge branch 'tor-gitlab/mr/221' 2020-11-24 10:26:17 -05:00
Roger Dingledine
4f1e38ec8e fix two trivial comment mistakes 2020-11-23 14:08:42 -05:00
Nick Mathewson
2f87b2ab75 bump to 0.4.5.2-alpha-dev 2020-11-23 14:03:53 -05:00
George Kadianakis
eaf814bd50 Constify result of CONST_TO_OR_CIRCUIT. 2020-11-23 13:35:26 +02:00
George Kadianakis
0bd12cfe99 Revert HSv3 stats string formatting to its old %u self.
The rest of rephist.c is doing the same kind of unsigned casting. For example
see rep_hist_format_buffer_stats() and rep_hist_format_exit_stats().

The previous switch to %ld made Appveyor fail:
    https://ci.appveyor.com/project/torproject/tor/builds/36118502
2020-11-23 13:35:26 +02:00
Nick Mathewson
73fb44dcba Bump to 0.4.5.2-alpha. 2020-11-21 15:09:08 -05:00
Neel Chauhan
0522f0e507 Fix ControlSocketsGroupWritable typo 2020-11-21 11:12:07 -08:00
Neel Chauhan
157fe4597e Add tests for bug #40084 2020-11-19 12:00:56 -08:00
Alexander Færøy
9bc0306b8c Merge branch 'maint-0.4.5' 2020-11-19 17:44:00 +00:00
Alexander Færøy
b274e46309 Merge branch 'maint-0.4.4' into maint-0.4.5 2020-11-19 17:44:00 +00:00
Alexander Færøy
77bb4b0838 Merge branch 'maint-0.4.3' into maint-0.4.4 2020-11-19 17:43:59 +00:00
Alexander Færøy
2e7cbd7a9c Merge remote-tracking branch 'tor-gitlab/mr/196' into maint-0.4.3 2020-11-19 17:43:44 +00:00
Alexander Færøy
6ce2550468 Merge branch 'maint-0.4.5' 2020-11-19 17:41:05 +00:00
Nick Mathewson
c4e0b28ecb Merge remote-tracking branch 'tor-gitlab/mr/214' into master 2020-11-19 10:42:04 -05:00
David Goulet
ea52705e4b config: Bridge line with a transport must have a ClientTransportPlugin
Fixes #25528

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-11-18 11:31:37 -05:00
George Kadianakis
34feedea60 Merge remote-tracking branch 'tor-gitlab/mr/216' 2020-11-18 12:37:02 +02:00
David Goulet
16351d655d sendme: Turn log warning into debug
When sending the stream level SENDME, it is possible the cirucit was marked
for close or any other failures that can occur. These events can occur
naturally.

Fixes #40142

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-11-17 13:23:34 -05:00
David Goulet
0921fdf633 Merge branch 'maint-0.4.5' into master 2020-11-17 12:25:56 -05:00
David Goulet
07006785fd Merge branch 'tor-gitlab/mr/203' into maint-0.4.5 2020-11-17 12:25:48 -05:00
Neel Chauhan
bc968097f2 Fix script failures 2020-11-17 11:23:08 -05:00
Neel Chauhan
1588767e65 Allow listing ed25519 fingerprints on the command line 2020-11-17 11:23:08 -05:00
Nick Mathewson
3900b19379 Merge branch 'maint-0.4.5' into master 2020-11-17 10:53:39 -05:00
David Goulet
7c06707750 Merge branch 'tor-gitlab/mr/182' into master 2020-11-17 10:36:05 -05:00
David Goulet
d04a27bed2 config: Really ignore non ORPorts when removing duplicates
The function in charge of removing duplicate ORPorts from our configured ports
was skipping all non ORPorts port but only for the outer loop thus resulting
in comparing an ORPort with a non-ORPort which lead to problems.

For example, tor configured with the following would fail:

  ORPort auto
  DirPort auto

Both end up being the same configuration except that one is a OR listener and
one is a Dir listener. Thus because of the missing check in the inner loop,
they looked exactly the same and thus one is removed.

Fixes #40195

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-11-17 09:40:16 -05:00
Nick Mathewson
6c61011781 Merge remote-tracking branch 'tor-gitlab/mr/184' into master 2020-11-17 08:22:44 -05:00
Nick Mathewson
aed2a48c66 Bump version to 0.4.6.0-alpha-dev 2020-11-17 08:01:08 -05:00
Nick Mathewson
b13f32ee97 Merge branch 'ticket40071_045_01_squashed' into master 2020-11-17 07:58:37 -05:00
David Goulet
bc5f26ff70 relay: Launch dummy circuit only when descriptor build fails
First, this commit moves the launch_dummy_circuit_as_needed() function into
relay_find_addr.c and renames it to relay_addr_learn_from_dirauth(). This is
an attempt to centralize anything relate with address discovery in the right
module.

Second, when building a descriptor and we fail to discover our address,
immediately launch a dummy circuit to an authority in an attempt to learn our
descriptor.

It is still only done every 20 minutes even though the descriptor build is
done every minute. We ought to avoid load on the authority and if we can't
learn in the first place our address from them, chances are more things are
wrong.

Related to #40071

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-11-17 07:58:26 -05:00
David Goulet
a5538a3603 relay: Look at our cache when looking for an IP change
Regularly, tor looks if its IP has changed. It does the entire auto discovery
process again. However, it is possible that it does not find anything.

Instead of thinking the IP changed to an unknown address, look at our cache
and see if that value has changed.

The reason for this is because if tor gets its address as a suggestion from a
directory authority, it is because the auto discovery failed and thus that
address should be consider for the IP change check.

Related to #40071

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-11-17 07:58:26 -05:00
David Goulet
4b98140733 relay: Use testing circuit instead of dummy descriptor fetch
Tor now can learn its address from a NETINFO cell coming from an authority.
Thus, instead from launching a dummy descriptor fetch to learn the address
from the directory response (unauthenticated), we simply now launch a one-hop
testing circuit.

Related to #40071

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-11-17 07:58:26 -05:00
Guinness
4382e977f7
Add the compiler name, version and libs used to compile
This changes the behaviour of `tor --version` in such a way.
```console
src/app/tor --version
Tor version 0.4.5.1-alpha-dev (git-46ccde66a97d7985).
Tor is running on Linux with Libevent 2.1.12-stable, OpenSSL 1.1.1h, Zlib 1.2.11, Liblzma 5.2.4, Libzstd 1.4.5 and Glibc 2.31 as libc.
Tor compiled with GCC version 10.2.0
```

Fixes #32102
2020-11-17 10:43:00 +01:00
Nick Mathewson
41bea71adc Merge remote-tracking branch 'tor-gitlab/mr/197' into master 2020-11-16 22:43:09 -05:00
Nick Mathewson
c79957581e Merge branch 'maint-0.4.4' into master 2020-11-16 22:42:23 -05:00
Nick Mathewson
9001732394 Merge branch 'maint-0.4.3' into maint-0.4.4 2020-11-16 22:42:22 -05:00
Nick Mathewson
7c0778ef7e Merge branch 'maint-0.3.5' into maint-0.4.3 2020-11-16 22:42:22 -05:00
Nick Mathewson
fcae26adf7 Merge remote-tracking branch 'tor-gitlab/mr/195' into maint-0.3.5 2020-11-16 22:42:15 -05:00
Neel Chauhan
8785a75e2f Give a descriptive error message with "tor-gencert --create-identity-key" 2020-11-16 09:35:23 -08:00
Neel Chauhan
af48afe667 Unbreak build 2020-11-16 08:47:12 -08:00
Neel Chauhan
eacf528915 Add support for creating v3 onion services form the control port 2020-11-15 16:02:59 -08:00
David Goulet
d425dbf04a port: Don't ignore ports of a different family
Commit c3a0f75796 added this feature for ORPort
that we ignore any port that is not the family of our default address when
parsing the port. So if port_parse_config() was called with an IPv4 default
address, all IPv6 address would be ignored.

That makes sense for ORPort since we call twice port_parse_config() for
0.0.0.0 and [::] but for the rest of the ports, it is not good since a
perfectly valid configuration can be:

  SocksPort 9050
  SocksPort [::1]:9050

Any non-ORPort only binds by default to an IPv4 except the ORPort that binds
to both IPv4 and IPv6 by default.

The fix here is to always parse all ports within port_parse_config() and then,
specifically for ORPort, remove the duplicates or superseding ones. The
warning is only emitted when a port supersedes another.

A unit tests is added to make sure SocksPort of different family always exists
together.

Fixes #40183

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-11-13 08:38:22 -05:00
Daniel Pinto
877dbfc056 Use SRWLocks to implement locking on Windows #17927
Replace the Windows locking implementation which used critical
sections with the faster SRWLocks available since Vista.
2020-11-12 19:50:55 +00:00
Neel Chauhan
d1494d140c Remove orconn_ext_or_id_map and related functions 2020-11-12 11:19:21 -08:00
Neel Chauhan
46ccde66a9 Use connection_or_change_state() in v3 handshaking state change 2020-11-12 12:06:34 -05:00
Nick Mathewson
dbc8d2a4e4 When handling includes, detect missing interned strings earlier.
There were three separate places where we were hitting a sandbox Bug
warning before we actually exited.

Fixes #40094; bugfix on 0.3.1.1-alpha when %includes were introduced.
2020-11-12 11:55:55 -05:00
Samanta Navarro
4a0cd79588 Fix typos.
Typos found with codespell.

Please keep in mind that this should have impact on actual code
and must be carefully evaluated:

src/core/or/lttng_circuit.inc
-    ctf_enum_value("CONTROLER", CIRCUIT_PURPOSE_CONTROLLER)
+    ctf_enum_value("CONTROLLER", CIRCUIT_PURPOSE_CONTROLLER)
2020-11-12 11:44:09 -05:00
Nick Mathewson
ffa7b15950 Deliberately close OR connections if proxies leave extra data
We already did this, but we did it by accident, which is pretty
risky: if we hadn't, then our code would have treated extra data in
the inbuf as having been transmitted as TLS-authenticated data.

Closes ticket 40017; Found by opara.
2020-11-12 11:07:33 -05:00
Nick Mathewson
f2168d28f7 Fake the current time when we're loading TEST_DESCRIPTORS.
Fixes bug 40187; bugfix on 0.4.5.1-alpha.
2020-11-12 09:28:27 -05:00
Nick Mathewson
7d8290f0ac Merge remote-tracking branch 'tor-gitlab/mr/183' into master 2020-11-12 08:47:05 -05:00
Nick Mathewson
3f1544bbd9 Bump to 0.4.4.6-dev 2020-11-12 08:13:07 -05:00
Nick Mathewson
fd22fa183b Bump to 0.4.3.7-dev 2020-11-12 08:12:11 -05:00
Nick Mathewson
862c44e4ec Bump to 0.3.5.12-dev 2020-11-12 08:11:01 -05:00
Nick Mathewson
210a94b231 Bump to 0.4.4.6 2020-11-09 17:13:02 -05:00
Nick Mathewson
6338c35e9d Bump to 0.4.3.7 2020-11-09 17:12:41 -05:00
Nick Mathewson
665083be9f Bump to 0.3.5.12 2020-11-09 17:12:18 -05:00
Nick Mathewson
ec0f000445 Merge branch 'maint-0.4.3' into maint-0.4.4 2020-11-09 16:17:42 -05:00
Nick Mathewson
0b2c64effd Merge branch 'maint-0.3.5' into maint-0.4.3 2020-11-09 16:13:42 -05:00
Nick Mathewson
52e439c13e Merge remote-tracking branch 'tor-gitlab/mr/189' into maint-0.3.5 2020-11-09 16:13:24 -05:00
Alexander Færøy
0702cf10db Merge remote-tracking branch 'tor-gitlab/mr/192' 2020-11-09 14:15:03 +00:00
Alexander Færøy
5e65a746aa Merge remote-tracking branch 'tor-gitlab/mr/190' 2020-11-09 14:12:45 +00:00
Nick Mathewson
b22568a545 Rename OpenSSL_version_num() as defined in Tor
This way, if we guess wrong about whether the library has it,
we don't conflict with the library's headers.

Fixes #40181; bug not in any released version.
2020-11-06 10:31:32 -05:00
Nick Mathewson
4154158d79 Make config/parse_tcp_proxy_line work in the presence of DNS hijacking
We can use our existing mocking functionality to do this: We have
been in this position before.

Fixes part of #40179; bugfix on 0.4.3.1-alpha.
2020-11-05 09:47:32 -05:00
Nick Mathewson
31a6a101a0 Handle a change in the implementation of hashlib in Python 3.9
Previously, hashlib.shake_256 was a class (if present); now it can
also be a function.  This change invalidated our old
compatibility/workaround code, and made one of our tests fail.

Fixes bug 40179; bugfix on 0.3.1.6-rc when the workaround code was
added.
2020-11-05 09:34:36 -05:00
George Kadianakis
0812ecd517 Add more docs about the HSv3 stat collection period. 2020-11-03 19:19:02 +02:00
George Kadianakis
810183aaf1 Improve string formatting in rep_hist_format_hs_stats(). 2020-11-03 19:15:01 +02:00
George Kadianakis
7ae576edaf Use CONST_TO_OR_CIRCUIT() in v2/v3 rend cell detection. 2020-11-03 19:14:57 +02:00
George Kadianakis
9a98d1da30 Switch v3_onions_seen_this_period to digest256map_t. 2020-11-03 19:14:57 +02:00
George Kadianakis
dd119b277b Merge remote-tracking branch 'tor-gitlab/mr/185' into master 2020-11-03 16:06:12 +02:00
George Kadianakis
4f5a116618 Merge remote-tracking branch 'tor-gitlab/mr/187' into master 2020-11-03 13:04:09 +02:00
George Kadianakis
a96432ab06 Abstract v2/v3 "format stats to str" logic into a single function. 2020-11-03 11:12:17 +02:00
George Kadianakis
6178a64fcf Abstract v2/v3 "write stats to file" logic into a single function. 2020-11-03 11:12:17 +02:00
George Kadianakis
131da887d7 Write unittests for v3 metrics. 2020-11-03 11:12:17 +02:00
George Kadianakis
5c00bee1b1 Introduce v3 stat formatting functions.
They will be merged with the v2 ones in later commits.
2020-11-03 11:12:17 +02:00
George Kadianakis
d0be2ae7f9 Extend get_voting_interval() so that it's callable by relays.
In the past, only authorities and clients had to use that function because of
the SRV subsystem. However, because of its use in rep_hist_hs_stats_init() it
will now also be used by relays when bootstrapping without a consensus. Make it
do something sensible.

Another approach (instead of using magic values) would be to wait
initialization of HSv3 stats until we get a consensus but that seems messy to
schedule.

Another approach would be to make dirauth_sched_get_configured_interval() also
work for relays (particularly when TestingNetwork is enabled), but that also
seems a good amount of work.
2020-11-03 11:12:17 +02:00
George Kadianakis
f2eff17126 Introduce generic HS stats methods that apply to v2 and v3. 2020-11-03 11:12:17 +02:00
George Kadianakis
3cbc513ae7 Implement support for "v3 rend traffic" stat. 2020-11-03 11:09:34 +02:00
George Kadianakis
05880d238a Implement support for "unique v3 onions" stat. 2020-11-03 11:09:34 +02:00
George Kadianakis
bd28551763 Introduce v3_stats_t structure and some of its methods. 2020-11-03 11:09:24 +02:00
George Kadianakis
5ed7fcec41 Make room for v3: Complete move from hs_stats_t to hs_v2_stats_t. 2020-11-02 21:05:50 +02:00
George Kadianakis
1de7843658 Make room for v3: s/hs_stats/hs_v2_stats/ 2020-11-02 21:05:05 +02:00
George Kadianakis
62d682e624 Make room for v3: Rename rephist objects to signify they are v2-only. 2020-11-02 21:04:43 +02:00
David Goulet
474369e3fa Merge branch 'tor-gitlab/mr/186' 2020-11-02 13:14:02 -05:00
David Goulet
8b240fbe40 Merge branch 'tor-gitlab/mr/188' 2020-11-02 13:09:15 -05:00
David Goulet
dc6438b549 or: Missing .inc file in include.am
Fixes #40173

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-11-02 08:25:48 -05:00
Nick Mathewson
7a75a1064f Fix another duplicate typedef.
Fixes #40177; bugfix on 0.4.5.1-alpha.
2020-11-02 07:15:10 -05:00
Nick Mathewson
aa85284038 Update to 0.4.5.1-alpha-dev 2020-11-01 16:41:56 -05:00
Daniel Pinto
f3b9be4422 Implement WIN32 tor_cond_wait using condition variables #30187
Fix bug where running a relay on Windows would use 100% CPU
after some time. Makes Windows >= Vista the required Windows
version to build and run tor.
2020-11-01 03:10:25 +00:00
Nick Mathewson
e01f586e05 Bump version to 0.4.5.1-alpha 2020-10-30 11:05:22 -04:00
Nick Mathewson
148b5b03a3 Merge branch 'bug40080_035' 2020-10-30 10:51:20 -04:00
George Kadianakis
54e6109499 Merge remote-tracking branch 'tor-gitlab/mr/174' into master 2020-10-30 14:14:14 +02:00
Nick Mathewson
df16376004 Fix duplicate typedef in metrics_store_entry.h
Fixes #40171. Bug not in any released Tor.
2020-10-28 16:36:14 -04:00
Nick Mathewson
f7d0bde4f0 Remove "GETINFO network-status".
It was deprecated 0.3.1.1-alpha.

According to #22473, nothing uses it.

Closes #22473.
2020-10-28 11:48:23 -04:00
Alexander Færøy
b0e6ec627c Merge branch 'maint-0.4.3' into maint-0.4.4 2020-10-28 15:39:37 +00:00
Alexander Færøy
4876409c2a Merge branch 'maint-0.3.5' into maint-0.4.3 2020-10-28 15:39:37 +00:00
Nick Mathewson
3f442987f1 Log a warning if Tor was built with any "risky" compile-time options
These options are meant for testing builds only, and are likely to
cause trouble if used in a production environment.

Closes #18888.
2020-10-28 11:34:30 -04:00
Alexander Færøy
c37d05d0c6 Merge remote-tracking branch 'tor-gitlab/mr/171' 2020-10-28 15:15:39 +00:00
Nick Mathewson
c48d25ac8d Fix a previously overstrict log message check.
OpenSSL doesn't seem to report error locations in the same way as
before, which broke one of our tests.

Fixes bug 40170; bugfix on 0.2.8.1-alpha.
2020-10-28 10:47:39 -04:00
Nick Mathewson
2b4a3d07b2 Do not define OPENSSL_VERSION in compat_openssl.h
Apparently it conflicts with definitions elsewhere in Openssl 3.0.0.
2020-10-28 10:32:06 -04:00
Nick Mathewson
d9221968ce Include a more modest openssl header in crypto_openssl_mgt.h
The "engines.h" header has lots of stuff; the "opensslv.h" header
has the version number, which is all we actually need here.

We need to do this because we're about to change this header to
conditionally define OPENSSL_SUPPRESS_DEPRECATED, and it would be
too late to do so if we'd already included "engines.h".
2020-10-28 10:11:42 -04:00
Nick Mathewson
511822529a Revise fix for bug 32178 (spaces at end of log msg).
The loop in the earlier patch would invoke undefined behavior in two
ways: First, it would check whether it was looking at a space before
it checked whether the pointer was in-range.  Second, it would let a
pointer reach a position _before_ the start of a string, which is
not allowed.

I've removed the assertion about empty messages: empty messages can
be their own warning IMO.

I've also added tests for this formatting code, to make sure it
actually works.
2020-10-28 09:41:51 -04:00
Amadeusz Pawlik
ec7a6757ec Removes trailing spaces in control event log 2020-10-28 09:08:53 -04:00
David Goulet
2edda444da test: Missing tor_free() in metrics unit tests
Found by coverity:

  *** CID 1468664:  Resource leaks  (RESOURCE_LEAK)
  /src/test/test_metrics.c: 83 in test_config()
  77       tt_int_op(ret, OP_EQ, false);
  78
  79      done:
  80       SMARTLIST_FOREACH(ports, port_cfg_t *, c, port_cfg_free(c));
  81       smartlist_free(ports);
  82       or_options_free(options);
  >>>     CID 1468664:  Resource leaks  (RESOURCE_LEAK)
  >>>     Variable "err_msg" going out of scope leaks the storage it points to.
  83     }
  84
  85     static char _c_buf[256];
  86     #define CONTAINS(conn, msg) \
  87       do { \
  88         tt_int_op(buf_datalen(conn->outbuf), OP_EQ, (strlen(msg))); \

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-28 08:52:02 -04:00
Neel Chauhan
09b3af578d Stop forcing IPv4 and IPv6 traffic on non-SOCKSPorts 2020-10-27 17:57:48 -07:00
Neel Chauhan
0c79cddc6b Avoid asserts with flag 2020-10-27 14:47:42 -07:00
David Goulet
362229f184 lib/metrics: Fix wrong macro expansion
The "METRICS_PREFIX" was not expanded but rather used as a litteral. Fix that
by just removing the define and using "tor_" directly.

Reviewed-by: Alexander Færøy <ahf@torproject.org>
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 13:00:20 -04:00
David Goulet
5de6673972 metrics: Add tor_ namespace to all metrics
Closes #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
238340ce54 test: Add test for onion service metrics module
Related to #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
f65c0820af test: Metrics tests for lib/ and feature/
Related to #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
4c19eed35c tests: Fix unit tests after adding new HS metrics module
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
1c06c9f1c0 doc: Initial documentation of the lib/metrics
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
97731196c4 hs: Collect introduction circuit metrics
Tracks the total number of established introduction circuit.

Related to #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
c081bee38a hs: Collect rendezvous circuit metrics
The total number of rendezvous circuit created and the number of established
ones which is a gauge that decreases to keep an updated counter.

Related to #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
2fe0322fe4 hs: Collect service traffic metrics
Related to #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
695957511b hs: Always note the virtual port in the ident
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
50f44afeb4 hs: New metrics module
At this commit, a new service registers to the module and a store is created.
It also remove itself from the metrics module if it goes away.

In order to hook into the metrics subsystem, this commit attaches the HS
subsystem into the subsystem global list so its get_metrics() call can be
accessible.

HS initialization is still _not_ done through the subsys module as it is
likely require much more testing.

Related to #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
4f5cea1f59 conn: New Metrics listener port
If MetricsPort is defined, listen on it and handle the incoming request.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
a882d1bf0a metrics: New feature module to track tor metrics
Related to #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
ec731290a5 lib: New metrics library
Used to provide an interface to create metrics store and update the entries.

Related to #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
26cfac1880 Merge branch 'tor-gitlab/mr/176' into maint-0.4.4 2020-10-27 10:18:16 -04:00
David Goulet
6338fc2afa Merge branch 'tor-gitlab/mr/173' 2020-10-27 09:43:04 -04:00
David Goulet
683c794273 Merge branch 'tor-gitlab/mr/176' 2020-10-27 09:36:16 -04:00
Nick Mathewson
c90535c539 Merge branch 'maint-0.4.4' 2020-10-26 16:39:31 -04:00
George Kadianakis
07f2a06c61 Merge remote-tracking branch 'tor-gitlab/mr/169' into master 2020-10-26 17:04:58 +02:00
Nick Mathewson
f43fe890dd Merge remote-tracking branch 'tor-gitlab/mr/127' 2020-10-23 11:47:40 -04:00
Nick Mathewson
fd58e74ddc Update required/recommended protocol lists more systematically
First I began with a set of candidates:

  The client's _required_ list starts with all the protocols
  supported by every release in 0.2.9-stable through current
  master.

  The client's _required_ list starts with all the protocols
  supported by every release in 0.3.5-stable through current
  master.

  Everybody's _recommended_ list starts with all the protocols
  supported by every release in 0.3.5-stable through current master.

Then I removed the protocol versions that we do not actually want to
require or recommend:

  DirCache=1 (deprecated)
  HSDir=1, HSIntro=1-3, HSRend=1 (deprecated)
  (All HS* protocol requirements for clients)
  Link=1-3 (deprecated)
  LinkAuth=1 (obsolete)
  Relay=1 (obsolete)
2020-10-23 11:23:08 -04:00
Nick Mathewson
2908086694 Merge branch 'combined_libs' 2020-10-23 10:33:07 -04:00
Roger Dingledine
00118355f5 Turn ConsensusParams into a Linelist
Make it possible to specify multiple ConsensusParams torrc
lines.

Now directory authority operators can for example put the
main ConsensusParams config in one torrc file and then add to it
from a different torrc file.

Closes ticket 40164.
2020-10-22 03:26:03 -04:00
David Goulet
0d420918e7 main: Off by one when dumping subsystem list
Fixes #40163

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-21 13:48:37 -04:00
Daniel Pinto
bb9707420e Allow mutiple lines on configuration for ROUTERSET entries. #28361
Affected entries are: EntryNodes, ExcludeNodes, ExcludeExitNodes,
ExitNodes, MiddleNodes, HSLayer2Nodes and HSLayer3Nodes.
2020-10-21 01:53:50 +01:00
Guinness
0668437b58
Set is_padding_timer_scheduled to 0
When calling `circpad_send_padding_cell_for_callback()`, the flag
`is_padding_timer_scheduled` was not resetted to 0 which caused an issue
in the circpad simulator.
This commit fixes this problem.

Fixes #32671.
2020-10-20 21:04:33 +02:00
Nick Mathewson
579f200efc Merge branch 'mr_175_squashed' 2020-10-20 09:03:26 -04:00
Guinness
5248d08ede Consider 301 as an error like 404
Tor does not follow redirects when bootstraping so we encountered an
error.

Fixes #40053
2020-10-20 08:57:42 -04:00
George Kadianakis
19302a1dfd Merge remote-tracking branch 'tor-gitlab/mr/148' into master 2020-10-20 13:26:19 +03:00
Nick Mathewson
cb4cedae68 Explain why we use "mark_as_used_for_origin_circuit" where we do
Also, explain why it's relevant for bootstrapping.

This is a comments-only patch.
2020-10-19 11:45:24 -04:00
Nick Mathewson
f7adf3653f Simplify logic to use smartlist_add_asprintf() 2020-10-19 11:24:32 -04:00
Nick Mathewson
151d446aa1 Merge remote-tracking branch 'tor-gitlab/mr/167' 2020-10-19 11:15:20 -04:00
Nick Mathewson
d872c69255 Update required/recommended protocol versions.
Cons=1 is the old format of consensuses, without ed25519 keys. It
  is no longer required or recommended.

  Cons=2 is the new format of consensuses, with ed25519 keys. It
  is now required.

  (Similarly for Desc=1,2 and Microdesc=1,2)

No supported client or relay versions should be affected by this
change, since these versions are supported by clients and relays
running 0.2.9 and later.  It will only take effect once enough
authorities vote for it.

Closes ticket 40162.
2020-10-18 16:23:53 -04:00
Nick Mathewson
4298d87756 Split required/recommended protocol lists into multiple lines
This should make diffs easier to read.
2020-10-18 16:18:42 -04:00
Nick Mathewson
62667b49e9 Regenerate extample_extrainfo.inc and adjust tests. 2020-10-16 16:07:46 -04:00
Nick Mathewson
5032b8f178 Regenerate complete failing_routerdescs.inc and adjust tests accordingly. 2020-10-16 16:07:46 -04:00
Nick Mathewson
0031d2b0ad Update makedesc.py script so that it works with python3. 2020-10-16 16:07:46 -04:00
Nick Mathewson
98c4e218b8 Update slow_ed25519.py to work with python 3. 2020-10-16 16:07:46 -04:00
Nick Mathewson
5e2294c6fe Fix formats_rsa_ed25519 tests.
The "protos" field is mandatory, and so are Ed25519 signatures.

Also, remove formats_rsa (the version without Ed25519), since
RSA-only relays are no longer supported.
2020-10-16 16:07:46 -04:00
Nick Mathewson
84c13a35db Add pr= lines to test_dir_clip_unmeasured*. 2020-10-16 16:07:46 -04:00
Nick Mathewson
bae5ba8073 Fix a couple of routerstatus-based tests. 2020-10-16 16:07:46 -04:00
Nick Mathewson
61a5a303f9 Replace the contents of test_descriptors.inc with a new set.
Had to replace these since we're updating the list of required fields.

These are taken from a chutney instance.  Shockingly, this is enough
to make the test_dir_handle_get.c tests pass again.
2020-10-16 16:07:46 -04:00
Nick Mathewson
769882ea7c test_dir_handle_get: add ntor-onion-key to microdescriptor example
Shockingly, this test didn't break after this change!
2020-10-16 16:07:46 -04:00
Nick Mathewson
acf4225441 Fix up vote tests in test_dir_handle_get.
These tests used a hardcoded vote with a hardcoded digest.  That
vote didn't have any pr lines, and so it is now invalid. I've
adjusted the testing code so that it mocks the signature-checking,
so that we can more easily change the contents of the vote.
2020-10-16 16:07:46 -04:00
Nick Mathewson
36ea25c236 Fix the tests in test_microdesc.c
This was fairly simple: just had to replace the examples with ones
that had ntor keys.  There were a couple of example chutney
routerinfos that I had to replace too.

I also removed tests for producing microdescs via consensus methods
that we don't support any longer.
2020-10-16 16:07:46 -04:00
Nick Mathewson
bb275e3712 Fix router/dump_router_to_string_no_bridge_distribution_method
The descriptor it generated needed to include ed25519 keys; needed
to have a correct TAP crosscert.
2020-10-16 16:07:46 -04:00
Nick Mathewson
6d419a3da3 test_dir_common: make sure we include pr lines. Fixes 7 tests. 2020-10-16 07:40:54 -04:00
Nick Mathewson
e934d713b3 Mark as required fields from prop315.
This change breaks some unit tests; it's time to fix those in
subsequent commits.
2020-10-15 18:02:16 -04:00
Nick Mathewson
47d6eef190 Also, include ed25519 identities in connection_describe().
Related to #22668.
2020-10-15 10:53:45 -04:00
Nick Mathewson
5718f38c85 Add ed25519 identities to relay descriptions.
(Or at least, to all those relay descriptions that derive from
format_node_description()).

Closes #22668.
2020-10-15 10:29:01 -04:00
Nick Mathewson
93e7661fef Add a function to get an ed25519 ID from a routerinfo. 2020-10-15 10:20:42 -04:00
Nick Mathewson
33fb51a111 Protover: simplify implementation structure to use 64-bit property
Now that prop318 is in, we can simplify our representation for
protocol range sets to just be a bitmask.
2020-10-14 13:09:29 -04:00
Nick Mathewson
4a80dde43c Merge branch 'prop318_limit_protover_035' into prop318_limit_protover_045 2020-10-14 11:31:58 -04:00
Nick Mathewson
dd63b97288 Implement proposal 318: Limit protovers to 0..63
In brief: we go through a lot of gymnastics to handle huge protover
numbers, but after years of development we're not even close to 10
for any of our current versions.  We also have a convenient
workaround available in case we ever run out of protocols: if (for
example) we someday need Link=64, we can just add Link2=0 or
something.

This patch is a minimal patch to change tor's behavior; it doesn't
take advantage of the new restrictions.

Implements #40133 and proposal 318.
2020-10-14 11:28:37 -04:00
David Goulet
bb249a221f Merge branch 'tor-gitlab/mr/170' 2020-10-14 09:46:44 -04:00
Nick Mathewson
42a5e652cb Make OptimisticData always-on.
We've been using it for years, and it seems to work just fine.  This
patch removes the option and its network parameter.

Part of #40139
2020-10-13 14:38:32 -04:00
Nick Mathewson
ac311a38ec Make "usecreatefast" always-off.
Part of #40139, where I'm removing network parameters that we
shouldn't be looking at any longer.
2020-10-13 14:00:34 -04:00
Alexander Færøy
78aa037c41 Merge remote-tracking branch 'tor-gitlab/mr/161' 2020-10-13 13:50:14 +00:00
Neel Chauhan
05242f5555 Pass the SOCKS request address in relay begin cells 2020-10-12 20:46:42 -07:00
Alex Xu (Hello71)
29065db381 dirclient: print bandwidth usage on one line (#40159) 2020-10-08 09:48:38 -04:00
Nick Mathewson
c4812698c3 Remove long-obsolete members from the state file.
Tor has a feature to preserve unrecognized state file entries in
order to maintain forward compatibility.  But this feature, along
with some unused code that we never actually removed, led to us
keeping items that were of no use to the user, other than at worst
to preserve ancient information about them.

This commit adds a feature to remove obsolete entries when we load
the file.

Closes ticket 40137.
2020-10-07 20:46:37 +03:00
Nick Mathewson
2ceea13140 Merge remote-tracking branch 'tor-gitlab/mr/164' 2020-10-07 09:42:37 -04:00
Nick Mathewson
741edf1b45 Merge remote-tracking branch 'tor-github/pr/1827/head' into maint-0.3.5 2020-10-07 09:29:07 -04:00
Nick Mathewson
40f0db75bd Merge branch 'maint-0.3.5' into maint-0.4.3 2020-10-07 08:38:30 -04:00
David Goulet
b404f085ad hs-v2: Add deprecation warning for service
If at least one service is configured as a version 2, a log warning is emitted
once and only once.

Closes #40003

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-07 08:38:23 -04:00
Nick Mathewson
0e2e517019 Merge branch 'maint-0.4.3' into maint-0.4.4 2020-10-07 08:35:18 -04:00
Neel Chauhan
884cad3edf Make HSFETCH take the decoded length into account, not the base32 one 2020-10-07 08:35:12 -04:00
Nick Mathewson
3e9fa5a029 Merge branch 'maint-0.3.5' into maint-0.4.3 2020-10-07 08:29:31 -04:00
Nick Mathewson
5f5587ee50 Merge remote-tracking branch 'tor-gitlab/mr/77' into maint-0.3.5 2020-10-07 08:29:23 -04:00
Nick Mathewson
701a1936fa Merge branch 'maint-0.3.5' into maint-0.4.3 2020-10-07 08:26:04 -04:00
Nick Mathewson
ad7ffa5240 Merge remote-tracking branch 'tor-gitlab/mr/79' into maint-0.3.5 2020-10-07 08:25:55 -04:00
Nick Mathewson
98e14720b5 Merge remote-tracking branch 'tor-github/pr/1661/head' into maint-0.3.5 2020-10-07 08:14:46 -04:00
Nick Mathewson
9587512578 Merge branch 'maint-0.3.5' into maint-0.4.3 2020-10-07 08:10:08 -04:00
Nick Mathewson
968b6c30c1 Merge remote-tracking branch 'tor-gitlab/mr/43' into maint-0.3.5 2020-10-07 08:09:59 -04:00
Nick Mathewson
8505dd5e37 Merge branch 'maint-0.4.3' into maint-0.4.4 2020-10-07 08:08:02 -04:00
Nick Mathewson
9029444482 Merge branch 'maint-0.3.5' into maint-0.4.3 2020-10-07 08:08:01 -04:00
Nick Mathewson
e0e0ef713e Merge remote-tracking branch 'tor-gitlab/mr/137' into maint-0.3.5 2020-10-07 08:07:53 -04:00
Nick Mathewson
8a561fc5bf Merge branch 'maint-0.3.5' into maint-0.4.3 2020-10-07 08:05:40 -04:00
Nick Mathewson
84a5bd48e2 Merge remote-tracking branch 'tor-gitlab/mr/103' into maint-0.3.5 2020-10-07 08:05:31 -04:00
Nick Mathewson
b5a88e8d47 Merge branch 'maint-0.3.5' into maint-0.4.3 2020-10-07 08:01:37 -04:00
Nick Mathewson
ed6a328297 Merge branch 'mr_124_squashed' into maint-0.3.5 2020-10-07 08:00:59 -04:00
Nick Mathewson
c5ba8b6221 Parallelize src/test/test into chunks.
First, we introduce a flag to teach src/test/test to split its work
into chunks.  Then we replace our invocation of src/test/test in our
"make check" target with a set of 8 scripts that invoke the first
8th of the tests, the second 8th, and so on.

This change makes our "make -kj4 check" target in our hardened
gitlab build more than twice as fast, since src/test/test was taking
the longest to finish.

Closes 40098.
2020-10-07 08:00:49 -04:00
George Kadianakis
438aba6c0b Merge branch 'maint-0.4.4' into master 2020-10-07 13:42:57 +03:00
George Kadianakis
a914ac5d7c Merge remote-tracking branch 'tor-gitlab/mr/154' into maint-0.4.4 2020-10-07 13:32:17 +03:00
George Kadianakis
84e825598a Merge branch 'maint-0.4.4' into master 2020-10-07 13:29:16 +03:00
George Kadianakis
149b7a2418 Merge remote-tracking branch 'tor-gitlab/mr/163' into maint-0.4.4 2020-10-07 13:29:00 +03:00
Alexander Færøy
5f61e19d8a Expose TOR_PT_OUTBOUND_BIND_ADDRESS_{V4,V6} to Pluggable Transports.
This patch adds support for exposing the environment variables
`TOR_PT_OUTBOUND_BIND_ADDRESS_V4` and `TOR_PT_OUTBOUND_BIND_ADDRESS_V6` to
Pluggable Transport proccesses. These two values will contain the IPv4
and IPv6 address that the user have specified in torrc that they wish
the PT to use for all outgoing IP packets.

It is important to note here that it is up to the indvidual Pluggable
Transport if they are willing to honor these values or ignore them
completely.

One can test this feature using the following dummy PT written in POSIX
shell script:

    #!/bin/sh

    echo "LOG SEVERITY=warning MESSAGE=\"Value for IPv4: ${TOR_PT_OUTBOUND_BIND_ADDRESS_V4}\""
    echo "LOG SEVERITY=warning MESSAGE=\"Value for IPv6: ${TOR_PT_OUTBOUND_BIND_ADDRESS_V6}\""

    while true ; do
        sleep 1
    done

with the following entries in your torrc:

    OutboundBindAddressPT 203.0.113.4
    OutboundBindAddress 203.0.113.5
    OutboundBindAddressPT 2001:db8::4
    OutboundBindAddress 2001:db8::5

See: https://bugs.torproject.org/5304
2020-10-06 09:30:11 -04:00
Alexander Færøy
69c1a4ebc3 Move parse logic for outbound addresses to before we handle PT's.
This patch moves the logic for handling outbound addresses in torrc to
before we handle pluggable transports. Since we need access to the
values in OutboundBindAddress and friends for #5304 we have to parse
these values before we spawn any PT's.

This commit is code movement only.

See: https://bugs.torproject.org/5304
2020-10-06 09:30:10 -04:00
Alexander Færøy
ad08743299 Rename OUTBOUND_ADDR_EXIT_AND_OR to OUTBOUND_ADDR_ANY.
This patch renames the enumeration value in `outbound_addr_t` from
`OUTBOUND_ADDR_EXIT_AND_OR` to `OUTBOUND_ADDR_ANY` since with the
arrival of `OUTBOUND_ADDR_PT` it no longer makes sense to call the
fallback value for "Exit and OR". Instead we rename it to "any".

See: https://bugs.torproject.org/5304
2020-10-06 09:30:10 -04:00
Alexander Færøy
db0aaf428e Add OutboundBindAddressPT to torrc.
This patch adds a new option to torrc: `OutboundBindAddressPT`. This
option works in the same way as `OutboundBindAddressOR` and
`OutboundBindAddressExit` in that it allows the user to specify which
outbound IP address the user wants the PT to make its connections from.

There is one difference though in that OutboundBindAddressPT will only
be a suggestion for the PT to use since Tor cannot enforce whether or
not the PT actually uses this option for anything.

See: https://bugs.torproject.org/5304
2020-10-06 09:30:10 -04:00
Alexander Færøy
25bffccd71 Document enumeration values for outbound_addr_t.
This patch adds doxygen documentation strings for each of the values in
`outbound_addr_t`.

See: https://bugs.torproject.org/5304
2020-10-06 09:30:10 -04:00
Daniel Pinto
304ae473ca Fix %include bug with pattern with */ on glibc < 2.19 #40141
Fix bug where %including a pattern ending in */ would include
files and folders (instead of folders only) in versions of
glibc < 2.19.
2020-10-03 04:10:52 +01:00
Roger Dingledine
4f114f59e6 fix typos
no actual changes
2020-10-01 19:32:32 -04:00
Nick Mathewson
f5ddc45647 Merge branch 'bug40133_035' into bug40133_043 2020-09-28 10:37:14 -04:00
Nick Mathewson
79d7773968 Merge branch 'maint-0.3.5' into bug40133_035 2020-09-28 10:35:12 -04:00
Nick Mathewson
e68770719e Add missing documentation for get_net_param_from_list 2020-09-28 08:41:47 -04:00
Nick Mathewson
228ac47c2c Fix memory leak in vote generation 2020-09-23 15:41:27 -04:00
Nick Mathewson
2b39543dfc Move a DIGESTMAP_FOREACH_END (cosmetic) 2020-09-23 15:19:25 -04:00
Nick Mathewson
458897e3c5 Remove parseconf test with AndroidIdentityTag. 2020-09-23 14:40:38 -04:00
Nick Mathewson
5c9b4a0060 Remove support for old android "logcat" API
This is apparently obsolete; syslog is modern instead.  If users
have an android log configured, given them a syslog if we can.

Closes #32181.
2020-09-23 12:33:58 -04:00
Nick Mathewson
d07f17f676 IPv6 sybil: consider addresses in the same /64 to be equal. 2020-09-23 12:06:38 -04:00
Nick Mathewson
1be9e84b9c Refactor address comparison in get_sybil_list_by_ip_version 2020-09-23 12:04:09 -04:00
Nick Mathewson
2dba667928 get_all_possible_sybil: small indentation and comment cleanups 2020-09-23 11:53:28 -04:00
Nick Mathewson
e0f6047ea0 Remove needless sort operation. 2020-09-23 11:50:57 -04:00
Nick Mathewson
3196de33a5 Tidy up compare_routerinfo_by_ipv{4,6} to match better. 2020-09-23 11:48:20 -04:00
Nick Mathewson
81c05e1e98 Style and correctness issues in test_dirvote.
Style:
  - We end our types with _t.
  - Use 'static' to declare functions that only exist in a single
    module.

Correctness:
  - Many tt_...() macros can invoke "goto done;" -- we need to make
    sure that all the variables that could get freed are initialized
    before any "goto done" is hit, or else we might free an
    uninitialized variable.
2020-09-23 11:32:28 -04:00
Nick Mathewson
939d12be58 Fix memory leaks. 2020-09-23 11:32:22 -04:00
vnepveu
43672f9fca Implement IPv6 sybil protection.
[This is a squashed patch for ticket 7193, based on taking a "git
   diff" for the original branch, then applying it with "git apply
   -3".  I earlier attempted to squash the branch with "git rebase",
   but there were too many conflicts. --nickm]
2020-09-23 11:30:15 -04:00
David Goulet
beffad8529 Merge branch 'maint-0.3.5' into maint-0.4.3 2020-09-22 13:47:08 -04:00
David Goulet
b6429430c6 Merge branch 'maint-0.4.3' into maint-0.4.4 2020-09-22 13:47:08 -04:00
David Goulet
3f8201f229 Merge branch 'maint-0.4.4' 2020-09-22 13:47:08 -04:00
David Goulet
4dbbc000b5 Merge branch 'tor-gitlab/mr/145' 2020-09-22 13:39:55 -04:00
David Goulet
faf89ec6c2 srv: Remove spammy debug log
Fixes #40135

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-09-22 11:06:34 -04:00
Nick Mathewson
88d99fc1bd Fix warnings when using two unusual options together.
The option `--enable-all-bugs-are-fatal` when used with
`--disable-module-relay` caused GCC to warn about functions that
it thought should be labeled noreturn.

I've tried a couple of approaches, but disabling the warning on
these functions seems to be the best approach.

Fixed #40129; bugfix on 0.4.4.1-alpha.
2020-09-22 10:07:14 -04:00
Nick Mathewson
6bf964a3e5 Renerate src/test/fuzz/include.am 2020-09-18 16:08:41 -04:00
Nick Mathewson
e9dbb5e395 Build one big .a library full of Tor's implementation.
This is experimental and probably will break some platforms
2020-09-18 16:08:24 -04:00
Alexander Færøy
485990641b Merge remote-tracking branch 'tor-gitlab/mr/137' 2020-09-18 14:51:54 +00:00
Nick Mathewson
781ab9eea4 Add flag for whether an OR conn "counts" for bootstrap tracking
We set this flag if we've launched the connection in order to
satisfy an origin circuit, or when we decide the connection _would_
satisfy an origin circuit.  These are the only or_connections we
want to consider for bootstrapping: other or_connections are opened
because of client EXTEND requests, and they may succeed or fail
because of the clients' confusion or misconfiguration.

Closes #25061.
2020-09-18 10:03:57 -04:00
David Goulet
2ddbfc64af Merge branch 'maint-0.3.5' into maint-0.4.3 2020-09-18 09:45:25 -04:00
David Goulet
2e3603d96d Merge branch 'maint-0.4.3' into maint-0.4.4 2020-09-18 09:45:25 -04:00
David Goulet
e8a4482335 Merge branch 'maint-0.4.4' 2020-09-18 09:45:25 -04:00
Nick Mathewson
7945e075a4 Fix underflow in rend_cache/free_all test.
We already fixed these in #40099 and #40125.

This patch fixes #40126.  Bugfix on 0.2.8.1-alpha.
2020-09-17 14:04:54 -04:00
Nick Mathewson
404c224c71 Merge branch 'maint-0.4.4' 2020-09-17 13:56:40 -04:00
Nick Mathewson
078194ecaf Merge branch 'maint-0.3.5' into maint-0.4.3 2020-09-17 13:56:40 -04:00
Nick Mathewson
54cd2578ef Merge branch 'maint-0.4.3' into maint-0.4.4 2020-09-17 13:56:40 -04:00
David Goulet
47f1d19f8e test: Increment rend cache allocation before freeing
The rend_cache/entry_free was missing the rend cache allocation increment
before freeing the object.

Without it, it had an underflow bug:

  Sep 17 08:40:13.845 [warn] rend_cache_decrement_allocation(): Bug: Underflow
  in rend_cache_decrement_allocation (on Tor 0.4.5.0-alpha-dev
  7eef9ced61)

Fixes #40125

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-09-17 13:00:23 -04:00
David Goulet
a47d12c64d Merge branch 'tor-gitlab/mr/129' 2020-09-17 09:17:53 -04:00
Nick Mathewson
4e8cb410a7 Resolve some coverity complaints in test_util_glob().
Coverity's first complaint was that we didn't check the return
values from chmod.  That's easily fixed.

Coverity's second complaint was that there were code paths where we pass
NULL to chmod.  For example, if this line failed, we'd "goto done",
and then pass NULL to chmod.
  tt_ptr_op(dirname, OP_NE, NULL);

Closes #40103.  Bug not in any released Tor.
2020-09-17 09:17:49 -04:00
Nick Mathewson
5d1d7afcd3 Use the correct SIGNED_KEY_TYPE value for signing->link certs
Our code was using [01] as for the key type of signed->link certs,
which was incorrect.  The value should be [03], to indicate that the
value as the SHA256 of an x.509 cert.

Fortunately, nothing cares about this value, so there shouldn't be
compatibility issues.

Fixes bug 40124; bugfix on 0.2.7.2-alpha.
2020-09-17 08:42:25 -04:00
David Goulet
7eef9ced61 Merge branch 'tor-gitlab/mr/131' 2020-09-17 08:33:10 -04:00
Nick Mathewson
22643272d2 Fix wide lines 2020-09-17 08:19:53 -04:00
Nick Mathewson
c92e19268b Rename tor_cert_create to tor_cert_create_ed25519
This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        tor_cert_create tor_cert_create_ed25519

It was generated with --no-verify, so it probably breaks some commit hooks.
The commiter should be sure to fix them up in a subsequent commit.
2020-09-17 08:17:36 -04:00
Nick Mathewson
bf5bf33661 Bump version to 0.4.4.5-dev. 2020-09-15 08:52:37 -04:00
Nick Mathewson
f6b8894726 Bump version to 0.4.4.5 2020-09-14 13:17:37 -04:00
Nick Mathewson
020e8e41c6 Resolve a compilation warning in test_connection.c
Instead of casting an enum to a void and back, use a string --
that's better C anyway.

Fixes bug 40113; bugfix on 0.2.9.3-alpha.
2020-09-14 11:50:38 -04:00
Nick Mathewson
33380f6b27 Update remaining trac.tpo wiki urls 2020-09-14 11:02:38 -04:00
Alexander Færøy
1c4b140427 Check if glob() is available at build-time.
This patch disables the glob() support in the path library if glob() is
unavailable at build-time. This currently happens with the Android NDK
used for Tor Browser.

See: https://bugs.torproject.org/tpo/core/tor/40114
2020-09-10 10:51:57 -04:00
David Goulet
12c7583126 Merge branch 'maint-0.4.4' 2020-09-08 11:14:12 -04:00
George Kadianakis
85a1e6c601 statistics: Properly count all rendezvous cells (avoid undercounting).
tl;dr We were not counting cells flying from the client to the service, but we
were counting cells flying from the service to the client.

When a rendezvous cell arrives from the client to the RP, the RP forwards it to
the service.

For this to happen, the cell first passes through command_process_relay_cell()
which normally does the statistics counting. However because the `rend_circ`
circuit was not flagged with `circuit_carries_hs_traffic_stats` in
rend_mid_rendezvous(), the cell is not counted there.

Then the cell goes to circuit_receive_relay_cell() which has a special code
block based on `rend_splice` specifically for rendezvous cells, and the cell
gets directly passed to `rend_circ` via a direct call to
circuit_receive_relay_cell(). The cell never passes through
command_process_relay_cell() ever again and hence is never counted by our
rephist module.

The fix here is to flag the `rend_circ` circuit with
`circuit_carries_hs_traffic_stats` so that the cell is counted as soon as it
hits command_process_relay_cell().

Furthermore we avoid double-counting cells since the special code block of
circuit_receive_relay_cell() makes us count rendezvous cells only as they enter
the RP and not as they exit it.

Fixes #40117.
2020-09-07 13:30:21 +03:00
George Kadianakis
248cbc2d22 statistics: Properly count all rendezvous cells (avoid undercounting).
tl;dr We were not counting cells flying from the client to the service, but we
were counting cells flying from the service to the client.

When a rendezvous cell arrives from the client to the RP, the RP forwards it to
the service.

For this to happen, the cell first passes through command_process_relay_cell()
which normally does the statistics counting. However because the `rend_circ`
circuit was not flagged with `circuit_carries_hs_traffic_stats` in
rend_mid_rendezvous(), the cell is not counted there.

Then the cell goes to circuit_receive_relay_cell() which has a special code
block based on `rend_splice` specifically for rendezvous cells, and the cell
gets directly passed to `rend_circ` via a direct call to
circuit_receive_relay_cell(). The cell never passes through
command_process_relay_cell() ever again and hence is never counted by our
rephist module.

The fix here is to flag the `rend_circ` circuit with
`circuit_carries_hs_traffic_stats` so that the cell is counted as soon as it
hits command_process_relay_cell().

Furthermore we avoid double-counting cells since the special code block of
circuit_receive_relay_cell() makes us count rendezvous cells only as they enter
the RP and not as they exit it.

Fixes #40117.
2020-09-07 13:29:44 +03:00
David Goulet
ae6430818e addr: Missing AF family to index conversion
When accessing the last_resolved_address cache we always need to convert the
AF family value to an index value else we are out of bound and thus
overflowing if we write to it.

This fix is on code that has not been released.

GeKo reported the following libasan crash using Tor Browser alpha with tor
0.4.5.0-alpha-dev (3c884bc9e0):

==4240==ERROR: AddressSanitizer: global-buffer-overflow on address
0x55888490e388 at pc 0x5588842cc216 bp 0x7ffc8c421b00 sp 0x7ffc8c421af8
READ of size 2 at 0x55888490e388 thread T0
    #0 0x5588842cc215 in tor_addr_compare_masked
(/home/thomas/Arbeit/Tor/tor-browser-build/tor-browser_en-US/Browser/TorBrowser/Tor/tor+0x5a6215)
    #1 0x558884203210 in is_local_to_resolve_addr
(/home/thomas/Arbeit/Tor/tor-browser-build/tor-browser_en-US/Browser/TorBrowser/Tor/tor+0x4dd210)
    #2 0x558883f7e252 in channel_tls_connect
(/home/thomas/Arbeit/Tor/tor-browser-build/tor-browser_en-US/Browser/TorBrowser/Tor/tor+0x258252)
    #3 0x558883f87ff7 in channel_connect_for_circuit
(/home/thomas/Arbeit/Tor/tor-browser-build/tor-browser_en-US/Browser/TorBrowser/Tor/tor+0x261ff7)
    #4 0x558883f8bc90 in circuit_handle_first_hop
(/home/thomas/Arbeit/Tor/tor-browser-build/tor-browser_en-US/Browser/TorBrowser/Tor/tor+0x265c90)
    #5 0x558883f8c891 in circuit_establish_circuit
(/home/thomas/Arbeit/Tor/tor-browser-build/tor-browser_en-US/Browser/TorBrowser/Tor/tor+0x266891)
    #6 0x558883fc3bbc in circuit_launch_by_extend_info
(/home/thomas/Arbeit/Tor/tor-browser-build/tor-browser_en-US/Browser/TorBrowser/Tor/tor+0x29dbbc)
    #7 0x558883fc5900
(/home/thomas/Arbeit/Tor/tor-browser-build/tor-browser_en-US/Browser/TorBrowser/Tor/tor+0x29f900)
    #8 0x558883fc6988 in connection_ap_handshake_attach_circuit
(/home/thomas/Arbeit/Tor/tor-browser-build/tor-browser_en-US/Browser/TorBrowser/Tor/tor+0x2a0988)
    #9 0x558883fd0d3f in connection_ap_attach_pending
(/home/thomas/Arbeit/Tor/tor-browser-build/tor-browser_en-US/Browser/TorBrowser/Tor/tor+0x2aad3f)
    #10 0x7f4d50110885  (TorBrowser/Tor/libevent-2.1.so.7+0x22885)
    #11 0x7f4d501110de in event_base_loop
(TorBrowser/Tor/libevent-2.1.so.7+0x230de)
    #12 0x558883f69b3c in do_main_loop
(/home/thomas/Arbeit/Tor/tor-browser-build/tor-browser_en-US/Browser/TorBrowser/Tor/tor+0x243b3c)
    #13 0x558883f3f70c in tor_run_main
(/home/thomas/Arbeit/Tor/tor-browser-build/tor-browser_en-US/Browser/TorBrowser/Tor/tor+0x21970c)
    #14 0x558883f3c2f7 in tor_main
(/home/thomas/Arbeit/Tor/tor-browser-build/tor-browser_en-US/Browser/TorBrowser/Tor/tor+0x2162f7)
    #15 0x558883f3531b in main
(/home/thomas/Arbeit/Tor/tor-browser-build/tor-browser_en-US/Browser/TorBrowser/Tor/tor+0x20f31b)
    #16 0x7f4d4f76acc9 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x26cc9)
    #17 0x558883f3ba00
(/home/thomas/Arbeit/Tor/tor-browser-build/tor-browser_en-US/Browser/TorBrowser/Tor/tor+0x215a00)

0x55888490e388 is located 24 bytes to the left of global variable
'state_mgr' defined in 'src/app/config/statefile.c:184:22'
(0x55888490e3a0) of size 8
0x55888490e388 is located 32 bytes to the right of global variable
'global_state' defined in 'src/app/config/statefile.c:204:20'
(0x55888490e360) of size 8
SUMMARY: AddressSanitizer: global-buffer-overflow
(/home/thomas/Arbeit/Tor/tor-browser-build/tor-browser_en-US/Browser/TorBrowser/Tor/tor+0x5a6215)
in tor_addr_compare_masked
Shadow bytes around the buggy address:
  0x0ab190919c20: 00 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9
  0x0ab190919c30: 04 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 03 f9 f9 f9
  0x0ab190919c40: f9 f9 f9 f9 03 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
  0x0ab190919c50: 00 00 00 04 f9 f9 f9 f9 00 00 00 00 00 00 00 04
  0x0ab190919c60: f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9
=>0x0ab190919c70: f9[f9]f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
  0x0ab190919c80: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
  0x0ab190919c90: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
  0x0ab190919ca0: 00 00 00 00 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
  0x0ab190919cb0: 01 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9
  0x0ab190919cc0: 00 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==4240==ABORTING

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-09-03 16:07:19 +00:00
David Goulet
ea339227c2 conn: Remove assert on new listener connection when retrying
Opening a new listener connection can fail in many ways like a bind()
permission denied on a low port for instance.

And thus, we should expect to handle an error when creating a new one instead
of assert() on it.

To hit the removed assert:

  ORPort 80
  KeepBindCapabilities 0

Start tor. Then edit torrc:

  ORPort <some-IP>:80

HUP tor and the assert is hit.

Fixes #40073

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-09-01 10:01:21 -04:00
Alexander Færøy
511730db2d Merge remote-tracking branch 'tor-gitlab/mr/133' 2020-08-26 21:55:39 +00:00
David Goulet
a6a97236fc Merge branch 'tor-gitlab/mr/135' 2020-08-26 11:04:53 -04:00
George Kadianakis
d4f3cfe99a Merge branch 'mr/113' 2020-08-25 20:37:04 +03:00
Neel Chauhan
90707c9264 Even argument spacing for some functions in feature/client/bridges.c 2020-08-25 09:16:58 -04:00
Nick Mathewson
75772ea096 Validate address more carefully when checking self-reachability
Previously, we would treat *any* incoming circuit on a non-local
channel as meaning that our ORPort was reachable.  With this patch,
we make sure that the address that the peer _says_ we have is the
same as the one we're trying to advertise right now.

Closes 20165. Bugfix on 4f5192b280 in 0.1.0.1-rc, when
reachability self-tests were first introduced.
2020-08-25 16:02:59 +03:00
George Kadianakis
cc4e42ee32 Merge remote-tracking branch 'tor-gitlab/mr/115' 2020-08-25 15:43:00 +03:00
David Goulet
6dc0b04319 Merge branch 'maint-0.4.4' 2020-08-25 08:23:06 -04:00
George Kadianakis
53cd1c9710 Avoid guard-related warning when upgrading from 043 to 044.
Fixes #40105.
2020-08-25 15:09:57 +03:00
George Kadianakis
4b9ed14d9b Merge remote-tracking branch 'tor-gitlab/mr/108' 2020-08-25 15:02:04 +03:00
George Kadianakis
935160ce86 Merge branch 'maint-0.4.4' 2020-08-25 14:51:23 +03:00
George Kadianakis
1397a86bbd Merge remote-tracking branch 'tor-gitlab/mr/130' into maint-0.4.4 2020-08-25 14:51:05 +03:00
Neel Chauhan
b16d82043c Include crypto_rand.h in ed25519_tor.c 2020-08-23 06:05:08 -07:00
George Kadianakis
36203e8894 Merge branch 'maint-0.4.4' 2020-08-20 14:34:56 +03:00
Neel Chauhan
6e37086f85 v3 control: Persist ONION_CLIENT_AUTH_ADD client name 2020-08-20 14:34:21 +03:00
David Goulet
83052372a0 relay: Query our cache when deciding for dummy descriptor fetch
Instead of looking at the "Address" option alone, instead check if we have an
address in our cache (that is discovered by tor). If not, then it tells us
that tor does not have an address to work with so we can then ask a directory
authority for a suggestion.

Related #2178

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-08-19 10:25:47 -04:00
David Goulet
f5c9f6d432 hs: Don't overwrite DoS parameters on circuit with consensus params
Turns out that the HS DoS defenses parameters were overwritten by the
consensus parameters everytime a new consensus would arrive.

This means that a service operator can still enable the defenses but as soon
as the intro point relay would get a new consensus, they would be overwritten.
And at this commit, the network is entirely disabling DoS defenses.

Fix this by introducing an "explicit" flag that indicate if the
ESTABLISH_INTRO cell DoS extension set those parameters or not. If set, avoid
using the consenus at once.

We are not bumping the protover HSIntro value for this because 0.4.2.x series
is EOL in 1 month and thus 0.4.3.x would be the only series with this bug. We
are confident that a backport and then upgrade path to the latest 0.4.4.x
stable coming up soon is enough to mitigate this problem in the coming months.

It avoids the upgrade path on the service side by keeping the requirement for
protover HSIntro=5.

Fixes #40109

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-08-19 09:47:34 -04:00
George Kadianakis
4e3f55fba1 Merge branch 'maint-0.4.4' 2020-08-19 13:56:34 +03:00
George Kadianakis
b1b0079675 Merge branch 'mr/124' into maint-0.4.4 2020-08-19 13:55:07 +03:00
Nick Mathewson
974abdf632 Parallelize src/test/test into chunks.
First, we introduce a flag to teach src/test/test to split its work
into chunks.  Then we replace our invocation of src/test/test in our
"make check" target with a set of 8 scripts that invoke the first
8th of the tests, the second 8th, and so on.

This change makes our "make -kj4 check" target in our hardened
gitlab build more than twice as fast, since src/test/test was taking
the longest to finish.

Closes 40098.
2020-08-19 13:46:50 +03:00
David Goulet
1089ac6f22 Merge branch 'tor-gitlab/mr/126' 2020-08-18 08:56:27 -04:00
David Goulet
80d2376f33 Merge branch 'maint-0.4.4' 2020-08-18 08:49:07 -04:00
David Goulet
deea196370 Merge branch 'tor-gitlab/mr/121' into maint-0.4.4 2020-08-18 08:49:01 -04:00
Daniel Pinto
ebaa1a1d23 Make options_init_from_torrc smaller #40102
Split implementation of several command line options from
options_init_from_torrc into smaller isolated functions.
2020-08-14 16:01:02 +01:00
Nick Mathewson
563f8610fd Revise trac.torproject.org urls to refer to gitlab replacements.
Closes #40101.
2020-08-14 09:21:28 -04:00
Nick Mathewson
7915b651d9 Merge branch 'maint-0.4.2' into maint-0.4.3 2020-08-13 14:20:39 -04:00
Nick Mathewson
ef18fb56c9 Merge branch 'maint-0.4.3' into maint-0.4.4 2020-08-13 14:20:39 -04:00
Nick Mathewson
8669ace2fb Merge branch 'maint-0.4.4' 2020-08-13 14:20:39 -04:00
Nick Mathewson
45d9830493 Merge branch 'maint-0.3.5' into maint-0.4.2 2020-08-13 14:20:39 -04:00
Nick Mathewson
26b257757b Bump to 0.4.4.4-rc-dev 2020-08-13 09:43:54 -04:00
Nick Mathewson
7b4716a762 Make test_glob() pass even when run as root.
Previously the test relied on not being able to look inside 000
directories, which is a thing root _can_ do.

Bug not in any released Tor version.
2020-08-12 20:36:23 -04:00
Nick Mathewson
9ef991dbe3 Use correct type for gl_closedir to avoid a compiler warning 2020-08-12 14:42:30 -04:00
Nick Mathewson
e151442037 Merge remote-tracking branch 'tor-gitlab/mr/62' 2020-08-12 14:37:21 -04:00
Nick Mathewson
f9bb49d870 Fix allocation counting in clean_v2_descs_as_dir test.
Without this fix, running this test on its own would fail.

Fixes bug 40099. Bugfix on ade5005853 in 0.2.8.1-alpha.
2020-08-12 14:25:46 -04:00
Daniel Pinto
60c436d14d Attempt to fix test_include.py on TravisCI #25140 2020-08-12 14:35:51 +01:00
George Kadianakis
347f87ae9d Merge branch 'maint-0.4.4' 2020-08-12 13:47:59 +03:00
George Kadianakis
5a1918d7e7 Merge remote-tracking branch 'tor-gitlab/mr/107' into maint-0.4.4 2020-08-12 13:47:34 +03:00
George Kadianakis
c591a0d246 Merge branch 'maint-0.4.4' 2020-08-12 13:23:33 +03:00
George Kadianakis
8e9edb93be Merge remote-tracking branch 'tor-gitlab/mr/104' into maint-0.4.4 2020-08-12 13:23:08 +03:00
Nick Mathewson
4fdec27a12 Remove extraneous EVENT_CONTROLLER_WAIT
This turned into a new StreamStatus value.

Closes #40092. Bug not in any released Tor.
2020-08-11 18:41:15 -04:00
Nick Mathewson
1770d1c216 bump version to 0.4.4.4-rc 2020-08-11 17:46:44 -04:00
Nick Mathewson
a02002dc99 Lower the minimum value for MaxMemInQueues to 64 MB for relays.
For clients, there is no minimum value; in both cases, we warn if
the value seems too low.

Closes ticket 24308.
2020-08-11 17:01:49 -04:00
Daniel Pinto
0b633b1f6d Improved documentation and comments #25140 2020-08-11 18:26:41 +01:00
Nick Mathewson
431dcc42e0 Rename argument to compute_real_max_mem_in_queues() 2020-08-11 12:59:07 -04:00
Nick Mathewson
d76f8457f3 Merge remote-tracking branch 'tor-gitlab/mr/119' into maint-0.4.4 2020-08-11 12:40:02 -04:00
Nick Mathewson
11961f0bc5 Merge remote-tracking branch 'tor-gitlab/mr/119' 2020-08-11 12:39:30 -04:00
George Kadianakis
b705cfa024 Merge remote-tracking branch 'tor-gitlab/mr/111' 2020-08-11 15:12:43 +03:00
George Kadianakis
f971a8fbad Merge branch 'mr/105' 2020-08-11 15:04:15 +03:00
Nick Mathewson
7df52b71bf Only log port self-testing message when we are _starting_ to test.
(Unlike approaches in earlier versions of Tor, this one logs if and
only if we are launching a test, and we haven't said that we're
testing this port.)

Fixes bug 40068; bug not in any released version.

Closes #40068.
2020-08-11 15:02:44 +03:00
George Kadianakis
b8003fbe99 Merge branch 'maint-0.4.4' 2020-08-11 14:54:26 +03:00
George Kadianakis
ab9c35f043 Merge remote-tracking branch 'tor-gitlab/mr/102' into maint-0.4.4 2020-08-11 14:53:03 +03:00
George Kadianakis
9316ca9f06 Remove a BUG() that could normally trigger in edge-cases. 2020-08-11 14:42:18 +03:00
Nick Mathewson
069946852a Merge branch 'maint-0.4.4' 2020-08-10 19:33:07 -04:00
Nick Mathewson
7d80bf80fe Merge branch 'maint-0.4.3' into maint-0.4.4 2020-08-10 19:33:07 -04:00
Nick Mathewson
f3fcc89d05 Merge branch 'maint-0.4.2' into maint-0.4.3 2020-08-10 19:33:06 -04:00
Nick Mathewson
68f8250cbb Merge branch 'maint-0.3.5' into maint-0.4.2 2020-08-10 19:32:49 -04:00
Nick Mathewson
e873c7e893 small code tweaks to try to work around debian stable complaints 2020-08-10 19:20:05 -04:00
Nick Mathewson
3eb9331133 Merge remote-tracking branch 'tor-gitlab/mr/110' 2020-08-10 14:51:12 -04:00
Nick Mathewson
24c721de37 Log number of inbound/outbound ipv4/6 conns as part of heartbeat
Closes #29113
2020-08-07 10:45:29 -04:00
Nick Mathewson
6fde1548f2 Revise test_status to use log testing helpers.
This change lets us make these tests much shorter and easier to
maintain.
2020-08-07 10:42:12 -04:00
Nick Mathewson
afb6ff1739 Validate ed25519 keys and canonicity from circuit_n_conn_done()
Fixes bug 40080. Bugfix on 0.2.7.2-alpha.
2020-08-06 15:59:28 -04:00
Nick Mathewson
b417594dbc Replace several C identifiers for ticket 18106.
We used to have a single boolean, "FascistFirewall".  Ages ago, in
tickets #17840 and #9067, we added an improved "ReachableAddresses"
mechanism.  It's time to rename related identifiers in the code for
consistency.  This closes #18106.

This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        fascist_firewall_allows_address reachable_addr_allows \
        fascist_firewall_use_ipv6 reachable_addr_use_ipv6 \
        fascist_firewall_prefer_ipv6_impl reachable_addr_prefer_ipv6_impl \
        fascist_firewall_prefer_ipv6_orport reachable_addr_prefer_ipv6_orport \
        fascist_firewall_prefer_ipv6_dirport reachable_addr_prefer_ipv6_dirport \
        fascist_firewall_allows_address_addr reachable_addr_allows_addr \
        fascist_firewall_allows_address_ap reachable_addr_allows_ap \
        fascist_firewall_allows_base reachable_addr_allows_base \
        fascist_firewall_allows_ri_impl reachable_addr_allows_ri_impl \
        fascist_firewall_allows_rs_impl reachable_addr_allows_rs_impl \
        fascist_firewall_allows_rs reachable_addr_allows_rs \
        fascist_firewall_allows_md_impl reachable_addr_allows_md_impl \
        fascist_firewall_allows_node reachable_addr_allows_node \
        fascist_firewall_allows_dir_server reachable_addr_allows_dir_server \
        fascist_firewall_choose_address_impl reachable_addr_choose_impl \
        fascist_firewall_choose_address reachable_addr_choose \
        fascist_firewall_choose_address_base reachable_addr_choose_base \
        fascist_firewall_choose_address_rs reachable_addr_choose_from_rs \
        fascist_firewall_choose_address_ls reachable_addr_choose_from_ls \
        fascist_firewall_choose_address_node reachable_addr_choose_from_node \
        fascist_firewall_choose_address_dir_server reachable_addr_choose_from_dir_server
2020-08-05 16:34:45 -04:00
George Kadianakis
afd88ee87f Merge remote-tracking branch 'tor-gitlab/mr/88' 2020-08-05 14:57:20 +03:00
Neel Chauhan
d1413e04f8 ipv6: Specialize GETINFO address interface for v4 and v6 2020-08-04 13:59:49 -07:00
Nick Mathewson
1d0695fe7e Improve ratelimit message to list true interval.
Previous message would say "N messages in the last T seconds", but
would give an inaccurate number for N.

We now give an accurate number, rounded up to the nearest 60 seconds.

Closes #19431.
2020-08-04 13:56:28 -04:00
Nick Mathewson
04926126ee Merge remote-tracking branch 'tor-gitlab/mr/100' 2020-08-04 13:28:51 -04:00
Nick Mathewson
08de260682 Merge branch 'bug40083_035' into bug40083_042
Fixes conflicts due to code movement.
2020-08-04 13:10:16 -04:00
Nick Mathewson
62361cc698 Launch early reachability tests once a minute, not once a second.
This fixes bug 40083, which was introduced in 9f31908a in
0.2.8.1-alpha.
2020-08-04 13:05:07 -04:00
Daniel Pinto
ccdd0d801a Minor style improvements. #30045 2020-08-03 20:08:17 +01:00