Commit Graph

514 Commits

Author SHA1 Message Date
George Kadianakis
ce477da8a7 Ignore regular cells in padding circuits.
Padding circuits were regular cells that got closed before their padding
machine could finish. This means that they can still receive regular cells from
their past life, but they have no way or reason to answer them anymore. Hence
let's ignore them before they even get to the proper subsystems.
2019-08-05 18:03:23 +03:00
George Kadianakis
7a032c5e48 Split connection_edge_process_relay_cell() in two functions.
One function does the validation, the other does the handling.
2019-08-05 18:02:33 +03:00
Nick Mathewson
54ad92a240 Merge branch 'maint-0.4.1' 2019-08-05 09:59:40 -04:00
George Kadianakis
74c0595965 Ignore regular cells in padding circuits.
Padding circuits were regular cells that got closed before their padding
machine could finish. This means that they can still receive regular cells from
their past life, but they have no way or reason to answer them anymore. Hence
let's ignore them before they even get to the proper subsystems.
2019-08-05 13:48:58 +03:00
David Goulet
044bb019b6 Merge branch 'maint-0.4.1' 2019-07-25 10:27:41 -04:00
George Kadianakis
af26cd6101 Always check the retval of circpad_machine_current_state(). 2019-07-25 10:24:23 -04:00
George Kadianakis
bd1ac408d8 Remove dead code from circpad_machine_remove_token(). 2019-07-25 10:24:19 -04:00
Nick Mathewson
ab1f39322c Merge remote-tracking branch 'tor-github/pr/1185' 2019-07-23 12:32:14 -04:00
pulls
c2f6064325 Improve circpad documentation.
Patch by Tobias Pulls.
2019-07-23 12:44:43 +03:00
pulls
fd1f285189 transition when we send our first padding packet, not on received 2019-07-23 11:52:25 +03:00
pulls
5f95b37f6c remove specified target_hopnum from relay-side machines (only for origin-side machines) 2019-07-23 11:52:25 +03:00
George Kadianakis
5303dbe624 Merge branch 'tor-github/pr/1152' 2019-07-04 17:14:06 +03:00
Roger Dingledine
a5911c4551 get rid of accidental second space 2019-06-29 22:26:00 -04:00
Nick Mathewson
0fa3dc3228 begin_cell_parse(): Add an assertion to please coverity.
Coverity doesn't understand that if begin_cell_parse() returns 0 and
sets is_begindir to 0, its address field will always be set.

Fixes bug 30126; bugfix on 0.2.4.7-alpha; Fixes CID 1447296.
2019-06-28 11:29:51 -04:00
Nick Mathewson
da11304136 Merge branch 'maint-0.4.1' 2019-06-26 10:06:02 -04:00
Nick Mathewson
3ccf91027b Merge remote-tracking branch 'tor-github/pr/1101' into maint-0.4.1 2019-06-26 10:05:51 -04:00
David Goulet
f7e8b3b68c Merge branch 'tor-github/pr/1040' 2019-06-11 11:59:39 -04:00
Taylor Yu
0bce0c339d Rework origin circuit tracking to use pubsub
Part of ticket 29976.
2019-06-11 11:59:30 -04:00
Taylor Yu
a8c0f4ddfe Rework orconn tracking to use pubsub
Part of ticket 29976.
2019-06-11 11:59:30 -04:00
George Kadianakis
a15ec8bf84 circpad: some more logging changes.
- Add an info log when receiving a STOP command.
- Keep warning if we receive padding from a wrong hop.
2019-06-11 14:28:38 +03:00
George Kadianakis
e5ad6fb092 Merge branch 'ticket30769_041_01' 2019-06-11 14:11:24 +03:00
David Goulet
c1359b32a4 trunnel: Rename sendme.trunnel to sendme_cell.trunnel
This is to avoid having two sendme.{c|h} in the repository since the subsystem
is implemented in src/core/or/sendme.{c|h}.

Fixes #30769

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-06-11 14:11:10 +03:00
Mike Perry
e54ce03b4f More LOG_PROTOCOL_WARN.
Make origin-side messages about padding negotiation failure into
LOG_PROTOCOL_WARN.

