From 5cad9fb4776979285596c4b26230683de6bb84c6 Mon Sep 17 00:00:00 2001 From: Neel Chauhan Date: Thu, 11 Apr 2019 20:21:51 -0400 Subject: [PATCH 01/10] Become an exit relay if IPv6Exit is 1 --- src/core/or/policies.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/core/or/policies.c b/src/core/or/policies.c index a6d66d36de..ab320dd2ca 100644 --- a/src/core/or/policies.c +++ b/src/core/or/policies.c @@ -1182,9 +1182,9 @@ validate_addr_policies(const or_options_t *options, char **msg) static int warned_about_nonexit = 0; - if (public_server_mode(options) && - !warned_about_nonexit && options->ExitPolicy == NULL && - options->ExitRelay == -1 && options->ReducedExitPolicy == 0) { + if (public_server_mode(options) && !warned_about_nonexit && + options->ExitPolicy == NULL && options->ExitRelay == -1 && + options->ReducedExitPolicy == 0 && options->IPv6Exit == 0) { warned_about_nonexit = 1; log_notice(LD_CONFIG, "By default, Tor does not run as an exit relay. " "If you want to be an exit relay, " @@ -2142,8 +2142,9 @@ policies_parse_exit_policy_from_options(const or_options_t *or_options, /* Short-circuit for non-exit relays, or for relays where we didn't specify * ExitPolicy or ReducedExitPolicy and ExitRelay is auto. */ - if (or_options->ExitRelay == 0 || (or_options->ExitPolicy == NULL && - or_options->ExitRelay == -1 && or_options->ReducedExitPolicy == 0)) { + if (or_options->ExitRelay == 0 || + (or_options->ExitPolicy == NULL && or_options->ExitRelay == -1 && + or_options->ReducedExitPolicy == 0 && or_options->IPv6Exit == 0)) { append_exit_policy_string(result, "reject *4:*"); append_exit_policy_string(result, "reject *6:*"); return 0; From 03464a916571a5f682b42513c47568e317f38b18 Mon Sep 17 00:00:00 2001 From: Neel Chauhan Date: Thu, 11 Apr 2019 20:22:27 -0400 Subject: [PATCH 02/10] Update torrc.sample.in to IPv6Exit 1 being an exit by default --- src/config/torrc.sample.in | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/config/torrc.sample.in b/src/config/torrc.sample.in index c2ae707e93..95167d03fd 100644 --- a/src/config/torrc.sample.in +++ b/src/config/torrc.sample.in @@ -174,13 +174,11 @@ ## Uncomment this if you want your relay to be an exit, with the default ## exit policy (or whatever exit policy you set below). -## (If ReducedExitPolicy or ExitPolicy are set, relays are exits. +## (If ReducedExitPolicy, ExitPolicy, or IPv6Exit are set, relays are exits. ## If neither exit policy option is set, relays are non-exits.) #ExitRelay 1 ## Uncomment this if you want your relay to allow IPv6 exit traffic. -## You must also set ExitRelay, ReducedExitPolicy, or ExitPolicy to make your -## relay into an exit. ## (Relays do not allow any exit traffic by default.) #IPv6Exit 1 From e7288111101b2a0fe74ec87a314d6d33c1a2920a Mon Sep 17 00:00:00 2001 From: Neel Chauhan Date: Thu, 11 Apr 2019 20:22:46 -0400 Subject: [PATCH 03/10] Add changes file for Bug #29613 --- changes/bug29613 | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changes/bug29613 diff --git a/changes/bug29613 b/changes/bug29613 new file mode 100644 index 0000000000..e966973255 --- /dev/null +++ b/changes/bug29613 @@ -0,0 +1,5 @@ + o Minor bugfixes (relay): + - If we are are a relay and have IPv6Exit to 1 while ExitRelay is + auto, we act as if ExitRelay is 1. Previously, we ignored IPv6Exit + if ExitRelay was 0 or auto. Fixes bug 29613; bugfix on 0.3.5.1-alpha. + Patch by Neel Chauhan. From d4f980d29ac4f9c850fff967018f88115bf3cc2d Mon Sep 17 00:00:00 2001 From: Neel Chauhan Date: Sun, 14 Apr 2019 14:27:05 -0400 Subject: [PATCH 04/10] Update exceptions.txt for Bug #29613 --- scripts/maint/practracker/exceptions.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/maint/practracker/exceptions.txt b/scripts/maint/practracker/exceptions.txt index 7d03bf27d6..8601c58033 100644 --- a/scripts/maint/practracker/exceptions.txt +++ b/scripts/maint/practracker/exceptions.txt @@ -117,7 +117,7 @@ problem include-count /src/core/or/connection_or.c 51 problem function-size /src/core/or/connection_or.c:connection_or_group_set_badness_() 105 problem function-size /src/core/or/connection_or.c:connection_or_client_learned_peer_id() 144 problem function-size /src/core/or/connection_or.c:connection_or_compute_authenticate_cell_body() 235 -problem file-size /src/core/or/policies.c 3163 +problem file-size /src/core/or/policies.c 3164 problem function-size /src/core/or/policies.c:policy_summarize() 107 problem function-size /src/core/or/protover.c:protover_all_supported() 116 problem file-size /src/core/or/relay.c 3173 From e7c22e6e4882332cc0e3377f0d3494f3bf47ad96 Mon Sep 17 00:00:00 2001 From: Neel Chauhan Date: Tue, 16 Apr 2019 08:19:44 -0400 Subject: [PATCH 05/10] Add policy_using_default_exit_options() to determine if we're using the default exit options --- src/core/or/policies.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/or/policies.c b/src/core/or/policies.c index ab320dd2ca..41d221b19d 100644 --- a/src/core/or/policies.c +++ b/src/core/or/policies.c @@ -1164,6 +1164,15 @@ authdir_policy_badexit_address(uint32_t addr, uint16_t port) #define REJECT(arg) \ STMT_BEGIN *msg = tor_strdup(arg); goto err; STMT_END +/** Check or_options to determine whether or not we are using the + * default options for exit policy. Return true if so, false otherwise. */ +static int +policy_using_default_exit_options(const or_options_t *or_options) +{ + return (or_options->ExitPolicy == NULL && or_options->ExitRelay == -1 && + or_options->ReducedExitPolicy == 0 && or_options->IPv6Exit == 0); +} + /** Config helper: If there's any problem with the policy configuration * options in options, return -1 and set msg to a newly * allocated description of the error. Else return 0. */ @@ -1183,8 +1192,7 @@ validate_addr_policies(const or_options_t *options, char **msg) static int warned_about_nonexit = 0; if (public_server_mode(options) && !warned_about_nonexit && - options->ExitPolicy == NULL && options->ExitRelay == -1 && - options->ReducedExitPolicy == 0 && options->IPv6Exit == 0) { + policy_using_default_exit_options(options)) { warned_about_nonexit = 1; log_notice(LD_CONFIG, "By default, Tor does not run as an exit relay. " "If you want to be an exit relay, " @@ -2143,8 +2151,7 @@ policies_parse_exit_policy_from_options(const or_options_t *or_options, /* Short-circuit for non-exit relays, or for relays where we didn't specify * ExitPolicy or ReducedExitPolicy and ExitRelay is auto. */ if (or_options->ExitRelay == 0 || - (or_options->ExitPolicy == NULL && or_options->ExitRelay == -1 && - or_options->ReducedExitPolicy == 0 && or_options->IPv6Exit == 0)) { + policy_using_default_exit_options(or_options)) { append_exit_policy_string(result, "reject *4:*"); append_exit_policy_string(result, "reject *6:*"); return 0; From 06c76e79aab3ff9cbed04bd3f670099e57d851b6 Mon Sep 17 00:00:00 2001 From: Neel Chauhan Date: Tue, 16 Apr 2019 08:20:48 -0400 Subject: [PATCH 06/10] Clarify torrc comment for IPv6Exit --- src/config/torrc.sample.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/torrc.sample.in b/src/config/torrc.sample.in index 95167d03fd..9d514e6bda 100644 --- a/src/config/torrc.sample.in +++ b/src/config/torrc.sample.in @@ -175,7 +175,7 @@ ## Uncomment this if you want your relay to be an exit, with the default ## exit policy (or whatever exit policy you set below). ## (If ReducedExitPolicy, ExitPolicy, or IPv6Exit are set, relays are exits. -## If neither exit policy option is set, relays are non-exits.) +## If none of these options are set, relays are non-exits.) #ExitRelay 1 ## Uncomment this if you want your relay to allow IPv6 exit traffic. From ada673291402d1e015e79cadca67c0bdd31b4019 Mon Sep 17 00:00:00 2001 From: Neel Chauhan Date: Tue, 16 Apr 2019 08:22:17 -0400 Subject: [PATCH 07/10] Clarify comment about IPv6Exit in policies_parse_exit_policy_from_options() --- src/core/or/policies.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/or/policies.c b/src/core/or/policies.c index 41d221b19d..f59894ea8f 100644 --- a/src/core/or/policies.c +++ b/src/core/or/policies.c @@ -2149,7 +2149,7 @@ policies_parse_exit_policy_from_options(const or_options_t *or_options, int rv = 0; /* Short-circuit for non-exit relays, or for relays where we didn't specify - * ExitPolicy or ReducedExitPolicy and ExitRelay is auto. */ + * ExitPolicy or ReducedExitPolicy or IPv6Exit and ExitRelay is auto. */ if (or_options->ExitRelay == 0 || policy_using_default_exit_options(or_options)) { append_exit_policy_string(result, "reject *4:*"); From f643020e64a3730f262f810ed68ed7910da2a9f4 Mon Sep 17 00:00:00 2001 From: Neel Chauhan Date: Tue, 16 Apr 2019 09:16:52 -0400 Subject: [PATCH 08/10] Update practracker exceptions.txt for policies.c --- scripts/maint/practracker/exceptions.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/maint/practracker/exceptions.txt b/scripts/maint/practracker/exceptions.txt index 8601c58033..c99cdc0160 100644 --- a/scripts/maint/practracker/exceptions.txt +++ b/scripts/maint/practracker/exceptions.txt @@ -117,7 +117,7 @@ problem include-count /src/core/or/connection_or.c 51 problem function-size /src/core/or/connection_or.c:connection_or_group_set_badness_() 105 problem function-size /src/core/or/connection_or.c:connection_or_client_learned_peer_id() 144 problem function-size /src/core/or/connection_or.c:connection_or_compute_authenticate_cell_body() 235 -problem file-size /src/core/or/policies.c 3164 +problem file-size /src/core/or/policies.c 3171 problem function-size /src/core/or/policies.c:policy_summarize() 107 problem function-size /src/core/or/protover.c:protover_all_supported() 116 problem file-size /src/core/or/relay.c 3173 From cfada969a9d450ba12548ab4ff112a2fe3642b95 Mon Sep 17 00:00:00 2001 From: Neel Chauhan Date: Wed, 17 Apr 2019 07:26:55 -0400 Subject: [PATCH 09/10] Update tor.1 man page for IPv6Exit --- doc/tor.1.txt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/tor.1.txt b/doc/tor.1.txt index f992172405..23b7e7b607 100644 --- a/doc/tor.1.txt +++ b/doc/tor.1.txt @@ -1935,13 +1935,13 @@ is non-zero): exit according to the ExitPolicy option, the ReducedExitPolicy option, or the default ExitPolicy (if no other exit policy option is specified). + + - If ExitRelay is set to 0, no traffic is allowed to - exit, and the ExitPolicy and ReducedExitPolicy options are ignored. + + If ExitRelay is set to 0, no traffic is allowed to exit, and the + ExitPolicy, ReducedExitPolicy, and IPv6Exit options are ignored. + + - If ExitRelay is set to "auto", then Tor checks the ExitPolicy and - ReducedExitPolicy options. If either is set, Tor behaves as if ExitRelay - were set to 1. If neither exit policy option is set, Tor behaves as if - ExitRelay were set to 0. (Default: auto) + If ExitRelay is set to "auto", then Tor checks the ExitPolicy, + ReducedExitPolicy, and IPv6Exit options. If either is set, Tor behaves + as if ExitRelay were set to 1. If neither exit policy option is set, Tor + behaves as if ExitRelay were set to 0. (Default: auto) [[ExitPolicy]] **ExitPolicy** __policy__,__policy__,__...__:: Set an exit policy for this server. Each policy is of the form @@ -2136,8 +2136,9 @@ is non-zero): (Default: 0) [[IPv6Exit]] **IPv6Exit** **0**|**1**:: - If set, and we are an exit node, allow clients to use us for IPv6 - traffic. (Default: 0) + If set, and we are an exit node, allow clients to use us for IPv6 traffic. + When this option is set and ExitRelay is auto, we act as if ExitRelay + is 1. (Default: 0) [[MaxOnionQueueDelay]] **MaxOnionQueueDelay** __NUM__ [**msec**|**second**]:: If we have more onionskins queued for processing than we can process in From caa55a6d37426073dc264d2adec7201ec65aec19 Mon Sep 17 00:00:00 2001 From: Neel Chauhan Date: Wed, 17 Apr 2019 21:41:31 -0400 Subject: [PATCH 10/10] Grammar fixes for IPv6Exit in tor.1.txt --- doc/tor.1.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/tor.1.txt b/doc/tor.1.txt index 23b7e7b607..cbbc3515bb 100644 --- a/doc/tor.1.txt +++ b/doc/tor.1.txt @@ -1939,9 +1939,10 @@ is non-zero): ExitPolicy, ReducedExitPolicy, and IPv6Exit options are ignored. + + If ExitRelay is set to "auto", then Tor checks the ExitPolicy, - ReducedExitPolicy, and IPv6Exit options. If either is set, Tor behaves - as if ExitRelay were set to 1. If neither exit policy option is set, Tor - behaves as if ExitRelay were set to 0. (Default: auto) + ReducedExitPolicy, and IPv6Exit options. If at least one of these options + is set, Tor behaves as if ExitRelay were set to 1. If none of these exit + policy options are set, Tor behaves as if ExitRelay were set to 0. + (Default: auto) [[ExitPolicy]] **ExitPolicy** __policy__,__policy__,__...__:: Set an exit policy for this server. Each policy is of the form