Commit Graph

7871 Commits

Author SHA1 Message Date
Nick Mathewson
ed6a328297 Merge branch 'mr_124_squashed' into maint-0.3.5 2020-10-07 08:00:59 -04:00
Nick Mathewson
c5ba8b6221 Parallelize src/test/test into chunks.
First, we introduce a flag to teach src/test/test to split its work
into chunks.  Then we replace our invocation of src/test/test in our
"make check" target with a set of 8 scripts that invoke the first
8th of the tests, the second 8th, and so on.

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

Closes 40098.
2020-10-07 08:00:49 -04:00
David Goulet
faf89ec6c2 srv: Remove spammy debug log
Fixes #40135

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-09-22 11:06:34 -04:00
Nick Mathewson
7945e075a4 Fix underflow in rend_cache/free_all test.
We already fixed these in #40099 and #40125.

This patch fixes #40126.  Bugfix on 0.2.8.1-alpha.
2020-09-17 14:04:54 -04:00
David Goulet
47f1d19f8e test: Increment rend cache allocation before freeing
The rend_cache/entry_free was missing the rend cache allocation increment
before freeing the object.

Without it, it had an underflow bug:

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

Fixes #40125

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-09-17 13:00:23 -04:00
Nick Mathewson
020e8e41c6 Resolve a compilation warning in test_connection.c
Instead of casting an enum to a void and back, use a string --
that's better C anyway.

Fixes bug 40113; bugfix on 0.2.9.3-alpha.
2020-09-14 11:50:38 -04:00
George Kadianakis
248cbc2d22 statistics: Properly count all rendezvous cells (avoid undercounting).
tl;dr We were not counting cells flying from the client to the service, but we
were counting cells flying from the service to the client.

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

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

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

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

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

Fixes #40117.
2020-09-07 13:29:44 +03:00
David Goulet
ea339227c2 conn: Remove assert on new listener connection when retrying
Opening a new listener connection can fail in many ways like a bind()
permission denied on a low port for instance.

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

To hit the removed assert:

  ORPort 80
  KeepBindCapabilities 0

Start tor. Then edit torrc:

  ORPort <some-IP>:80

HUP tor and the assert is hit.

Fixes #40073

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-09-01 10:01:21 -04:00
Nick Mathewson
f9bb49d870 Fix allocation counting in clean_v2_descs_as_dir test.
Without this fix, running this test on its own would fail.

Fixes bug 40099. Bugfix on ade5005853 in 0.2.8.1-alpha.
2020-08-12 14:25:46 -04:00
Nick Mathewson
afb6ff1739 Validate ed25519 keys and canonicity from circuit_n_conn_done()
Fixes bug 40080. Bugfix on 0.2.7.2-alpha.
2020-08-06 15:59:28 -04:00
Nick Mathewson
435f31aed3 Remove channel_is_canonical_is_reliable()
This function once served to let circuits continue to be built over
version-1 link connections.  But such connections are long-obsolete,
and it's time to remove this check.

Closes #40081.
2020-08-03 11:25:37 -04:00
Nick Mathewson
c4742b89b2 Fix a bug in buf_move_all() when the input buffer is empty.
We found this in #40076, after we started using buf_move_all() in
more places.  Fixes bug #40076; bugfix on 0.3.3.1-alpha.  As far as
I know, the crash only affects master, but I think this warrants a
backport, "just in case".
2020-07-30 14:24:25 -04:00
Nick Mathewson
dcc60294ad Use _lseeki64() on windows.
Fixes bug 31036; bugfix on 0.2.1.8-alpha when we moved the logging
system to use posix fds.
2020-07-28 11:30:47 -04:00
Nick Mathewson
f916ddd312 More info in the fallbackdir changes file 2020-07-23 10:08:42 -04:00
David Goulet
6f19e67c98 fallbackdir: Update list for 2020
Closes #40061

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-23 10:05:11 -04:00
Nick Mathewson
ceb6585a4b Treat all extorport connections with un-set addresses as remote
Without this fix, if an PT forgets to send a USERADDR command, that
results in a connection getting treated as local for the purposes of
rate-limiting.