I'm not sure I like this either.. But the negotiation refusal case might
happen naturally due to consensus drift, and is functionally no different than
a corrupted cell.
2019-06-05 12:33:39 -07:00
Mike Perry
c525135dac Bug 29034: Cleanup hs circuitmap when purpose changes.
Leave the other rend and hs_ident data around until circuit free, since code
may still try to inspect it after marking the circuit for close. The
circuitmap is the important thing to clean up, since repurposed
intropoints must be removed from this map to ensure validity.
2019-06-05 11:50:44 -07:00
Mike Perry
31c34f6524 Revert "hs: Implement a helper to repurpose a circuit"
This reverts commit 3789f22bcb.
2019-06-05 11:38:01 -07:00
Nick Mathewson
60213a3621 Run "make autostyle." 2019-06-05 09:33:35 -04:00
Nick Mathewson
b39a8d315d Merge remote-tracking branch 'tor-github/pr/1053' 2019-06-05 09:04:09 -04:00
George Kadianakis
99bf3d8e14 Merge branch 'tor-github/pr/1072' 2019-06-05 14:40:38 +03:00
Nick Mathewson
4022b6d6b7 Merge branch 'bug29670_035' into bug29670_041 2019-06-04 08:29:05 -04:00
David Goulet
33382184b6 sendme: Do not decrement window in a log_debug()
If "Log debug ..." is not set, the decrement never happens. This lead to the
package/deliver window to be out of sync at the stream level and thus breaking
the connection after 50+ cells.

Fixes #30628

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-06-03 14:31:51 -04:00
Mike Perry
6263755728 Make some warns into protocol warns
I'm not sure I agree with this option.
2019-05-30 16:25:29 -07:00
Mike Perry
de3eb8c5e4 Bug 30649: Check that machine is absent before warn 2019-05-30 15:28:17 -07:00
Nick Mathewson
5cbd71b977 Make get_proxy_type() connection-specific
Previously, we were looking at our global settings to see what kind
of proxy we had.  But doing this would sometimes give us the wrong
results when we had ClientTransportPlugin configured but we weren't
using it for a particular connection.  In several places in the
code, we had added checks to see if we were _really_ using a PT or
whether we were using a socks proxy, but we had forgotten to do so
in at least once case.  Instead, since every time we call this
function we are asking about a single connection, it is probably
best just to make this function connection-specific.

Fixes bug 29670; bugfix on 0.2.6.2-alpha.
2019-05-29 11:00:09 -04:00
David Goulet
3789f22bcb hs: Implement a helper to repurpose a circuit
When we repurpose a hidden service circuit, we need to clean up from the HS
circuit map and any HS related data structured contained in the circuit.

This commit adds an helper function that does it when repurposing a hidden
service circuit.

Fixes #29034

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-05-29 09:40:13 -04:00
George Kadianakis
130eb227ac Merge branch 'tor-github/pr/1043' 2019-05-27 14:20:51 +03:00
Nick Mathewson
fcd51fd49f Tests for deciding how full our relay cells should be 2019-05-27 14:20:36 +03:00
Nick Mathewson
0bc1241494 Make sure that we send at least some random data in RELAY_DATA cells
Proposal 289 prevents SENDME-flooding by requiring the other side to
authenticate the data it has received.  But this data won't actually
be random if they are downloading a known resource.  "No problem",
we said, "let's fell the empty parts of our cells with some
randomness!" and we did that in #26871.

Unfortunately, if the relay data payloads are all completely full,
there won't be any empty parts for us to randomize.

Therefore, we now pick random "randomness windows" between
CIRCWINDOW_INCREMENT/2 and CIRCWINDOW_INCREMENT. We remember whether we have
sent a cell containing at least 16 bytes of randomness in that window.  If we
haven't, then when the window is exhausted, we send one.  (This window approach
is designed to lower the number of rng checks we have to do.  The number 16 is
pulled out of a hat to change the attacker's guessing difficulty to
"impossible".)

Implements 28646.
2019-05-27 14:20:07 +03:00
Roger Dingledine
94914e2a4d trivial whitespace fixes 2019-05-26 17:32:42 -04:00
Nick Mathewson
530d1179ff Extract length-deciding function from package_raw_inbuf. 2019-05-23 08:28:46 -04:00
Roger Dingledine
e4d1187584 refactor logic to decide how much to package from inbuf
no actual changes in behavior
2019-05-23 08:28:46 -04:00
Nick Mathewson
e6b862e6a8 Merge branch 'ticket30428_041_02_squashed' 2019-05-22 11:48:43 -04:00
David Goulet
0cad83bea4 sendme: Add non fatal asserts for extra safety
Two non fatal asserts are added in this commit. First one is to see if the
SENDME digest list kept on the circuit for validation ever grows bigger than
the maximum number of expected SENDME on a circuit (currently 10).

