Commit Graph

26567 Commits

Author SHA1 Message Date
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
David Goulet
2ac2ba4e2c node: Rename addrs_in_same_network_family()
New name reflects that the function is only used to compare router addresses
in order to learn if they are in the same network.

The network check is /16 and /32 respectively for IPv4 and IPv6.

Related to #40009

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30 13:48:22 -04:00
David Goulet
b14b1f2b1d addr: Don't guess our address if no Address lines are valid
If at least one Address line is given but invalid, we should not attempt to
guess our address.

This commit sends back the "bail" signal so find_my_address() can return an
error if the requested family doesn't exists but still an Address line is
found which is likely another family.

Fixed in #33235
Related to #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30 12:13:23 -04:00
David Goulet
6f1423cb57 addr: Continue trying all Address options on resolve failure
When going over all Address lines from the configuration, continue to attempt
resolving other lines if one fails.

Before that, we would bail right away and never noticed the other Address
lines.

Fixed in #33235
Related to #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30 12:12:04 -04:00
David Goulet
a8b8a1ee99 addr: Only attempt Address resolution on non parsable lines
In get_address_from_config(), we would attempt to resolve an Address line that
is not from the requested family but that line could be a valid address from
another family (v4 vs v6).

This makes it that we don't attempt to resolve a valid address from another
family.

Found with unit test config/find_my_address_mixed.

Fixed in #33235
Related to #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30 12:05:56 -04:00
David Goulet
89c26f4cfd test: Mixed unit tests for find_my_address()
This unit tests validates the use of IPv4 _and_ IPv6 together as in multiple
option Address lines both addresses and hostnames.

Closes #33235

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30 12:04:18 -04:00
Nick Mathewson
39830b6408 Downgrade "Bug: No entry found in extrainfo map" message.
This is not actually a bug!  It can happen for a bunch of reasons,
which all boil down to "trying to add an extrainfo for which we no
longer have the corresponding routerinfo".

Fixes #16016; bugfix on 0.2.6.3-alpha.
2020-06-30 11:54:13 -04:00
Nick Mathewson
2238b6320b Refactor reachability test logging: log exactly what we launch.
Previously we had two chains of logic for reachability tests: one
for launching them, and one for telling the user that we had
launched them.  Now, we simply have the launch code inform the user:
this way, we can't get out of sync.

Closes ticket 34137.
2020-06-30 11:12:46 -04:00
Alexander Færøy
dbb70d85bf Merge branch 'maint-0.3.5' into maint-0.4.2 2020-06-30 14:23:41 +00:00
Alexander Færøy
8697205be4 Merge branch 'tor-github/pr/1909' into maint-0.3.5 2020-06-30 14:23:17 +00:00
David Goulet
fe6b049651 test: Unit tests for find_my_address() IPv6
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30 10:22:01 -04:00
Alexander Færøy
5a38c73f70 Merge branch 'tor-github/pr/1887' into maint-0.4.3 2020-06-30 14:19:28 +00:00
Alexander Færøy
881f50a9a9 Merge branch 'tor-github/pr/1806' into maint-0.4.2 2020-06-30 14:15:57 +00:00
Alexander Færøy
c9c4a3d0f6 Merge branch 'maint-0.3.5' into maint-0.4.2 2020-06-30 14:03:04 +00:00
David Goulet
faba6909f8 test: Rename function to be IPv4 specific
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30 09:56:14 -04:00
Alexander Færøy
8444fbe904 Merge branch 'tor-github/pr/1793' into maint-0.3.5 2020-06-30 13:55:39 +00:00
Alexander Færøy
483082b57b Merge branch 'maint-0.3.5' into maint-0.4.2 2020-06-30 13:48:49 +00:00
Alexander Færøy
c3ad2a1d23 Merge branch 'tor-github/pr/1785' into maint-0.3.5 2020-06-30 13:47:55 +00:00
Alexander Færøy
b0bfee8c78 Merge branch 'maint-0.3.5' into maint-0.4.2 2020-06-30 13:37:20 +00:00
Alexander Færøy
bebdd2888f Merge remote-tracking branch 'nickm-github/bug32884_035' into maint-0.3.5 2020-06-30 13:35:13 +00:00
Alexander Færøy
96876d3ad7 Merge branch 'tor-github/pr/1940' 2020-06-30 01:22:44 +00:00
Nick Mathewson
d235e523d5 Merge branch 'ticket33290_v2_042' into maint-0.4.2 2020-06-29 13:57:13 -04:00
Nick Mathewson
a692b87f82 Merge remote-tracking branch 'tor-github/pr/1696/head' into maint-0.4.2 2020-06-29 13:53:27 -04:00
Nick Mathewson
0575a182a6 Merge remote-tracking branch 'tor-github/pr/1697/head' into maint-0.4.2 2020-06-29 13:48:25 -04:00
Nick Mathewson
216456299f Merge remote-tracking branch 'tor-github/pr/1722/head' into maint-0.4.2 2020-06-29 12:58:23 -04:00
Nick Mathewson
3008255aea Merge remote-tracking branch 'tor-github/pr/1829/head' into maint-0.4.3 2020-06-29 12:56:39 -04:00
Nick Mathewson
fd8ce812b0 Merge branch 'maint-0.3.5' into maint-0.4.2 2020-06-29 12:55:35 -04:00
Nick Mathewson
0c0214bcc0 Merge remote-tracking branch 'tor-github/pr/1725/head' into maint-0.3.5 2020-06-29 12:55:27 -04:00
Alexander Færøy
f1932265fc Merge branch 'dgoulet/tor-ticket40008_045_01' 2020-06-29 14:09:53 +00:00
Nick Mathewson
e429ceb266 Add a TLS_ERROR bootstrap failure reason.
If our TLS connection fails for a "misc" reason, we don't need to
say that the reason is "misc" -- we can at least localize it to
the TLS module.

Part of a fix for #32622.
2020-06-26 10:59:59 -04:00
Nick Mathewson
d486c6cf74 Store errors from TLS write and handshake in the tls_error field.
Previously, we would only update this field when the error happened
during a read.

This will improves our reporting for our bootstrap status, and help
to address #32622.  The problem is not completely solved by this
patch, however: too many errors are still lumped into "MISC".
2020-06-26 10:58:53 -04:00
Nick Mathewson
5336ac2669 Move remaining CodeStructure.md contents into doxygen. 2020-06-26 10:11:42 -04:00
Nick Mathewson
a7aa97298b Remove special authority semantics for AssumeReachable.
AssumeReachable should only be about whether a relay thinks that it
is reachable itself.  But previously, we've had it also turn off
reachability checking of _other_ relays on authorities.
(Technically, reachability tests were still run, but we would ignore
the results.)

With this patch, there is a new AuthDirTestReachability option
(default 1) that controls whether authorities run reachability
tests.

Making this change allows us to have test networks where authorities
set AssumeReachable without disabling their reachability testing
entirely.