If the PT _does_ use USERADDR, we still believe it.

Closes ticket 33747.
2020-07-22 15:21:56 -04:00
Nick Mathewson
faa752f3c9 Adjust the rules for warning about too many connections.
Previously we tolerated up to 1.5 connections for every relay we
were connected to, and didn't warn if we had fewer than 5
connections total.

Now we tolerate up to 1.5 connections per relay, and up to 4
connections per authority, and we don't warn at all when we have
fewer than 25 connections total.

Fixes bug 33880, which seems to have been provoked by our #17592
change in 0.3.5.
2020-07-22 14:45:03 -04:00
Alexander Færøy
abe7196c53 Strip '\r' characters when reading text files on Unix.
This patch ensures that we strip "\r" characters on both Windows as well
as Unix when we read text files. This should prevent the issue where
some Tor state files have been moved from a Windows machine, and thus
contains CRLF line ending, to a Unix machine where only \n is needed.

We add a test-case to ensure that we handle this properly on all our
platforms.

See: https://bugs.torproject.org/tpo/core/tor/33781
2020-07-14 17:41:51 +00:00
Nick Mathewson
40eb6b19a3 NSS: Tell NSS that our SSL sockets are nonblocking.
Closes ticket 40035.
2020-07-10 13:14:33 -04:00
Nick Mathewson
7142f3e435 Merge branch 'trove_2020_001_035' into maint-0.3.5 2020-07-09 09:28:36 -04: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
d9cc2b2928 CI: Fix Appveyor printf format error
For some reasons, Appveyor started to use the stdio printf format for 64 bit
values (PRIu64, ...). Mingw doesn't like that so force it to use the Windows
specific macros by setting D__USE_MINGW_ANSI_STDIO=0.

Fixes #40026
2020-07-07 09:53:54 -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
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
Alexander Færøy
8697205be4 Merge branch 'tor-github/pr/1909' into maint-0.3.5 2020-06-30 14:23:17 +00: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
c3ad2a1d23 Merge branch 'tor-github/pr/1785' into maint-0.3.5 2020-06-30 13:47:55 +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
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
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
Nick Mathewson
dd795fbee4 changes file for bug 34078. 2020-05-06 16:58:06 -04: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
861337fd6d
router: Stop advertising incorrect auto IPv6 ORPorts
When IPv6 ORPorts are set to "auto", tor relays and bridges would
advertise an incorrect port in their descriptor.

This may be a low-severity memory safety issue, because the published
port number may be derived from uninitialised or out-of-bounds memory
reads.

Fixes bug 32588; bugfix on 0.2.3.9-alpha.
2020-03-21 03:36:39 +10:00
teor
38e07b88fa
Appveyor: Copy required DLLs to test and app
Copy required DLLs to test and app, before running tor's tests.

This ensures that tor.exe and test*.exe use the correct version of each
DLL. This fix is not required, but we hope it will avoid DLL search
issues in future.

Closes bug 33673; bugfix on 0.3.4.2-alpha.
2020-03-20 14:48:31 +10:00
Nick Mathewson
ee3d23c05a Appveyor: disable crypto/openssl_version 2020-03-19 18:36:36 -04:00
Nick Mathewson
6bafe97bc1 Add a TOR_SKIP_TESTCASES environment variable for suppressing tests.
For example, "TOR_SKIP_TESTCASES=crypto/.. ./src/test/test" will run
the tests and suppress all the "crypto/" tests.  You could get the
same effect by running "./src/test/test :crypto/..", but that can be
harder to arrange from CI.

Part of a fix/workaround for 33643.
2020-03-19 18:36:36 -04:00
Nick Mathewson
fe3d8ec38e Merge branch 'trove_2020_002_035' into maint-0.3.5 2020-03-17 15:21:48 -04:00
George Kadianakis
089e57d22f Fix TROVE-2020-003.
Given that ed25519 public key validity checks are usually not needed
and (so far) they are only necessary for onion addesses in the Tor
protocol, we decided to fix this specific bug instance without
modifying the rest of the codebase (see below for other fix
approaches).

