Commit Graph

19400 Commits

Author SHA1 Message Date
Nick Mathewson
ca19a95d54 Merge remote-tracking branch 'dgoulet/ticket23355_032_01' 2017-09-08 12:13:48 -04:00
Nick Mathewson
2264172fb3 Merge remote-tracking branch 'asn/bug23387_squashed' 2017-09-08 12:09:02 -04:00
George Kadianakis
0307e7e0e7 test: Test that client picks the right HSDir for service.
This test is important because it tests that upload_descriptor_to_all()
is in synch with pick_hsdir_v3(). That's not the case for the
reachability test which just compares the responsible hsdir sets.
2017-09-08 19:07:00 +03:00
George Kadianakis
e0371935a1 prop224: Pick the right hsdir index based on descriptor.
There was a bug in upload_descriptor_to_all() where we picked between
first and second hsdir index based on which time segment we are. That's
not right and instead we should be uploading our two descriptors using a
different hsdir index every time. That is, upload first descriptor using
first hsdir index, and upload second descriptor using second hdsir index.

Also simplify stuff in pick_hdsir_v3() since that's only used to fetch
descriptors and hence we can just always use the fetch hsdir index.
2017-09-08 19:07:00 +03:00
George Kadianakis
e7bdb9eedc prop224: hs_time_between_tp_and_srv() -> hs_in_period_between_tp_and_srv()
Conflicts:
	src/or/nodelist.c
2017-09-08 19:07:00 +03:00
George Kadianakis
eb81a8e69c prop224: 'is_new_tp' -> 'use_second_hdsir_index' in hs_get_responsible_hsdirs() 2017-09-08 19:07:00 +03:00
David Goulet
6c6ba07517 test: Improve our rotation and build descriptor tests
Because of the latest changes on when we rotate, longer lifetime of
descriptors and no more overlap period, the tests needed to be improved to
test more functionnalities.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-08 19:07:00 +03:00
David Goulet
f2c93f9943 test: Fix use out of scope and consensus timings
First, this fixes #23372.

Second, the consensus timings for the build descriptor have been changed to
the current test can pass. More extensive tests of descriptor rotation are
coming in a commit near you because the rotation and time period logic has
been changed.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-08 19:07:00 +03:00
David Goulet
87585ebd2d test: Add an HS v3 reachability unit test
This is a large and important unit test for the hidden service version
3! It tests the service reachability for a client using different
consensus timings and makes sure that the computed hashring is the same
on both side so it is actually reachable.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-08 19:07:00 +03:00
David Goulet
4d38731e93 prop224: Make client and service pick same HSDir
With the latest change on how we use the HSDir index, the client and service
need to pick their responsible HSDir differently that is depending on if they
are before or after a new time period.

The overlap mode is active function has been renamed for this and test added.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-08 19:07:00 +03:00
David Goulet
cd07af60c9 prop224: Expand the overlap period concept to be a full SRV protocol run
Because of #23387, we've realized that there is one scenario that makes
the client unable to reach the service because of a desynch in the time
period used. The scenario is as follows:

  +------------------------------------------------------------------+
  |                                                                  |
  | 00:00      12:00       00:00       12:00       00:00       12:00 |
  | SRV#1      TP#1        SRV#2       TP#2        SRV#3       TP#3  |
  |                                                                  |
  |  $==========|-----------$===========|-----------$===========|    |
  |                                    ^ ^                           |
  |                                    C S                           |
  +------------------------------------------------------------------+

In this scenario the HS has a newer consensus than the client, and the
HS just moved to the next TP but the client is still stuck on the old
one. However, the service is not in any sort of overlap mode so it
doesn't cover the old TP anymore, so the client is unable to fetch a
descriptor.

We've decided to solve this by extending the concept of overlap period
to be permanent so that the service always publishes two descriptors and
aims to cover clients with both older and newer consensuses. See the
spec patch in #23387 for more details.
2017-09-08 19:07:00 +03:00
David Goulet
b586de78e3 prop224: Use fetch and store HSDir indexes.
Based on our #23387 findings, it seems like to maintain 24/7
reachability we need to employ different logic when computing hsdir
indices for fetching vs storing. That's to guarantee that the client
will always fetch the current descriptor, while the service will always
publish two descriptors aiming to cover all possible edge cases.

For more details see the next commit and the spec branch.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-08 19:06:56 +03:00
Nick Mathewson
926914a09c Merge remote-tracking branch 'dgoulet/bug23429_032_01' 2017-09-08 09:01:39 -04:00
Nick Mathewson
c151f46445 Merge branch 'ticket20119' 2017-09-08 08:56:53 -04:00
Nick Mathewson
f5092e711f Merge branch 'maint-0.2.9' into maint-0.3.0 2017-09-08 08:24:47 -04:00
Nick Mathewson
7a83cf75dc Merge branch 'maint-0.3.0' into maint-0.3.1 2017-09-08 08:24:47 -04:00
Nick Mathewson
ad3f0953e6 Merge branch 'maint-0.3.1' 2017-09-08 08:24:47 -04:00
Nick Mathewson
3cace828a9 Merge branch 'bug22644_029' into maint-0.2.9 2017-09-08 08:24:36 -04:00
Nick Mathewson
eebfe4f539 Merge branch 'ticket22731' 2017-09-08 08:11:11 -04:00
Nick Mathewson
1b1eeb0fb9 Merge branch 'feature23237' 2017-09-08 08:10:15 -04:00
Nick Mathewson
22e6880296 Merge branch 'ticket22377' 2017-09-08 08:06:44 -04:00
Nick Mathewson
a9d4df9a08 Merge branch 'maint-0.2.9' into maint-0.3.0 2017-09-07 15:18:01 -04:00
Nick Mathewson
54fb1d0f7f Merge branch 'maint-0.3.0' into maint-0.3.1 2017-09-07 15:18:01 -04:00
Nick Mathewson
36104e55e4 Merge branch 'maint-0.3.1' 2017-09-07 15:18:01 -04:00
Nick Mathewson
bcf2b413c3 Merge branch 'maint-0.2.5' into maint-0.2.8 2017-09-07 15:18:00 -04:00
Nick Mathewson
08592c95fa Merge branch 'maint-0.2.8' into maint-0.2.9 2017-09-07 15:18:00 -04:00
Karsten Loesing
09618ffe38 Update geoip and geoip6 to the September 6 2017 database. 2017-09-07 21:06:16 +02:00
David Goulet
fa87aa00c4 hs: Do not assert on rend_data while iterating over circuits
The pruning process and the deleting ephemeral service function iterates over
all circuits and were asserting on rend_data for a matching circuit. This is
not good because now we have v3 circuits without a rend_data.

