[tor-commits] [webwml/master] Revert "Drop broken TorBrowser link"
commit 6f83149ceea0fa621529d403c1d1390c2fc257a5 Author: Roger Dingledine Date: Tue Feb 7 21:18:08 2017 -0500 Revert "Drop broken TorBrowser link" This reverts commit dfca2029f35e01297434d5ba288f89cc312948f2. --- getinvolved/en/volunteer.wml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getinvolved/en/volunteer.wml b/getinvolved/en/volunteer.wml index dd41a85..e276865 100644 --- a/getinvolved/en/volunteer.wml +++ b/getinvolved/en/volunteer.wml @@ -399,7 +399,7 @@ meetings around the world. -Tor Browser (Tor Browser (https://gitweb.torproject.org/tor-browser.git";>code, https://trac.torproject.org/projects/tor/query?status=accepted&status=assigned&status=needs_review&status=new&status=reopened&component=Applications%2FTor+Browser&component=Applications%2FTorbutton&component=Applications%2FTor+Launcher&component=Applications%2FTor+bundles%2Finstallation&col=id&col=summary&col=status&col=owner&col=type&col=priority&col=milestone&order=priority";>bug tracker, https://www.torproject.org/projects/torbrowser/design/";>design doc) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [webwml/master] fix a very subtle html breakage
commit 5bb684790a110fdaad4731cd03382c1d024f91e4 Author: Roger Dingledine Date: Tue Feb 7 21:16:51 2017 -0500 fix a very subtle html breakage introduced in commit d886c1470 this breakage was also the reason why commit dfca2029 happened (which i'll revert next). --- getinvolved/en/volunteer.wml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getinvolved/en/volunteer.wml b/getinvolved/en/volunteer.wml index 75ef8c2..dd41a85 100644 --- a/getinvolved/en/volunteer.wml +++ b/getinvolved/en/volunteer.wml @@ -374,7 +374,7 @@ meetings around the world. None arma, nickm - * Project is still in an alpha state. ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.8] Merge branch 'maint-0.2.4' into maint-0.2.5
commit c056d19323e499a0003ba9de0db2bdee9c301872 Merge: b9ef21c 85a2487 Author: Nick Mathewson Date: Tue Feb 7 10:37:31 2017 -0500 Merge branch 'maint-0.2.4' into maint-0.2.5 changes/bug16248 | 8 src/or/main.c| 55 +++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --cc src/or/main.c index 031f758,9e78ea0..31fbdcd --- a/src/or/main.c +++ b/src/or/main.c @@@ -524,9 -506,48 +524,48 @@@ connection_is_reading(connection_t *con (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } + /** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { + /* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ + bad = ev != NULL; + } else { + /* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ + bad = ev == NULL; + } + + if (bad) { + log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); + //log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); + return -1; + } + return 0; + } + /** Tell the main loop to stop notifying conn of any read events. */ -void -connection_stop_reading(connection_t *conn) +MOCK_IMPL(void, +connection_stop_reading,(connection_t *conn)) { tor_assert(conn); ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.8] Merge branch 'maint-0.2.7' into maint-0.2.8
commit eca4a89319c566c0e320c7f713aed0f7e34330eb Merge: a9f936d 4bce207 Author: Nick Mathewson Date: Tue Feb 7 10:39:13 2017 -0500 Merge branch 'maint-0.2.7' into maint-0.2.8 ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.8] Merge branch 'maint-0.2.6' into maint-0.2.7
commit 4bce2072acaca38d40086c943d8f332ed2c2cf50 Merge: 86d5a6f f2a3041 Author: Nick Mathewson Date: Tue Feb 7 10:39:03 2017 -0500 Merge branch 'maint-0.2.6' into maint-0.2.7 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.9] Merge branch 'maint-0.2.7' into maint-0.2.8
commit eca4a89319c566c0e320c7f713aed0f7e34330eb Merge: a9f936d 4bce207 Author: Nick Mathewson Date: Tue Feb 7 10:39:13 2017 -0500 Merge branch 'maint-0.2.7' into maint-0.2.8 ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.9] Add comments to connection_check_event().
commit cfeb1db2fb881db85a11d80e70a1a14c62b46950 Author: Nick Mathewson Date: Mon Mar 14 12:53:21 2016 -0400 Add comments to connection_check_event(). --- src/or/main.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index 1200b55..89e5a51 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,14 +506,24 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +/** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +/* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ bad = ev != NULL; } else { +/* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ bad = ev == NULL; } ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.9] Merge branch 'maint-0.2.8' into maint-0.2.9
commit 23f1caf2af300c55a33b7cb3f1671b0b9c2f73f2 Merge: 65cda78 eca4a89 Author: Nick Mathewson Date: Tue Feb 7 10:39:23 2017 -0500 Merge branch 'maint-0.2.8' into maint-0.2.9 ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.9] Merge branch 'maint-0.2.9' into release-0.2.9
commit 788a05a50fd0b93be891dc6226ed8f95fa7e96b1 Merge: 4f1fcaa 23f1caf Author: Nick Mathewson Date: Tue Feb 7 10:39:58 2017 -0500 Merge branch 'maint-0.2.9' into release-0.2.9 ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.4] Change behavior on missing/present event to warn instead of asserting.
commit 457d38a6e9212de3a5cab24fc59829c689f88560 Author: Nick Mathewson Date: Fri Mar 11 10:50:36 2016 -0500 Change behavior on missing/present event to warn instead of asserting. Add a changes file. --- changes/bug16248 | 8 src/or/main.c| 49 + 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/changes/bug16248 b/changes/bug16248 new file mode 100644 index 000..399b709 --- /dev/null +++ b/changes/bug16248 @@ -0,0 +1,8 @@ + o Major bugfixes (dns proxy mode, crash): +- Avoid crashing when running as a DNS proxy. Closes bug 16248; bugfix on + 0.2.0.1-alpha. Patch from 'cypherpunks'. + + o Minor features (bug-resistance): +- Make Tor survive errors involving connections without a corresponding + event object. Previously we'd fail with an assertion; now we produce a + log message. Related to bug 16248. diff --git a/src/or/main.c b/src/or/main.c index a2b032d..1200b55 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,6 +506,35 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +static int +connection_check_event(connection_t *conn, struct event *ev) +{ + int bad; + + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +bad = ev != NULL; + } else { +bad = ev == NULL; + } + + if (bad) { +log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); +log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +return -1; + } + return 0; +} + /** Tell the main loop to stop notifying conn of any read events. */ void connection_stop_reading(connection_t *conn) @@ -517,14 +546,10 @@ connection_stop_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 0; connection_stop_reading_from_linked_conn(conn); @@ -548,14 +573,10 @@ connection_start_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 1; if (connection_should_read_from_linked_conn(conn)) @@ -594,7 +615,9 @@ connection_stop_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 0; @@ -620,7 +643,9 @@ connection_start_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 1; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.7] Add comments to connection_check_event().
commit cfeb1db2fb881db85a11d80e70a1a14c62b46950 Author: Nick Mathewson Date: Mon Mar 14 12:53:21 2016 -0400 Add comments to connection_check_event(). --- src/or/main.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index 1200b55..89e5a51 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,14 +506,24 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +/** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +/* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ bad = ev != NULL; } else { +/* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ bad = ev == NULL; } ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.8] Add comments to connection_check_event().
commit cfeb1db2fb881db85a11d80e70a1a14c62b46950 Author: Nick Mathewson Date: Mon Mar 14 12:53:21 2016 -0400 Add comments to connection_check_event(). --- src/or/main.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index 1200b55..89e5a51 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,14 +506,24 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +/** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +/* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ bad = ev != NULL; } else { +/* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ bad = ev == NULL; } ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.7] Merge branch 'maint-0.2.7' into release-0.2.7
commit 26ea56a6c2deaadd3031e9efde928a28120c1647 Merge: 6cfbaed 4bce207 Author: Nick Mathewson Date: Tue Feb 7 10:39:54 2017 -0500 Merge branch 'maint-0.2.7' into release-0.2.7 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.8] Merge branch 'maint-0.2.8' into release-0.2.8
commit 1243c1000cdcfd4edf414ff8a14e34ea15aa2cef Merge: 5f84409 eca4a89 Author: Nick Mathewson Date: Tue Feb 7 10:39:56 2017 -0500 Merge branch 'maint-0.2.8' into release-0.2.8 ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.7] Merge branch 'maint-0.2.4' into maint-0.2.5
commit c056d19323e499a0003ba9de0db2bdee9c301872 Merge: b9ef21c 85a2487 Author: Nick Mathewson Date: Tue Feb 7 10:37:31 2017 -0500 Merge branch 'maint-0.2.4' into maint-0.2.5 changes/bug16248 | 8 src/or/main.c| 55 +++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --cc src/or/main.c index 031f758,9e78ea0..31fbdcd --- a/src/or/main.c +++ b/src/or/main.c @@@ -524,9 -506,48 +524,48 @@@ connection_is_reading(connection_t *con (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } + /** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { + /* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ + bad = ev != NULL; + } else { + /* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ + bad = ev == NULL; + } + + if (bad) { + log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); + //log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); + return -1; + } + return 0; + } + /** Tell the main loop to stop notifying conn of any read events. */ -void -connection_stop_reading(connection_t *conn) +MOCK_IMPL(void, +connection_stop_reading,(connection_t *conn)) { tor_assert(conn); ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.9] Change behavior on missing/present event to warn instead of asserting.
commit 457d38a6e9212de3a5cab24fc59829c689f88560 Author: Nick Mathewson Date: Fri Mar 11 10:50:36 2016 -0500 Change behavior on missing/present event to warn instead of asserting. Add a changes file. --- changes/bug16248 | 8 src/or/main.c| 49 + 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/changes/bug16248 b/changes/bug16248 new file mode 100644 index 000..399b709 --- /dev/null +++ b/changes/bug16248 @@ -0,0 +1,8 @@ + o Major bugfixes (dns proxy mode, crash): +- Avoid crashing when running as a DNS proxy. Closes bug 16248; bugfix on + 0.2.0.1-alpha. Patch from 'cypherpunks'. + + o Minor features (bug-resistance): +- Make Tor survive errors involving connections without a corresponding + event object. Previously we'd fail with an assertion; now we produce a + log message. Related to bug 16248. diff --git a/src/or/main.c b/src/or/main.c index a2b032d..1200b55 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,6 +506,35 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +static int +connection_check_event(connection_t *conn, struct event *ev) +{ + int bad; + + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +bad = ev != NULL; + } else { +bad = ev == NULL; + } + + if (bad) { +log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); +log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +return -1; + } + return 0; +} + /** Tell the main loop to stop notifying conn of any read events. */ void connection_stop_reading(connection_t *conn) @@ -517,14 +546,10 @@ connection_stop_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 0; connection_stop_reading_from_linked_conn(conn); @@ -548,14 +573,10 @@ connection_start_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 1; if (connection_should_read_from_linked_conn(conn)) @@ -594,7 +615,9 @@ connection_stop_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 0; @@ -620,7 +643,9 @@ connection_start_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 1; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.8] Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix
commit 85a2487f9704cfeff0255c5f660d977ec9c30cff Author: Nick Mathewson Date: Tue Feb 7 09:49:23 2017 -0500 Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix --- src/or/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/or/main.c b/src/or/main.c index 89e5a51..9e78ea0 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -539,7 +539,7 @@ connection_check_event(connection_t *conn, struct event *ev) conn->marked_for_close_file ? conn->marked_for_close_file : "-", conn->marked_for_close ); -log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +//log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); return -1; } return 0; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.8] Change behavior on missing/present event to warn instead of asserting.
commit 457d38a6e9212de3a5cab24fc59829c689f88560 Author: Nick Mathewson Date: Fri Mar 11 10:50:36 2016 -0500 Change behavior on missing/present event to warn instead of asserting. Add a changes file. --- changes/bug16248 | 8 src/or/main.c| 49 + 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/changes/bug16248 b/changes/bug16248 new file mode 100644 index 000..399b709 --- /dev/null +++ b/changes/bug16248 @@ -0,0 +1,8 @@ + o Major bugfixes (dns proxy mode, crash): +- Avoid crashing when running as a DNS proxy. Closes bug 16248; bugfix on + 0.2.0.1-alpha. Patch from 'cypherpunks'. + + o Minor features (bug-resistance): +- Make Tor survive errors involving connections without a corresponding + event object. Previously we'd fail with an assertion; now we produce a + log message. Related to bug 16248. diff --git a/src/or/main.c b/src/or/main.c index a2b032d..1200b55 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,6 +506,35 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +static int +connection_check_event(connection_t *conn, struct event *ev) +{ + int bad; + + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +bad = ev != NULL; + } else { +bad = ev == NULL; + } + + if (bad) { +log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); +log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +return -1; + } + return 0; +} + /** Tell the main loop to stop notifying conn of any read events. */ void connection_stop_reading(connection_t *conn) @@ -517,14 +546,10 @@ connection_stop_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 0; connection_stop_reading_from_linked_conn(conn); @@ -548,14 +573,10 @@ connection_start_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 1; if (connection_should_read_from_linked_conn(conn)) @@ -594,7 +615,9 @@ connection_stop_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 0; @@ -620,7 +643,9 @@ connection_start_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 1; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.8] If we start/stop reading on a dnsserv connection, don't assert.
commit 650c03127a877eb0de1cfad8afa5cb3d8474a956 Author: Nick Mathewson Date: Fri Mar 11 10:33:19 2016 -0500 If we start/stop reading on a dnsserv connection, don't assert. Fixes bug 16248. Patch from cypherpunks. Bugfix on 0.2.0.1-alpha. --- src/or/main.c | 12 1 file changed, 12 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index bd23141..a2b032d 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -517,6 +517,12 @@ connection_stop_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { @@ -542,6 +548,12 @@ connection_start_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.7] Merge branch 'maint-0.2.5' into maint-0.2.6
commit f2a30413a35bb360323a98fb124fbc629245978d Merge: 5446cb8 2ce4330 Author: Nick Mathewson Date: Tue Feb 7 10:37:53 2017 -0500 Merge branch 'maint-0.2.5' into maint-0.2.6 changes/bug16248 | 8 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- src/or/main.c| 55 +++ 4 files changed, 66 insertions(+), 7 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.6] Merge branch 'maint-0.2.6' into release-0.2.6
commit 0c18b2dc769413dd6a2293fd598cd405dc8a6e82 Merge: f9be4b9 f2a3041 Author: Nick Mathewson Date: Tue Feb 7 10:39:52 2017 -0500 Merge branch 'maint-0.2.6' into release-0.2.6 changes/bug16248 | 8 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- src/or/main.c| 55 +++ 4 files changed, 66 insertions(+), 7 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.8] Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5
commit 2ce43302490ac916be4188bff70f70958aee1790 Merge: c056d19 0ca3f49 Author: Nick Mathewson Date: Tue Feb 7 10:37:43 2017 -0500 Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.6] Add comments to connection_check_event().
commit cfeb1db2fb881db85a11d80e70a1a14c62b46950 Author: Nick Mathewson Date: Mon Mar 14 12:53:21 2016 -0400 Add comments to connection_check_event(). --- src/or/main.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index 1200b55..89e5a51 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,14 +506,24 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +/** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +/* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ bad = ev != NULL; } else { +/* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ bad = ev == NULL; } ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.4] Change behavior on missing/present event to warn instead of asserting.
commit 457d38a6e9212de3a5cab24fc59829c689f88560 Author: Nick Mathewson Date: Fri Mar 11 10:50:36 2016 -0500 Change behavior on missing/present event to warn instead of asserting. Add a changes file. --- changes/bug16248 | 8 src/or/main.c| 49 + 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/changes/bug16248 b/changes/bug16248 new file mode 100644 index 000..399b709 --- /dev/null +++ b/changes/bug16248 @@ -0,0 +1,8 @@ + o Major bugfixes (dns proxy mode, crash): +- Avoid crashing when running as a DNS proxy. Closes bug 16248; bugfix on + 0.2.0.1-alpha. Patch from 'cypherpunks'. + + o Minor features (bug-resistance): +- Make Tor survive errors involving connections without a corresponding + event object. Previously we'd fail with an assertion; now we produce a + log message. Related to bug 16248. diff --git a/src/or/main.c b/src/or/main.c index a2b032d..1200b55 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,6 +506,35 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +static int +connection_check_event(connection_t *conn, struct event *ev) +{ + int bad; + + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +bad = ev != NULL; + } else { +bad = ev == NULL; + } + + if (bad) { +log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); +log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +return -1; + } + return 0; +} + /** Tell the main loop to stop notifying conn of any read events. */ void connection_stop_reading(connection_t *conn) @@ -517,14 +546,10 @@ connection_stop_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 0; connection_stop_reading_from_linked_conn(conn); @@ -548,14 +573,10 @@ connection_start_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 1; if (connection_should_read_from_linked_conn(conn)) @@ -594,7 +615,9 @@ connection_stop_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 0; @@ -620,7 +643,9 @@ connection_start_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 1; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.6] Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5
commit 2ce43302490ac916be4188bff70f70958aee1790 Merge: c056d19 0ca3f49 Author: Nick Mathewson Date: Tue Feb 7 10:37:43 2017 -0500 Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.5] Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5
commit 2ce43302490ac916be4188bff70f70958aee1790 Merge: c056d19 0ca3f49 Author: Nick Mathewson Date: Tue Feb 7 10:37:43 2017 -0500 Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.9] Merge branch 'maint-0.2.4' into maint-0.2.5
commit c056d19323e499a0003ba9de0db2bdee9c301872 Merge: b9ef21c 85a2487 Author: Nick Mathewson Date: Tue Feb 7 10:37:31 2017 -0500 Merge branch 'maint-0.2.4' into maint-0.2.5 changes/bug16248 | 8 src/or/main.c| 55 +++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --cc src/or/main.c index 031f758,9e78ea0..31fbdcd --- a/src/or/main.c +++ b/src/or/main.c @@@ -524,9 -506,48 +524,48 @@@ connection_is_reading(connection_t *con (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } + /** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { + /* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ + bad = ev != NULL; + } else { + /* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ + bad = ev == NULL; + } + + if (bad) { + log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); + //log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); + return -1; + } + return 0; + } + /** Tell the main loop to stop notifying conn of any read events. */ -void -connection_stop_reading(connection_t *conn) +MOCK_IMPL(void, +connection_stop_reading,(connection_t *conn)) { tor_assert(conn); ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.9] Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5
commit 2ce43302490ac916be4188bff70f70958aee1790 Merge: c056d19 0ca3f49 Author: Nick Mathewson Date: Tue Feb 7 10:37:43 2017 -0500 Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.9] If we start/stop reading on a dnsserv connection, don't assert.
commit 650c03127a877eb0de1cfad8afa5cb3d8474a956 Author: Nick Mathewson Date: Fri Mar 11 10:33:19 2016 -0500 If we start/stop reading on a dnsserv connection, don't assert. Fixes bug 16248. Patch from cypherpunks. Bugfix on 0.2.0.1-alpha. --- src/or/main.c | 12 1 file changed, 12 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index bd23141..a2b032d 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -517,6 +517,12 @@ connection_stop_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { @@ -542,6 +548,12 @@ connection_start_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.9] Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix
commit 85a2487f9704cfeff0255c5f660d977ec9c30cff Author: Nick Mathewson Date: Tue Feb 7 09:49:23 2017 -0500 Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix --- src/or/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/or/main.c b/src/or/main.c index 89e5a51..9e78ea0 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -539,7 +539,7 @@ connection_check_event(connection_t *conn, struct event *ev) conn->marked_for_close_file ? conn->marked_for_close_file : "-", conn->marked_for_close ); -log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +//log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); return -1; } return 0; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.9] Merge branch 'maint-0.2.6' into maint-0.2.7
commit 4bce2072acaca38d40086c943d8f332ed2c2cf50 Merge: 86d5a6f f2a3041 Author: Nick Mathewson Date: Tue Feb 7 10:39:03 2017 -0500 Merge branch 'maint-0.2.6' into maint-0.2.7 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.9] Merge branch 'maint-0.2.5' into maint-0.2.6
commit f2a30413a35bb360323a98fb124fbc629245978d Merge: 5446cb8 2ce4330 Author: Nick Mathewson Date: Tue Feb 7 10:37:53 2017 -0500 Merge branch 'maint-0.2.5' into maint-0.2.6 changes/bug16248 | 8 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- src/or/main.c| 55 +++ 4 files changed, 66 insertions(+), 7 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.7] Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix
commit 85a2487f9704cfeff0255c5f660d977ec9c30cff Author: Nick Mathewson Date: Tue Feb 7 09:49:23 2017 -0500 Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix --- src/or/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/or/main.c b/src/or/main.c index 89e5a51..9e78ea0 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -539,7 +539,7 @@ connection_check_event(connection_t *conn, struct event *ev) conn->marked_for_close_file ? conn->marked_for_close_file : "-", conn->marked_for_close ); -log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +//log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); return -1; } return 0; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.7] Merge branch 'maint-0.2.6' into maint-0.2.7
commit 4bce2072acaca38d40086c943d8f332ed2c2cf50 Merge: 86d5a6f f2a3041 Author: Nick Mathewson Date: Tue Feb 7 10:39:03 2017 -0500 Merge branch 'maint-0.2.6' into maint-0.2.7 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.8] Merge branch 'maint-0.2.5' into maint-0.2.6
commit f2a30413a35bb360323a98fb124fbc629245978d Merge: 5446cb8 2ce4330 Author: Nick Mathewson Date: Tue Feb 7 10:37:53 2017 -0500 Merge branch 'maint-0.2.5' into maint-0.2.6 changes/bug16248 | 8 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- src/or/main.c| 55 +++ 4 files changed, 66 insertions(+), 7 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.7] Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5
commit 2ce43302490ac916be4188bff70f70958aee1790 Merge: c056d19 0ca3f49 Author: Nick Mathewson Date: Tue Feb 7 10:37:43 2017 -0500 Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.7] If we start/stop reading on a dnsserv connection, don't assert.
commit 650c03127a877eb0de1cfad8afa5cb3d8474a956 Author: Nick Mathewson Date: Fri Mar 11 10:33:19 2016 -0500 If we start/stop reading on a dnsserv connection, don't assert. Fixes bug 16248. Patch from cypherpunks. Bugfix on 0.2.0.1-alpha. --- src/or/main.c | 12 1 file changed, 12 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index bd23141..a2b032d 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -517,6 +517,12 @@ connection_stop_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { @@ -542,6 +548,12 @@ connection_start_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.7] Fix dnsserv.c assertion when no supported questions are requested.
commit 0ca3f495c6fad074606ab75942b64738ed61926a Author: Scott Dial Date: Wed May 4 14:45:09 2016 -0400 Fix dnsserv.c assertion when no supported questions are requested. The problem is that "q" is always set on the first iteration even if the question is not a supported question. This set of "q" is not necessary, and will be handled after exiting the loop if there if a supported q->type was found. [Changes file by nickm] lease enter the commit message for your changes. Lines starting --- changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/changes/bug18710 b/changes/bug18710 new file mode 100644 index 000..2693955 --- /dev/null +++ b/changes/bug18710 @@ -0,0 +1,6 @@ + o Major bugfixes (DNS proxy): +- Stop a crash that could occur when a client running with DNSPort + received a query with multiple address types, where the first + address type was not supported. Found and fixed by Scott Dial. + Fixes bug 18710; bugfix on 0.2.5.4-alpha. + diff --git a/src/or/dnsserv.c b/src/or/dnsserv.c index ecd45be..9b0368d 100644 --- a/src/or/dnsserv.c +++ b/src/or/dnsserv.c @@ -87,8 +87,6 @@ evdns_server_callback(struct evdns_server_request *req, void *data_) for (i = 0; i < req->nquestions; ++i) { if (req->questions[i]->dns_question_class != EVDNS_CLASS_INET) continue; -if (! q) - q = req->questions[i]; switch (req->questions[i]->type) { case EVDNS_TYPE_A: case EVDNS_TYPE_: @@ -96,7 +94,7 @@ evdns_server_callback(struct evdns_server_request *req, void *data_) /* We always pick the first one of these questions, if there is one. */ if (! supported_q) - supported_q = q; + supported_q = req->questions[i]; break; default: break; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.7] Change behavior on missing/present event to warn instead of asserting.
commit 457d38a6e9212de3a5cab24fc59829c689f88560 Author: Nick Mathewson Date: Fri Mar 11 10:50:36 2016 -0500 Change behavior on missing/present event to warn instead of asserting. Add a changes file. --- changes/bug16248 | 8 src/or/main.c| 49 + 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/changes/bug16248 b/changes/bug16248 new file mode 100644 index 000..399b709 --- /dev/null +++ b/changes/bug16248 @@ -0,0 +1,8 @@ + o Major bugfixes (dns proxy mode, crash): +- Avoid crashing when running as a DNS proxy. Closes bug 16248; bugfix on + 0.2.0.1-alpha. Patch from 'cypherpunks'. + + o Minor features (bug-resistance): +- Make Tor survive errors involving connections without a corresponding + event object. Previously we'd fail with an assertion; now we produce a + log message. Related to bug 16248. diff --git a/src/or/main.c b/src/or/main.c index a2b032d..1200b55 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,6 +506,35 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +static int +connection_check_event(connection_t *conn, struct event *ev) +{ + int bad; + + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +bad = ev != NULL; + } else { +bad = ev == NULL; + } + + if (bad) { +log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); +log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +return -1; + } + return 0; +} + /** Tell the main loop to stop notifying conn of any read events. */ void connection_stop_reading(connection_t *conn) @@ -517,14 +546,10 @@ connection_stop_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 0; connection_stop_reading_from_linked_conn(conn); @@ -548,14 +573,10 @@ connection_start_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 1; if (connection_should_read_from_linked_conn(conn)) @@ -594,7 +615,9 @@ connection_stop_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 0; @@ -620,7 +643,9 @@ connection_start_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 1; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.6] Merge branch 'maint-0.2.4' into maint-0.2.5
commit c056d19323e499a0003ba9de0db2bdee9c301872 Merge: b9ef21c 85a2487 Author: Nick Mathewson Date: Tue Feb 7 10:37:31 2017 -0500 Merge branch 'maint-0.2.4' into maint-0.2.5 changes/bug16248 | 8 src/or/main.c| 55 +++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --cc src/or/main.c index 031f758,9e78ea0..31fbdcd --- a/src/or/main.c +++ b/src/or/main.c @@@ -524,9 -506,48 +524,48 @@@ connection_is_reading(connection_t *con (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } + /** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { + /* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ + bad = ev != NULL; + } else { + /* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ + bad = ev == NULL; + } + + if (bad) { + log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); + //log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); + return -1; + } + return 0; + } + /** Tell the main loop to stop notifying conn of any read events. */ -void -connection_stop_reading(connection_t *conn) +MOCK_IMPL(void, +connection_stop_reading,(connection_t *conn)) { tor_assert(conn); ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.6] Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5
commit 2ce43302490ac916be4188bff70f70958aee1790 Merge: c056d19 0ca3f49 Author: Nick Mathewson Date: Tue Feb 7 10:37:43 2017 -0500 Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.6] Fix dnsserv.c assertion when no supported questions are requested.
commit 0ca3f495c6fad074606ab75942b64738ed61926a Author: Scott Dial Date: Wed May 4 14:45:09 2016 -0400 Fix dnsserv.c assertion when no supported questions are requested. The problem is that "q" is always set on the first iteration even if the question is not a supported question. This set of "q" is not necessary, and will be handled after exiting the loop if there if a supported q->type was found. [Changes file by nickm] lease enter the commit message for your changes. Lines starting --- changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/changes/bug18710 b/changes/bug18710 new file mode 100644 index 000..2693955 --- /dev/null +++ b/changes/bug18710 @@ -0,0 +1,6 @@ + o Major bugfixes (DNS proxy): +- Stop a crash that could occur when a client running with DNSPort + received a query with multiple address types, where the first + address type was not supported. Found and fixed by Scott Dial. + Fixes bug 18710; bugfix on 0.2.5.4-alpha. + diff --git a/src/or/dnsserv.c b/src/or/dnsserv.c index ecd45be..9b0368d 100644 --- a/src/or/dnsserv.c +++ b/src/or/dnsserv.c @@ -87,8 +87,6 @@ evdns_server_callback(struct evdns_server_request *req, void *data_) for (i = 0; i < req->nquestions; ++i) { if (req->questions[i]->dns_question_class != EVDNS_CLASS_INET) continue; -if (! q) - q = req->questions[i]; switch (req->questions[i]->type) { case EVDNS_TYPE_A: case EVDNS_TYPE_: @@ -96,7 +94,7 @@ evdns_server_callback(struct evdns_server_request *req, void *data_) /* We always pick the first one of these questions, if there is one. */ if (! supported_q) - supported_q = q; + supported_q = req->questions[i]; break; default: break; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.4] If we start/stop reading on a dnsserv connection, don't assert.
commit 650c03127a877eb0de1cfad8afa5cb3d8474a956 Author: Nick Mathewson Date: Fri Mar 11 10:33:19 2016 -0500 If we start/stop reading on a dnsserv connection, don't assert. Fixes bug 16248. Patch from cypherpunks. Bugfix on 0.2.0.1-alpha. --- src/or/main.c | 12 1 file changed, 12 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index bd23141..a2b032d 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -517,6 +517,12 @@ connection_stop_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { @@ -542,6 +548,12 @@ connection_start_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.4] Add comments to connection_check_event().
commit cfeb1db2fb881db85a11d80e70a1a14c62b46950 Author: Nick Mathewson Date: Mon Mar 14 12:53:21 2016 -0400 Add comments to connection_check_event(). --- src/or/main.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index 1200b55..89e5a51 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,14 +506,24 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +/** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +/* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ bad = ev != NULL; } else { +/* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ bad = ev == NULL; } ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.4] Merge branch 'maint-0.2.4' into release-0.2.4
commit 8bcc14f62e620c4a15084449c335680096511001 Merge: 9c5ff56 85a2487 Author: Nick Mathewson Date: Tue Feb 7 10:39:48 2017 -0500 Merge branch 'maint-0.2.4' into release-0.2.4 changes/bug16248 | 8 src/or/main.c| 55 +++ 2 files changed, 59 insertions(+), 4 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.5] Add comments to connection_check_event().
commit cfeb1db2fb881db85a11d80e70a1a14c62b46950 Author: Nick Mathewson Date: Mon Mar 14 12:53:21 2016 -0400 Add comments to connection_check_event(). --- src/or/main.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index 1200b55..89e5a51 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,14 +506,24 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +/** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +/* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ bad = ev != NULL; } else { +/* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ bad = ev == NULL; } ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.5] Fix dnsserv.c assertion when no supported questions are requested.
commit 0ca3f495c6fad074606ab75942b64738ed61926a Author: Scott Dial Date: Wed May 4 14:45:09 2016 -0400 Fix dnsserv.c assertion when no supported questions are requested. The problem is that "q" is always set on the first iteration even if the question is not a supported question. This set of "q" is not necessary, and will be handled after exiting the loop if there if a supported q->type was found. [Changes file by nickm] lease enter the commit message for your changes. Lines starting --- changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/changes/bug18710 b/changes/bug18710 new file mode 100644 index 000..2693955 --- /dev/null +++ b/changes/bug18710 @@ -0,0 +1,6 @@ + o Major bugfixes (DNS proxy): +- Stop a crash that could occur when a client running with DNSPort + received a query with multiple address types, where the first + address type was not supported. Found and fixed by Scott Dial. + Fixes bug 18710; bugfix on 0.2.5.4-alpha. + diff --git a/src/or/dnsserv.c b/src/or/dnsserv.c index ecd45be..9b0368d 100644 --- a/src/or/dnsserv.c +++ b/src/or/dnsserv.c @@ -87,8 +87,6 @@ evdns_server_callback(struct evdns_server_request *req, void *data_) for (i = 0; i < req->nquestions; ++i) { if (req->questions[i]->dns_question_class != EVDNS_CLASS_INET) continue; -if (! q) - q = req->questions[i]; switch (req->questions[i]->type) { case EVDNS_TYPE_A: case EVDNS_TYPE_: @@ -96,7 +94,7 @@ evdns_server_callback(struct evdns_server_request *req, void *data_) /* We always pick the first one of these questions, if there is one. */ if (! supported_q) - supported_q = q; + supported_q = req->questions[i]; break; default: break; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.5] Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5
commit 2ce43302490ac916be4188bff70f70958aee1790 Merge: c056d19 0ca3f49 Author: Nick Mathewson Date: Tue Feb 7 10:37:43 2017 -0500 Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.5] Change behavior on missing/present event to warn instead of asserting.
commit 457d38a6e9212de3a5cab24fc59829c689f88560 Author: Nick Mathewson Date: Fri Mar 11 10:50:36 2016 -0500 Change behavior on missing/present event to warn instead of asserting. Add a changes file. --- changes/bug16248 | 8 src/or/main.c| 49 + 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/changes/bug16248 b/changes/bug16248 new file mode 100644 index 000..399b709 --- /dev/null +++ b/changes/bug16248 @@ -0,0 +1,8 @@ + o Major bugfixes (dns proxy mode, crash): +- Avoid crashing when running as a DNS proxy. Closes bug 16248; bugfix on + 0.2.0.1-alpha. Patch from 'cypherpunks'. + + o Minor features (bug-resistance): +- Make Tor survive errors involving connections without a corresponding + event object. Previously we'd fail with an assertion; now we produce a + log message. Related to bug 16248. diff --git a/src/or/main.c b/src/or/main.c index a2b032d..1200b55 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,6 +506,35 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +static int +connection_check_event(connection_t *conn, struct event *ev) +{ + int bad; + + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +bad = ev != NULL; + } else { +bad = ev == NULL; + } + + if (bad) { +log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); +log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +return -1; + } + return 0; +} + /** Tell the main loop to stop notifying conn of any read events. */ void connection_stop_reading(connection_t *conn) @@ -517,14 +546,10 @@ connection_stop_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 0; connection_stop_reading_from_linked_conn(conn); @@ -548,14 +573,10 @@ connection_start_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 1; if (connection_should_read_from_linked_conn(conn)) @@ -594,7 +615,9 @@ connection_stop_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 0; @@ -620,7 +643,9 @@ connection_start_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 1; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.6] Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix
commit 85a2487f9704cfeff0255c5f660d977ec9c30cff Author: Nick Mathewson Date: Tue Feb 7 09:49:23 2017 -0500 Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix --- src/or/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/or/main.c b/src/or/main.c index 89e5a51..9e78ea0 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -539,7 +539,7 @@ connection_check_event(connection_t *conn, struct event *ev) conn->marked_for_close_file ? conn->marked_for_close_file : "-", conn->marked_for_close ); -log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +//log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); return -1; } return 0; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.5] Merge branch 'maint-0.2.4' into maint-0.2.5
commit c056d19323e499a0003ba9de0db2bdee9c301872 Merge: b9ef21c 85a2487 Author: Nick Mathewson Date: Tue Feb 7 10:37:31 2017 -0500 Merge branch 'maint-0.2.4' into maint-0.2.5 changes/bug16248 | 8 src/or/main.c| 55 +++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --cc src/or/main.c index 031f758,9e78ea0..31fbdcd --- a/src/or/main.c +++ b/src/or/main.c @@@ -524,9 -506,48 +524,48 @@@ connection_is_reading(connection_t *con (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } + /** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { + /* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ + bad = ev != NULL; + } else { + /* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ + bad = ev == NULL; + } + + if (bad) { + log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); + //log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); + return -1; + } + return 0; + } + /** Tell the main loop to stop notifying conn of any read events. */ -void -connection_stop_reading(connection_t *conn) +MOCK_IMPL(void, +connection_stop_reading,(connection_t *conn)) { tor_assert(conn); ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.5] Merge branch 'maint-0.2.5' into release-0.2.5
commit 2f6a66a17402029b58f7a29af7c0eae56f5ea390 Merge: 72d9e05 2ce4330 Author: Nick Mathewson Date: Tue Feb 7 10:39:50 2017 -0500 Merge branch 'maint-0.2.5' into release-0.2.5 changes/bug16248 | 8 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- src/or/main.c| 55 +++ 4 files changed, 66 insertions(+), 7 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.5] If we start/stop reading on a dnsserv connection, don't assert.
commit 650c03127a877eb0de1cfad8afa5cb3d8474a956 Author: Nick Mathewson Date: Fri Mar 11 10:33:19 2016 -0500 If we start/stop reading on a dnsserv connection, don't assert. Fixes bug 16248. Patch from cypherpunks. Bugfix on 0.2.0.1-alpha. --- src/or/main.c | 12 1 file changed, 12 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index bd23141..a2b032d 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -517,6 +517,12 @@ connection_stop_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { @@ -542,6 +548,12 @@ connection_start_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.5] Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix
commit 85a2487f9704cfeff0255c5f660d977ec9c30cff Author: Nick Mathewson Date: Tue Feb 7 09:49:23 2017 -0500 Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix --- src/or/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/or/main.c b/src/or/main.c index 89e5a51..9e78ea0 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -539,7 +539,7 @@ connection_check_event(connection_t *conn, struct event *ev) conn->marked_for_close_file ? conn->marked_for_close_file : "-", conn->marked_for_close ); -log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +//log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); return -1; } return 0; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.4] Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix
commit 85a2487f9704cfeff0255c5f660d977ec9c30cff Author: Nick Mathewson Date: Tue Feb 7 09:49:23 2017 -0500 Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix --- src/or/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/or/main.c b/src/or/main.c index 89e5a51..9e78ea0 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -539,7 +539,7 @@ connection_check_event(connection_t *conn, struct event *ev) conn->marked_for_close_file ? conn->marked_for_close_file : "-", conn->marked_for_close ); -log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +//log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); return -1; } return 0; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.6] Change behavior on missing/present event to warn instead of asserting.
commit 457d38a6e9212de3a5cab24fc59829c689f88560 Author: Nick Mathewson Date: Fri Mar 11 10:50:36 2016 -0500 Change behavior on missing/present event to warn instead of asserting. Add a changes file. --- changes/bug16248 | 8 src/or/main.c| 49 + 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/changes/bug16248 b/changes/bug16248 new file mode 100644 index 000..399b709 --- /dev/null +++ b/changes/bug16248 @@ -0,0 +1,8 @@ + o Major bugfixes (dns proxy mode, crash): +- Avoid crashing when running as a DNS proxy. Closes bug 16248; bugfix on + 0.2.0.1-alpha. Patch from 'cypherpunks'. + + o Minor features (bug-resistance): +- Make Tor survive errors involving connections without a corresponding + event object. Previously we'd fail with an assertion; now we produce a + log message. Related to bug 16248. diff --git a/src/or/main.c b/src/or/main.c index a2b032d..1200b55 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,6 +506,35 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +static int +connection_check_event(connection_t *conn, struct event *ev) +{ + int bad; + + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +bad = ev != NULL; + } else { +bad = ev == NULL; + } + + if (bad) { +log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); +log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +return -1; + } + return 0; +} + /** Tell the main loop to stop notifying conn of any read events. */ void connection_stop_reading(connection_t *conn) @@ -517,14 +546,10 @@ connection_stop_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 0; connection_stop_reading_from_linked_conn(conn); @@ -548,14 +573,10 @@ connection_start_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 1; if (connection_should_read_from_linked_conn(conn)) @@ -594,7 +615,9 @@ connection_stop_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 0; @@ -620,7 +643,9 @@ connection_start_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 1; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.6] If we start/stop reading on a dnsserv connection, don't assert.
commit 650c03127a877eb0de1cfad8afa5cb3d8474a956 Author: Nick Mathewson Date: Fri Mar 11 10:33:19 2016 -0500 If we start/stop reading on a dnsserv connection, don't assert. Fixes bug 16248. Patch from cypherpunks. Bugfix on 0.2.0.1-alpha. --- src/or/main.c | 12 1 file changed, 12 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index bd23141..a2b032d 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -517,6 +517,12 @@ connection_stop_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { @@ -542,6 +548,12 @@ connection_start_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/master] Add comments to connection_check_event().
commit cfeb1db2fb881db85a11d80e70a1a14c62b46950 Author: Nick Mathewson Date: Mon Mar 14 12:53:21 2016 -0400 Add comments to connection_check_event(). --- src/or/main.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index 1200b55..89e5a51 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,14 +506,24 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +/** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +/* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ bad = ev != NULL; } else { +/* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ bad = ev == NULL; } ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/release-0.2.6] Merge branch 'maint-0.2.5' into maint-0.2.6
commit f2a30413a35bb360323a98fb124fbc629245978d Merge: 5446cb8 2ce4330 Author: Nick Mathewson Date: Tue Feb 7 10:37:53 2017 -0500 Merge branch 'maint-0.2.5' into maint-0.2.6 changes/bug16248 | 8 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- src/or/main.c| 55 +++ 4 files changed, 66 insertions(+), 7 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/master] Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix
commit 85a2487f9704cfeff0255c5f660d977ec9c30cff Author: Nick Mathewson Date: Tue Feb 7 09:49:23 2017 -0500 Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix --- src/or/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/or/main.c b/src/or/main.c index 89e5a51..9e78ea0 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -539,7 +539,7 @@ connection_check_event(connection_t *conn, struct event *ev) conn->marked_for_close_file ? conn->marked_for_close_file : "-", conn->marked_for_close ); -log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +//log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); return -1; } return 0; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.9] Merge branch 'maint-0.2.8' into maint-0.2.9
commit 23f1caf2af300c55a33b7cb3f1671b0b9c2f73f2 Merge: 65cda78 eca4a89 Author: Nick Mathewson Date: Tue Feb 7 10:39:23 2017 -0500 Merge branch 'maint-0.2.8' into maint-0.2.9 ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/master] Merge branch 'maint-0.2.7' into maint-0.2.8
commit eca4a89319c566c0e320c7f713aed0f7e34330eb Merge: a9f936d 4bce207 Author: Nick Mathewson Date: Tue Feb 7 10:39:13 2017 -0500 Merge branch 'maint-0.2.7' into maint-0.2.8 ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/master] Merge branch 'maint-0.2.6' into maint-0.2.7
commit 4bce2072acaca38d40086c943d8f332ed2c2cf50 Merge: 86d5a6f f2a3041 Author: Nick Mathewson Date: Tue Feb 7 10:39:03 2017 -0500 Merge branch 'maint-0.2.6' into maint-0.2.7 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/master] Change behavior on missing/present event to warn instead of asserting.
commit 457d38a6e9212de3a5cab24fc59829c689f88560 Author: Nick Mathewson Date: Fri Mar 11 10:50:36 2016 -0500 Change behavior on missing/present event to warn instead of asserting. Add a changes file. --- changes/bug16248 | 8 src/or/main.c| 49 + 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/changes/bug16248 b/changes/bug16248 new file mode 100644 index 000..399b709 --- /dev/null +++ b/changes/bug16248 @@ -0,0 +1,8 @@ + o Major bugfixes (dns proxy mode, crash): +- Avoid crashing when running as a DNS proxy. Closes bug 16248; bugfix on + 0.2.0.1-alpha. Patch from 'cypherpunks'. + + o Minor features (bug-resistance): +- Make Tor survive errors involving connections without a corresponding + event object. Previously we'd fail with an assertion; now we produce a + log message. Related to bug 16248. diff --git a/src/or/main.c b/src/or/main.c index a2b032d..1200b55 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,6 +506,35 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +static int +connection_check_event(connection_t *conn, struct event *ev) +{ + int bad; + + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +bad = ev != NULL; + } else { +bad = ev == NULL; + } + + if (bad) { +log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); +log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +return -1; + } + return 0; +} + /** Tell the main loop to stop notifying conn of any read events. */ void connection_stop_reading(connection_t *conn) @@ -517,14 +546,10 @@ connection_stop_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 0; connection_stop_reading_from_linked_conn(conn); @@ -548,14 +573,10 @@ connection_start_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 1; if (connection_should_read_from_linked_conn(conn)) @@ -594,7 +615,9 @@ connection_stop_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 0; @@ -620,7 +643,9 @@ connection_start_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 1; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/master] Merge branch 'maint-0.2.9'
commit 9a9f4ffdfa965e50de05a4f1bd8c4d68cfb95f12 Merge: 274094b 23f1caf Author: Nick Mathewson Date: Tue Feb 7 10:39:36 2017 -0500 Merge branch 'maint-0.2.9' ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.9] Merge branch 'maint-0.2.6' into maint-0.2.7
commit 4bce2072acaca38d40086c943d8f332ed2c2cf50 Merge: 86d5a6f f2a3041 Author: Nick Mathewson Date: Tue Feb 7 10:39:03 2017 -0500 Merge branch 'maint-0.2.6' into maint-0.2.7 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.9] Merge branch 'maint-0.2.4' into maint-0.2.5
commit c056d19323e499a0003ba9de0db2bdee9c301872 Merge: b9ef21c 85a2487 Author: Nick Mathewson Date: Tue Feb 7 10:37:31 2017 -0500 Merge branch 'maint-0.2.4' into maint-0.2.5 changes/bug16248 | 8 src/or/main.c| 55 +++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --cc src/or/main.c index 031f758,9e78ea0..31fbdcd --- a/src/or/main.c +++ b/src/or/main.c @@@ -524,9 -506,48 +524,48 @@@ connection_is_reading(connection_t *con (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } + /** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { + /* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ + bad = ev != NULL; + } else { + /* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ + bad = ev == NULL; + } + + if (bad) { + log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); + //log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); + return -1; + } + return 0; + } + /** Tell the main loop to stop notifying conn of any read events. */ -void -connection_stop_reading(connection_t *conn) +MOCK_IMPL(void, +connection_stop_reading,(connection_t *conn)) { tor_assert(conn); ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/master] Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5
commit 2ce43302490ac916be4188bff70f70958aee1790 Merge: c056d19 0ca3f49 Author: Nick Mathewson Date: Tue Feb 7 10:37:43 2017 -0500 Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/master] Merge branch 'maint-0.2.5' into maint-0.2.6
commit f2a30413a35bb360323a98fb124fbc629245978d Merge: 5446cb8 2ce4330 Author: Nick Mathewson Date: Tue Feb 7 10:37:53 2017 -0500 Merge branch 'maint-0.2.5' into maint-0.2.6 changes/bug16248 | 8 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- src/or/main.c| 55 +++ 4 files changed, 66 insertions(+), 7 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.9] Merge branch 'maint-0.2.5' into maint-0.2.6
commit f2a30413a35bb360323a98fb124fbc629245978d Merge: 5446cb8 2ce4330 Author: Nick Mathewson Date: Tue Feb 7 10:37:53 2017 -0500 Merge branch 'maint-0.2.5' into maint-0.2.6 changes/bug16248 | 8 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- src/or/main.c| 55 +++ 4 files changed, 66 insertions(+), 7 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/master] Merge branch 'maint-0.2.4' into maint-0.2.5
commit c056d19323e499a0003ba9de0db2bdee9c301872 Merge: b9ef21c 85a2487 Author: Nick Mathewson Date: Tue Feb 7 10:37:31 2017 -0500 Merge branch 'maint-0.2.4' into maint-0.2.5 changes/bug16248 | 8 src/or/main.c| 55 +++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --cc src/or/main.c index 031f758,9e78ea0..31fbdcd --- a/src/or/main.c +++ b/src/or/main.c @@@ -524,9 -506,48 +524,48 @@@ connection_is_reading(connection_t *con (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } + /** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { + /* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ + bad = ev != NULL; + } else { + /* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ + bad = ev == NULL; + } + + if (bad) { + log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); + //log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); + return -1; + } + return 0; + } + /** Tell the main loop to stop notifying conn of any read events. */ -void -connection_stop_reading(connection_t *conn) +MOCK_IMPL(void, +connection_stop_reading,(connection_t *conn)) { tor_assert(conn); ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/master] If we start/stop reading on a dnsserv connection, don't assert.
commit 650c03127a877eb0de1cfad8afa5cb3d8474a956 Author: Nick Mathewson Date: Fri Mar 11 10:33:19 2016 -0500 If we start/stop reading on a dnsserv connection, don't assert. Fixes bug 16248. Patch from cypherpunks. Bugfix on 0.2.0.1-alpha. --- src/or/main.c | 12 1 file changed, 12 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index bd23141..a2b032d 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -517,6 +517,12 @@ connection_stop_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { @@ -542,6 +548,12 @@ connection_start_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.9] Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix
commit 85a2487f9704cfeff0255c5f660d977ec9c30cff Author: Nick Mathewson Date: Tue Feb 7 09:49:23 2017 -0500 Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix --- src/or/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/or/main.c b/src/or/main.c index 89e5a51..9e78ea0 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -539,7 +539,7 @@ connection_check_event(connection_t *conn, struct event *ev) conn->marked_for_close_file ? conn->marked_for_close_file : "-", conn->marked_for_close ); -log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +//log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); return -1; } return 0; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.9] Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5
commit 2ce43302490ac916be4188bff70f70958aee1790 Merge: c056d19 0ca3f49 Author: Nick Mathewson Date: Tue Feb 7 10:37:43 2017 -0500 Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/master] Merge branch 'maint-0.2.8' into maint-0.2.9
commit 23f1caf2af300c55a33b7cb3f1671b0b9c2f73f2 Merge: 65cda78 eca4a89 Author: Nick Mathewson Date: Tue Feb 7 10:39:23 2017 -0500 Merge branch 'maint-0.2.8' into maint-0.2.9 ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.7] Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5
commit 2ce43302490ac916be4188bff70f70958aee1790 Merge: c056d19 0ca3f49 Author: Nick Mathewson Date: Tue Feb 7 10:37:43 2017 -0500 Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.9] Merge branch 'maint-0.2.7' into maint-0.2.8
commit eca4a89319c566c0e320c7f713aed0f7e34330eb Merge: a9f936d 4bce207 Author: Nick Mathewson Date: Tue Feb 7 10:39:13 2017 -0500 Merge branch 'maint-0.2.7' into maint-0.2.8 ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.8] Add comments to connection_check_event().
commit cfeb1db2fb881db85a11d80e70a1a14c62b46950 Author: Nick Mathewson Date: Mon Mar 14 12:53:21 2016 -0400 Add comments to connection_check_event(). --- src/or/main.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index 1200b55..89e5a51 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,14 +506,24 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +/** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +/* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ bad = ev != NULL; } else { +/* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ bad = ev == NULL; } ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.7] Merge branch 'maint-0.2.6' into maint-0.2.7
commit 4bce2072acaca38d40086c943d8f332ed2c2cf50 Merge: 86d5a6f f2a3041 Author: Nick Mathewson Date: Tue Feb 7 10:39:03 2017 -0500 Merge branch 'maint-0.2.6' into maint-0.2.7 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.8] If we start/stop reading on a dnsserv connection, don't assert.
commit 650c03127a877eb0de1cfad8afa5cb3d8474a956 Author: Nick Mathewson Date: Fri Mar 11 10:33:19 2016 -0500 If we start/stop reading on a dnsserv connection, don't assert. Fixes bug 16248. Patch from cypherpunks. Bugfix on 0.2.0.1-alpha. --- src/or/main.c | 12 1 file changed, 12 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index bd23141..a2b032d 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -517,6 +517,12 @@ connection_stop_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { @@ -542,6 +548,12 @@ connection_start_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.9] Change behavior on missing/present event to warn instead of asserting.
commit 457d38a6e9212de3a5cab24fc59829c689f88560 Author: Nick Mathewson Date: Fri Mar 11 10:50:36 2016 -0500 Change behavior on missing/present event to warn instead of asserting. Add a changes file. --- changes/bug16248 | 8 src/or/main.c| 49 + 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/changes/bug16248 b/changes/bug16248 new file mode 100644 index 000..399b709 --- /dev/null +++ b/changes/bug16248 @@ -0,0 +1,8 @@ + o Major bugfixes (dns proxy mode, crash): +- Avoid crashing when running as a DNS proxy. Closes bug 16248; bugfix on + 0.2.0.1-alpha. Patch from 'cypherpunks'. + + o Minor features (bug-resistance): +- Make Tor survive errors involving connections without a corresponding + event object. Previously we'd fail with an assertion; now we produce a + log message. Related to bug 16248. diff --git a/src/or/main.c b/src/or/main.c index a2b032d..1200b55 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,6 +506,35 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +static int +connection_check_event(connection_t *conn, struct event *ev) +{ + int bad; + + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +bad = ev != NULL; + } else { +bad = ev == NULL; + } + + if (bad) { +log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); +log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +return -1; + } + return 0; +} + /** Tell the main loop to stop notifying conn of any read events. */ void connection_stop_reading(connection_t *conn) @@ -517,14 +546,10 @@ connection_stop_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 0; connection_stop_reading_from_linked_conn(conn); @@ -548,14 +573,10 @@ connection_start_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 1; if (connection_should_read_from_linked_conn(conn)) @@ -594,7 +615,9 @@ connection_stop_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 0; @@ -620,7 +643,9 @@ connection_start_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 1; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.8] Merge branch 'maint-0.2.7' into maint-0.2.8
commit eca4a89319c566c0e320c7f713aed0f7e34330eb Merge: a9f936d 4bce207 Author: Nick Mathewson Date: Tue Feb 7 10:39:13 2017 -0500 Merge branch 'maint-0.2.7' into maint-0.2.8 ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.7] Merge branch 'maint-0.2.5' into maint-0.2.6
commit f2a30413a35bb360323a98fb124fbc629245978d Merge: 5446cb8 2ce4330 Author: Nick Mathewson Date: Tue Feb 7 10:37:53 2017 -0500 Merge branch 'maint-0.2.5' into maint-0.2.6 changes/bug16248 | 8 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- src/or/main.c| 55 +++ 4 files changed, 66 insertions(+), 7 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.8] Change behavior on missing/present event to warn instead of asserting.
commit 457d38a6e9212de3a5cab24fc59829c689f88560 Author: Nick Mathewson Date: Fri Mar 11 10:50:36 2016 -0500 Change behavior on missing/present event to warn instead of asserting. Add a changes file. --- changes/bug16248 | 8 src/or/main.c| 49 + 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/changes/bug16248 b/changes/bug16248 new file mode 100644 index 000..399b709 --- /dev/null +++ b/changes/bug16248 @@ -0,0 +1,8 @@ + o Major bugfixes (dns proxy mode, crash): +- Avoid crashing when running as a DNS proxy. Closes bug 16248; bugfix on + 0.2.0.1-alpha. Patch from 'cypherpunks'. + + o Minor features (bug-resistance): +- Make Tor survive errors involving connections without a corresponding + event object. Previously we'd fail with an assertion; now we produce a + log message. Related to bug 16248. diff --git a/src/or/main.c b/src/or/main.c index a2b032d..1200b55 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,6 +506,35 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +static int +connection_check_event(connection_t *conn, struct event *ev) +{ + int bad; + + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +bad = ev != NULL; + } else { +bad = ev == NULL; + } + + if (bad) { +log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); +log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +return -1; + } + return 0; +} + /** Tell the main loop to stop notifying conn of any read events. */ void connection_stop_reading(connection_t *conn) @@ -517,14 +546,10 @@ connection_stop_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 0; connection_stop_reading_from_linked_conn(conn); @@ -548,14 +573,10 @@ connection_start_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 1; if (connection_should_read_from_linked_conn(conn)) @@ -594,7 +615,9 @@ connection_stop_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 0; @@ -620,7 +643,9 @@ connection_start_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 1; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.8] Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5
commit 2ce43302490ac916be4188bff70f70958aee1790 Merge: c056d19 0ca3f49 Author: Nick Mathewson Date: Tue Feb 7 10:37:43 2017 -0500 Merge remote-tracking branch 'public/bug18710_025' into maint-0.2.5 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.8] Merge branch 'maint-0.2.5' into maint-0.2.6
commit f2a30413a35bb360323a98fb124fbc629245978d Merge: 5446cb8 2ce4330 Author: Nick Mathewson Date: Tue Feb 7 10:37:53 2017 -0500 Merge branch 'maint-0.2.5' into maint-0.2.6 changes/bug16248 | 8 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- src/or/main.c| 55 +++ 4 files changed, 66 insertions(+), 7 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.8] Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix
commit 85a2487f9704cfeff0255c5f660d977ec9c30cff Author: Nick Mathewson Date: Tue Feb 7 09:49:23 2017 -0500 Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix --- src/or/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/or/main.c b/src/or/main.c index 89e5a51..9e78ea0 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -539,7 +539,7 @@ connection_check_event(connection_t *conn, struct event *ev) conn->marked_for_close_file ? conn->marked_for_close_file : "-", conn->marked_for_close ); -log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +//log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); return -1; } return 0; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.8] Merge branch 'maint-0.2.6' into maint-0.2.7
commit 4bce2072acaca38d40086c943d8f332ed2c2cf50 Merge: 86d5a6f f2a3041 Author: Nick Mathewson Date: Tue Feb 7 10:39:03 2017 -0500 Merge branch 'maint-0.2.6' into maint-0.2.7 changes/bug18710 | 6 ++ src/or/dnsserv.c | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.9] If we start/stop reading on a dnsserv connection, don't assert.
commit 650c03127a877eb0de1cfad8afa5cb3d8474a956 Author: Nick Mathewson Date: Fri Mar 11 10:33:19 2016 -0500 If we start/stop reading on a dnsserv connection, don't assert. Fixes bug 16248. Patch from cypherpunks. Bugfix on 0.2.0.1-alpha. --- src/or/main.c | 12 1 file changed, 12 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index bd23141..a2b032d 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -517,6 +517,12 @@ connection_stop_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { @@ -542,6 +548,12 @@ connection_start_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.7] If we start/stop reading on a dnsserv connection, don't assert.
commit 650c03127a877eb0de1cfad8afa5cb3d8474a956 Author: Nick Mathewson Date: Fri Mar 11 10:33:19 2016 -0500 If we start/stop reading on a dnsserv connection, don't assert. Fixes bug 16248. Patch from cypherpunks. Bugfix on 0.2.0.1-alpha. --- src/or/main.c | 12 1 file changed, 12 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index bd23141..a2b032d 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -517,6 +517,12 @@ connection_stop_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { @@ -542,6 +548,12 @@ connection_start_reading(connection_t *conn) return; }); + /* if dummy conn then no socket and no event, nothing to do here */ + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +tor_assert(!conn->read_event); +return; + } + tor_assert(conn->read_event); if (conn->linked) { ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.7] Merge branch 'maint-0.2.4' into maint-0.2.5
commit c056d19323e499a0003ba9de0db2bdee9c301872 Merge: b9ef21c 85a2487 Author: Nick Mathewson Date: Tue Feb 7 10:37:31 2017 -0500 Merge branch 'maint-0.2.4' into maint-0.2.5 changes/bug16248 | 8 src/or/main.c| 55 +++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --cc src/or/main.c index 031f758,9e78ea0..31fbdcd --- a/src/or/main.c +++ b/src/or/main.c @@@ -524,9 -506,48 +524,48 @@@ connection_is_reading(connection_t *con (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } + /** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { + /* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ + bad = ev != NULL; + } else { + /* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ + bad = ev == NULL; + } + + if (bad) { + log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); + //log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); + return -1; + } + return 0; + } + /** Tell the main loop to stop notifying conn of any read events. */ -void -connection_stop_reading(connection_t *conn) +MOCK_IMPL(void, +connection_stop_reading,(connection_t *conn)) { tor_assert(conn); ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.7] Add comments to connection_check_event().
commit cfeb1db2fb881db85a11d80e70a1a14c62b46950 Author: Nick Mathewson Date: Mon Mar 14 12:53:21 2016 -0400 Add comments to connection_check_event(). --- src/or/main.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index 1200b55..89e5a51 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,14 +506,24 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +/** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +/* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ bad = ev != NULL; } else { +/* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ bad = ev == NULL; } ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.7] Change behavior on missing/present event to warn instead of asserting.
commit 457d38a6e9212de3a5cab24fc59829c689f88560 Author: Nick Mathewson Date: Fri Mar 11 10:50:36 2016 -0500 Change behavior on missing/present event to warn instead of asserting. Add a changes file. --- changes/bug16248 | 8 src/or/main.c| 49 + 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/changes/bug16248 b/changes/bug16248 new file mode 100644 index 000..399b709 --- /dev/null +++ b/changes/bug16248 @@ -0,0 +1,8 @@ + o Major bugfixes (dns proxy mode, crash): +- Avoid crashing when running as a DNS proxy. Closes bug 16248; bugfix on + 0.2.0.1-alpha. Patch from 'cypherpunks'. + + o Minor features (bug-resistance): +- Make Tor survive errors involving connections without a corresponding + event object. Previously we'd fail with an assertion; now we produce a + log message. Related to bug 16248. diff --git a/src/or/main.c b/src/or/main.c index a2b032d..1200b55 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,6 +506,35 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +static int +connection_check_event(connection_t *conn, struct event *ev) +{ + int bad; + + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +bad = ev != NULL; + } else { +bad = ev == NULL; + } + + if (bad) { +log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); +log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +return -1; + } + return 0; +} + /** Tell the main loop to stop notifying conn of any read events. */ void connection_stop_reading(connection_t *conn) @@ -517,14 +546,10 @@ connection_stop_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 0; connection_stop_reading_from_linked_conn(conn); @@ -548,14 +573,10 @@ connection_start_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 1; if (connection_should_read_from_linked_conn(conn)) @@ -594,7 +615,9 @@ connection_stop_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 0; @@ -620,7 +643,9 @@ connection_start_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 1; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.9] Add comments to connection_check_event().
commit cfeb1db2fb881db85a11d80e70a1a14c62b46950 Author: Nick Mathewson Date: Mon Mar 14 12:53:21 2016 -0400 Add comments to connection_check_event(). --- src/or/main.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index 1200b55..89e5a51 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,14 +506,24 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +/** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +/* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ bad = ev != NULL; } else { +/* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ bad = ev == NULL; } ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.8] Merge branch 'maint-0.2.4' into maint-0.2.5
commit c056d19323e499a0003ba9de0db2bdee9c301872 Merge: b9ef21c 85a2487 Author: Nick Mathewson Date: Tue Feb 7 10:37:31 2017 -0500 Merge branch 'maint-0.2.4' into maint-0.2.5 changes/bug16248 | 8 src/or/main.c| 55 +++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --cc src/or/main.c index 031f758,9e78ea0..31fbdcd --- a/src/or/main.c +++ b/src/or/main.c @@@ -524,9 -506,48 +524,48 @@@ connection_is_reading(connection_t *con (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } + /** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { + /* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ + bad = ev != NULL; + } else { + /* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ + bad = ev == NULL; + } + + if (bad) { + log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); + //log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); + return -1; + } + return 0; + } + /** Tell the main loop to stop notifying conn of any read events. */ -void -connection_stop_reading(connection_t *conn) +MOCK_IMPL(void, +connection_stop_reading,(connection_t *conn)) { tor_assert(conn); ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.6] Merge branch 'maint-0.2.4' into maint-0.2.5
commit c056d19323e499a0003ba9de0db2bdee9c301872 Merge: b9ef21c 85a2487 Author: Nick Mathewson Date: Tue Feb 7 10:37:31 2017 -0500 Merge branch 'maint-0.2.4' into maint-0.2.5 changes/bug16248 | 8 src/or/main.c| 55 +++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --cc src/or/main.c index 031f758,9e78ea0..31fbdcd --- a/src/or/main.c +++ b/src/or/main.c @@@ -524,9 -506,48 +524,48 @@@ connection_is_reading(connection_t *con (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } + /** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { + /* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ + bad = ev != NULL; + } else { + /* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ + bad = ev == NULL; + } + + if (bad) { + log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); + //log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); + return -1; + } + return 0; + } + /** Tell the main loop to stop notifying conn of any read events. */ -void -connection_stop_reading(connection_t *conn) +MOCK_IMPL(void, +connection_stop_reading,(connection_t *conn)) { tor_assert(conn); ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.7] Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix
commit 85a2487f9704cfeff0255c5f660d977ec9c30cff Author: Nick Mathewson Date: Tue Feb 7 09:49:23 2017 -0500 Disable a log_backtrace (which 0.2.4 does not have) in 16248 fix --- src/or/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/or/main.c b/src/or/main.c index 89e5a51..9e78ea0 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -539,7 +539,7 @@ connection_check_event(connection_t *conn, struct event *ev) conn->marked_for_close_file ? conn->marked_for_close_file : "-", conn->marked_for_close ); -log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +//log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); return -1; } return 0; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.5] Merge branch 'maint-0.2.4' into maint-0.2.5
commit c056d19323e499a0003ba9de0db2bdee9c301872 Merge: b9ef21c 85a2487 Author: Nick Mathewson Date: Tue Feb 7 10:37:31 2017 -0500 Merge branch 'maint-0.2.4' into maint-0.2.5 changes/bug16248 | 8 src/or/main.c| 55 +++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --cc src/or/main.c index 031f758,9e78ea0..31fbdcd --- a/src/or/main.c +++ b/src/or/main.c @@@ -524,9 -506,48 +524,48 @@@ connection_is_reading(connection_t *con (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } + /** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { + /* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ + bad = ev != NULL; + } else { + /* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ + bad = ev == NULL; + } + + if (bad) { + log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); + //log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); + return -1; + } + return 0; + } + /** Tell the main loop to stop notifying conn of any read events. */ -void -connection_stop_reading(connection_t *conn) +MOCK_IMPL(void, +connection_stop_reading,(connection_t *conn)) { tor_assert(conn); ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.5] Change behavior on missing/present event to warn instead of asserting.
commit 457d38a6e9212de3a5cab24fc59829c689f88560 Author: Nick Mathewson Date: Fri Mar 11 10:50:36 2016 -0500 Change behavior on missing/present event to warn instead of asserting. Add a changes file. --- changes/bug16248 | 8 src/or/main.c| 49 + 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/changes/bug16248 b/changes/bug16248 new file mode 100644 index 000..399b709 --- /dev/null +++ b/changes/bug16248 @@ -0,0 +1,8 @@ + o Major bugfixes (dns proxy mode, crash): +- Avoid crashing when running as a DNS proxy. Closes bug 16248; bugfix on + 0.2.0.1-alpha. Patch from 'cypherpunks'. + + o Minor features (bug-resistance): +- Make Tor survive errors involving connections without a corresponding + event object. Previously we'd fail with an assertion; now we produce a + log message. Related to bug 16248. diff --git a/src/or/main.c b/src/or/main.c index a2b032d..1200b55 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,6 +506,35 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +static int +connection_check_event(connection_t *conn, struct event *ev) +{ + int bad; + + if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +bad = ev != NULL; + } else { +bad = ev == NULL; + } + + if (bad) { +log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. " + "socket=%d. linked=%d. " + "is_dns_request=%d. Marked_for_close=%s:%d", + conn, + conn_type_to_string(conn->type), + conn_state_to_string(conn->type, conn->state), + (int)conn->s, (int)conn->linked, + (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request), + conn->marked_for_close_file ? conn->marked_for_close_file : "-", + conn->marked_for_close + ); +log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached."); +return -1; + } + return 0; +} + /** Tell the main loop to stop notifying conn of any read events. */ void connection_stop_reading(connection_t *conn) @@ -517,14 +546,10 @@ connection_stop_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 0; connection_stop_reading_from_linked_conn(conn); @@ -548,14 +573,10 @@ connection_start_reading(connection_t *conn) return; }); - /* if dummy conn then no socket and no event, nothing to do here */ - if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { -tor_assert(!conn->read_event); + if (connection_check_event(conn, conn->read_event) < 0) { return; } - tor_assert(conn->read_event); - if (conn->linked) { conn->reading_from_linked_conn = 1; if (connection_should_read_from_linked_conn(conn)) @@ -594,7 +615,9 @@ connection_stop_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 0; @@ -620,7 +643,9 @@ connection_start_writing(connection_t *conn) return; }); - tor_assert(conn->write_event); + if (connection_check_event(conn, conn->write_event) < 0) { +return; + } if (conn->linked) { conn->writing_to_linked_conn = 1; ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits
[tor-commits] [tor/maint-0.2.6] Add comments to connection_check_event().
commit cfeb1db2fb881db85a11d80e70a1a14c62b46950 Author: Nick Mathewson Date: Mon Mar 14 12:53:21 2016 -0400 Add comments to connection_check_event(). --- src/or/main.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/or/main.c b/src/or/main.c index 1200b55..89e5a51 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -506,14 +506,24 @@ connection_is_reading(connection_t *conn) (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } +/** Check whether conn is correct in having (or not having) a + * read/write event (passed in evtype == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) { +/* DNS requests which we launch through the dnsserv.c module do not have + * any underlying socket or any underlying linked connection, so they + * shouldn't have any attached events either. + */ bad = ev != NULL; } else { +/* Everytyhing else should have an underlying socket, or a linked + * connection (which is also tracked with a read_event/write_event pair). + */ bad = ev == NULL; } ___ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits