Commit Graph

26273 Commits

Author SHA1 Message Date
Nick Mathewson
0bb227d170 bump to 0.3.5.11 2020-07-09 10:28:21 -04:00
George Kadianakis
b1a32761be Merge branch 'maint-0.4.4' 2020-07-09 17:08:34 +03:00
George Kadianakis
e500ea2eae Merge branch 'tor-github/pr/1989' into maint-0.4.4 2020-07-09 17:08:07 +03:00
Nick Mathewson
be6b30e642 Merge branch 'maint-0.4.4' 2020-07-09 09:59:54 -04:00
Nick Mathewson
8dd89e4330 Merge remote-tracking branch 'dgoulet/ticket33796_044_01' into maint-0.4.4 2020-07-09 09:59:45 -04:00
Nick Mathewson
b0399c6026 Merge branch 'maint-0.4.4' 2020-07-09 09:28:53 -04:00
Nick Mathewson
0f39cc10f6 Merge branch 'maint-0.4.3' into maint-0.4.4 2020-07-09 09:28:53 -04:00
Nick Mathewson
af08dad6d1 Merge branch 'maint-0.4.2' into maint-0.4.3 2020-07-09 09:28:53 -04:00
Nick Mathewson
283ce30c53 Merge branch 'maint-0.3.5' into maint-0.4.2 2020-07-09 09:28:53 -04:00
Nick Mathewson
7142f3e435 Merge branch 'trove_2020_001_035' into maint-0.3.5 2020-07-09 09:28:36 -04:00
David Goulet
63a54858c3 hs-v3: Remove a possible BUG() condition
When receiving an introduction NACK, the client either decides to close or
re-extend the circuit to another intro point.

In order to do this, the service descriptor needs to exists but it is possible
that it gets removed from the cache between the establishement of the
introduction circuit and the reception of the (N)ACK.

For that reason, the BUG(desc == NULL) is removed because it is a possible
normal use case. Tor recovers gracefully already.

Fixes #34087

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-09 08:32:53 -04:00
David Goulet
32a0bc2a84 Merge branch 'maint-0.4.4' 2020-07-09 07:27:25 -04:00
David Goulet
1af7f40dad Merge branch 'tor-github/pr/1988' into maint-0.4.4 2020-07-09 07:27:13 -04:00
David Goulet
d7f3d1196c Merge branch 'maint-0.4.4' 2020-07-09 07:25:26 -04:00
George Kadianakis
c1598be1e0 Refactor setup_intro_circ_auth_key() to make it simpler.
It now uses the 'goto err' pattern, instead of the fatal_unreached()
pattern. The latter pattern is usually used when there is a loop, but there is
no loop in this function so it can be simplified easily.
2020-07-09 10:40:56 +03:00
George Kadianakis
e0da64fd27 Handle a failure edge-case when a client-side intro circ opens. 2020-07-09 10:10:57 +03:00
Guinness
562957e0db socks: Returns 0xF6 only if BAD_HOSTNAME
This commit modifies the behavior of `parse_extended_address` in such a way
that if it fails, it will always return a `BAD_HOSTNAME` value, which is then
used to return the 0xF6 extended error code.  This way, in any case that is
not a valid v2 address, we return the 0xF6 error code, which is the expected
behavior.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08 16:20:31 -04:00
David Goulet
b049cc3ace trace: Emit a warning if tracing is built in
Built in tracing should _not_ be run if it was not set on purpose. Warn as
loud as we can in order to inform the user that they are running a version
with tracing capabilities built in.

This commit also adds a subsys stub because utlimately the logging will happen
in the init phase but because the default log file is not set in the
sys_logging init function, the stub is not useful for now.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08 11:11:58 -04:00
David Goulet
3604d86a01 trace: Helper macro to disambiguate identifiers
In order to disambiguate the subsystem and event_name identifiers in the
tor_trace() macro, add TR_SUBSYS() and TR_EV() which help to identify the
parameters of tor_trace() explicitly.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08 09:18:33 -04:00
David Goulet
d80c34d214 trace: Move LTTng specific declartion to .inc file
LTTng tracepoint probe declaration is not really following a C standard that
coccinelle and checkSpace.pl likes.

Move everything to a .inc file and standardize the trace_probes_circuit.h
header to include that LTTng specific file if the instrumentation was enabled
at configure time.

Part of #32910

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08 09:18:33 -04:00
David Goulet
24a5983d84 trace: Only build probes if instrumentation is enabled
For now, trace_probes_circuit.c only contains LTTng probes so build it only if
enabled within in the build system _and_ the code.