In our minimal fix we check that the pubkey in
hs_service_add_ephemeral() is valid and error out otherwise.
2020-03-17 11:44:45 -04:00
teor
1c688ba925
Travis: Produce detailed chutney diagnostics
When a Travis chutney job fails, use chutney's new "diagnostics.sh" tool
to produce detailed diagnostic output.

Closes ticket 32792.
2020-03-16 16:04:51 +10:00
Nick Mathewson
b9d71f3848 Merge remote-tracking branch 'tor-github/pr/1693/head' into maint-0.3.5 2020-03-13 16:46:09 -04:00
David Goulet
b755a489bd config: Warn if ContactInfo is not set
Closes #33361

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-03-12 12:43:00 -04:00
Nick Mathewson
5721ec22d8 pem_decode(): Tolerate CRLF line endings
Fixes bug 33032; bugfix on 0.3.5.1-alpha when we introduced our own
PEM decoder.
2020-03-11 10:35:17 -04:00
David Goulet
894ff2dc84 dos: Pass transport name on new client connection
For a bridge configured with a pluggable transport, the transport name is
used, with the IP address, for the GeoIP client cache entry.

However, the DoS subsystem was not aware of it and always passing NULL when
doing a lookup into the GeoIP cache.

This resulted in bridges with a PT are never able to apply DoS defenses for
newly created connections.

Fixes #33491

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-03-10 14:45:13 -04:00
teor
add387c507
Travis: Sort jobs in order of speed
Putting the slowest jobs first takes full advantage of Travis
concurrency.

Closes 33194.
2020-02-13 13:52:41 +10:00
teor
fc3555100f
Travis: Remove a redundant distcheck job
Part of 33194.
2020-02-13 13:45:18 +10:00
teor
03650e0f60
Travis: Require the macOS IPv6 chutney job
The job was previously set to fast_finish / allow_failure, to
speed up the build.

Closes ticket 33195.
2020-02-13 13:43:59 +10:00
David Goulet
88489cd290
hs-v3: Remove BUG() that can occur normally
Fixes #28992

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-02-12 14:09:40 +10:00
Alexander Færøy
b9c7c61ea5
Lowercase the BridgeDistribution value from torrc in descriptors.
This patch ensures that we always lowercase the BridgeDistribution from
torrc in descriptors before submitting it.

See: https://bugs.torproject.org/32753
2020-02-12 12:21:41 +10:00
teor
88723ad169
Merge remote-tracking branch 'tor-github/pr/1689' into maint-0.3.5 2020-02-12 12:18:59 +10:00
Nick Mathewson
99d044d553 Fix a Rust compilation warning; resolve bug 33212. 2020-02-10 13:32:09 -05:00
Nick Mathewson
d0bce65ce2 changes file for 33119 aka TROVE-2020-002 2020-02-05 12:02:32 -05:00
teor
41d52e9cd8
Merge remote-tracking branch 'tor-github/pr/1614' into maint-0.3.5 2020-01-30 07:53:53 +10:00
Nick Mathewson
1f163fcbde Change BUG() messages in buf_flush_to_tls() to IF_BUG_ONCE()
We introduced these BUG() checks in b0ddaac074 to prevent a
recurrence of bug 23690.  But there's a report of the BUG() message
getting triggered and filling up the disk.  Let's change it to
IF_BUG_ONCE().

Fixes bug 33093; bugfix on 0.3.2.2-alpha.
2020-01-29 08:31:22 -05:00
teor
9d771ccc86
Travis: Stop allowing stem test failures
Stop allowing failures on the Travis CI stem tests job. It looks like
all the stem hangs we were seeing are now fixed, but let's make sure we
see them if they happen again.