Closes ticket #34445.
2020-06-26 08:37:36 -04:00
Nick Mathewson
dbc2b75009 Merge branch 'assume_reachable_revamp' 2020-06-26 08:34:56 -04:00
Nick Mathewson
cb25f57724 Remove stub macro for router_new_consensus_params()
I had incorrectly believed that the router.c file was disabled when
we were building with relay mode disabled.
2020-06-26 08:32:33 -04:00
David Goulet
40922629fe addr: Look at /48 for IPv6 in is_local_addr()
Closes #33618

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-25 13:45:05 -04:00
David Goulet
069566b40a Merge branch 'tor-github/pr/1951' 2020-06-25 13:41:45 -04:00
David Goulet
374626c09b Merge branch 'tor-github/pr/1917' 2020-06-25 13:35:34 -04:00
Neel Chauhan
7b2ab93f65 Add test for fingerprint-ed25519 file 2020-06-25 13:35:15 -04:00
Neel Chauhan
ef563a8fef Add an fingerprint-ed25519 file to the data directory 2020-06-25 13:35:15 -04:00
David Goulet
dc4f3a219f Merge branch 'tor-github/pr/1948' 2020-06-25 10:13:04 -04:00
Nick Mathewson
50abc06d84 Remove now-unused OPTIONS_DUMP_DEFAULTS. 2020-06-25 10:02:17 -04:00
Nick Mathewson
62e1d983cf Deprecate the "--dump-config non-builtin" option
When it works, "non-builtin" doesn't do anything different from
"short".  (When it doesn't work, it gives an assertion failure.)

Closes ticket #33398.
2020-06-25 10:01:40 -04:00
David Goulet
c370b4a049 Merge branch 'maint-0.4.4' 2020-06-25 07:36:56 -04:00
David Goulet
fd5b2d0f1c Merge branch 'tor-github/pr/1935' 2020-06-24 15:48:47 -04:00
Neel Chauhan
c8fd7b7040 Make HSFETCH take the decoded length into account, not the base32 one 2020-06-24 15:47:57 -04:00
Nick Mathewson
edb023b1e7 Add an AssumeReachableIPv6 autobool option.
This option tells Tor that our IPv6 orport is reachable, and doesn't
need to be checked.

Closes the rest of 33224.
2020-06-24 15:25:34 -04:00
Nick Mathewson
6edf7f6710 Add two new networkstatus parameters to emulate AssumeReachable.
These parameters do not suppress checks, but they tell relays that
it's okay to publish even when those checks fail.

I have chosen lowercase hyphenated names, since these seem to be
more common in networkstatus params.

Closes #33224 and part of #34064.
2020-06-24 15:25:26 -04:00
Nick Mathewson
f9de0affd3 Rename router_should_skip_orport_reachability_check.
This was supposed to happen in #40012, but the command line was wrong.

This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        router_should_skip_orport_reachability_check router_all_orports_seem_reachable
2020-06-24 15:25:17 -04:00
Nick Mathewson
5c5fb0fcca Move code into notify_after_networkstatus_changes().
The purpose of having this function was to inform other code that
the consensus has changed, so it should go there.
2020-06-24 15:25:12 -04:00
Nick Mathewson
93ccb3294b Make a bunch of networkstatus_t parameters constant.
This is part of refactoring our "notify the rest of the code that we
have a new consensus" code.
2020-06-24 15:25:07 -04:00
Nick Mathewson
366c695020 Add a control event for launching IPv6 ORPort checks. 2020-06-24 14:00:34 -04:00
David Goulet
86da0cfd36 Merge branch 'tor-github/pr/1945' 2020-06-24 13:51:51 -04:00
David Goulet
29a35d262c addr: Rename resolved_addr_is_local()
Better function name.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
59f5c3d263 addr: Refactor find_my_address() to simplify it
Instead of a complex if/else block, use a table of functions that have the
same interface and each of them attempt to find the address one after the
other.

Pointed out by nickm's during review.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
25a451bac7 addr: Set out parameters to NULL in resolve_addr.c
By doing this, a memory leak was found with "hostname_used" that could have
been overwritten by another function.

This commit changes that by making it a NULL string instead.

Found by nickm's review.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
5895aafe7e addr: Safeguard last resolved address index access
The last resolved address cache uses an index that is mapped to an address
family (AF_INET and AF_INET6).

This commit adds a conversion function from af to index and change the code to
use that all the time only.

In the process, this commit fixes a bug that the last resolved address
accessors were using the af value insted of the index.

Spotted by nickm during review

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
5f62ae2577 test: Modernize find_my_address() unit test
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
b76325190b addr: Remove resolve_my_address_v4()
Replace it by find_my_address() everywhere. This changes many parts of the
code that uses it to use a tor_addr_t instead of a plain uint32_t for IPv4.

Many changes to the unit test to also use the new interface.

Part #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
2f3b4e3888 addr: Refactor is_local_addr() to support IPv6
Series of changes:

  1. Rename function to reflect the namespace of the file.

  2. Use the new last resolved cache instead of the unused
     last_resolved_addr_v4 (which is also removed in this commit).

  3. Make the entire code base use the new resolved_addr_is_local() function.

You will notice that this function uses /24 to differentiate subnets where the
rest of tor uses /16 (including documentation of EnforceDistinctSubnets).
Ticket #40009 has been opened for that.

But that the moment, the function keeps looking at /24.

Part of #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
7795dd7ef6 addr: Refactor last resolved address cache accessors
Series of things done in this commit:

  1. Rename the functions to better reflect the namespace of the file.

  2. Make both reset and get function to operate on the last_resolved_addrs
     cache that is per family.

  3. Make the get function to take a tor_addr_t.

  4. Change all callsite to use the new convention.

Part of #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
b8042c9d9a addr: Make resolve_my_address_v4() use find_my_address()
In order to transition smoothly, maek resolve_my_address_v4() call the new
fancy find_my_address() with AF_INET.

Next commits should remove the use of resolve_my_address_v4() accross the code
to use find_my_address().

This commit is so the unit tests would be more easily fixed and port to the
new find_my_address() internals.

Part of #33233.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
9e85056de9 addr: New find_my_address() to support multiple address families
resolve_my_address() was beyond repair in terms of refactoring. Way too
complex and doing too many things.

This commit implements find_my_address() which in theory does the same as
resolve_my_address() but in a more clean, concise and modern way using the
tor_addr_t interface and for multiple address family.

The caller needs to pass the address family (IPv4 or IPv6) which this
interface supports. For both, a last resolved cache is used as well.

Implements #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 13:51:37 -04:00
David Goulet
4af6e3b4dc Merge branch 'tor-github/pr/1947' 2020-06-24 13:49:03 -04:00
Nick Mathewson
fd3e0c561d Merge branch 'pr_1931_squashed' 2020-06-24 13:38:32 -04:00
Neel Chauhan
c3c7ef5125 Add routerset_contains_router() test 2020-06-24 13:38:27 -04:00
Neel Chauhan
0a3e6d81bb Make routerset_contains_router() support IPv6 2020-06-24 13:38:27 -04:00
Nick Mathewson
636cf9763a Replace router_should_skip_*() identifiers.
These identifiers are confusing and unreadable.  I think these
replacements should be better. Closes ticket #40012.

This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        router_should_skip_orport_reachability_check_family router_orport_seems_reachable \
        router_should_skip_dirport_reachability_check router_dirport_seems_reachable \
        router_should_skip_dirport_reachability_check router_all_orports_seem_reachable
2020-06-24 13:25:49 -04:00
David Goulet
bc50f082bd Merge branch 'tor-github/pr/1944' 2020-06-24 10:48:14 -04:00
David Goulet
3adabaf3e9 tls: Make buf_read_from_tls() read at most bytes
The buf_read_from_tls() function was designed to read up to a certain number
of bytes a TLS socket using read_to_chunk_tls() which boils down to SSL_read()
(with OpenSSL, common case).

However, at the end of the loop, the returned number of bytes from
read_to_chunk_tls() was treated like the syscall read() for which if less
bytes than the total asked are returned, it signals EOF.

But, with SSL_read(), it returns up to a TLS record which can be less than
what was asked. The assumption that it was EOF was wrong which made the while
loop exiting before it was able to consume all requested bytes (at_most
parameter).

The general use case that Tor sees is that it will ask the network layer to
give it at most 16KB (that is roughly 32 cells) but because of KIST scheduler,
the highest possible TLS record we currently observe is 4096 bytes (4KB or 8
cells). Thus the loop would at best always return 8 cells even though much
more could be on the TLS socket. See ticket #40006 for more details.

Fixes #40006

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 10:47:53 -04:00
George Kadianakis
2eae59e475 Merge branch 'tor-github/pr/1939' 2020-06-24 17:22:53 +03:00
Neel Chauhan
1bd0494f8c Make summarize_protover_flags() handle NULL and empty string the same 2020-06-24 17:22:45 +03:00
David Goulet
2d91960540 Merge branch 'tor-github/pr/1942' 2020-06-24 07:44:41 -04:00
George Kadianakis
a3b573b392 Merge branch 'tor-github/pr/1943' 2020-06-23 20:31:44 +03:00
Mike Perry
220ed863ce Relocate CBT event to control_events.c
Needed to satisfy practracker.
2020-06-23 20:31:26 +03:00
Mike Perry
ad1f8b70b7 Mark state file dirty upon DROPTIMEOUTS command 2020-06-23 20:31:26 +03:00
George Kadianakis
68d848e244 Reinstate support for GUARD NEW/UP/DOWN control port events. 2020-06-23 19:48:37 +03:00
Nick Mathewson
65328fd4e7 Merge branch 'maint-0.4.4' 2020-06-23 12:29:47 -04:00
Nick Mathewson
318753f502 Merge branch 'ticket34382' into maint-0.4.4 2020-06-23 12:29:39 -04:00
Nick Mathewson
ac648fa307 Clarify logic in router_should_skip_orport_reachability_check_family()
The '!=' checks were confusing the issue of what the code was really
doing.
2020-06-23 11:24:20 -04:00
Nick Mathewson
b365179ee0 reachability_warnings_callback: simplify v4/v6_ok logic
Since "skip orport check" is the "and" of v4_ok and v6_ok, we can
just compute v4_ok and v6_ok once, to clarify that we don't enter
this block of code if they're both true.
2020-06-23 11:20:05 -04:00
David Goulet
d08d7e1535 addr: Rename last_resolved_addr to be v4 specific
Part of #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-23 09:25:36 -04:00
David Goulet
6da8c0b4fa addr: Rename resolve_my_address to be v4 specific
Part of #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-23 09:25:36 -04:00
David Goulet
47f9edde69 config: Change Address to be a LINELIST
With prop312, we want to support IPv4 and IPv6 thus multiple Address statement
(up to 2) will be accepted.

For this, "Address" option becomes a LINELIST so we can properly process the
IPv4 or/and IPv6.

Part of #33233

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-23 09:25:36 -04:00
David Goulet
d3bcbccab9 Merge branch 'maint-0.4.4' 2020-06-23 08:52:33 -04:00
David Goulet
5232315168 Merge branch 'tor-github/pr/1937' into maint-0.4.4 2020-06-23 08:52:16 -04:00
Nick Mathewson
ceddc39c59 Merge branch 'pr_1930_squashed' 2020-06-22 15:33:27 -04:00
Neel Chauhan
3bb955a02f Add circuit_extend_add_ipv(4/6)_helper() test 2020-06-22 15:33:03 -04:00
Neel Chauhan
48310a0e76 Fill in missing IPv6 addresses in extend cells 2020-06-22 15:33:03 -04:00
David Goulet
c55e633f74 kist: Document a magic value in channel_should_write_to_kernel()
Closes #40008

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-22 15:28:47 -04:00
David Goulet
033f804429 Merge branch 'maint-0.4.4' 2020-06-22 14:57:50 -04:00
Miguel Jacq
3d0e1c42d9 Consistently use 'address' in Invalid v3 address responses to ONION_CLIENT_AUTH commands 2020-06-22 14:56:07 -04:00
Nick Mathewson
bc9979a670 Split "can reach ipv4 orport" from "can reach ipv6 orport".
I've managed to keep this change mainly contained to our
self-testing module.  The changes here are:

  * There are two different variables for tracking "is our orport
    reachable".

  * We have a new function that says whether we can skip a single
    family's orport reachability test; the old function for this now
    tells whether we can skip _all_ orport reachability testing.

    (The name, router_should_skip_orport_reachability_test, is not
    so good.  I will rename it later if I can think of a good
    replacement.)

  * The function that launches orport reachability tests now only
    launches the ones that haven't completed.

  * The function that notes that we're reachable on an ORPort now
    takes a family.

  * Various log messages are cleaned up.
2020-06-18 16:05:16 -04:00
Neel Chauhan
caebfa5f6f Fix typo in test_build_update_descriptors() comment 2020-06-17 20:12:13 -07:00
Nick Mathewson
6c3897826a selftest: turn can_reach_{dir,or}_port into bools 2020-06-17 16:29:24 -04:00
Neel Chauhan
7cf031a0cc Reject Tor relays running the 0.4.1 series 2020-06-17 12:00:44 -07:00
Nick Mathewson
b67f7d722d Update the list of recommended protocol versions to match >=0.3.5.
Since Tor 0.2.9 has been unsupported since January, 0.3.5 is the
oldest supported version, and its features constitute the oldest
recommended feature-set.

This patch updates these recommendations:

   DirCache=2

      Support for consensus diffs.
      New in 0.3.1.1-alpha.

   HSDir=2

      Support for v3 onion service descriptors.
      New in 0.3.0.4-alpha.

   HSIntro=4

      Support for Ed25519 intropoint authentication keys.
      New in 0.3.0-4-alpha.

   HSRend=2

      Support for rendezvous cells longer than 20 bytes.
      New in 0.2.9.4-alpha.

   Link=5

      Link padding and link padding negotiation.
      New in 0.3.3.2-alpha.

   LinkAuth=3

       Ed25519 link authentication.
       New in 0.3.0.1-alpha.
2020-06-17 11:07:43 -04:00
Nick Mathewson
a82c0cdfcf Spelling fix: "RECCOMEND" => "RECOMMEND". 2020-06-17 10:37:47 -04:00
Nick Mathewson
93d582b8e9 Bump to 0.4.4.1-alpha-dev 2020-06-16 19:38:38 -04:00
Mike Perry
a4a0cb8d55 Bug 32040: Machine updates.
Does not require protover update, since this is just client-side.
2020-06-16 12:26:17 -05:00
Mike Perry
ce9a4e5baf Bug 32040: Tests 2020-06-16 12:24:34 -05:00
Mike Perry
f697ac5861 Bug 32040: Add a keep_*_mask to keep circpad machines
Allows us to program machines that stay around after creation if circuit state
or purpose changes.
2020-06-16 12:24:29 -05:00
Nick Mathewson
148291a52e Bump to 0.4.4.1-alpha 2020-06-15 16:45:18 -04:00
Nick Mathewson
9fdaede3f7 Remove AssumeReachable from TestingTorNetwork.
Closes ticket 34446.
2020-06-15 14:08:42 -04:00
David Goulet
8361e3c4ab core: Remove unused files
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-12 14:40:49 -04:00
George Kadianakis
3cb77a9cca Merge branch 'maint-0.4.4' 2020-06-11 17:29:54 +03:00
George Kadianakis
755b8252a4 Fix and update unittests.
Co-authored-by: Florentin Rochet <florentin.rochet@uclouvain.be>
2020-06-11 16:13:20 +03:00
George Kadianakis
714e235a3c Update functions that load and write the guard state file.
Co-authored-by: Florentin Rochet <florentin.rochet@uclouvain.be>
2020-06-11 16:13:13 +03:00
George Kadianakis
d2c3b6ea1e Pick guards on the order they were sampled (prop310).
Co-authored-by: Florentin Rochet <florentin.rochet@uclouvain.be>
2020-06-11 16:13:09 +03:00
Florentin Rochet
7bf0587ef1 Refactor some guard state file parsing code into functions.
Co-authored-by: Florentin Rochet <florentin.rochet@uclouvain.be>
2020-06-11 16:12:31 +03:00
George Kadianakis
1797d05165 Merge branch 'tor-github/pr/1925' 2020-06-10 15:37:59 +03:00
Mike Perry
1300e6a512 Bug 30992: Update tests 2020-06-10 15:37:44 +03:00
Mike Perry
0a4bc8fe90 Bug 30992: Track a padding machine ctr to reduce race issues.
This tracking of the instantiation count should eliminate race conditions due
to starting and stopping machines rapidly. Now, we should no longer obey
STOP commands for previous machines.
2020-06-10 15:37:44 +03:00
Nick Mathewson
354f085e5f Merge remote-tracking branch 'tor-github/pr/1888/head' 2020-06-09 15:44:58 -04:00
Nick Mathewson
d2f136aab1 Bump version to 0.4.5.0-alpha-dev 2020-06-09 14:14:43 -04:00
Mike Perry
9eb0eeb68e Update Trunnel for new machine_ctr field.
This field area was memset to 0 in old versions, which the code treats as
"match any machine instance", for backward compatibility without a protover
bump.
2020-06-08 18:05:34 -05:00
Mike Perry
6ec01c5f72 Provide a DROPTIMEOUTS command to drop CBT times
This allows us to reset CBT when we change guards in fixed-guards onionperf
instances (#33325 and children).
2020-06-07 22:16:25 -05:00
Daniel Pinto
27315de590 Make curve25519_public_to_base64 output padding optional #7869 2020-06-06 10:44:28 +01:00
Nick Mathewson
1fb9be5396 Merge remote-tracking branch 'tor-github/pr/1902/head' 2020-06-05 10:08:27 -04:00
rl1987
3e4814edeb Fix some checks of tor_inet_ntoa() return value
Also, fix a format string.
2020-06-05 11:49:24 +03:00
Nick Mathewson
1e98d56617 sandbox: Do not require M_SYSCALL.
M_SYSCALL is used to report information about a sandbox violation,
but when we don't have a definition for it, it still makes sense to
compile.

Closes ticket 34382.
2020-06-04 12:08:02 -04:00
Nick Mathewson
2b98df3c74 Merge remote-tracking branch 'tor-github/pr/1910/head' 2020-06-04 10:33:36 -04:00
c
8b568b50a5
config: Styling fix + use fmt_addr()
Conform to C99 as suggested by nickm on #32888 and use fmt_addr() rather
than tor_addr_to_str_dup()
2020-06-04 13:15:27 +00:00
c
1934e399af
config: Add interface address debug logging
Add logging for "the local network interface addresses" as requested by
ticket #32888.
2020-06-03 14:42:53 +00:00
Nick Mathewson
b4ccafd175 remove a period from a doxygen heading
The other headings don't have periods.
2020-06-02 11:47:20 -04:00
George Kadianakis
6b05d447bb Merge branch 'tor-github/pr/1909' into maint-0.4.3 2020-06-02 14:05:33 +03:00
George Kadianakis
22a26a273e Merge branch 'tor-github/pr/1909' 2020-06-02 14:01:49 +03:00
c
7640a95602
config: Add IPv4 Address config debug logging
Per ticket #32888 this should address logging "the Address torrc
option", "and whether it is an IP address, or a DNS name"; or the
detected "local hostname", "and whether it is an IP address, or a DNS
name". Some of these details already seem to be logged, so just add
what's missing.
2020-06-01 13:02:21 +00:00
Roger Dingledine
39f2411b3f Preemptive circs should work with UseEntryGuards 0
Resume being willing to use preemptively-built circuits when
UseEntryGuards is set to 0. We accidentally disabled this feature with
that config setting (in our fix for #24469), leading to slower load times.

Fixes bug 34303; bugfix on 0.3.3.2-alpha.
2020-05-30 02:20:48 -04:00
David Goulet
5922087ea8 Merge branch 'tor-github/pr/1901' 2020-05-28 09:52:29 -04:00
George Kadianakis
6891d1bbcb Merge branch 'tor-github/pr/1792' into maint-0.4.3 2020-05-28 12:25:57 +03:00
David Goulet
1810771799 hs-v3: Improve accessor semantic of client cached object
Add an inline helper function that indicates if the cached object contains a
decrypted descriptor or not.

The descriptor object is NULL if tor is unable to decrypt it (lacking client
authorization) and some actions need to be done only when we have a decrypted
object.

This improves code semantic.

Fixes #33458

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-05-28 12:25:42 +03:00
George Kadianakis
8d8a9d7f1d Merge branch 'tor-github/pr/1898' 2020-05-27 15:17:55 +03:00
Neel Chauhan
fd5ea48c27 Add HS v3 status to the SIGUSR1 dumpstats() 2020-05-27 15:16:39 +03:00
Nick Mathewson
43f4324e29 Merge remote-tracking branch 'tor-github/pr/1899/head' 2020-05-21 10:08:48 -04:00
George Kadianakis
3121e5c103 Merge branch 'tor-github/pr/1850' 2020-05-21 16:24:32 +03:00
George Kadianakis
fb281daf29 Merge branch 'tor-github/pr/1861' 2020-05-21 16:22:47 +03:00
rl1987
7a004fce8d Tweak format string 2020-05-21 14:26:08 +03:00
rl1987
a5d28bf88f Check for NULL from tor_dup_ip() 2020-05-21 14:17:15 +03:00
rl1987
ded99992b8 Bail out of format_networkstatus_vote if fmt_addr32() failed.
Something is fishy if we cannot put IP address string into dir-vote line.
2020-05-21 13:43:45 +03:00
rl1987
38cbfda119 Actually, bail out of routerstatus_format_entry() if fmt_addr32() fails 2020-05-21 13:43:41 +03:00
rl1987
8ab7e30484 Check that fmt_addr32() returned non-empty string before putting it into documents 2020-05-21 13:41:19 +03:00
rl1987
d8e24684b6 Check for possible failures of tor_inet_ntop/tor_inet_ntoa in fmt_addr32 and tor_dup_ip 2020-05-21 13:41:15 +03:00
rl1987
b5bfdbfd41 Check output value of tor_inet_ntop/tor_inet_ntoa in dns.c 2020-05-21 13:41:11 +03:00
George Kadianakis
baee2feddd Fix an enum comparison that was blowing up jenkins.
The warning was:
    11:23:10 ../tor/src/feature/hs/hs_service.c: In function 'log_cant_upload_desc':
    11:23:10 ../tor/src/feature/hs/hs_service.c:3118:3: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
See #34254 for more info.

I guess this means that gcc assigned an unsigned type to the
`log_desc_upload_reason_t` enum and it warned if we compared it against 0...

For now I think it's simpler to remove that check instead of turning the enum
to a signed type, or trying to hack it some other way.

From what it seems, enum is up to the compiler on whether it's signed/unsigned:
     https://stackoverflow.com/questions/159034/are-c-enums-signed-or-unsigned
2020-05-21 13:39:49 +03:00
Damon Harris
c4fb3bfed5 Add support for console control signals in Windows 2020-05-20 23:28:39 +05:30
David Goulet
ca13249dcc Merge branch 'tor-github/pr/1886' 2020-05-19 15:18:17 -04:00
David Goulet
ee0fb69fee Merge branch 'tor-github/pr/1897' 2020-05-19 15:17:08 -04:00
David Goulet
5d99985e43 Merge branch 'tor-github/pr/1894' 2020-05-19 15:14:38 -04:00
Nick Mathewson
400bc46d83 doxygen: add a link to src-ref on mainpage.md.
Closes 34246.
2020-05-19 09:44:36 -04:00
Nick Mathewson
9b55a62e73 Merge branch 'maint-0.4.3' 2020-05-19 09:39:12 -04:00
Nick Mathewson
68fe8826dd Doxygen: fix unbalanced groups.
Closes ticket 34255.
2020-05-19 09:18:39 -04:00
teor
8fbcc055e5 node: Clean up some outdated comments
Part of 34200.
2020-05-18 21:53:52 +10:00
teor
73ace125a9 routerlist: Choose bridges for direct bridge connections
When counting and choosing nodes on a client that uses bridges, only
choose bridges for direct connections.

Part of 34200.
2020-05-18 21:53:52 +10:00
teor
e46c3d95f4 circuitbuild: Do node checks when counting nodes
Use the node check function to check that there are enough nodes to
select a circuit path.

Adds these checks, which are implied by other code:
* supports EXTEND2 cells,
* does not allow single-hop exits,

Adds these extra checks:
* has a general-purpose routerinfo,
* if it is a direct connection, check reachable addresses.
These checks reduce the node count, but they will never under-count
nodes.

Bridge nodes aren't handled correctly, we'll fix that in the next
commit.

Part of 34200.
2020-05-18 21:53:52 +10:00
teor
766fc86df4 circuitbuild: Do node checks when choosing exits
And check that the correct flags are passed when choosing exits.

Adds the following checks for exits:
* must support EXTEND2 cells,
* must have an ntor circuit crypto key,
* can't require the guard flag,
* can't be a direct connection.

All these checks are already implied by other code.

Part of 34200.
2020-05-18 21:53:52 +10:00
teor
38c72400b7 routerlist: Split the node checks into their own function
Split the node choosing checks into their own function, so we can call
it independently of iterating through the nodelist.

Part of 34200.
2020-05-18 21:53:52 +10:00
teor
a3244c03fb nodelist: Replace int with bool
Make some interfaces and implementations consistent by replacing int
with bool.

Part of 34200.
2020-05-18 21:53:52 +10:00
teor
3f7f976d48 nodelist: Stop recursing in router_choose_random_node()
Instead, call out to a helper function, repeating the call if needed.

Avoids duplicating exclusions for:
  * the current relay's family, and
  * any exclusions specified by the caller.

Part of 34200.
2020-05-18 21:53:52 +10:00
teor
2ea1692c20 nodelist: Rewrite router_crn_flags_t
Re-order the flags in a logical order, and re-number them.
Add missing comments, fix comment typos.

Part of 34200.
2020-05-18 21:53:52 +10:00
teor
48413dc65f nodelist: Remove the unused CRN_WEIGHT_FOR_EXIT flag
Part of 34200.
2020-05-18 21:53:52 +10:00
teor
1ec604f0f9 nodelist: Move node flag checks
Move node flag checks to router_add_running_nodes_to_smartlist(), where
they are actually used.

Part of 34200.
2020-05-18 21:53:52 +10:00
teor
280195f414 nodelist: Move the v3 onion service rendezvous check
And delete a loop that is now empty. This change should improve tor's
performance, because we no longer iterate through the nodelist twice for
every node in every circuit path.

Part of 34200.
2020-05-18 21:53:52 +10:00
teor
ce11e3bf69 nodelist: Move the single-hop exit check
Check for single-hop exits in router_add_running_nodes_to_smartlist(),
rather than router_choose_random_node().

Part of 34200.
2020-05-18 21:53:52 +10:00
teor
4bcec38fce test/protover: Add debug logs to some tests
Part of 33222.
2020-05-18 21:51:31 +10:00
teor
3efe53562f rust/protover: Fix protocol version support error handling
Make Rust protocol version support checks consistent with the
undocumented error behaviour of the corresponding C code.

Fixes bug 34251; bugfix on 0.3.3.5-rc.
2020-05-18 21:50:35 +10:00
teor
f05c144d7c rust: declare HSIntro=5
Declare support for the onion service introduction point denial of
service extensions, when building tor with Rust.

Fixes bug 34248; bugfix on 0.4.2.1-alpha.
2020-05-18 20:16:11 +10:00
Neel Chauhan
087b466fcf Declare variables in for loops in rend_service_dump_stats() 2020-05-17 15:19:39 -07:00
teor
c6bcc92c17 test/protover: Add tests for summarize flags
Part of 33222.
2020-05-17 22:51:43 +10:00
Neel Chauhan
32e791be09 Fix spacing in if statement in tor_version_parse() 2020-05-16 22:26:30 -07:00
Neel Chauhan
2e0d0360cd Fix spacing in if statement in port_parse_config() 2020-05-16 22:23:59 -07:00
teor
277baf676b versions: Improve the protover summary comments
Part of 33222.
2020-05-15 23:34:43 +10:00
Nick Mathewson
c0dd2a6e39 bump to 0.4.3.5-dev 2020-05-15 09:02:12 -04:00
teor
a702e92c82 protover: Add defines for recent protocol versions
Also update the protover/supported_protocols test.

Part of 33226.
2020-05-15 14:59:10 +10:00
teor
c39394afa2 test/circuitbuild: Tests for node selection flags
Part of 33222.
2020-05-15 12:22:34 +10:00
Nick Mathewson
75fc33f337 bump to 0.4.3.5 2020-05-14 10:37:42 -04:00
teor
5f577b0f25 circuitbuild: Refactor IPv6 extend node selection
Move this complex check into its own function.

Part of 33222.
2020-05-14 22:06:14 +10:00
teor
2e41d82cc5 circuitbuild: Refactor build state node selection flags
Move common build state to node selection flags conversion code into its
own function.

Part of 33222.
2020-05-14 22:05:46 +10:00
teor
6a0fdf381d circuitbuild: test relays sending IPv6 extend cells
Add tests for relays sending IPv6 extend cells in
circuit_send_next_onion_skin().

Clients also use this code, check that they can only extend over IPv4
(for now).

Part of 33222.
2020-05-14 21:15:16 +10:00
teor
d41d13ea73 test: Move the origin circuit function to test helpers
Part of 33222.
2020-05-14 10:44:56 +10:00
teor
9949b545c8 test/circuitstats: Refactor common code
Refactor common circuitstats test code into its own function.

Part of 33222.
2020-05-14 10:38:09 +10:00
teor
e9c9e171ae test/circuitstats: Fix a bunch of coding style issues
Part of 33222.
2020-05-14 10:23:14 +10:00
teor
115a453f04 test/circuitbuild: Add a test for origin_circuit_init()
Part of 33222.
2020-05-13 20:06:27 +10:00
Nick Mathewson
1557e73c82 Merge branch 'bug34130_035' 2020-05-12 12:58:19 -04:00
Daniel Pinto
2913dbd6d9 Fix crash when tor is compiled with NSS and seccomp sandbox is enabled
Adds seccomp rules for socket and getpeername used by NSS
2020-05-12 12:56:06 -04:00
teor
8829d2d644 nodelist: Fix a comment and a log message 2020-05-11 17:01:49 +10:00
teor
1c1faf586a routerlist: Choose nodes that can initiate IPv6 extends
Part of 33226.
2020-05-11 17:00:25 +10:00
teor
9e7f51e469 circuit: Add flags for IPv6 extends
But don't implement the actual node selection yet.

Part of 33226.
2020-05-11 16:54:01 +10:00
teor
c7f085d9bd protover: Add node functions for IPv6 extend support
Part of 33226.
2020-05-11 14:39:42 +10:00
teor
51f32140b4 protover: Sort version flags by their underlying protocols
Also fix some comment typos, mainly ">=" when the code says "=".

Part of 33226.
2020-05-11 12:24:06 +10:00
teor
e787e521af protover: Declare support for Relay=3
Declare support for the new Relay=3 IPv6 extend protocol,
in C and Rust.

Part of 33226.
2020-05-11 11:08:20 +10:00
Daniel Pinto
cce16a939c Improve logging of included config files 2020-05-08 01:10:59 +01:00
Nick Mathewson
b7a165228f Merge remote-tracking branch 'tor-github/pr/1880/head' 2020-05-07 08:19:11 -04:00
teor
492c512af4 relay: Improve docs on inform_testing_reachability()
Document race conditions that we'll resolve in 34067 and 34137.

Part of 33222.
2020-05-07 22:06:13 +10:00
teor
504b16fb75 relay: Rewrite inform_testing_reachability()
Rewrite inform_testing_reachability() to use separate buffers for IPv4
ORPort, IPv6 ORPort, and IPv4 DirPort. And use consistent APIs to fill
those buffers.

Part of 33222.
2020-05-07 20:59:10 +10:00
teor
e887887cd3 relay: Clarify a comment in selftest.c 2020-05-07 20:57:14 +10:00
Neel Chauhan
0daa1da3ba Define and use TOR_ADDRPORT_BUF_LEN 2020-05-07 20:38:25 +10:00
teor
c76f310fe7 routerinfo: Make router_get_orport() return an error status
Part of 33222.
2020-05-07 20:25:36 +10:00
teor
e1eecac888 Replace several C identifiers.
This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        client_or_conn_should_skip_reachable_address_check router_or_conn_should_skip_reachable_address_check \
        client_dir_conn_should_skip_reachable_address_check router_dir_conn_should_skip_reachable_address_check
2020-05-07 20:17:57 +10:00
teor
74902c8aca Wrap long lines 2020-05-07 20:16:56 +10:00
teor
05c56ae455 Replace several C identifiers.
This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        router_skip_orport_reachability_check router_should_skip_orport_reachability_check \
        router_skip_dirport_reachability_check router_should_skip_dirport_reachability_check \
        router_connect_assume_or_reachable client_or_conn_should_skip_reachable_address_check \
        router_connect_assume_dir_reachable client_dir_conn_should_skip_reachable_address_check

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-05-07 20:07:13 +10:00
Nick Mathewson
3a785dd5be Merge branch 'maint-0.4.3' 2020-05-06 17:17:19 -04:00
Nick Mathewson
b444096be5 Fix a boolean logic error when logging about invalid hostnames.
Fixes bug 34131; bugfix on 0.4.3.1-alpha.
2020-05-06 17:15:37 -04:00
Nick Mathewson
b7fcbb28d4 connection_or_finished_flushing(): add a missing "break;"
This one is harmless like the others (so far)
2020-05-06 17:09:27 -04:00
Nick Mathewson
e8fdba198e Merge branch 'maint-0.4.2' into maint-0.4.3 2020-05-06 17:07:47 -04:00
Nick Mathewson
b16c1e4cf6 Merge branch 'maint-0.4.1' into maint-0.4.2 2020-05-06 17:07:27 -04:00
Nick Mathewson
d41f1cd3ed btrack_orconn_cevent.c: Add a missing "break;" 2020-05-06 17:07:12 -04:00
Nick Mathewson
4a2347d290 Merge branch 'maint-0.4.3'
Amazingly, this time we had no merge conflicts with "falls through" comments.
2020-05-06 16:55:41 -04:00
Nick Mathewson
c116728209 Use __attribute__((fallthrough)) rather than magic GCC comments.
GCC added an implicit-fallthrough warning a while back, where it
would complain if you had a nontrivial "case:" block that didn't end
with break, return, or something like that.  Clang recently added
the same thing.

GCC, however, would let you annotate a fall-through as intended by
any of various magic "/* fall through */" comments.  Clang, however,
only seems to like "__attribute__((fallthrough))".  Fortunately, GCC
accepts that too.

A previous commit in this branch defined a FALLTHROUGH macro to do
the right thing if GNUC is defined; here we replace all of our "fall
through" comments with uses of that macro.

This is an automated commit, made with the following perl one-liner:

  #!/usr/bin/perl -i -p
  s#/\* *falls? ?thr.*?\*/#FALLTHROUGH;#i;

(In order to avoid conflicts, I'm applying this script separately to
each maint branch. This is the 0.4.3 version.)
2020-05-06 16:55:25 -04:00
Nick Mathewson
28ac17f433 Use __attribute__((fallthrough)) rather than magic GCC comments.
GCC added an implicit-fallthrough warning a while back, where it
would complain if you had a nontrivial "case:" block that didn't end
with break, return, or something like that.  Clang recently added
the same thing.

GCC, however, would let you annotate a fall-through as intended by
any of various magic "/* fall through */" comments.  Clang, however,
only seems to like "__attribute__((fallthrough))".  Fortunately, GCC
accepts that too.

A previous commit in this branch defined a FALLTHROUGH macro to do
the right thing if GNUC is defined; here we replace all of our "fall
through" comments with uses of that macro.

This is an automated commit, made with the following perl one-liner:

  #!/usr/bin/perl -i -p
  s#/\* *falls? ?thr.*?\*/#FALLTHROUGH;#i;

(In order to avoid conflicts, I'm applying this script separately to
each maint branch. This is the 0.4.2 version.)
2020-05-06 16:53:40 -04:00
Nick Mathewson
79ff2b6aab Use __attribute__((fallthrough)) rather than magic GCC comments.
GCC added an implicit-fallthrough warning a while back, where it
would complain if you had a nontrivial "case:" block that didn't end
with break, return, or something like that.  Clang recently added
the same thing.

GCC, however, would let you annotate a fall-through as intended by
any of various magic "/* fall through */" comments.  Clang, however,
only seems to like "__attribute__((fallthrough))".  Fortunately, GCC
accepts that too.

A previous commit in this branch defined a FALLTHROUGH macro to do
the right thing if GNUC is defined; here we replace all of our "fall
through" comments with uses of that macro.

This is an automated commit, made with the following perl one-liner:

  #!/usr/bin/perl -i -p
  s#/\* *falls? ?thr.*?\*/#FALLTHROUGH;#i;

(In order to avoid conflicts, I'm applying this script separately to
each maint branch. This is the 0.4.1 version.)
2020-05-06 16:52:03 -04:00
Nick Mathewson
cc397449fc Use __attribute__((fallthrough)) rather than magic GCC comments.
GCC added an implicit-fallthrough warning a while back, where it
would complain if you had a nontrivial "case:" block that didn't end
with break, return, or something like that.  Clang recently added
the same thing.

GCC, however, would let you annotate a fall-through as intended by
any of various magic "/* fall through */" comments.  Clang, however,
only seems to like "__attribute__((fallthrough))".  Fortunately, GCC
accepts that too.

A previous commit in this branch defined a FALLTHROUGH macro to do
the right thing if GNUC is defined; here we replace all of our "fall
through" comments with uses of that macro.

This is an automated commit, made with the following perl one-liner:

  #!/usr/bin/perl -i -p
  s#/\* *falls? ?thr.*?\*/#FALLTHROUGH;#i;
2020-05-06 16:51:11 -04:00
Nick Mathewson
42246f8c9a Merge branch 'maint-0.4.3' 2020-05-06 16:50:21 -04:00
Nick Mathewson
2cd1c07658 hs_dos.c: rewrite a comment not to say "fallthrough"
There's nothing wrong with the comment, but the script I'm about to
apply wouldn't like it.
2020-05-06 16:49:57 -04:00
Nick Mathewson
d04b708b4b Merge branch 'maint-0.4.1' into maint-0.4.2 2020-05-06 16:47:03 -04:00
Nick Mathewson
82effefb69 Merge branch 'maint-0.4.3' 2020-05-06 16:47:03 -04:00
Nick Mathewson
fecc5fd38d Merge branch 'maint-0.4.2' into maint-0.4.3 2020-05-06 16:47:03 -04:00
Nick Mathewson
3e42464f5a Merge branch 'bug34078_prelim_035' into bug34078_prelim_041 2020-05-06 15:18:36 -04:00
Nick Mathewson
3d3641152b Remove an incorrect "Fall through" comment. 2020-05-06 15:08:02 -04:00
Nick Mathewson
8798c0a94a address.c: add a single (harmless) missing break; 2020-05-06 15:08:02 -04:00
Nick Mathewson
37b8324ed3 include compat_compiler for ed25519_donna 2020-05-06 15:08:02 -04:00
Nick Mathewson
9fe23b8672 Replace some "fall through" comments not at the end of a case. 2020-05-06 15:08:02 -04:00
Nick Mathewson
75547c01a3 Replace a "fall through" comment that was outside a switch. 2020-05-06 15:08:02 -04:00
Nick Mathewson
6c3c94357c Add a fallthrough macro.
This macro defers to __attribute__((fallthrough)) on GCC (and
clang).  Previously we had been using GCC's magic /* fallthrough */
comments, but clang very sensibly doesn't accept those.

Since not all compiler recognize it, we only define it when our
configure script detects that it works.

Part of a fix for 34078.
2020-05-06 15:08:02 -04:00
David Goulet
c81c5a2646 relay: Rename relay_resolve_addr.{c|h} file
New name is more accurate semantically.

Closes #33789

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-05-05 15:34:58 -04:00
Alex Xu (Hello71)
42dfcd0ae3 core/or: Lift slow call out of loop, #33977 2020-05-05 15:07:42 -04:00
David Goulet
a25f167072 config: New file resolve_addr.{c|h}
Move a series of function from config.c into that new file which is related to
address resolving.

Part of #33789

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-05-05 14:24:04 -04:00
David Goulet
445df9e7b5 relay: New file relay_resolve_addr.{c|h}
This commit moves router_pick_published_address() and the related helper
functions into the new file.

The log_addr_has_changed() function has been made public in router.h so we can
use it in relay_resolve_addr.c.

This is a refactoring as part of Sponsor 55. Only code movement at this
commit.

Part of #33789

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-05-05 14:24:04 -04:00
Nick Mathewson
f96b6ccee1 Merge branch 'maint-0.4.3' 2020-05-04 10:25:53 -04:00
Nick Mathewson
bbfc498e21 Merge branch 'maint-0.4.1' into maint-0.4.2 2020-05-04 10:25:52 -04:00
Nick Mathewson
b1c383e3e6 Fix a GCC 10.0.1 compilation error.
Do not try to stuff "HS_DESC_DECODE_GENERIC_ERROR" (-1) into a
socks5_reply_status_t (enum).  It doesn't actually make sense, and
isn't one of our documented extensions.

(This can only happen on a nonfatal assertion that we haven't seen,
so it probably isn't happening in practice.)

Fixes another case of bug 34077; bugfix on 0.4.3.1-alpha.
2020-04-30 23:04:56 -04:00
Nick Mathewson
6aaee6133d Merge branch 'bug34077_042' into bug34077_043 2020-04-30 23:01:58 -04:00
Nick Mathewson
b4b1882da0 Merge branch 'bug34077_041' into bug34077_042 2020-04-30 22:59:08 -04:00
Nick Mathewson
d7e166bd95 Fix a GCC 10.0.1 compilation warning.
Fixes 34077 for 0.4.1; bugfix on 0.4.0.3-alpha. (Specifically, GCC
first gives this warning for 9eeff921ae)
2020-04-30 22:56:31 -04:00
teor
4a36dfebee circuitbuild: Allow relays to send IPv6 extend cells
Allow relays and bridges to send IPv4 or IPv6 extend cells.
But keep restricting clients to IPv4 extend cells, because sending IPv6
extend cells would be an obvious version distinguisher.

Part of 33222.
2020-04-30 23:27:48 +10:00
teor
4969dee102 relay: Update some self-test comments for IPv6
Part of 33222.
2020-04-30 23:27:38 +10:00
teor
aade9f31e7 relay: Log IPv4 and IPv6 ORPorts when testing reachability
When a relay starts testing reachability, log its IPv6 ORPort.
The existing code logs the IPv4 ORPort and DirPort.

The IPv4 ORPort is required. The other ports are only logged if they
are present.

Part of 33222.
2020-04-30 23:27:27 +10:00
teor
2a0e48385d relay: Launch IPv4 and IPv6 ORPort self-test circuits
When launching relay ORPort reachability self-tests, launch tests to the
IPv4 and IPv6 ORPorts (if available).

Part of 33222.
2020-04-30 23:27:13 +10:00
teor
01d940e71b relay: Refactor dirport self-test circuit launch
Remove some redundant variables, and improve some comments.

Explain that there are no advertised IPv6 DirPorts.

Part of 33222.
2020-04-30 23:26:58 +10:00
teor
a250dd6042 relay: Refactor reachability circuit launches
Split OR and Dir reachability circuits into their own functions.

Part of 33222.
2020-04-30 23:26:45 +10:00
teor
900994e46a relay: Remove unused DirPort self-test code
DIRIND_ANON_DIRPORT never uses our ORPort, so we don't need to set it in
the directory request.

Part of 33222.
2020-04-30 23:26:35 +10:00
teor
18174fb82f relay: Add an address family to self-test launches
Add an address family argument to the functions that launch relay ORPort
self-test circuits.

Part of 33222.
2020-04-30 23:26:31 +10:00
teor
6dc9930d3a
Merge branch 'pr1870_squashed' 2020-04-30 22:22:09 +10:00
Neel Chauhan
7bf257b129
Define and use TOR_ADDRPORT_BUF_LEN 2020-04-30 22:21:48 +10:00
teor
42e765efad relay: Minor selftest comment updates
Part of 33222.
2020-04-30 15:58:59 +10:00
teor
d1c52e585b relay: Wrap long lines
Part of 33222.
2020-04-30 15:58:59 +10:00
teor
c5ee3d7eb8 relay: Clarify reachability status check functions
This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        check_whether_orport_reachable router_skip_orport_reachability_check \
        check_whether_dirport_reachable router_skip_dirport_reachability_check

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.

Part of 33222.
2020-04-30 15:58:37 +10:00
teor
c32a8243cb nodelist: Wrap long lines, and improve comments
Part of 33222.
2020-04-30 15:12:35 +10:00
teor
caab67d0c2 nodelist: Distinguish client and relay reachability
Change some function names to distinguish between:
* client first hop reachability (ReachableAddresses)
* relay port reachability self-tests

This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        router_skip_or_reachability router_connect_assume_or_reachable \
        router_skip_dir_reachability router_connect_assume_dir_reachable

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.

Part of 33222.
2020-04-30 15:12:27 +10:00
teor
3eca667ae4
relay: Fix a comment typo in the selftest.c header 2020-04-30 13:54:40 +10:00
Nick Mathewson
49800cf539 Merge remote-tracking branch 'tor-github/pr/1864/head' 2020-04-29 19:16:40 -04:00
teor
15a4180a7e relay: Refactor can extend over IPv6 checks
Split "can extend over IPv6" and "has advertised IPv6 ORPort" into
separate functions. They currently have the same result, but this may
change in 33818 with ExtendAllowIPv6Addresses.

Part of 33817.
2020-04-30 06:54:42 +10:00
teor
066d2deb3d channel: Refactor matches target address function
Refactor channel_matches_target_addr_for_extend() to return a boolean
result.

Part of 33817.
2020-04-30 06:54:42 +10:00
teor
496ddd2877 relay: Refactor extend address validity function
Rename the function, and give it a boolean return value.

No behaviour change.

Part of 33817.
2020-04-30 06:54:42 +10:00
teor
cd7e2fc210 net: Make all address bytes functions take uint8_t *
Part of 33817.
2020-04-30 06:54:42 +10:00
teor
f62b051e87 Rename tor_addr_get_ipv6_bytes to tor_addr_copy_ipv6_bytes
This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        tor_addr_get_ipv6_bytes tor_addr_copy_ipv6_bytes
2020-04-30 05:54:39 +10:00
teor
bcec1ec071 relay: Refactor choosing extend IPs
Flatten the logic in circuit_choose_ip_ap_for_extend().

Part of 33817.
2020-04-29 22:43:09 +10:00
teor
df5ea29775 relay: Add tests for choosing extend IPs
Part of 33817.
2020-04-29 22:43:09 +10:00
teor
9a6186c267 relay: Refactor circuit_open_connection_for_extend()
Refactor circuit_open_connection_for_extend(), splitting out the IP
address choice code into a new function.

Adds unit tests. No behaviour changes in tor.

Part of 33817.
2020-04-29 22:43:09 +10:00
teor
cab05a84cd relay: Add IP version tests for circuit extends
Add IPv4-only and IPv6-only tests for
circuit_open_connection_for_extend().

Part of 33817.
2020-04-29 22:43:09 +10:00
teor
c3e058dfac relay: Choose between IPv4 and IPv6 extends at random
When an EXTEND2 cell has an IPv4 and an IPv6 address, choose one of them
uniformly at random.

Part of 33817.
2020-04-29 22:43:09 +10:00
teor
a0b12f3cd4 relay/circuitbuild: Refactor open connection for extend
Re-use the newly created extend_info to launch the connection in
circuit_open_connection_for_extend().

No behaviour change.

Part of 33817.
2020-04-29 22:43:09 +10:00
teor
063505446f test/circuitbuild: Disable some tests when ALL_BUGS_ARE_FATAL
Some tests use IF_BUG_ONCE(), which is fatal when ALL_BUGS_ARE_FATAL,
after the fixes in 33917.

Also run "make autostyle" on these changes.

Part of 33817.
2020-04-29 22:43:09 +10:00
teor
6c458d2d6e log/util_bug: Make IF_BUG_ONCE() support ALL_BUGS_ARE_FATAL
... and DISABLE_ASSERTS_IN_UNIT_TESTS.

Make all of tor's assertion macros support the ALL_BUGS_ARE_FATAL and
DISABLE_ASSERTS_IN_UNIT_TESTS debugging modes.

Implements these modes for IF_BUG_ONCE(). (It used to log a non-fatal
warning, regardless of the debugging mode.)

Fixes bug 33917; bugfix on 0.2.9.1-alpha.
2020-04-29 22:43:09 +10:00
teor
16f3f6a1af relay/circuitbuild: Re-use IPv6 connections for circuits
Search for existing connections using the remote IPv4 and IPv6
addresses.

Part of 33817.
2020-04-29 22:43:09 +10:00
teor
ec5f4f3c5a relay/circuitbuild: Report IPv6 addresses in a debug log
Part of 33817.
2020-04-29 22:43:09 +10:00
teor
f8f688b309 channel: Make channel_matches_target_addr_for_extend() static
It isn't used outside channel.c.

Part of 33817.
2020-04-29 22:43:09 +10:00
teor
bad1181b5d relay/circuitbuild: Consider IPv6-only extends valid
Allow extend cells with IPv6-only link specifiers.
Warn and fail if both IPv4 and IPv6 are invalid.

Also warn if the IPv4 or IPv6 addresses are unexpectedly internal,
but continue with the valid address.

Part of 33817.
2020-04-29 22:43:09 +10:00
teor
7cef02ec1f test/circuitbuild: Show bad addresses in some logs
Disable SafeLogging for some extend tests, so we can check the actual
addresses.

Part of 33817.
2020-04-29 22:43:09 +10:00
teor
44f71e08c4 relay: Log the address in circuit protocol warnings
Always log the address family in extend protocol warnings.

If SafeLogging is 0, also log the address and port.

Diagnostics for 33817.
2020-04-29 22:43:09 +10:00
teor
a72e017e7f net: Add fmt_addrport_ap() and fmt_addr_family()
Add fmt_addrport_ap(), a macro that takes a tor_addr_port_t, and uses
it to call fmt_addrport().

Add fmt_addr_family(), a function that returns a string constant
describing the address family.

Utility functions for 33817.
2020-04-29 22:43:09 +10:00
teor
e9d04b05c6 net: Remove an extra space in address.h 2020-04-29 22:43:09 +10:00
teor
ffc2fd001a relay: Refactor address checks into a function
No behaviour change.

Part of 33817.
2020-04-29 22:43:09 +10:00
teor
07c008c672 relay: Refactor address and port checks
tor_addr_port_is_valid_ap(ap, 0) checks if the address or port are
zero, exactly like the previous code.

Preparation for 33817.
2020-04-29 22:43:09 +10:00
teor
587a7fbcf6 core/or: Check extends for zero addresses and ports
Check for invalid zero IPv4 addresses and ports, when sending and
receiving extend cells.

Fixes bug 33900; bugfix on 0.2.4.8-alpha.
2020-04-29 22:43:09 +10:00
teor
f6c8a8c538 test/cell_formats: Expand the IPv6-only EXTEND2 test
Part of 33901.
2020-04-29 22:43:09 +10:00
teor
bd6ab90ad4 core/or: Support IPv6 EXTEND2 cells
Allow clients and relays to send dual-stack and IPv6-only EXTEND2 cells.
Parse dual-stack and IPv6-only EXTEND2 cells on relays.

Relays do not make connections or extend circuits via IPv6: that's the
next step.

Closes ticket 33901.
2020-04-29 22:43:09 +10:00
Nick Mathewson
cbe9e56590 Merge remote-tracking branch 'tor-github/pr/1868/head' 2020-04-29 08:32:44 -04:00
teor
3253c357ee
Run "make autostyle" 2020-04-29 22:08:33 +10:00
teor
6eec43161a
rand: Clarify the crypto_rand_uint() range 2020-04-29 21:50:37 +10:00
teor
398e0e0247
nodelist: Remove an outdated comment
Part of 33817.
2020-04-29 21:50:26 +10:00
teor
7517e1b5d3
channeltls: Clarify a relay impersonation defence
Clarify the comments in channel_tls_matches_target_method(), and make
it clear that the attack is a covert attack.
2020-04-28 21:11:10 +10:00
Nick Mathewson
4dd4dbf046 Merge remote-tracking branch 'onionk/inbufoverflow1-043' into ticket33131_044 2020-04-24 08:15:53 -04:00
Nick Mathewson
7f9eaec538 Merge remote-tracking branch 'tor-github/pr/1862/head' 2020-04-24 08:14:59 -04:00
Nick Mathewson
b2849f449b Merge branch 'maint-0.4.3' 2020-04-21 12:22:37 -04:00
teor
42507429ce channeltls: Stop truncating IPv6 in logs
Stop truncating IPv6 addresses and ports in channel and connection logs.

Fixes bug 33918; bugfix on 0.2.4.4-alpha.
2020-04-21 12:22:30 -04:00
teor
e3b1e617ae
test/channel: Fix a comment typo 2020-04-15 19:45:56 +10:00
Nick Mathewson
77e65076ab Merge remote-tracking branch 'tor-github/pr/1860/head' 2020-04-14 11:52:00 -04:00
teor
a2daca594b
core/or: Update file comment in connection_or.c
Fix a typo, and say "v3 (and later) handshake".

Comment-only change.
2020-04-14 14:55:37 +10:00
teor
8c55d34e0a core/or: Accurately log remote relay IPv6 addresses
Log IPv6 addresses on connections where this relay is the responder.

Previously, responding relays would replace the remote IPv6 address with
the IPv4 address from the consensus.

(The port is replaced with the IPv6 ORPort from the consensus, we will
resolve this issue in 33898.)

Fixes bug 33899; bugfix on 0.3.1.1-alpha.
2020-04-14 12:21:49 +10:00
teor
41fa07f751 core/or: Allow IPv6 connections to be canonical
Consider IPv6 addresses when checking if a connection is canonical.

In 17604, relays assumed that a remote relay could consider an IPv6
connection canonical, but did not set the canonical flag on their side
of the connection.

Fixes bug 33899; bugfix on 0.3.1.1-alpha.
2020-04-14 12:16:48 +10:00
teor
ab8ff32bec core/or: Remove unused function prototype
Remove the unused function prototype for connection_or_get_for_extend().

There is no function implementation.

Part of 33817.
2020-04-14 10:37:20 +10:00
Nick Mathewson
2e80d7f193 bump to 0.4.3.4-rc-dev 2020-04-13 17:02:20 -04:00
Nick Mathewson
e22a8d9c95 Merge branch 'maint-0.4.3' 2020-04-13 14:14:41 -04:00
Nick Mathewson
55cb6c3fcd Merge branch 'bug33545_043_squashed' into maint-0.4.3 2020-04-13 14:13:44 -04:00
George Kadianakis
f2f718bca5 hs-v3: Change all-zeroes hard-assert to a BUG-and-err.
And also disallow all-zeroes keys from the filesystem; add a test for it too.
2020-04-13 14:13:33 -04:00
George Kadianakis
37bcc9f3d2 hs-v3: Don't allow registration of an all-zeroes client auth key.
The client auth protocol allows attacker-controlled x25519 private keys being
passed around, which allows an attacker to potentially trigger the all-zeroes
assert for client_auth_sk in hs_descriptor.c:decrypt_descriptor_cookie().

We fixed that by making sure that an all-zeroes client auth key will not be
used.

There are no guidelines for validating x25519 private keys, and the assert was
there as a sanity check for code flow issues (we don't want to enter that
function with an unitialized key if client auth is being used). To avoid such
crashes in the future, we also changed the assert to a BUG-and-err.
2020-04-13 14:13:33 -04:00
Neel Chauhan
8e59b8560a Return a descriptive error for 'GETINFO status/fresh-relay-descs' 2020-04-12 13:13:50 -07:00
Neel Chauhan
a638514783 Fix typo in router_build_fresh_unsigned_routerinfo() comment 2020-04-12 12:43:21 -07:00
Nick Mathewson
80031db32a Merge remote-tracking branch 'tor-github/pr/1801/head' 2020-04-09 11:50:20 -04:00
Nick Mathewson
bfea7a7326 bump to 0.4.3.4-rc 2020-04-09 08:38:41 -04:00
Nick Mathewson
25729910af Merge branch 'maint-0.4.3' 2020-04-09 08:33:36 -04:00
Nick Mathewson
c4da0a5094 Add fsync to list of syscalls permitted by sandbox
(Our fix for 33087 requires this, I believe.)
2020-04-09 08:33:19 -04:00
Nick Mathewson
c2aea6134a Merge remote-tracking branch 'tor-github/pr/1723/head' into maint-0.4.3 2020-04-09 08:30:14 -04:00
Nick Mathewson
29693b83bc Make sure that we free 'addr' at the end of a pair of addr tests
Fixes a couple of Coverity warnings about possible memory leaks.
Bug not in any released Tor.
2020-04-09 07:54:23 -04:00
David Goulet
cca9e1c803 hs-v3: Several fixes after #32542 review
asn: Accidentally left this commit out when merging #32542, so cherry-picking
it now.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-04-09 13:59:18 +03:00
teor
f6efb3a184
Merge branch 'pr1854_squashed' into maint-0.4.3
Squashed PR 1854, and fixed a minor typo (IPv4 -> IPv6).
2020-04-09 11:05:59 +10:00
David Goulet
cd2121a126
client: Revert setting PreferIPv6 on by default
This change broke torsocks that by default is expecting an IPv4 for hostname
resolution because it can't ask tor for a specific IP version with the SOCKS5
extension.

PreferIPv6 made it that sometimes the IPv6 could be returned to torsocks that
was expecting an IPv4.

Torsocks is probably a very unique case because the runtime flow is that it
hijacks DNS resolution (ex: getaddrinfo()), gets an IP and then sends it back
for the connect() to happen.

The libc has DNS resolution functions that allows the caller to request a
specific INET family but torsocks can't tell tor to resolve the hostname only
to an IPv4 or IPv6 and thus by default fallsback to IPv4.

Reverting this change into 0.4.3.x series but we'll keep it in the 0.4.4.x
series in the hope that we add this SOCKS5 extension to tor for DNS resolution
and then change torsocks to use that.

Fixes #33804

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-04-09 11:05:32 +10:00
teor
2d6f00e45b
Merge branch 'maint-0.4.2' into maint-0.4.3 2020-04-09 11:03:34 +10:00
teor
2d7e08d57e
Merge branch 'maint-0.4.1' into maint-0.4.2 2020-04-09 11:03:27 +10:00
teor
987f2fa50a
Merge branch 'maint-0.3.5' into maint-0.4.1 2020-04-09 11:03:20 +10:00
teor
d380acaeca
Merge remote-tracking branch 'tor-github/pr/1784' into maint-0.3.5 2020-04-09 11:02:49 +10:00
teor
cb262930f5 relay: Run "make autostyle"
But only take the changes from the relay module.

Part of 33633.
2020-04-09 11:00:04 +10:00
teor
00a45a900e test/circuitbuild: Add a test for onionskin_answer()
Part of 33633.
2020-04-09 11:00:04 +10:00
teor
d79e5d52bc relay/circuitbuild: Refactor circuit_extend()
Make the "else" case explicit at the end of the function.

Part of 33633.
2020-04-09 11:00:04 +10:00
teor
6d75f3244f test/circuitbuild: Add tests for circuit_extend()
Part of 33633.
2020-04-09 11:00:04 +10:00
teor
2b66429fcf core/or: Make some functions mockable
Preparation for testing circuit_extend().

Part of 33633.
2020-04-09 11:00:04 +10:00