Also, ignore trace_probes_circuit.h for coccinelle parsing.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08 09:12:37 -04:00
David Goulet
79d6127a47 trace: Comments and improve doc/HACKING/Tracing.md
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08 09:12:36 -04:00
David Goulet
c8f632784b trace: Add two circuit tracepoints for new circuits
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08 09:10:30 -04:00
David Goulet
4cb6887471 trace: Add two origin circuit specific tracepoints
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08 09:10:30 -04:00
David Goulet
d36a44ffa9 trace: Add four generic circuit tracepoints
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08 09:10:29 -04:00
David Goulet
a706334577 trace: Add four more circuit subsystem tracepoints
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08 09:10:08 -04:00
David Goulet
bf0e2ae0d0 trace: Add single tracepoint in circuit subsystem
This is the very first tracepoint in tor. It is in the circuit subsystem for
when a new circuit opens.

LTTng instrumentation requires lot more around a tracepoint than USDT thus
this commit only adds one tracepoint in order to outline a base to add more
tracepoints later.

The idea is that we separate subsystem into what LTTng defines as "providers"
so the circuit provider contains the tracepoint definitions for the circuit
subsystem.

Signed-off-by: David Goulet <dgoulet@torproject.org>

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08 09:10:08 -04:00
David Goulet
c31d469f37 trace: Comments and configure fix
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08 09:10:08 -04:00
David Goulet
0de543aae6 trace: Add LTTng-UST interface support
No probes at this point. They are per subsystem and thus in later commits.

Part of #32910
2020-07-08 09:10:08 -04:00
David Goulet
668fc70a20 trace: Add USDT probes generation support
This commit adds both configure options and probe generation for tracepoints.

Part of #32910

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08 09:10:08 -04:00
David Goulet
70f031528d trace: Hook lib/trace as a subsystem
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08 09:10:08 -04:00
David Goulet
6fc6cbd9b3 trace: Better structure lib/trace and configure options
In the next commits, we'll add more tracing options for instrumentation and
specific tracer.

This rename follows a more meaningful naming standard. It also adds a catch
all "HAVE_TRACING" define that indicate in the code that we have tracing
enabled.

Part of #32910

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08 09:10:08 -04:00
David Goulet
46e3484261 addr: Initialize resolved address cache to NULL address
Related to #40022

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08 07:50:50 -04:00
David Goulet
9b2cadb492 addr: Validate identity key when getting a suggestion
We do look at the address but with this we also look if the identity digest of
the relay suggesting us an address is a trusted source.

Related to #40022

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08 07:46:16 -04:00
Alexander Færøy
c364e0e83b Merge branch 'maint-0.4.2' into maint-0.4.3 2020-07-08 00:36:48 +00:00
Alexander Færøy
e4bfa734a6 Merge branch 'maint-0.4.4' 2020-07-08 00:36:48 +00:00
Alexander Færøy
9603d8af0b Merge branch 'maint-0.4.3' into maint-0.4.4 2020-07-08 00:36:48 +00:00
Alexander Færøy
b81e24cda6 Merge branch 'maint-0.3.5' into maint-0.4.2 2020-07-08 00:36:47 +00:00
Nick Mathewson
3e08dd9df1 Resolve a compiler warning from a 32-bit signed/unsigned comparison
This warning only affects platforms (like win32) with 32-bit time_t.

Fixes bug 40028; bugfix on 0.3.2.8-rc.
2020-07-07 15:05:38 -04:00
David Goulet
66d5292ee6 Revert "config: Make clients tell dual-stack exits they prefer IPv6"
This reverts commit bf2a399fc0.

Don't set by default the prefer IPv6 feature on client ports because it breaks
the torsocks use case. The SOCKS resolve command is lacking a mechanism to ask
for a specific address family (v4 or v6) thus prioritizing IPv6 when an IPv4
address is asked on the resolve SOCKS interface resulting in a failure.

Tor Browser explicitly set PreferIPv6 so this should not affect the majority
of our users.

Closes #33796

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-07 12:58:41 -04:00
Nick Mathewson
9e33391ebb Merge remote-tracking branch 'tor-github/pr/1974/head' 2020-07-07 11:08:20 -04:00
David Goulet
809c864707 addr: Attempt to learn our address with ORPort
If no Address statement are found in the configuration file, attempt to learn
our address by looking at the ORPort address if any. Specifying an address is
optional so if we can't find one, it is fine, we move on to the next discovery
mechanism.

Note that specifying a hostname on the ORPort is not yet supported at this
commit.

