aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/channeltls.c
AgeCommit message (Collapse)Author
2023-10-12fix bridge transport statisticstrinity-1686a
2023-08-09Extend DoS protection to partially-open channelsMicah Elizabeth Scott
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.
2021-10-04Turn orconn watermarks into consensus parameters.Mike Perry
Tuning these may reduce memory usage and latency.
2021-03-12Run "make autostyle" in advance of new series.Nick Mathewson
2021-03-12Update copyrights to 2021, using "make update-copyright"Nick Mathewson
2021-01-19Merge branch 'maint-0.4.4' into maint-0.4.5Nick Mathewson
2021-01-19Merge branch 'maint-0.4.3' into maint-0.4.4Nick Mathewson
2021-01-19Merge branch 'maint-0.3.5' into maint-0.4.3Nick Mathewson
2021-01-13Better fix for #40241 (--enable-all-bugs-are-fatal and fallthrough)Nick Mathewson
This one should work on GCC _and_ on Clang. The previous version made Clang happier by not having unreachable "fallthrough" statements, but made GCC sad because GCC didn't think that the unconditional failures were really unconditional, and therefore _wanted_ a FALLTHROUGH. This patch adds a FALLTHROUGH_UNLESS_ALL_BUGS_ARE_FATAL macro that seems to please both GCC and Clang in this case: ordinarily it is a FALLTHROUGH, but when ALL_BUGS_ARE_FATAL is defined, it's an abort(). Fixes bug 40241 again. Bugfix on earlier fix for 40241, which was merged into maint-0.3.5 and forward, and released in 0.4.5.3-rc.
2021-01-11Merge branch 'maint-0.4.3' into maint-0.4.4Nick Mathewson
2021-01-11Merge branch 'maint-0.4.4' into maint-0.4.5Nick Mathewson
2021-01-11Merge branch 'maint-0.3.5' into maint-0.4.3Nick Mathewson
2021-01-11Fix warnings in current debian-hardened CI.Nick Mathewson
We're getting "fallback annotation annotation in unreachable code" warnings when we build with ALL_BUGS_ARE_FATAL. This patch fixes that. Fixes bug 40241. Bugfix on 0.3.5.4-alpha.
2020-11-12Use connection_or_change_state() in v3 handshaking state changeNeel Chauhan
2020-10-19Explain why we use "mark_as_used_for_origin_circuit" where we doNick Mathewson
Also, explain why it's relevant for bootstrapping. This is a comments-only patch.
2020-10-07Merge branch 'maint-0.3.5' into maint-0.4.3Nick Mathewson
2020-09-18Add flag for whether an OR conn "counts" for bootstrap trackingNick Mathewson
We set this flag if we've launched the connection in order to satisfy an origin circuit, or when we decide the connection _would_ satisfy an origin circuit. These are the only or_connections we want to consider for bootstrapping: other or_connections are opened because of client EXTEND requests, and they may succeed or fail because of the clients' confusion or misconfiguration. Closes #25061.
2020-08-25Merge branch 'mr/113'George Kadianakis
2020-08-25Validate address more carefully when checking self-reachabilityNick Mathewson
Previously, we would treat *any* incoming circuit on a non-local channel as meaning that our ORPort was reachable. With this patch, we make sure that the address that the peer _says_ we have is the same as the one we're trying to advertise right now. Closes 20165. Bugfix on 4f5192b2803c706 in 0.1.0.1-rc, when reachability self-tests were first introduced.
2020-08-12Merge branch 'maint-0.4.4'George Kadianakis
2020-08-03Merge branch 'ticket40081_035' into ticket40081_044Nick Mathewson
Resolves conflicts: src/core/or/channel.c src/test/test_channel.c
2020-08-03Remove channel_is_canonical_is_reliable()Nick Mathewson
This function once served to let circuits continue to be built over version-1 link connections. But such connections are long-obsolete, and it's time to remove this check. Closes #40081.
2020-07-17Document some channel_matches_extend_info issues that confused me.Nick Mathewson
2020-07-17or_connection_t: replace real_addr with canonical_orport.Nick Mathewson
Instead of replacing connection_t.{addr,port} with a canonical orport, and tracking the truth in real_addr, we now leave connection_t.addr alone, and put the canonical address in canonical_orport. Closes #40042 Closes #33898
2020-07-16Use CONST_TO_* macros in more places.Nick Mathewson
This is an automated commit made with a python script. After running the automated script, I had to hand-revert the cases where it made the conversion functions call themselves. Additionally, I had to edit a variable declaration in control_bootstrap.c so that the result of a const cast could be put in a const field.
2020-07-16Define const variants for our channel_tls_t* casts.Nick Mathewson
2020-07-16Collapse channel_get_*_remote_addr() into a single function.Nick Mathewson
Since we can list the real address and the canonical one in a human-readable format we don't need to pick.
2020-07-16Refactor channel description internals.Nick Mathewson
Now that we've clarified that these functions only need to describe the peer in a human-readable way, we can have them delegate to connection_describe_peer().
2020-07-16Remove "ADDR_ONLY" mode from channel_get_*_remote_descr.Nick Mathewson
This mode was only used in one place, and it caused a dangerous mingling of functionality. The method is supposed to _describe_ the peer's address, not give its actual address. We already had a function to get the actual address.
2020-07-16Minor refactoring on channel_get_remote_addr_if_possible()Nick Mathewson
* We no longer call this an optional method * We document that it returns the real address, not a canonical one. * We have it try harder if the real address hasn't been set yet.
2020-07-16Use connection_describe() for log messages.Nick Mathewson
2020-07-14addr: Use tor_addr_t instead of uint32_t for IPv4David Goulet
This changes a LOT of code but in the end, behavior is the same. Unfortunately, many functions had to be changed to accomodate but in majority of cases, to become simpler. Functions are also removed specifically those that were there to convert an IPv4 as a host format to a tor_addr_t. Those are not needed anymore. The IPv4 address field has been standardized to "ipv4_addr", the ORPort to "ipv4_orport" (currently IPv6 uses ipv6_orport) and DirPort to "ipv4_dirport". This is related to Sponsor 55 work that adds IPv6 support for relays and this work is needed in order to have a common interface between IPv4 and IPv6. Closes #40043. Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-10Make channel_get_addr_if_possible() take a const channel_t.Nick Mathewson
(There is no reason that looking up the address of a channel should ever change it.)
2020-07-08addr: Validate identity key when getting a suggestionDavid Goulet
We do look at the address but with this we also look if the identity digest of the relay suggesting us an address is a trusted source. Related to #40022 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-07channel: Consider NETINFO other address as oursDavid Goulet
Attempt to learn our address from the NETINFO cell. At this commit, the address won't be used in the descriptor if selected. Next commit will make it happen. Related to #40022 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-07channel: Continue refactor NETINFO process functionDavid Goulet
In the spirit of reducing technical debt. Move code that marks a channel as a client into its own function and document it properly. No behavior change, only code movement. Related to #40022 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-07channel: Refactor NETINFO process functionDavid Goulet
In order to process a NETINFO cell, the OR connection needs to go through a series of validation else we don't process the cell. Move those into its own function in and improve documentation. This is an attempt at reducing technical debt of the rather large and complicated channel_tls_process_netinfo_cell() function. Related to #40022 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-02Add a function for comparing the orport on an extendinfo.Nick Mathewson
2020-06-24addr: Rename resolved_addr_is_local()David Goulet
Better function name. Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24addr: Refactor is_local_addr() to support IPv6David Goulet
Series of changes: 1. Rename function to reflect the namespace of the file. 2. Use the new last resolved cache instead of the unused last_resolved_addr_v4 (which is also removed in this commit). 3. Make the entire code base use the new resolved_addr_is_local() function. You will notice that this function uses /24 to differentiate subnets where the rest of tor uses /16 (including documentation of EnforceDistinctSubnets). Ticket #40009 has been opened for that. But that the moment, the function keeps looking at /24. Part of #33233 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-05-07Merge remote-tracking branch 'tor-github/pr/1880/head'Nick Mathewson
2020-05-06Merge branch 'maint-0.4.3'Nick Mathewson
Amazingly, this time we had no merge conflicts with "falls through" comments.
2020-05-06Use __attribute__((fallthrough)) rather than magic GCC comments.Nick Mathewson
GCC added an implicit-fallthrough warning a while back, where it would complain if you had a nontrivial "case:" block that didn't end with break, return, or something like that. Clang recently added the same thing. GCC, however, would let you annotate a fall-through as intended by any of various magic "/* fall through */" comments. Clang, however, only seems to like "__attribute__((fallthrough))". Fortunately, GCC accepts that too. A previous commit in this branch defined a FALLTHROUGH macro to do the right thing if GNUC is defined; here we replace all of our "fall through" comments with uses of that macro. This is an automated commit, made with the following perl one-liner: #!/usr/bin/perl -i -p s#/\* *falls? ?thr.*?\*/#FALLTHROUGH;#i; (In order to avoid conflicts, I'm applying this script separately to each maint branch. This is the 0.4.3 version.)
2020-05-06Use __attribute__((fallthrough)) rather than magic GCC comments.Nick Mathewson
GCC added an implicit-fallthrough warning a while back, where it would complain if you had a nontrivial "case:" block that didn't end with break, return, or something like that. Clang recently added the same thing. GCC, however, would let you annotate a fall-through as intended by any of various magic "/* fall through */" comments. Clang, however, only seems to like "__attribute__((fallthrough))". Fortunately, GCC accepts that too. A previous commit in this branch defined a FALLTHROUGH macro to do the right thing if GNUC is defined; here we replace all of our "fall through" comments with uses of that macro. This is an automated commit, made with the following perl one-liner: #!/usr/bin/perl -i -p s#/\* *falls? ?thr.*?\*/#FALLTHROUGH;#i;
2020-05-05config: New file resolve_addr.{c|h}David Goulet
Move a series of function from config.c into that new file which is related to address resolving. Part of #33789 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-04-30Merge branch 'pr1870_squashed'teor
2020-04-30Define and use TOR_ADDRPORT_BUF_LENNeel Chauhan
2020-04-30net: Make all address bytes functions take uint8_t *teor
Part of 33817.
2020-04-28channeltls: Clarify a relay impersonation defenceteor
Clarify the comments in channel_tls_matches_target_method(), and make it clear that the attack is a covert attack.
2020-04-21Merge branch 'maint-0.4.3'Nick Mathewson