Closes ticket 33075.
2020-01-28 19:56:56 +10:00
teor
19954cffd7
Merge remote-tracking branch 'tor-github/pr/1513' into maint-0.3.5 2020-01-16 09:57:27 +10:00
Nick Mathewson
165a92e33f Replace an assertion with a check-and-log
We hit this assertion with bug 32868, but I'm stymied figuring out
how we wound up with a routerstatus like this.  This patch is a
diagnostic to attempt to figure out what is going on, and to avoid a
crash in the meantime.
2020-01-14 13:16:39 -05:00
Nick Mathewson
4f6901d7cc When initializing pthreads, always set the main thread.
Fixes bug 32884.  This is a bugfix on 0.3.3.1-alpha, when we started
allowing restart-in-process with tor_api.h.
2020-01-06 09:37:12 -05:00
Peter Gerber
0d64bafcfe Correct how we use libseccomp
This fixes a startup crash with libseccomp v2.4.0 if Sandbox is
set to 1.
2019-12-17 09:47:28 -05:00
teor
0b3763612c
Merge remote-tracking branch 'tor-github/pr/1459' into bug32240_32242_035 2019-12-16 09:21:05 +10:00
teor
75096de4c7
Merge branch 'bug32240_029' into bug32240_035
Merge
* Chutney Trusty deletion in bug32240_029
* NSS addition in maint-0.3.5
2019-12-16 09:09:16 +10:00
teor
37b04aeed7
changes: file for 32240 2019-12-16 09:06:25 +10:00
teor
05908d57f6
Merge remote-tracking branch 'tor-github/pr/1576' into maint-0.3.5 2019-12-16 08:14:04 +10:00
teor
7dd5946094
Merge remote-tracking branch 'tor-github/pr/1575' into maint-0.2.9 2019-12-16 08:13:38 +10:00
Nick Mathewson
74cae547e5 Merge branch 'maint-0.2.9' into maint-0.3.5 2019-12-06 16:02:07 -05:00
Karsten Loesing
b7b467d3af Update geoip and geoip6 to the December 3 2019 database. 2019-12-06 11:50:35 +01:00
teor
a277f28947
changes: file for 32629 2019-12-06 10:51:43 +10:00
teor
b84e7715da
changes: file for 32629 2019-12-06 10:51:05 +10:00
teor
aee966cb06
Merge remote-tracking branch 'tor-github/pr/1277' into maint-0.3.5 2019-12-05 10:11:18 +10:00
teor
145ff92d92
Merge branch 'maint-0.2.9' into maint-0.3.5
Merge C_DIALECT_OPTIONS from ticket32500_029 with
other configure options from maint-0.3.5.
2019-12-03 12:45:41 +10:00
teor
792c15fde2
Travis: use -std=gnu99 in some jobs
Require C99 standards-conforming code in Travis CI, but allow GNU gcc
extensions. Also activates clang's -Wtypedef-redefinition warnings.

Builds some jobs with -std=gnu99, and some jobs without.

Closes ticket 32500.
2019-12-03 12:42:39 +10:00
teor
f2f7491cd9
Merge branch 'ticket32629_029' into ticket32629_035
Merge re-enable chutney from ticket32629_029 with
stem from maint-0.3.5.
2019-11-28 12:21:08 +10:00
teor
99b5f1b261
Revert "Travis: Disable all but one macOS build"
This reverts commit 511aeba8ee.
2019-11-28 12:10:10 +10:00
teor
501b5174d8
Merge remote-tracking branch 'tor-github/pr/1464' into maint-0.3.5 2019-11-25 12:35:11 +10:00
teor
400cee261e
Merge remote-tracking branch 'tor-github/pr/1422' into maint-0.3.5 2019-11-25 12:34:29 +10:00
teor
54c01119ed
Merge remote-tracking branch 'tor-github/pr/1405' into maint-0.3.5 2019-11-25 12:33:55 +10:00
teor
83424cb62f
Merge remote-tracking branch 'tor-github/pr/1395' into maint-0.3.5 2019-11-25 12:33:14 +10:00
teor
f9812ee5f7
Merge remote-tracking branch 'tor-github/pr/1394' into maint-0.3.5 2019-11-25 12:29:43 +10:00
Nick Mathewson
7beaaed245 Merge branch 'maint-0.2.9' into maint-0.3.5 2019-11-11 10:14:03 -05:00
teor
2abff832dd
Appveyor: Install OpenSSL to resolve a header/library mismatch
Install the mingw OpenSSL package in Appveyor. This makes sure that
the OpenSSL headers and libraries match in Tor's Appveyor builds.

