Commit Graph

1106 Commits

Author SHA1 Message Date
David Goulet bc50f082bd Merge branch 'tor-github/pr/1944' 2020-06-24 10:48:14 -04:00
David Goulet 3adabaf3e9 tls: Make buf_read_from_tls() read at most bytes
The buf_read_from_tls() function was designed to read up to a certain number
of bytes a TLS socket using read_to_chunk_tls() which boils down to SSL_read()
(with OpenSSL, common case).

However, at the end of the loop, the returned number of bytes from
read_to_chunk_tls() was treated like the syscall read() for which if less
bytes than the total asked are returned, it signals EOF.

But, with SSL_read(), it returns up to a TLS record which can be less than
what was asked. The assumption that it was EOF was wrong which made the while
loop exiting before it was able to consume all requested bytes (at_most
parameter).

The general use case that Tor sees is that it will ask the network layer to
give it at most 16KB (that is roughly 32 cells) but because of KIST scheduler,
the highest possible TLS record we currently observe is 4096 bytes (4KB or 8
cells). Thus the loop would at best always return 8 cells even though much
more could be on the TLS socket. See ticket #40006 for more details.

Fixes #40006

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24 10:47:53 -04:00
Nick Mathewson 65328fd4e7 Merge branch 'maint-0.4.4' 2020-06-23 12:29:47 -04:00
Nick Mathewson 318753f502 Merge branch 'ticket34382' into maint-0.4.4 2020-06-23 12:29:39 -04:00
Nick Mathewson 354f085e5f Merge remote-tracking branch 'tor-github/pr/1888/head' 2020-06-09 15:44:58 -04:00
Nick Mathewson 1fb9be5396 Merge remote-tracking branch 'tor-github/pr/1902/head' 2020-06-05 10:08:27 -04:00
rl1987 3e4814edeb Fix some checks of tor_inet_ntoa() return value
Also, fix a format string.
2020-06-05 11:49:24 +03:00
Nick Mathewson 1e98d56617 sandbox: Do not require M_SYSCALL.
M_SYSCALL is used to report information about a sandbox violation,
but when we don't have a definition for it, it still makes sense to
compile.

Closes ticket 34382.
2020-06-04 12:08:02 -04:00
Nick Mathewson 2b98df3c74 Merge remote-tracking branch 'tor-github/pr/1910/head' 2020-06-04 10:33:36 -04:00
c 8b568b50a5 config: Styling fix + use fmt_addr()
Conform to C99 as suggested by nickm on #32888 and use fmt_addr() rather
than tor_addr_to_str_dup()
2020-06-04 13:15:27 +00:00
c 1934e399af config: Add interface address debug logging
Add logging for "the local network interface addresses" as requested by
ticket #32888.
2020-06-03 14:42:53 +00:00
Nick Mathewson b4ccafd175 remove a period from a doxygen heading
The other headings don't have periods.
2020-06-02 11:47:20 -04:00
rl1987 7a004fce8d Tweak format string 2020-05-21 14:26:08 +03:00
rl1987 d8e24684b6 Check for possible failures of tor_inet_ntop/tor_inet_ntoa in fmt_addr32 and tor_dup_ip 2020-05-21 13:41:15 +03:00
David Goulet ca13249dcc Merge branch 'tor-github/pr/1886' 2020-05-19 15:18:17 -04:00
Nick Mathewson 9b55a62e73 Merge branch 'maint-0.4.3' 2020-05-19 09:39:12 -04:00
Nick Mathewson 68fe8826dd Doxygen: fix unbalanced groups.
Closes ticket 34255.
2020-05-19 09:18:39 -04:00
Nick Mathewson 1557e73c82 Merge branch 'bug34130_035' 2020-05-12 12:58:19 -04:00
Daniel Pinto 2913dbd6d9 Fix crash when tor is compiled with NSS and seccomp sandbox is enabled
Adds seccomp rules for socket and getpeername used by NSS
2020-05-12 12:56:06 -04:00
Daniel Pinto cce16a939c Improve logging of included config files 2020-05-08 01:10:59 +01:00
teor 504b16fb75 relay: Rewrite inform_testing_reachability()
Rewrite inform_testing_reachability() to use separate buffers for IPv4
ORPort, IPv6 ORPort, and IPv4 DirPort. And use consistent APIs to fill
those buffers.