Fixes #23429

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-07 14:24:49 -04:00
Matt Traudt
91c7bebfa2 consensus: Add a generic notification function on new consensus
Some groundwork for the KIST scheduler implementation.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-07 11:49:38 -04:00
David Goulet
72c7f81459 prop224: When computing hsdir index and time period, use valid_after time
Use the valid_after time from the consensus to get the time period number else
we might get out of sync with the overlap period that uses valid_after.

Make it an optional feature since some functions require passing a
specific time (like hs_get_start_time_of_next_time_period()).

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-07 18:16:07 +03:00
Nick Mathewson
27fa4a98d2 Make ClientDNSRejectInternalAddresses testing-only.
Undeprecate it;
rename it to TestingClientDNSRejectInternalAddresses;
add the old name as an alias;
reject configurations where it is set but TestingTorNetwork is not;
change the documentation accordingly.

Closes tickets 21031 and 21522.
2017-09-07 10:03:31 -04:00
Nick Mathewson
1502bf03fd Add a module comment to util_bug.h
Closes ticket 22824.
2017-09-07 09:31:30 -04:00
Nick Mathewson
12dad5ebf7 Fix crashes on empty +HSPOST and +POSTDESCRIPTOR commands
Fixes bug 22644; bugfix on 0.2.7.1-alpha and 0.2.0.1-alpha
respectively.
2017-09-07 09:20:00 -04:00
Nick Mathewson
1e079ec30d Merge branch 'maint-0.3.1' 2017-09-07 08:51:16 -04:00
Nick Mathewson
9c404602a0 Add a stack trace to the warning at issue with 23105.
With luck, this will help us diagnose 23105 and fix it.

I also added a stack trace to the warning right before it, since why
not.
2017-09-07 08:49:11 -04:00
Nick Mathewson
ae7cb3349e Merge branch 'bug23361_032_01_squashed2' 2017-09-07 08:35:35 -04:00
David Goulet
c527cde82f prop224: Pick rendezvous point of protover HSRend=2
Version 3 hidden service needs rendezvous point that have the protocol version
HSRend >= 2 else the rendezvous cells are rejected.

Fixes #23361

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-07 08:35:28 -04:00
Nick Mathewson
ab18e5e5fc Better error on failure to load seccomp2 sandbox
There are two reasons this is likeliest to happen -- no kernel
support, and some bug in Tor.  We'll ask people to check the former
before they report. Closes 23090.
2017-09-06 14:23:47 -04:00
Nick Mathewson
9261f612ad Merge remote-tracking branch 'dgoulet/bug23123_032_01' 2017-09-06 14:17:43 -04:00
Nick Mathewson
1098893e4f Exit when we can't write to a configured pid file
This is probably what the user wants, according to 20119.
2017-09-06 11:50:22 -04:00
Nick Mathewson
6fea44c673 Reject torrc if RunAsDaemon is given with relative paths.
The chdir() call in RunAsDaemon makes the behavior here surprising,
and either way of trying to resolve the surprise seems sure to
startle a significant fraction of users.  Instead, let's refuse to
guess, and refuse these configurations.

Closes ticket 22731.
2017-09-06 11:39:11 -04:00
Nick Mathewson
342712b9ef Make url-canonicalizer canonicalize correctly. 2017-09-05 15:02:16 -04:00
Nick Mathewson
4e02d02076 Fix an erroneous ! 2017-09-05 14:55:13 -04:00
Nick Mathewson
4ce60dab00 Resolve inconsistencies between buf refactor and HTTP connect 2017-09-05 14:41:35 -04:00
Nick Mathewson
73b0e2e6fd Merge branch 'http_tunnel_squashed' 2017-09-05 14:34:29 -04:00
Nick Mathewson
ad9190404b Add a fuzzer for HTTP CONNECT 2017-09-05 14:34:09 -04:00
Nick Mathewson
53e4272b65 Add stream isolation support for HTTP CONNECT tunnels
I'm doing this using the Proxy-Authorization: header to support
clients that understand it, and with a new tor-specific header that
makes more sense for our use.
2017-09-05 14:34:09 -04:00
Nick Mathewson
4b30ae1581 Add support for HTTP Connect tunnels 2017-09-05 14:34:09 -04:00
Nick Mathewson
eda79c2f78 Export http-command parsing functions. 2017-09-05 14:34:09 -04:00
Nick Mathewson
c0b9f594b6 Make preferred_chunk_size nonstatic, and add a prefix to it 2017-09-05 14:17:18 -04:00
Nick Mathewson
6ec5059723 Refactor buffer APIs to put a buf_t first.
By convention, a function that frobs a foo_t should be called
foo_frob, and it should have a foo_t * as its first argument.  But
for many of the buf_t functions, the buf_t was the final argument,
which is silly.
2017-09-05 13:57:51 -04:00
Nick Mathewson
d61da9e61f Repair wide lines from previous commit. 2017-09-05 13:57:51 -04:00
Nick Mathewson
4a7e90adc5 Repair buffer API so everything starts with buf_.
Our convention is that functions which manipulate a type T should be
named T_foo.  But the buffer functions were super old, and followed
all kinds of conventions.  Now they're uniform.

Here's the perl I used to do this:

\#!/usr/bin/perl -w -i -p