(This bug was triggered by an Appveyor image update.)

Fixes bug 32449; bugfix on 0.3.5.6-rc.
2019-11-11 13:19:15 +10:00
Karsten Loesing
853b6ad095 Update geoip and geoip6 to the November 6 2019 database. 2019-11-09 10:10:19 +01:00
Nick Mathewson
4d70e725d1 Do not try to shut down the event loop when it is not initialized.
Doing so caused us to crash in some unusual circumstances, such as
using --verify-config to verify a configuration that failed during
the options_act() stage.

Fixes bug 32407; bugfix on 0.3.3.1-alpha.
2019-11-06 11:33:23 -05:00
teor
1bde356bf6
Merge branch 'maint-0.2.9' into maint-0.3.5 2019-11-06 11:19:30 +10:00
teor
4abfcb7997
Merge remote-tracking branch 'tor-github/pr/1354' into maint-0.3.5 2019-11-06 11:18:09 +10:00
teor
0e2834a371
Merge remote-tracking branch 'tor-github/pr/1348' into maint-0.3.5 2019-11-06 11:17:43 +10:00
teor
d2e4262ebc
Merge remote-tracking branch 'tor-github/pr/1340' into maint-0.3.5 2019-11-06 11:17:01 +10:00
teor
6bfdd09679
Merge remote-tracking branch 'tor-github/pr/1343' into maint-0.3.5 2019-11-06 11:16:09 +10:00
teor
0650bf3695
Merge remote-tracking branch 'tor-github/pr/1342' into maint-0.2.9 2019-11-06 11:15:45 +10:00
teor
c06d540ff9
Merge remote-tracking branch 'tor-github/pr/1330' into maint-0.2.9 2019-11-06 11:14:53 +10:00
teor
15d67842f9
Merge branch 'maint-0.2.9' into maint-0.3.5 2019-10-29 08:26:32 +10:00
teor
752c35ca96
Merge remote-tracking branch 'tor-github/pr/1460' into maint-0.2.9 2019-10-29 08:23:35 +10:00
teor
e03db9934a
Merge branch 'maint-0.2.9' into maint-0.3.5 2019-10-25 10:55:51 +10:00
teor
93be7275ec
changes: file for 31919's bionic Travis image change 2019-10-25 09:53:11 +10:00
David Goulet
ed57a04a65 hs-v3: Remove a BUG() caused by an acceptable race
hs_client_purge_state() and hs_cache_clean_as_client() can remove a descriptor
from the client cache with a NEWNYM or simply when the descriptor expires.

Which means that for an INTRO circuit being established during that time, once
it opens, we lookup the descriptor to get the IP object but hey surprised, no
more descriptor.

The approach here is minimalist that is accept the race and close the circuit
since we can not continue. Before that, the circuit would stay opened and the
client wait the SockTimeout.

Fixers #28970.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-10-24 08:50:01 -04:00
teor
14b197a148
Travis: Use macOS 10.14 with Xcode 11.2
Closes ticket 32241.
2019-10-24 11:44:43 +10:00
teor
4342486649
Travis: Use zstd in our Travis Linux builds
Recent Ubuntu versions have zstd >= 1.1, which is an optional tor build
dependency.

Closes ticket 32242.
2019-10-24 09:26:54 +10:00
teor
c77162e4e9
Merge remote-tracking branch 'tor-github/pr/1360' into maint-0.3.5 2019-10-23 08:32:52 +10:00
teor
8682442c76
Merge remote-tracking branch 'tor-github/pr/1351' into maint-0.2.9 2019-10-23 08:32:22 +10:00
teor
27965f1ef2
Merge remote-tracking branch 'tor-github/pr/1284' into maint-0.3.5 2019-10-23 08:30:48 +10:00
teor
003be727c4
Merge remote-tracking branch 'tor-github/pr/1256' into maint-0.3.5 2019-10-23 08:28:03 +10:00
teor
7660a7cf7d
Merge remote-tracking branch 'tor-github/pr/1178' into maint-0.2.9 2019-10-23 08:20:45 +10:00