Part of 33222.
2020-05-07 20:59:10 +10:00
Neel Chauhan 0daa1da3ba Define and use TOR_ADDRPORT_BUF_LEN 2020-05-07 20:38:25 +10:00
Nick Mathewson 4a2347d290 Merge branch 'maint-0.4.3'
Amazingly, this time we had no merge conflicts with "falls through" comments.
2020-05-06 16:55:41 -04:00
Nick Mathewson c116728209 Use __attribute__((fallthrough)) rather than magic GCC comments.
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-06 16:55:25 -04:00
Nick Mathewson cc397449fc Use __attribute__((fallthrough)) rather than magic GCC comments.
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-06 16:51:11 -04:00
Nick Mathewson 82effefb69 Merge branch 'maint-0.4.3' 2020-05-06 16:47:03 -04:00
Nick Mathewson fecc5fd38d Merge branch 'maint-0.4.2' into maint-0.4.3 2020-05-06 16:47:03 -04:00
Nick Mathewson d04b708b4b Merge branch 'maint-0.4.1' into maint-0.4.2 2020-05-06 16:47:03 -04:00
Nick Mathewson 3e42464f5a Merge branch 'bug34078_prelim_035' into bug34078_prelim_041 2020-05-06 15:18:36 -04:00
Nick Mathewson 3d3641152b Remove an incorrect "Fall through" comment. 2020-05-06 15:08:02 -04:00
Nick Mathewson 8798c0a94a address.c: add a single (harmless) missing break; 2020-05-06 15:08:02 -04:00
Nick Mathewson 6c3c94357c Add a fallthrough macro.
This macro defers to __attribute__((fallthrough)) on GCC (and
clang).  Previously we had been using GCC's magic /* fallthrough */
comments, but clang very sensibly doesn't accept those.

Since not all compiler recognize it, we only define it when our
configure script detects that it works.

Part of a fix for 34078.
2020-05-06 15:08:02 -04:00
teor 2a0e48385d relay: Launch IPv4 and IPv6 ORPort self-test circuits
When launching relay ORPort reachability self-tests, launch tests to the
IPv4 and IPv6 ORPorts (if available).

Part of 33222.
2020-04-30 23:27:13 +10:00
teor 6dc9930d3a Merge branch 'pr1870_squashed' 2020-04-30 22:22:09 +10:00
Neel Chauhan 7bf257b129 Define and use TOR_ADDRPORT_BUF_LEN 2020-04-30 22:21:48 +10:00
Nick Mathewson 49800cf539 Merge remote-tracking branch 'tor-github/pr/1864/head' 2020-04-29 19:16:40 -04:00
teor cd7e2fc210 net: Make all address bytes functions take uint8_t *
Part of 33817.
2020-04-30 06:54:42 +10:00
teor f62b051e87 Rename tor_addr_get_ipv6_bytes to tor_addr_copy_ipv6_bytes
This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        tor_addr_get_ipv6_bytes tor_addr_copy_ipv6_bytes
2020-04-30 05:54:39 +10:00
teor 6c458d2d6e log/util_bug: Make IF_BUG_ONCE() support ALL_BUGS_ARE_FATAL
... and DISABLE_ASSERTS_IN_UNIT_TESTS.

Make all of tor's assertion macros support the ALL_BUGS_ARE_FATAL and
DISABLE_ASSERTS_IN_UNIT_TESTS debugging modes.

Implements these modes for IF_BUG_ONCE(). (It used to log a non-fatal
warning, regardless of the debugging mode.)

Fixes bug 33917; bugfix on 0.2.9.1-alpha.
2020-04-29 22:43:09 +10:00
teor 16f3f6a1af relay/circuitbuild: Re-use IPv6 connections for circuits
Search for existing connections using the remote IPv4 and IPv6
addresses.

Part of 33817.
2020-04-29 22:43:09 +10:00
teor a72e017e7f net: Add fmt_addrport_ap() and fmt_addr_family()
Add fmt_addrport_ap(), a macro that takes a tor_addr_port_t, and uses
it to call fmt_addrport().

Add fmt_addr_family(), a function that returns a string constant
describing the address family.

Utility functions for 33817.
2020-04-29 22:43:09 +10:00
teor e9d04b05c6 net: Remove an extra space in address.h 2020-04-29 22:43:09 +10:00
teor bd6ab90ad4 core/or: Support IPv6 EXTEND2 cells
Allow clients and relays to send dual-stack and IPv6-only EXTEND2 cells.
Parse dual-stack and IPv6-only EXTEND2 cells on relays.

Relays do not make connections or extend circuits via IPv6: that's the
next step.

Closes ticket 33901.
2020-04-29 22:43:09 +10:00
Nick Mathewson cbe9e56590 Merge remote-tracking branch 'tor-github/pr/1868/head' 2020-04-29 08:32:44 -04:00
teor 3253c357ee Run "make autostyle" 2020-04-29 22:08:33 +10:00
teor 6eec43161a rand: Clarify the crypto_rand_uint() range 2020-04-29 21:50:37 +10:00
Nick Mathewson 4dd4dbf046 Merge remote-tracking branch 'onionk/inbufoverflow1-043' into ticket33131_044 2020-04-24 08:15:53 -04:00
Nick Mathewson 25729910af Merge branch 'maint-0.4.3' 2020-04-09 08:33:36 -04:00
Nick Mathewson c4da0a5094 Add fsync to list of syscalls permitted by sandbox
(Our fix for 33087 requires this, I believe.)
2020-04-09 08:33:19 -04:00
Nick Mathewson c2aea6134a Merge remote-tracking branch 'tor-github/pr/1723/head' into maint-0.4.3 2020-04-09 08:30:14 -04:00