Closes #33236

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-07 10:52:43 -04:00
David Goulet
f5ce8a2bed channel: Consider NETINFO other address as ours
Attempt to learn our address from the NETINFO cell.

At this commit, the address won't be used in the descriptor if selected. Next
commit will make it happen.

Related to #40022

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-07 10:41:10 -04:00
David Goulet
192d367b41 addr: New function relay_address_new_suggestion()
This behaves like router_new_address_suggestion() but differs in couple of
ways:

  1. It takes a tor_addr_t instead of an address string and supports both
     AF_INET and AF_INET6.
  2. It does _not_ use the last_guessed_ip local cache and instead only relies
     on the last resolved address cache in resolve_addr.c

It is not used at this commit. This function is made to process a suggested
address found in a NETINFO cell exactly like router_new_address_suggestion()
does with the address a directory suggests us.

Related to #40022

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-07 10:41:10 -04:00
David Goulet
f57ce632fe addr: Rename and make resolved_addr_set_last() function public
Rename the static function update_resolved_cache() to resolved_addr_set_last()
and make it public.

We are about to use it in order to record any suggested address from a NETINFO
cell.

Related to #40022

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-07 10:41:10 -04:00
David Goulet
78bc52c47c channel: Continue refactor NETINFO process function
In the spirit of reducing technical debt. Move code that marks a channel as a
client into its own function and document it properly.

No behavior change, only code movement.

Related to #40022

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-07 10:41:10 -04:00
David Goulet
789beca783 channel: Refactor NETINFO process function
In order to process a NETINFO cell, the OR connection needs to go through a
series of validation else we don't process the cell.

Move those into its own function in and improve documentation.

This is an attempt at reducing technical debt of the rather large and
complicated channel_tls_process_netinfo_cell() function.

Related to #40022

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-07 10:37:06 -04:00
Nick Mathewson
2aa5e95f58 Fix coccinelle complaint in test-memwipe.c 2020-07-07 15:33:35 +03:00
George Kadianakis
118c35b55b Mark some log messages as used by Chutney. 2020-07-07 12:45:29 +03:00
Alexander Færøy
7b2d10700f Use ((x + 7) >> 3) instead of (x >> 3) when converting from bits to bytes.
This patch changes our bits-to-bytes conversion logic in the NSS
implementation of `tor_tls_cert_matches_key()` from using (x >> 3) to
((x + 7) >> 3) since DER bit-strings are allowed to contain a number of
bits that is not a multiple of 8.

Additionally, we add a comment on why we cannot use the
`DER_ConvertBitString()` macro from NSS, as we would potentially apply
the bits-to-bytes conversion logic twice, which would lead to an
insignificant amount of bytes being compared in
`SECITEM_ItemsAreEqual()` and thus turn the logic into being a
prefix match instead of a full match.

The `DER_ConvertBitString()` macro is defined in NSS as:

    /*
    ** Macro to convert der decoded bit string into a decoded octet
    ** string. All it needs to do is fiddle with the length code.
    */
    #define DER_ConvertBitString(item)            \
        {                                         \
            (item)->len = ((item)->len + 7) >> 3; \
        }

Thanks to Taylor Yu for spotting this problem.

This patch is part of the fix for TROVE-2020-001.

See: https://bugs.torproject.org/33119
2020-07-06 16:19:16 -04:00
Alexander Færøy
06f1e959c2 Add constness to length variables in tor_tls_cert_matches_key.
We add constness to `peer_info_orig_len` and `cert_info_orig_len` in
`tor_tls_cert_matches_key` to ensure that we don't accidentally alter
the variables.

This patch is part of the fix for TROVE-2020-001.

See: https://bugs.torproject.org/33119
2020-07-06 16:19:16 -04:00
Alexander Færøy
b46984e97e Fix out-of-bound memory read in tor_tls_cert_matches_key() for NSS.
This patch fixes an out-of-bound memory read in
`tor_tls_cert_matches_key()` when Tor is compiled to use Mozilla's NSS
instead of OpenSSL.

The NSS library stores some length fields in bits instead of bytes, but
the comparison function found in `SECITEM_ItemsAreEqual()` needs the
length to be encoded in bytes. This means that for a 140-byte,
DER-encoded, SubjectPublicKeyInfo struct (with a 1024-bit RSA public key
in it), we would ask `SECITEM_ItemsAreEqual()` to compare the first 1120
bytes instead of 140 (140bytes * 8bits = 1120bits).

This patch fixes the issue by converting from bits to bytes before
calling `SECITEM_ItemsAreEqual()` and convert the `len`-fields back to
bits before we leave the function.

This patch is part of the fix for TROVE-2020-001.