s/read_to_buf\(/buf_read_from_socket\(/;
s/flush_buf\(/buf_flush_to_socket\(/;
s/read_to_buf_tls\(/buf_read_from_tls\(/;
s/flush_buf_tls\(/buf_flush_to_tls\(/;
s/write_to_buf\(/buf_add\(/;
s/write_to_buf_compress\(/buf_add_compress\(/;
s/move_buf_to_buf\(/buf_move_to_buf\(/;
s/peek_from_buf\(/buf_peek\(/;
s/fetch_from_buf\(/buf_get_bytes\(/;
s/fetch_from_buf_line\(/buf_get_line\(/;
s/fetch_from_buf_line\(/buf_get_line\(/;
s/buf_remove_from_front\(/buf_drain\(/;
s/peek_buf_startswith\(/buf_peek_startswith\(/;
s/assert_buf_ok\(/buf_assert_ok\(/;
2017-09-05 13:57:51 -04:00
Nick Mathewson
336aa21e37 Move buffers.c and buffers_tls.c into src/common
These are no longer tor-specific, so they can be part of the
infrastructure.
2017-09-05 13:57:51 -04:00
Nick Mathewson
150089cbd7 Move the tls parts of buffers.c into buffers_tls.c 2017-09-05 13:57:51 -04:00
Nick Mathewson
5921b465e7 Make buffers.c independent of or.h
Also, put ext_or function in new module; it had accidentally gotten
into proto_socks.c
2017-09-05 13:57:51 -04:00
Nick Mathewson
f28e314b0d Make buf_pullup() expose the pulled-up data.
This lets us drop the testing-only function buf_get_first_chunk_data(),
and lets us implement proto_http and proto_socks without looking at
buf_t internals.
2017-09-05 13:57:51 -04:00
Nick Mathewson
cddac959e7 Replace buf->datalen usage in proto_*.c with buf_datalen() call.
This lets us remove BUFFERS_PRIVATE from two of the modules.
2017-09-05 13:57:51 -04:00
Nick Mathewson
234c5015f1 Move protocol-specific functions out of buffers.c
This commit does not change the implementation of any function: it
only moves code and adds new includes as necessary.  Part of #23149.
2017-09-05 13:57:51 -04:00
Nick Mathewson
fd0a894d28 Bump to 0.3.1.6-rc-dev 2017-09-05 10:20:34 -04:00
David Goulet
7eaf055b28 test: Fix memory leak in hs_descriptor/decode_bad_signature
Fixes #23319

Cherry-picked from master; bug not in any released Tor.
2017-09-05 09:26:21 -04:00
Nick Mathewson
2d55620a9e Bump version to 0.3.1.6-rc 2017-09-05 08:30:52 -04:00
Nick Mathewson
56df123933 Merge branch 'bug23331_032_01_squashed' 2017-09-05 08:24:28 -04:00
David Goulet
9e900d1db7 hs: Don't enter the HS v3 subsystem without a live consensus
The service needs the latest SRV and set of relays for the best accurate
hashring to upload its descriptor to so it needs a live consensus thus don't
do anything until we have it.

Fixes #23331

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-05 08:24:22 -04:00
Nick Mathewson
42394053c9 Merge branch 'maint-0.3.1' 2017-09-04 15:48:12 -04:00
Nick Mathewson
4d97efd4d1 Merge branch 'bug22752_031_simple' into maint-0.3.1 2017-09-04 15:48:01 -04:00
Nick Mathewson
33989cd002 Merge remote-tracking branch 'dgoulet/bug23366_032_01' 2017-09-04 12:48:26 -04:00
Nick Mathewson
834e1f8085 Merge remote-tracking branch 'asn/bug23346' 2017-09-04 12:30:51 -04:00
Nick Mathewson
109cfebca5 Merge remote-tracking branch 'dgoulet/bug23327_032_01' 2017-09-04 12:24:05 -04:00
Nick Mathewson
85688dc33d Merge branch 'bug23360_032_01' 2017-09-04 12:11:43 -04:00
David Goulet
8c41196254 hs: Remove dead code and uneeded feature
When merging #20657, somehow hs_service_dir_info_changed() became unused
leading to not use the re-upload to HSDir when we were missing information
feature.

Turns out that it is not possible to pick an HSDir with a missing descriptor
because in order to compute the HSDir index, the descriptor is mandatory to
have so we can know its position on the hashring.

This commit removes that dead feature and fix the
hs_service_dir_info_changed() not being used.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-04 12:11:31 -04:00
Nick Mathewson
e72dec18a9 Merge remote-tracking branch 'asn/ticket23056_v2' 2017-09-04 12:09:03 -04:00
Nick Mathewson
948be49ce0 22752: Improve comments to explain why we're doing this fix.
Based on questions and comments from dgoulet, I've tried to fill
in the reasoning about why these functions work in the way that they
do, so that it will be easier for future programmers to understand
why this code exists and works the way it does.
2017-09-04 11:54:49 -04:00
Nick Mathewson
e2e13e7c8a Merge branch 'maint-0.3.1' 2017-09-04 11:40:02 -04:00
Nick Mathewson
a7aeb6f58f Merge remote-tracking branch 'public/bug23275_031' into maint-0.3.1 2017-09-04 11:39:28 -04:00
David Goulet
a52a32c855 hs: Set rendezvous circuit timestamp_dirty all the time
We used to check if it was set to 0 which is what unused circuit have but when
the rendezvous circuit was cannibalized, the timestamp_dirty is not 0 but we
still need to reset it so we can actually use it without having the chance of
expiring the next second (or very soon).

Fixes #23123

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-31 11:40:22 -04:00
David Goulet
651629cbdf config: Make parse_outbound_addresses() return failures
The function was never returning an error code on failure to parse the
OutboundAddress* options.

In the process, it was making our test_options_validate__outbound_addresses()
not test the right thing.

Fixes #23366

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-31 08:29:09 -04:00
David Goulet
22295759af prop224: Purge client state on NEWNYM
Closes #23355

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-30 09:15:54 -04:00
George Kadianakis
b9f849bdee prop224: Clear list of prev hsdirs before we upload all descs.
This fixes a serious bug in our hsdir set change logic:

We used to add nodes in the list of previous hsdirs everytime we
uploaded to a new hsdir and we only cleared the list when we built a new
descriptor. This means that our prev_hsdirs list could end up with 7
hsdirs, if for some reason we ended up uploading our desc to 7 hsdirs
before rebuilding our descriptor (e.g. this can happen if the set of
hsdirs changed).

After our previous hdsir set had 7 nodes, then our old algorithm would
always think that the set has changed since it was comparing a smartlist
with 7 elements against a smartlist with 6 elements.

This commit fixes this bug, by clearning the prev_hsdirs list before we
upload to all hsdirs. This makes sure that our prev_hsdirs list always
contains the latest hsdirs!
2017-08-30 15:42:25 +03:00
George Kadianakis
1dc21b8790 prop224: Simplify HSDir set change algo.
Our logic for detecting hsdir set changes was needlessly compicated: we
had to sort smartlists and compare them.

Instead, we can simplify things by employing the following logic:
"We should reupload our descriptor if the latest HSDir set contains
nodes that were not previously there"
2017-08-30 15:30:22 +03:00
George Kadianakis
d3cefddfc5 prop224 test: Improve desc_reupload_logic() test with more nodes. 2017-08-30 15:29:30 +03:00
George Kadianakis
ac9066660e prop224 test: Simplify interface for adding nodes to hash ring.
We want to have tests with big hash rings so let's make it an one-liner
to add nodes.
2017-08-30 15:29:30 +03:00
David Goulet
0850ae5049 hs: Implement an HS client free all function
Called from main.c, the function for now purges the hidden service directory
request cache.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-29 16:02:13 -04:00
Nick Mathewson
da159c45e2 On windows, allow many entries in conscache directories
Since we can't be sure that we can unlink enough files on windows
here, let's let the number of permitted entries grow huge if it
really must.

We do this by letting the storagedir hold lots of entries, but still
trying to keep the number of entries under the configured limit.  We
also have to tell consdiffmgr not to freak out if it can't actually
remove enough entries.

Part of a fix for bug 22752
2017-08-29 13:03:36 -04:00
Nick Mathewson
5e97b34daa On windows, don't force-unlink active conscache objects.
Part of a fix for bug 22752: We can't unlink these because Windows
doesn't allow you to unlink an in-use file.
2017-08-29 13:02:02 -04:00
Nick Mathewson
209bfe715c Merge branch 'maint-0.3.1' 2017-08-29 11:11:12 -04:00
Nick Mathewson
6307a759ed Merge remote-tracking branch 'dgoulet/bug22159_031_01' into maint-0.3.1 2017-08-29 11:11:09 -04:00
Nick Mathewson
5e08cf350b Add test_hs_descriptor.inc to include.am to unbreak distcheck. 2017-08-29 10:57:13 -04:00
Nick Mathewson
3cf8da02f7 Merge remote-tracking branch 'asn/bug23343' 2017-08-28 15:49:11 -04:00
David Goulet
6507ecb7e8 hs: Fix the intro circuit max retry
Some parentheses were missing making the rend_max_intro_circs_per_period()
return a lower value than it was suppose to.

The calculation is that a service at most will open a number of intro points
that it wants which is 3 by default or HiddenServiceNumIntroductionPoints. Two
extra are launched for performance reason. Finally, this can happen twice for
two descriptors for the current and next time period.

From:
  2 * n_intro_wanted + 2

...which resulted in 8 for 3 intro points, this commit fixes it to:

  (n_intro_wanted + 2) * 2

... resulting in 12 possible intro point circuit which is the correct maximum
intro circuit allowed per period.

Last, this commit rate limits the the log message if we ever go above that
limit else over a INTRO_CIRC_RETRY_PERIOD, we can print it often!

Fixes #22159

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-28 14:43:42 -04:00
Nick Mathewson
5ef656e7d1 Temporarily disable compilation of the v3 hs fuzzing code
Turns out, it wasn't up-to-date with the latest v3 hs API :(
2017-08-28 14:12:56 -04:00
Nick Mathewson
f53d405084 Fix compilation. 2017-08-28 14:00:00 -04:00
Nick Mathewson
18bc7fa70b Merge remote-tracking branch 'haxxpop/fuzzing-hsv3' 2017-08-28 13:46:24 -04:00
George Kadianakis
e94f68e301 fixup! prop224: Fix length check when purging hidserv requests.
Improve doc based on david's comments.
2017-08-28 19:55:26 +03:00
Nick Mathewson
63fc23f826 Merge branch 'ticket22348_031' into maint-0.3.1 2017-08-28 11:44:18 -04:00
Nick Mathewson
c107aae3c2 Merge branch 'ticket22348_031' 2017-08-28 11:43:55 -04:00
Nick Mathewson
ab166fe68f Try to improve the keypinning-failure message even more 2017-08-28 11:35:30 -04:00
Nick Mathewson
4b4b3afb56 Merge branch 'bug22802_squashed' 2017-08-28 10:23:05 -04:00
Nick Mathewson
b88d00fea3 Don't fall back to _atoi64
We only did this on windows when building with MSVC 6 and earlier,
which is now considered a screamingly bad idea.
2017-08-28 10:21:29 -04:00
Nick Mathewson
e37c1df9cd Don't use "0" as a "base" argument to tor_parse_*().
Telling these functions to autodetect the numeric base has lead to
trouble in the past.

Fixes bug 22469. Bugfix on 0.2.2.various.
2017-08-28 10:21:29 -04:00
Nick Mathewson
5b8956df3b In test_establish_intro_wrong_purpose, use tt_i64_op on ssize_t
Since ssize_t is signed and might be 64 bits, we should use
tt_i64_op to make sure it's positive.  Otherwise, if it is negative,
and we use tt_u64_op, we'll be treating it as a uint64_t, and we
won't detect negative values.

This fixes CID 1416338 and 1416339.  Bug not in any released Tor.
2017-08-28 10:11:49 -04:00
Nick Mathewson
8de4a80125 Fix unlikely memory leak introduced in 418f3d6298
This is CID 1416880; bug not in any released Tor.
2017-08-28 10:08:52 -04:00
Nick Mathewson
b27c029266 Merge remote-tracking branch 'asn/bug23335' 2017-08-28 10:05:21 -04:00
George Kadianakis
93a0a4a422 prop224: Fix length check when purging hidserv requests.
That check was wrong:

a) We should be making sure that the size of `key` is big enough before
   proceeding, since that's the buffer that we would overread with the
   tor_memeq() below.

   The old check used to check that `req_key_str` is big enough which is
   not right, since we won't read deep into that buffer.

   The new check makes sure that `key` has enough size to survive the
   tor_memeq(), and if not it moves to the next element of the strmap.

b) That check shouldn't be a BUG since that strmap contains
   variable-sized elements and we should not be bugging out if we happen
   to compare a small sized element (v2) to a bigger one (v3).
2017-08-28 16:34:16 +03:00
George Kadianakis
d4f1b566e1 prop224: Add test that exposes the #23343 bug. 2017-08-28 16:34:13 +03:00
George Kadianakis
b1cb16867e Fix compilation warning on old clangs. 2017-08-28 15:00:09 +03:00
George Kadianakis
ad56a342b4 Silence some leftover warnings. 2017-08-28 14:54:36 +03:00
David Goulet
e8c584176b hs: Note the connection attempt if descriptor is unusable
This way, we can clear off the directory requests from our cache and thus
allow the next client to query those HSDir again at the next SOCKS connection.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-25 13:39:40 -04:00
David Goulet
11443bb74c hs: Implement note_connection_attempt_succeeded()
v3 client now cleans up the HSDir request cache when a connection to a service
was successful.

Closes #23308

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-25 13:23:55 -04:00
Nick Mathewson
96aed28f14 New GETINFO target to check if geoip is loaded
Closes ticket 23237.
2017-08-25 12:25:05 -04:00
Nick Mathewson
b91dce9454 Merge branch 'maint-0.3.1' 2017-08-25 11:39:38 -04:00
Nick Mathewson
6069c829f9 Merge branch 'bug19418_029' into maint-0.3.1 2017-08-25 11:38:24 -04:00
Nick Mathewson
0de3147bf1 fix wide lines 2017-08-25 11:34:42 -04:00
Nick Mathewson
82b581f3fc Merge remote-tracking branch 'asn/bug23309_v2' 2017-08-25 11:31:53 -04:00
George Kadianakis
6d48e75685 prop224: Better missing hsdir index logs.
Seems like hsdir index bugs are around to haunt us. Let's improve the
log messages to make debugging easier.
2017-08-25 17:18:05 +03:00
George Kadianakis
ea5af8f442 prop224: When HUPing, move HS state from old to new service.
We used to not copy the state which means that after HUP we would forget
if we are in overlap mode or not. That caused bugs where the service
would enter overlap mode twice, and rotate its descs twice, causing all
sorts of bugs.
2017-08-25 17:18:05 +03:00
George Kadianakis
409ecbec52 prop224: Be more careful to not overwrite descriptors in HUP. 2017-08-25 17:18:05 +03:00
George Kadianakis
17fd2c8a51 prop224: Move function move_descriptors() around.
We want to use some static functions so move it below them.
2017-08-25 17:18:05 +03:00
David Goulet
a9fb97e91a prop224: Don't move intro points but rather descriptors
Apart from the fact that a newly allocated service doesn't have descriptors
thus the move condition can never be true, the service needs the descriptor
signing key to cross-certify the authentication key of each intro point so we
need to move the descriptors between services and not only the intro points.

Fixes #23056

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-25 17:18:05 +03:00
David Goulet
2549b3e923 sandbox: Fix double free when initializing HSv3 filenames
Don't free a reference that has been stolen.

Fixes #23329

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-25 09:28:10 -04:00
George Kadianakis
e07b677bd9 prop224: Move service_desc_hsdirs_changed() and make it static.
That function could be static but needed to be moved to the top.
2017-08-25 14:41:06 +03:00
George Kadianakis
c980be9511 prop224: Refactor descriptor reupload logic.
We refactor the descriptor reupload logic to be similar to the v2 logic
where we update a global 'consider_republishing_rend_descriptors' flag
and then we use that to check for hash ring changes during the global
hidden service callbacks.

This fixes bugs where we would inspect the hash ring immediately as we
receive new dirinfo (e.g. consensus) but before running the hidden
service housekeeping events. That was leaving us in an inconsistent
state wrt hsdir indices and causing bugs all around.
2017-08-25 14:41:06 +03:00
George Kadianakis
8b8e39e04b prop224: Refactor descriptor rotation logic.
The problem was that when we went from overlap mode to non-overlap mode,
we were not wiping the 'desc_next' descriptor and instead we left it on
the service. This meant that all functions that iterated service
descriptors were also inspecting the useless 'desc_next' descriptor that
should have been deleted.

This commit refactors rotate_all_descriptors() so that it rotates
descriptor both when entering overlap mode and also when leaving it.
2017-08-25 14:41:06 +03:00
Nick Mathewson
408ed52e3d Remove the AUTHDIR_NEWDESCS feature: nobody is using it any more
If somebody asks for it, log a warning.

Closes ticket 22377.
2017-08-24 16:53:35 -04:00
David Goulet
dfaa5c65f9 test: Fix memory leak in hs_descriptor/decode_bad_signature
Fixes #23319

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 16:21:44 -04:00
Nick Mathewson
a007c02df0 Re-run trunnel. Cosmetic changes only. 2017-08-24 16:13:01 -04:00
Alexander Færøy
77b92c2214 Ensure that make check-spaces is happy.
The `test-operator-cleanup` patch, and related coccinelle patches,
don't do any checks for line length. This patch fixes the line
length issues caused by the previous commits.
2017-08-24 16:09:41 -04:00
Nick Mathewson
011d94fb11 apply ahf's test_assert_null.cocci 2017-08-24 15:55:27 -04:00
Nick Mathewson
047790a253 apply ahf's test_assert_int.cocci 2017-08-24 15:49:59 -04:00
Nick Mathewson
0b36208fd8 apply ahf's test_assert_zero.cocci 2017-08-24 15:34:34 -04:00
Nick Mathewson
067a4422fe Apply ahf's ceil_div.cocci patch. 2017-08-24 15:33:27 -04:00
Nick Mathewson
e884248118 Fix a needless line-continuation in aes.c
coccinelle was getting confused
2017-08-24 15:32:30 -04:00
Nick Mathewson
1d0f7b7ccd Apply test-operator-cleanup to src/common too. 2017-08-24 15:26:57 -04:00
Alexander Færøy
c4744a01cc Fix operator usage in src/test/*.c
This patch fixes the operator usage in src/test/*.c to use the symbolic
operators instead of the normal C comparison operators.

This patch was generated using:

    ./scripts/coccinelle/test-operator-cleanup src/test/*.[ch]
2017-08-24 15:24:34 -04:00
Nick Mathewson
91c6bc160b Merge remote-tracking branch 'dgoulet/ticket17242_032_03-squashed' 2017-08-24 15:12:16 -04:00
George Kadianakis
dc0264f659 Silence some spammy log messages. 2017-08-24 13:03:29 -04:00
David Goulet
e546ac6b32 circuit: Consider v3 hidden service circuit in circuit_expire_building()
For a ready v3 rendezvous circuit, consider it so we don't expire.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:29 -04:00
David Goulet
a112562544 hs: Update intro circuit timestamp when re-extending
A client can re-extend up to 3 intro points on the same circuit. This happens
when we get NACKed by the intro point for which we choose a new intro and
re-extend the circuit to it.

That process can be arbitrarly long so reset the dirty timestamp of the
circuit everytime we choose to re-extend so we get a bit more time to actually
do our introduction.

This is a client circuit so it is short live once opened thus giving us a bit
more time to complete the introduction is ok.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:29 -04:00
David Goulet
1077e9894c circuit: Avoid needless log info in circuit_get_best()
When looking for an introduction circuit in circuit_get_best(), we log an info
message if we are about to launch a new intro circuit in parallel. However,
the condition was considering marked for close circuit leading to the function
triggering the log info even though there is actually no valid intro circuit.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:29 -04:00
David Goulet
dca105d588 prop224: Register RP circuit when it opens
Only register the RP circuit when it opens and not when we send the INTRODUCE1
cell else, when re-extending to a new IP, we would register the same RP
circuit with the same cookie twice leading to the circuit being closed.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:29 -04:00
David Goulet
954f663831 prop224: Try to recover from a bad intro circuit
Changed the assert_intro_circ_ok() to an almost non fatal function so tor can
recover properly. We keep the anonymity assert because if that is not right,
we have much deeper problems and client should stop sending bytes to the
network immediately.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
5f94c4a0f1 prop224: Refactor how we use connection_ap_handle_onion
Simply directly return its returned value.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
98efb646fc hs: Remove unused rend_client_rendezvous_acked()
This function has been replaced by hs_client_receive_rendezvous_acked(() doing
the same exact thing for both v2 and v3 service.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
a16627db1f prop224: Add a function to find an intro point by legacy ID
The client needs to find the right intro point object from the circuit
identity digest it is opened to. This new function does that.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
7c543412fc prop224: Add a function to clear INTRO data
New function named hs_cell_introduce1_data_clear() is introduced to clear off
an hs_cell_introduce1_data_t object.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
cb462b95b7 prop224: Rename hs_desc_encode_lspec()
Give it a name that shows the transition from a descriptor link spec to a
trunnel link spec.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
61009d40d1 hs: Stub link_specifier_t in hs_descriptor.h
Avoid including a huge trunnel interface everytime we include hs_descriptor.h

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
e046e6fb48 prop224: Update OOM counters when storing a client descriptor cache object
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
68887fdc5d prop224: Update OOM counters when freeing a client descriptor cache object
When we free a client descriptor cache object, tell the OOM handler.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
47672ec1c7 prop224: Check decoded descriptor matches the expected blinded key
When a client decodes a descriptor, make sure it matches the expected blinded
key which is derived from the hidden service identity key.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
520fcdf2f3 test: Fix broken HS upload descriptor test
We can't trigger a valid upload because it would require us to MOCK a long
list of functions ultimately not really testing the upload because we aren't
on a running network.

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

Conflicts:
	src/test/test_hs_service.c
2017-08-24 13:03:28 -04:00
David Goulet
31da3898e7 prop224: Add directory_request_fetch_set_hs_ident()
Needed by the client when fetching a descriptor. This function checks the
directory purpose and hard assert if it is not for fetching.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
a64ef7d6c5 prop224: Implement hs_client_any_intro_points_usable()
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
14b858c4ce prop224: Use the intro point state cache
This commit makes the client use the intro point state cache. It notes down
when we get a NACK from the intro point and then uses that cache to decide if
it should either close the circuits or re-extend to a new intro point.

This also introduces a very useful function that checks if an intro point is
usable that is query the state cache and checks a series of requirement.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
2671399e67 prop224: Add a client intro point state cache
This cache keeps track of the state of intro points which is needed when we
have failures when using them. It is similar to the failure cache of the
legacy system.

At this commit, it is unused but initialized, cleanup and freed.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
88b843608a prop224: Move and refactor rend_client_reextend_intro_circuit()
This moves it to hs_client.c so it can be used by both system (legacy and
prop224). For now, only the legacy system uses it.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
88f64eee68 hs: Update the IP failure cache only if legacy
Don't assert() on rend_data when closing circuits to report an IP failure. The
prop224 code doesn't have yet the support for this.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
George Kadianakis
379ad6f6eb prop224: Use the client-side circuitmap in hs_client.c
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
George Kadianakis
3152c583af prop224: Add client-side rend circuit support to HS circuitmap
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
e67f8623f9 hs: Only note a connection attempt with a valid rend_data
For now, prop224 doesn't have a mechanism to note down connection attempts so
we only do it for legacy system using rend_data.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
9af3116306 prop224: Handle RENDEZVOUS2 cell
The client can now handle RENDEZVOUS2 cell when they arrive. This consolidate
both hidden service version in one function.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
ee15c16742 prop224: Parse RENDEZVOUS2 cell
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
2f1b3d647f trunnel: Add RENDEZVOUS2 cell definition
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
fca2f64e2f prop224: Handle INTRODUCE_ACK cell
The client is now able to handle an INTRODUCE_ACK cell and do the appropriate
actions.

An intro point failure cache is missing and a way to close all intro point
that were launched in parallel. Some notes are in the comment for that.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
cb336a7062 prop224: Parse INTRODUCE_ACK cell
Add a function to parse an INTRODUCE_ACK cell in hs_cell.c. Furthermore, add
an enum that lists all possible expected status code.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
e7c06e6947 prop224: Make client send INTRODUCE1 cell
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
abb840bf64 prop224: Client function to pick intro point
From an edge connection object, add a function that randomly pick an
introduction point for the requested service.

This follows the code design of rend_client_get_random_intro() and returns an
extend_info_t object ready to be used to extend to.

At this commit, it is not used yet.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
c38144bb0f prop224: Client callback when descriptor has arrived
When a descriptor fetch has completed and it has been successfully stored in
the client cache, this callback will take appropriate actions to attach
streams and/or launch neede circuits to connect to the service.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
89eb96c19a prop224: Handle client RENDEZVOUS_ESTABLISHED cell
Client now handles a RENDEZVOUS_ESTABLISHED cell when it arrives on the
rendezvous circuit. This new function applies for both the legacy system and
prop224.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
b91693f7c3 prop224: Build ESTABLISH_RENDEZVOUS cell and logic
Add a function to build the cell.

Add a the logic to send the cell when the rendezvous circuit opens.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
6eb125d14b prop224: Client has opened circuit logic
Make a single entry point for the entire HS subsystem when a client circuit
opens (every HS version).

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
d599325b5e prop224: Build INTRODUCE1 cell and send logic
Add a function in hs_cell.{c|h} for a client to build an INTRODUCE1 cell using
an object that contains all the needed keys to do so.

Add an entry point in hs_client.c that allows a tor client to send an
INTRODUCE1 cell on a given introduction circuit.

It includes the building of the cell, sending it and the setup of the
rendezvous circuit with the circuit identifier.

The entry point function is still unused at this commit.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
8a552bf49b prop224: Make lspecs to extend info public
The hs circuit file had this function that takes a list of link specifiers and
return a newly allocated extend info object. Make it public so the client side
can also use it to be able to extend to introduction point.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
8e2854372d prop224: Helper function to assert on invalid client intro circuit
Put all the possible assert() we can do on a client introduction circuit in
one helper function to make sure it is valid and usable.

It is disabled for now so gcc doesn't complain that we have a unused function.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
b13ee8e4ae hs: Move link specifier encoding to a function
This commit only moves code into a function. The client code will need a way
to take a bunch of descriptor link specifier object and encode them into link
specifiers objects.

Make this a public function so it can be used outside of hs_descriptor.c.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
6222eae8ca conn: Add a function to return a list of connection by state
This will be useful to the hidden service subsystem that needs to go over all
connections of a certain state to attach them to a hidden service circuit.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
George Kadianakis
6eb9de1b8c test: Add tests for fetching descs and handling SOCKS conns.
- Add tests that ensure that SOCKS requests for v2/v3 addresses get
  intercepted and handled.

- Add test that stores and lookups an HS descriptor in the client-side cache.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
79ff2e014f hs: Fix comment of the get max size descriptor function
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
b2a820958e prop224: Rename hs_client_note_connection_attempt_succeeded()
This is a static function so don't polute the hs_client_ namespace.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
David Goulet
343af1a9cf prop224: Add the dir purpose HAS_FETCHED
Once a descriptor has been successfully downloaded from an HSDir, we flag the
directory connection to "has fetched descriptor" so the connection subsystem
doesn't trigger a new fetch on success.

Same has DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2 but for prop224.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
George Kadianakis
f93b77a18c prop224: Add client code to handle fetched HS descriptors.
This code handles received HS descriptors by storing them in the
client-side HS cache.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
George Kadianakis
ebacf4dd6e prop224: Introduce v2/v3 HS desc fetch retry functionality.
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
George Kadianakis
776e796d96 prop224: Connect to v3 services in connection_ap_handle_onion().
Recognize and handle v3 addresses.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
George Kadianakis
c754864cfd prop224: Add code that launches v3 HS desc fetches.
Entry point is hs_client_refetch_v3_renddesc().

Will be used in subsequent commits.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
George Kadianakis
0f6633abb2 prop224: Refactor pick_hsdir() to be used by both v2 and v3.
Also refactor rendclient.c to use the new hs_pick_hdsir() func.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
George Kadianakis
5c9cd912ee prop224: Refactor rendclient.c to use the new hsdir_req code.
- Also add tests for the hidserv_req subsystem.
- Introduce purge_v2_hidserv_req() wrapper to simplify v2 code.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
George Kadianakis
15c9b7e891 prop224: Fix hidserv request code to work for both v2 and v3.
See documentation of `last_hid_serv_requests_` for how it works. strmaps are
cool!

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:28 -04:00
George Kadianakis
912c11761c prop224: Move some rendclient.c code to hs_common.c
Specifically move the pick_hsdir() function and all the HSDir request tracking
code. We plan to use all that code both for v2 and v3.

This commit only moves code.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:27 -04:00
George Kadianakis
7aef3ec0fd prop224: Add client-side HS descriptor cache.
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24 13:03:27 -04:00
Nick Mathewson
b5c5086aba Merge branch 'bug23106_032' 2017-08-24 09:45:03 -04:00
Nick Mathewson
35a29e81ae Merge branch 'bug19281_025' 2017-08-24 09:27:26 -04:00
Nick Mathewson
d37e8b407a Merge branch 'feature22976_squashed' 2017-08-24 09:23:43 -04:00
Nick Mathewson
a0bb1ff6ab Also disable spawning on Sandbox.
This isn't a functional change, but it makes our logic more clear,
and catches bugs earlier.
2017-08-24 09:23:32 -04:00
Nick Mathewson
f4f828640f Merge branch 'bug22779_031' 2017-08-24 09:18:39 -04:00
Nick Mathewson
18f3f1ffa3 add parenthesis to make cast work right. 2017-08-23 13:12:58 -04:00
Nick Mathewson
ee73c1848e Add test_hs_descriptor.inc to include.am to unbreak distcheck. 2017-08-23 13:08:59 -04:00
Nick Mathewson
86ee35ad5b Don't do expensive consensus stuff when not a cache.
This includes generating and storing compressed consensuses, and
consensus diffs.  Fixes bug 23275; bugfix on 0.3.1.1-alpha.
2017-08-23 10:22:51 -04:00
Nick Mathewson
80d3887360 Refactor node lookup APIs to take flags
Right now there's a single warn_if_unnamed flag for
router_get_consensus_status_by_nickname() and
node_get_by_nickname(), that is nearly always 1.  I've turned it
into an 'unsigned' bitfield, and inverted its sense.  I've added the
flags argument to node_get_by_hex_id() too, though it does nothing
there right now.

I've removed the router_get_consensus_status_by_nickname() function,
since it was only used in once place.

This patch changes the warning behavior of GETINFO ns/name/<name>,
since all other name lookups from the controller currently warn.

Later I'm going to add more flags, for ed25519 support.
2017-08-22 19:13:40 -04:00
Nick Mathewson
d7a3e336ee Remove some support for nickname-based hexdigests
We once used $X=N to mean "A relay with RSA ID digest X with the
Named flag and the nickname N."  But authorities no longer assign
the Named flag.
2017-08-22 18:47:57 -04:00
Nick Mathewson
40887b4d2e Unit tests for maintaining ed25519->node map. 2017-08-22 16:12:58 -04:00
Ties Stuij
2e99f839e9 22839: Build tor with rust enabled on win
- make tor_util static library name configurable
- fix Rust libary dependency order for Windows
2017-08-21 15:08:24 -04:00
Nick Mathewson
8f8a061b0c Merge branch 'maint-0.3.1' 2017-08-21 15:08:17 -04:00
Nick Mathewson
10b2428224 Merge branch 'bug23291_028' into maint-0.3.1 2017-08-21 15:06:39 -04:00
Ties Stuij
7ba873ca2d 22839: fix check_heap_buffer buffer size in test-memwipe 2017-08-21 15:03:54 -04:00
Nick Mathewson
6f3208670a Merge branch 'maint-0.3.1' 2017-08-21 14:20:38 -04:00
Nick Mathewson
6be0e28670 whitespace fixes 2017-08-21 14:18:41 -04:00
George Kadianakis
1491c0d024 Fix triggerable BUG() when decoding hsv3 descriptors.
Also improve the unittest to make sure it catches the right error.
2017-08-21 19:16:45 +03:00
George Kadianakis
45732a1a13 Add unittest for #23233.
This will fail currently since the bug is not fixed yet.
2017-08-21 19:16:30 +03:00
George Kadianakis
5d89ea1e6c prop224: Decouple the HS part of connection_ap_handshake_rewrite_and_attach().
We will need to edit this function, and it's already pretty huge. Let's make
it a bit smaller.

This commit moves code, fixes a 80 char line and add two lines at the start to
make it compile. Trivial change.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-19 16:42:26 +03:00
George Kadianakis
bce18a7642 prop224: Refactor parse_extended_hostname() to parse v3 addrs.
We need this func so that we recognize SOCKS conns to v3 addresses.

- Also rename rend_valid_service_id() to rend_valid_v2_service_id()

- Also move parse_extended_hostname() tests to their own unittest, and
  add a v3 address to the test as well.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-19 16:42:26 +03:00
George Kadianakis
3e593f09ad prop224: Recompute all HSDir indices when we enter overlap mode.
When we enter overlap mode we start using the next hsdir index of
relays. However, we only compute the next hsdir index of relays when we
receive a consensus or their descriptor. This means that there is a
window of time between entering the overlap period and fetching the
consensus where relays have their next hsdir index uninitialized. This
patch fixes this by recomputing all hsdir indices when we first enter
the overlap period.
2017-08-19 16:29:23 +03:00
George Kadianakis
7823c98a38 prop224: Improve descriptor reupload logic.
We want to reupload our descriptor if its set of responsible HSDirs
changed to minimize reachability issues.

This patch adds a callback everytime we get new dirinfo which checks if
the hash ring changed and reuploads descriptor if needed.
2017-08-19 16:28:48 +03:00
George Kadianakis
26c85fcc86 test: Improve get_responsible_hsdirs test. 2017-08-19 16:28:48 +03:00
George Kadianakis
1f7b8012ae prop224: Only upload descriptor if we have good hash ring and SRV.
Make sure we have a live consensus (for SRV) and enough descriptors (for
hash ring).

Also fix unittests that broke.
2017-08-19 16:28:47 +03:00
George Kadianakis
43343ec019 prop224: Improve our checks for unset HSDir index.
We used to not check next hsdir index.
2017-08-19 16:28:43 +03:00
David Goulet
5750f18bc7 sr: Log voting schedule at debug level
Because the HS subsystem calls it every second, change the log level to debug
so it doesn't spam the info log.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-19 16:20:07 +03:00
Suphanat Chunhapanya
97347b1109 Fuzz outer layer of hsv3 descriptor
The code in fuzz_hsdescv3.c fuzzes the unencrypted layer of the hsv3
descriptor. We need to fuzz the encrypted layer later.
2017-08-13 17:50:51 +07:00
Suphanat Chunhapanya
c860282fc0 Mock rsa_ed25519_crosscert_check
This commit just mocks the rsa_ed25519_crosscert_check to be used later
in the fuzzer.
2017-08-13 16:15:40 +07:00
David Goulet
257f50b22f Make Windows happy for time_t printf format
Our Windows compiler treats "time_t" as long long int but Linux likes it
long int so cast those to make Windows happy.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-11 15:08:45 -04:00
David Goulet
598bf986b6 test: Fix typing issues found by clang
Partially fix #23224.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-11 14:59:28 -04:00
David Goulet
9df4261407 test: Fix memory leak in test_hs_common.c
Partially fixes #23223

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-11 14:46:27 -04:00
David Goulet
60c7da71ab test: Fix hs common test for Windows
Use the PATH_SEPARATOR for a path comparaison so it works with Windows as
well.

Partially fix #23223

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-11 14:42:20 -04:00
Nick Mathewson
efbd4a33f4 Raise MIN_DL_PER_REQUEST to 32
This change should improve overhead for downloading small numbers of
descriptors and microdescriptors by improving compression
performance and lowering directory request overhead.

Closes ticket 23220.
2017-08-11 13:54:01 -04:00
Nick Mathewson
a368cadf95 Merge branch 'bug18982' 2017-08-11 12:11:42 -04:00
Nick Mathewson
c3a0cdeaab Add # to "hop N" messages to disambiguate from old messages. 2017-08-11 12:11:27 -04:00
Nick Mathewson
6247f5a5ba Merge branch 'maint-0.3.1' 2017-08-11 11:51:06 -04:00
Nick Mathewson
133e1e870b Merge remote-tracking branch 'dgoulet/bug23091_032_01' 2017-08-11 09:39:57 -04:00
Nick Mathewson
92b1dfd50e In node_get_ed25519_id, detect and warn on inconsistent IDs.
This shouldn't actually be possible, but it's worth checking for.
2017-08-09 15:00:32 -04:00
Nick Mathewson
fed3a08d8c Support the ed25519 map in nodelist_assert_ok() 2017-08-09 14:00:30 -04:00
Nick Mathewson
fc212458a6 Set formerly-unused fields of a stack-allocated routerinfo 2017-08-09 13:49:34 -04:00
Nick Mathewson
3cddd6570c Add a hashtable mapping to nodes from ed25519 ids 2017-08-09 13:45:03 -04:00
Nick Mathewson
b4963da987 Treat a bad tor_spawn_background() as a BUG().
The contract is that, if may_spawn_background_process() is 0, you're
not even allowed to try to spawn a process.
2017-08-09 10:58:07 -04:00
Nick Mathewson
5fa8d05bfa Block managed proxies at a higher point 2017-08-09 10:58:07 -04:00
Nick Mathewson
801aa5d03b Block the port-forwarding helper at a higher point 2017-08-09 10:58:07 -04:00
Nick Mathewson
eb43401bfb Add a 'NoExec' option that causes tor_spawn_background() to fail
Core of an implementation for 22976.
2017-08-09 10:45:48 -04:00
Nick Mathewson
94352368db Remove the #if 0ed code that was supposed to let the sandbox allow exec 2017-08-09 10:36:45 -04:00
Nick Mathewson
418f3d6298 Make sure we always wind up checking i2d_*'s output.
The biggest offender here was sometimes not checking the output of
crypto_pk_get_digest.

Fixes bug 19418.  Reported by Guido Vranken.
2017-08-09 09:24:16 -04:00
Nick Mathewson
6f7d548bc4 Make write_escaped_data more robust to large inputs.
The old implementation would fail with super-long inputs. We never
gave it any, but still, it's nicer to dtrt here.

Reported by Guido Vranken. Fixes bug 19281.
2017-08-09 09:02:12 -04:00
Nick Mathewson
d2713b4ddc fix another 32-bit warning 2017-08-09 08:32:39 -04:00
Nick Mathewson
a3685ba0c5 Fix a warning on 32-bit clang 2017-08-09 08:31:44 -04:00
George Kadianakis
21e5146529 prop224: Fix coverity warnings from #20657 merge.
- Fix various ssize_t/size_t confusions in the tests.

- Fix a weird memset argument:
  "bad_memset: Argument -16 in memset loses precision in
  memset(&desc_two->blinded_kp.pubkey.pubkey, -16, 32UL)."

- Fix check_after_deref instance in check_state_line_for_service_rev_counter():
  "check_after_deref: Null-checking items suggests that it may be null,
  but it has already been dereferenced on all paths leading to the
  check."
2017-08-09 13:49:12 +03:00
Nick Mathewson
8e84968ffb Re-run trunnel. 2017-08-08 20:34:39 -04:00
Nick Mathewson
34e4122025 Merge branch 'ticket20657_nickm_bugfixes_squashed' 2017-08-08 20:31:57 -04:00
Nick Mathewson
2f17743d6f Put comment in the trunnel file, so it wont go away. 2017-08-08 20:31:47 -04:00
George Kadianakis
686891d67e prop224: Add XXX about opaqueness of link_specifier_t. 2017-08-08 20:29:35 -04:00
George Kadianakis
5c4f4acedb prop224: Function to inc/decrement num rendezvous stream
Add a common function for both legacy and prop224 hidden service to increment
and decrement the rendezvous stream counter on an origin circuit.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08 20:29:35 -04:00
David Goulet
400ba2f636 prop224: Always note down the use of internal circuit
Also, this removes all the callsite of this rephist in the hs subsystem

Fixes #23097

Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08 20:29:35 -04:00
George Kadianakis
0a0bbfe96f Add note about handling INTRODUCE2 cells.
Also fix a check-spaces instance.
2017-08-08 20:29:35 -04:00
George Kadianakis
ff249ee4a6 Start caching disaster SRV values.
Also add some unittests.
2017-08-08 20:29:35 -04:00
George Kadianakis
101ce6da01 Fix the build_hs_index() function.
Also add a unittest for hs_get_responsible_hsdirs() which was used to
find and fix the bug.
2017-08-08 20:29:35 -04:00