The second one is to know if we ever send more than one SENDME at a time on a
circuit. In theory, we shouldn't but if we ever do, the v1 implementation
wouldn't work because we only keep one single cell digest (the previous cell
to the SENDME) on the circuit/cpath. Thus, sending two SENDME consecutively
will lead to a mismatch on the other side because the same cell digest would
be use and thus the circuit would collapse.

Finally, add an extra debug log in case we emit a v0 which also includes the
consensus emit version in that case.

Part of #30428

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-05-22 11:47:20 -04:00
David Goulet
5479ffabf8 sendme: Always pop last SENDME digest from circuit
We must not accumulate digests on the circuit if the other end point is using
another SENDME version that is not using those digests like v0.

This commit makes it that we always pop the digest regardless of the version.

Part of #30428

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-05-22 11:47:20 -04:00
David Goulet
482c4972b9 sendme: Clarify how sendme_circuit_cell_is_next() works
Commit 4ef8470fa5480d3b was actually reverted before because in the end we
needed to do this minus 1 check on the window.

This commit clarifies that in the code, takes the useful comment changes from
4ef8470fa5480d3b and makes sendme_circuit_cell_is_next() private since it
behaves in a very specific way that one external caller might expect.

Part of #30428.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-05-22 11:47:20 -04:00
David Goulet
3835a3acf5 sendme: Properly record SENDMEs on both edges
Turns out that we were only recording the "b_digest" but to have
bidirectionnal authenticated SENDMEs, we need to use the "f_digest" in the
forward cell situation.

Because of the cpath refactoring, this commit plays with the crypt_path_ and
relay_crypto_t API a little bit in order to respect the abstractions.

Previously, we would record the cell digest as the SENDME digest in the
decrypt cell function but to avoid code duplication (both directions needs to
record), we now do that right after iff the cell is recognized (at the edge).
It is now done in circuit_receive_relay_cell() instead.

We now also record the cell digest as the SENDME digest in both relay cell
encryption functions since they are split depending on the direction.
relay_encrypt_cell_outbound() and relay_encrypt_cell_inbound() need to
consider recording the cell digest depending on their direction (f vs b
digest).

Fixes #30428

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-05-22 11:47:20 -04:00
David Goulet
44265dd671 sendme: Never fallback to v0 if unknown version
There was a missing cell version check against our max supported version. In
other words, we do not fallback to v0 anymore in case we do know the SENDME
version.

We can either handle it or not, never fallback to the unauthenticated version
in order to avoid gaming the authenticated logic.

Add a unit tests making sure we properly test that and also test that we can
always handle the default emit and accepted versions.

Fixes #30428

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-05-22 11:47:20 -04:00
David Goulet
69e0d5bfc7 sendme: Validate v1 SENDMEs on both client and exit side
The validation of the SENDME cell is now done as the very first thing when
receiving it for both client and exit. On failure to validate, the circuit is
closed as detailed in the specification.

Part of #30428

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-05-22 11:47:20 -04:00
David Goulet
59b9eecc19 sendme: Record cell digest on both client and exit
It turns out that only the exit side is validating the authenticated SENDME v1
logic and never the client side. Which means that if a client ever uploaded
data towards an exit, the authenticated SENDME logic wouldn't apply.

For this to work, we have to record the cell digest client side as well which
introduced a new function that supports both type of edges.

This also removes a test that is not valid anymore which was that we didn't
allow cell recording on an origin circuit (client).

Part of #30428

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-05-22 11:47:20 -04:00
Mike Perry
857c54ca03 Refactor rend machines, stage 2/2: Move histogram code.
Comment clarifications now that the code is seperated. It's the same code, but
its doing this for different reasons on each side.
2019-05-16 20:17:14 +00:00
Mike Perry
0cba53c6ed Refactor rend machines, stage 1/2: Move state transition code. 2019-05-16 20:17:11 +00:00