See: https://bugs.torproject.org/33119
2020-07-06 16:19:16 -04:00
Alexander Færøy
33e1c2e6fd Run tor_tls_cert_matches_key() Test Suite with both OpenSSL and NSS.
This patch lifts the `tor_tls_cert_matches_key()` tests out of the
OpenSSL specific TLS test suite and moves it into the generic TLS test
suite that is executed for both OpenSSL and NSS.

This patch is largely a code movement, but we had to rewrite parts of
the test to avoid using OpenSSL specific data-types (such as `X509 *`)
and replace it with the generic Tor abstraction type
(`tor_x509_cert_impl_t *`).

This patch is part of the fix for TROVE-2020-001.

See: https://bugs.torproject.org/33119
2020-07-06 16:19:16 -04:00
Nick Mathewson
1ee748e4ca Fix coccinelle complaint in test_config.c 2020-07-06 15:17:47 -04:00
David Goulet
95fc085bf3 addr: Fix possible memleak in find_my_address()
Unit tests also suffered from a memleak.

Closes #40024

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-06 11:21:41 -04:00
Nick Mathewson
ac3bc88343 Merge remote-tracking branch 'tor-github/pr/1938/head' 2020-07-06 09:34:13 -04:00
George Kadianakis
00f921edb9 Merge branch 'maint-0.4.4' 2020-07-03 15:54:41 +03:00
George Kadianakis
05ca50c9a3 Merge branch 'tor-github/pr/1962' into maint-0.4.4 2020-07-03 15:54:24 +03:00
David Goulet
6ff4596753 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-07-03 15:52:54 +03:00
George Kadianakis
3bb9b7e743 Merge branch 'tor-github/pr/1934' 2020-07-03 10:50:47 +03:00
David Goulet
064e23e95c Merge branch 'tor-github/pr/1968' 2020-07-02 14:18:00 -04:00
Nick Mathewson
c5707d6cf0 Add braces to IF_BUG_ONCE()s introduced in ticket34069. 2020-07-02 14:17:51 -04:00
Nick Mathewson
873d6d3724 Clean up a redundant debug log in circuit_handle_first_hop().
We don't need to log that we're about to look for a channel for a
given extend_info_t, since we're either going to log that we're
launching one (at info), or that we're using an existing one (at
debug).
2020-07-02 14:17:51 -04:00
Nick Mathewson
e93ad428e2 Allow multiple addresses in extend_info_t.
In practice, there will be at most one ipv4 address and ipv6 address
for now, but this code is designed to not care which address is
which until forced to do so.

This patch does not yet actually create extend_info_t objects with
multiple addresses.

Closes #34069.
2020-07-02 14:17:51 -04:00
Nick Mathewson
b0a716dfb0 Move description of ext contents into an md file.
This way, doxygen can include it.
2020-07-02 13:46:25 -04:00
Nick Mathewson
fbf8bda30b Mention that src/ext should not be edited lightly.
Closes #32661
2020-07-02 13:38:17 -04:00
Nick Mathewson
a34b9a0b62 Merge branch 'ticket33238_045_01_squashed' 2020-07-02 11:00:48 -04:00
David Goulet
45afb31e1c addr: Prioritize interface lookup over local hostname
The find_my_address() function now prioritize the local interface over the
local hostname when guessing the IP address.

See proposal 312, section 3.2.1, general case:
https://gitweb.torproject.org/torspec.git/tree/proposals/312-relay-auto-ipv6-addr.txt#n359

The entire unit tests had to be refactored to make this possible. Instead of
hot patching it, it has been rewritten to cover all possible cases and the
test interface has been changed to accomodate both IPv4 and IPv6 in order for
them to be tested identically.

Closes #33238

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-02 11:00:42 -04:00
Nick Mathewson
2e98e88117 Merge branch 'maint-0.4.4' 2020-07-02 10:15:04 -04:00
Nick Mathewson
18fa53fdf4 Merge branch 'ticket32622_044_squashed' into maint-0.4.4 2020-07-02 10:14:55 -04:00
Nick Mathewson
7b5f58a1c9 Carry TLS error strings forward to controller when reporting them.
Now instead of saying "DONE, DONE" or "MISC, MISC" or "TLS_ERROR,
TLS_ERROR",  we can finally give a nice sensible "TLS_ERROR,
wrong version number" which should help debug a great deal.

