[tor-commits] [tor/release-0.4.2] dir: Look if circuit is closed in connection_dir_is_anonymous()

teor at torproject.org teor at torproject.org
Fri Oct 25 00:39:18 UTC 2019


commit 09468cc58b52132af1232e2cd3925c273382bba6
Author: David Goulet <dgoulet at torproject.org>
Date:   Thu Oct 24 11:08:25 2019 -0400

    dir: Look if circuit is closed in connection_dir_is_anonymous()
    
    Before inspecting the p_chan, we must check if the circuit is marked for close
    because if it is the case, the channels are nullified from the circuit.
    
    Several valid cases can mark the circuit for close of the directory
    connection.
    
    Fixes #31958
    
    Signed-off-by: David Goulet <dgoulet at torproject.org>
---
 changes/ticket31958               |  5 +++++
 src/feature/dircommon/directory.c | 12 +++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/changes/ticket31958 b/changes/ticket31958
new file mode 100644
index 000000000..8206064df
--- /dev/null
+++ b/changes/ticket31958
@@ -0,0 +1,5 @@
+  o Minor bugfixes (directory):
+    - When checking if a directory connection is anonymous, test if the circuit
+      was marked for close before looking at its channel. This avoids a BUG()
+      stacktrace in case it was previously closed. Fixes bug 31958; bugfix on
+      0.4.2.1-alpha.
diff --git a/src/feature/dircommon/directory.c b/src/feature/dircommon/directory.c
index b3db0aa10..1ac35dd8b 100644
--- a/src/feature/dircommon/directory.c
+++ b/src/feature/dircommon/directory.c
@@ -225,7 +225,17 @@ connection_dir_is_anonymous(const dir_connection_t *dir_conn)
     return false;
   }
 
-  /* Get the previous channel to learn if it is a client or relay link. */
+  /* It is possible that the circuit was closed because one of the channel was
+   * closed or a DESTROY cell was received. Either way, this connection can
+   * not continue so return that it is not anonymous since we can not know for
+   * sure if it is. */
+  if (circ->marked_for_close) {
+    return false;
+  }
+
+  /* Get the previous channel to learn if it is a client or relay link. We
+   * BUG() because if the circuit is not mark for close, we ought to have a
+   * p_chan else we have a code flow issue. */
   if (BUG(CONST_TO_OR_CIRCUIT(circ)->p_chan == NULL)) {
     log_info(LD_DIR, "Rejected HSDir request: no p_chan");
     return false;





More information about the tor-commits mailing list