Commit Graph

38785 Commits

Author SHA1 Message Date
Micah Elizabeth Scott
d0343b12c6 test_dos: Fixes for uninitialized stack memory
This was causing CI failures that didn't reproduce on my local machine.
The DoS subsystem now has a new assert() which triggers a BUG on some
nonzero memory contents (or_conn->tracked_for_dos_mitigation), and
uninitialized stack memory might be nonzero.
2023-08-11 18:05:07 -07:00
Micah Elizabeth Scott
2b8d629079 Extend DoS protection to IP addresses with known relays
This exemption used to be helpful in keeping exit relays from tripping
the DoS detection subsystem and losing Tor connectivity. Now exit relays
block re-entry into the network (tor issue #2667) so it's no longer
needed. We'd like to re-enable protection on these addresses to avoid
giving attackers a way around our DoS mitigations.
2023-08-11 16:32:22 -07:00
Micah Elizabeth Scott
a94ce25277 hashx: Fix rare compiler output overflow on aarch64
This is a fix for a very rare buffer overflow in hashx, specific to the
dynamic compiler on aarch64 platforms.

In practice this issue is extremely unlikely to hit randomly, and it's
only been seen in unit tests that supply unusual mock PRNG output to the
program generator. My best attempt at estimating the probability of
hitting the overflow randomly is about 10^-23. Crafting an input with
the intent to overflow can be done only as fast as an exhaustive search,
so long as Blake2B is unbroken.

The root cause is that hashx writes assembly code without any length
checks, and it uses an estimated size rather than an absolute maximum
size to allocate the buffer for compiled code. Some instructions are
much longer than others, especially on aarch64.

The length of the overflow is nearly 300 bytes in the worst synthetic
test cases I've developed so far. Overflow occurs during hashx_make(),
and the subsequent hashx_exec() will always SIGSEGV as the written code
crosses outside the region that's been marked executable. In typical use,
hashx_exec() is called immediately after hashx_make().

This fix increases the buffer size from 1 page to 2 pages on aarch64,
adds an analysis of the compiled code size, and adds runtime checks so we
can gracefully fail on overflow. It also adds a unit test (written in
Rust) that includes a PRNG sequence exercising the overflow. Without
this patch the unit test shows a SIGSEGV on aarch64, with this patch it
runs successfully and matches interpreter output.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-08-11 15:05:11 -07:00
Micah Elizabeth Scott
3e18507dc7 Extend DoS protection to partially-open channels
tor only marks a channel as 'open' once the TLS and OR handshakes have both
completed, and normal "client" (ORPort) DoS protection is not enabled until
the channel becomes open. This patch adds an additional earlier initialization
path for DoS protection on incoming TLS connections.

This leaves the existing dos_new_client_conn() call sites intact, but adds a
guard against multiple-initialization using the existing
tracked_for_dos_mitigation flag. Other types of channels shouldn't be affected
by this patch.
2023-08-09 18:07:34 -07:00
наб
9ae2f8a229
Clean up torify
Replace pathfind() which tries to parse $PATH manually with command -v.

exec is always fatal, regardless of if it managed to execute.
2023-08-09 15:58:45 +02:00
Micah Elizabeth Scott
ef08c00df2 hashx: Fix a few more compiler warnings
Fix a couple cases where size_t values were being confused with int.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-08-07 18:18:24 -07:00
Tor CI Release
3d63d713ea version: Bump version to 0.4.8.3-rc-dev 2023-08-04 10:44:28 -04:00
Tor CI Release
0ddbabfc54 version: Bump version to 0.4.8.3-rc 2023-08-04 10:15:28 -04:00
David Goulet
c862a66b6c release: ChangeLog update for 0.4.8.3-rc
Signed-off-by: David Goulet <dgoulet@torproject.org>
2023-08-04 10:11:44 -04:00
Tor CI Release
0c601d0025 fallbackdir: Update list generated on August 04, 2023 2023-08-04 10:08:22 -04:00
Tor CI Release
71748077d0 Update geoip files to match ipfire location db, 2023/08/04. 2023-08-04 10:08:16 -04:00
David Goulet
8a21d908ae geoip: Fix cargo target directory
Signed-off-by: David Goulet <dgoulet@torproject.org>
2023-08-04 10:04:36 -04:00
David Goulet
3f66ff9b00 cargo: Add geoip db tool to top level workspace
Signed-off-by: David Goulet <dgoulet@torproject.org>
2023-08-04 09:55:26 -04:00
David Goulet
49ea768465 ci: Move tag to the x86-64 template
Signed-off-by: David Goulet <dgoulet@torproject.org>
2023-08-02 13:30:28 -04:00
David Goulet
64f28d3366 ci: Tag physical our i386 minimal job
Signed-off-by: David Goulet <dgoulet@torproject.org>
2023-08-02 13:20:06 -04:00
David Goulet
ec7a03e112 Merge branch 'remove-conflux-bug-log' into 'main'
relay: Remove logging for a bug. It triggers a BUG() later

See merge request tpo/core/tor!738
2023-08-02 16:48:03 +00:00
David Goulet
3ed37ae53c relay: Remove logging for a bug. It triggers a BUG() later
Signed-off-by: David Goulet <dgoulet@torproject.org>
2023-08-02 12:09:41 -04:00
David Goulet
0c270735ef Merge branch 'cargo_hashx_rng' into 'main'
hashx: Rust hook for inspecting and modifying the random number stream

See merge request tpo/core/tor!734
2023-08-01 20:19:42 +00:00
David Goulet
f1fdb58611 Merge branch 'bug40827' into 'main'
Fix assert crash on relay-side due to on_circuit backpointer

See merge request tpo/core/tor!737
2023-08-01 20:13:32 +00:00
Mike Perry
78e14ca124 Changes file for bug 40827 2023-08-01 17:13:48 +00:00
Mike Perry
e3ad41e7e5 Bug 40827: Add additional logs and checks for 0-leg conflux case 2023-08-01 17:13:48 +00:00
David Goulet
5487476fd9 Nullify on_circuit if last conflux leg
Signed-off-by: David Goulet <dgoulet@torproject.org>
2023-08-01 17:12:11 +00:00
David Goulet
08ae74056f Merge branch 'bug40828' into 'main'
Bug40828

See merge request tpo/core/tor!736
2023-07-31 15:43:33 +00:00
Mike Perry
f26942cb0c Changes file for bug40828 2023-07-31 14:13:16 +00:00
Mike Perry
74d6fd534a Bug 40828: Add more log scrubbing to protocol warnings 2023-07-31 14:12:39 +00:00
Micah Elizabeth Scott
0ca2e62b28 hashx: Rust hook for inspecting and modifying the random number stream
This patch has no effect on the C tor build.

Adds a function hashx_rng_callback() to the hashx API, defined only
when HASHX_RNG_CALLBACK is defined. This is then used in the Rust
wrapper to implement a similar rng_callback().

Included some minimal test cases. This code is intented for
use in cross-compatibility fuzzing tests which drive multiple
implementations of hashx with the same custom Rng stream.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-07-28 21:27:10 -07:00
David Goulet
4667195ded Merge branch 'cargo' into 'main'
Include a basic Rust wrapper for Equi-X and HashX

See merge request tpo/core/tor!733
2023-07-26 20:01:56 +00:00
Micah Elizabeth Scott
95bcd17705 Include a basic Rust wrapper for Equi-X and HashX
The idea behind this is that we may want to start exporting more pieces
of c-tor as Rust crates so that Arti can perform cross compatibility and
comparison testing using Rust tooling.

This turns the 'tor' repo into a Cargo workspace, and adds one crate to
start with: "tor-c-equix", rooted in src/ext/equix. This actually
includes both Equi-X itself and HashX, since there's less overall
duplication if we package these together instead of packaging HashX
separately.

This patch adds a basic safe Rust interface, but doesn't expose any
additional internals for testing purposes.

No changes to the C code here or the normal Tor build system.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-07-26 12:27:15 -07:00
David Goulet
1e3b5c94ab Merge branch 'maint-0.4.7' 2023-07-26 12:02:47 -04:00
Tor CI Release
78cb761612 version: Bump version to 0.4.7.14-dev 2023-07-26 12:02:42 -04:00
David Goulet
652147413c Merge branch 'maint-0.4.7' 2023-07-26 10:23:27 -04:00
Tor CI Release
4333762b21 version: Bump version to 0.4.7.14 2023-07-26 10:22:32 -04:00
David Goulet
89b1e6568e Merge branch 'maint-0.4.7' 2023-07-26 10:13:21 -04:00
Tor CI Release
fa40b0a122 fallbackdir: Update list generated on July 26, 2023 2023-07-26 10:12:30 -04:00
Tor CI Release
e4308eb159 Update geoip files to match ipfire location db, 2023/07/26. 2023-07-26 10:12:24 -04:00
David Goulet
5e4cac26bb Merge branch 'maint-0.4.7' 2023-07-26 10:07:33 -04:00
David Goulet
2234ecd491 fallback: Take file from main for our release CI
Signed-off-by: David Goulet <dgoulet@torproject.org>
2023-07-26 10:07:27 -04:00
David Goulet
061343e8c2 Merge branch 'maint-0.4.7' 2023-07-26 09:59:36 -04:00
David Goulet
47434fc81a geoip: Take the database from main
Signed-off-by: David Goulet <dgoulet@torproject.org>
2023-07-26 09:59:26 -04:00
David Goulet
28dfa07069 Merge branch 'maint-0.4.7' 2023-07-24 10:18:53 -04:00
David Goulet
d6fd7d1035 Fix all -Werror=enum-int-mismatch warnings
Close #40824

Signed-off-by: David Goulet <dgoulet@torproject.org>
2023-07-24 09:44:42 -04:00
David Goulet
e6a9e00690 Merge branch 'warn-bridge-exit' into 'main'
Warn when operating as bridge and exit

Closes #40819

See merge request tpo/core/tor!730
2023-07-20 14:40:13 +00:00
David Goulet
6e43a27eb6 Merge branch 'no-assert-rotate-onion-key-fails' into 'main'
fix non-fatal assertion when rotate_onion_key fails

Closes #40554

See merge request tpo/core/tor!729
2023-07-20 14:38:36 +00:00
trinity-1686a
1901720fb9
Warn when operating as bridge and exit 2023-07-17 19:40:26 +02:00
David Goulet
1b4b354f4d Merge branch 'fix-apt-syntax' into 'main'
gitlab-ci: fix apt conf syntax for Acquire::Retries

See merge request tpo/core/tor!705
2023-07-17 16:08:17 +00:00
David Goulet
18534f9ef2 Merge branch 'geoip-db-prefix-more' into 'main'
Clarify where geoip-db-tool is.

See merge request tpo/core/tor!728
2023-07-17 16:05:02 +00:00
trinity-1686a
9ea80b465f
fix non-fatal assertion when rotate_onion_key fails 2023-07-16 22:29:23 +02:00
Nick Mathewson
f1fced828b Clarify where geoip-db-tool is.
Somebody emailed me to ask where to find the tool that generated our
geoip file. I was about to suggest that they search for "geoip-db-tool",
when I found that you can't actually search for that and find our code.

Therefore, I'm adding a link.
2023-07-13 16:04:35 -04:00
Tor CI Release
22757dbb53 version: Bump version to 0.4.8.2-alpha-dev 2023-07-12 10:15:10 -04:00
Tor CI Release
328f976245 version: Bump version to 0.4.8.2-alpha 2023-07-12 09:51:11 -04:00