Closes ticket 32622.
2020-07-02 10:14:48 -04:00
Nick Mathewson
cca3164f8d Add a convenience function to check for unspec address. 2020-07-02 09:51:04 -04:00
Nick Mathewson
1e97f96888 Refactor channel_connect_for_circuit() to take an extend_info_t. 2020-07-02 09:51:04 -04:00
Nick Mathewson
6a0b9e4746 Allow null ID argument to extend_info_new. 2020-07-02 09:51:04 -04:00
Nick Mathewson
ad71303f5f Remove an untrue comment in extend_cell_t 2020-07-02 09:51:04 -04:00
Nick Mathewson
81d312f12c Add a function for comparing the orport on an extendinfo. 2020-07-02 09:51:03 -04:00
Nick Mathewson
8f362b7bce Extract extend_info manipulation functions into a new file. 2020-07-02 09:51:03 -04:00
Nick Mathewson
56e33f73f1 Light edits to extend_info_t docs 2020-07-02 09:51:03 -04:00
Nick Mathewson
20d1a1cdbd Merge remote-tracking branch 'dgoulet/ticket32822_045_01' 2020-07-02 09:47:43 -04:00
David Goulet
9b560ea714 Merge branch 'maint-0.4.4' 2020-07-02 07:20:58 -04:00
David Goulet
8da10e8237 Merge branch 'maint-0.4.3' into maint-0.4.4 2020-07-02 07:20:58 -04:00
David Goulet
5a5ff3d8c5 Merge branch 'maint-0.4.2' into maint-0.4.3 2020-07-02 07:20:57 -04:00
David Goulet
07d8d398ca Merge branch 'maint-0.3.5' into maint-0.4.2 2020-07-02 07:20:57 -04:00
teor
82010b0e2e parseconf: Add an authority IPv6 ORPort test
These tests don't actually exercise the authority IPv6 ORPort
self-add feature in 32822, but they do improve coverage of the
related config code.

Part of 32822.
2020-07-02 07:09:02 -04:00
teor
1f58b0ca26 router: Authorities add their own IPv6 to trusted dir servers
Authorities currently add themselves to the trusted dir servers list,
but if they have an IPv6 ORPort, they leave it out.

This commit makes authorities add their own IPv6 ORPort to the trusted
dir servers list.

Closes ticket 32822.
2020-07-02 07:09:02 -04:00
Nick Mathewson
538b25241e Merge remote-tracking branch 'dgoulet/ticket33235_045_01' 2020-07-01 16:27:12 -04:00
David Goulet
f152d5b15f test: Rename test_rep_hist to test_stats
The exposed interface is "stats/" thus make the unit tests clear that it is
testing that specific GETINFO command.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-01 12:31:40 -04:00
David Goulet
f30f53e099 Merge branch 'tor-github/pr/1907' 2020-07-01 12:26:19 -04:00
Neel Chauhan
4173876bc4 Add GETINFO "rephist/{tap,ntor}/onion_handshakes_{assigned/requested}" test 2020-07-01 12:00:53 -04:00
Neel Chauhan
4477317cbe control: Add a key to GETINFO to fetch the circuit onion handshake rephist values 2020-07-01 12:00:53 -04:00
Nick Mathewson
368156fcb7 Merge branch 'ticket34137' 2020-07-01 10:34:39 -04:00
Nick Mathewson
5d956d797b Add a comment explaining reachability vs bandwidth self-tests
This is in response to a question about why we don't always log
orport self-tests as reachability tests.

I'm not 100% convinced that bandwidth self-tests are still useful,
but that's an issue for another day. :)
2020-07-01 10:33:27 -04:00
David Goulet
b039d3e803 Merge branch 'tor-github/pr/1953' 2020-07-01 09:47:26 -04:00
George Kadianakis
0d02c053f8 Merge branch 'maint-0.4.3' into maint-0.4.4 2020-07-01 12:55:03 +03:00
George Kadianakis
7f999203ce Merge branch 'maint-0.4.4' 2020-07-01 12:55:03 +03:00
George Kadianakis
1932a84ef5 Merge branch 'maint-0.4.2' into maint-0.4.3 2020-07-01 12:55:02 +03:00
George Kadianakis
38208185be Merge branch 'maint-0.3.5' into maint-0.4.2 2020-07-01 12:55:02 +03:00
George Kadianakis
9beae02713 Merge branch 'tor-github/pr/1766' into maint-0.3.5 2020-07-01 12:54:29 +03:00
Nick Mathewson
8f59b3e6f2 resolve_addr.c: remove a needless quote mark 2020-06-30 14:36:11 -04:00
David Goulet
ec57cbf179 addr: Document better is_local_addr_to_resolve_addr()
This function is about learning if a given address is local to us as in the
resolved address as a relay.

Closes #40009

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30 13:50:01 -04:00