aboutsummaryrefslogtreecommitdiff
path: root/src/feature/nodelist/nodelist.c
diff options
context:
space:
mode:
authorTaylor Yu <catalyst@torproject.org>2018-10-17 15:51:03 -0500
committerTaylor Yu <catalyst@torproject.org>2018-10-17 16:00:11 -0500
commit7f6c0fce469c7945a2504d29e942d4ef68967e07 (patch)
tree404f3c969f10c493bea80af713724beabafc3c31 /src/feature/nodelist/nodelist.c
parent389bae0e8b5aef5c485fc6674027c049a7f7d591 (diff)
parent4e7f65ee5dfc735cf78f3e78c33bad5ce882af9e (diff)
downloadtor-7f6c0fce469c7945a2504d29e942d4ef68967e07.tar.gz
tor-7f6c0fce469c7945a2504d29e942d4ef68967e07.zip
Merge branch 'bug27800-034' into bug27800-035
Diffstat (limited to 'src/feature/nodelist/nodelist.c')
-rw-r--r--src/feature/nodelist/nodelist.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/feature/nodelist/nodelist.c b/src/feature/nodelist/nodelist.c
index 600dfcf56c..a98a5c8655 100644
--- a/src/feature/nodelist/nodelist.c
+++ b/src/feature/nodelist/nodelist.c
@@ -64,6 +64,8 @@
#include "feature/nodelist/routerset.h"
#include "feature/nodelist/torcert.h"
#include "feature/rend/rendservice.h"
+#include "lib/encoding/binascii.h"
+#include "lib/err/backtrace.h"
#include "lib/geoip/geoip.h"
#include "lib/net/address.h"
@@ -284,6 +286,20 @@ node_remove_from_ed25519_map(node_t *node)
return rv;
}
+/** Helper function to log details of duplicated ed2559_ids */
+static void
+node_log_dup_ed_id(const node_t *old, const node_t *node, const char *ed_id)
+{
+ char *s;
+ char *olddesc = tor_strdup(node_describe(old));
+
+ tor_asprintf(&s, "Reused ed25519_id %s: old %s new %s", ed_id,
+ olddesc, node_describe(node));
+ log_backtrace(LOG_NOTICE, LD_DIR, s);
+ tor_free(olddesc);
+ tor_free(s);
+}
+
/** If <b>node</b> has an ed25519 id, and it is not already in the ed25519 id
* map, set its ed25519_id field, and add it to the ed25519 map.
*/
@@ -305,11 +321,24 @@ node_add_to_ed25519_map(node_t *node)
node_t *old;
memcpy(&node->ed25519_id, key, sizeof(node->ed25519_id));
old = HT_FIND(nodelist_ed_map, &the_nodelist->nodes_by_ed_id, node);
- if (BUG(old)) {
- /* XXXX order matters here, and this may mean that authorities aren't
- * pinning. */
- if (old != node)
+ if (old) {
+ char ed_id[BASE32_BUFSIZE(sizeof(key->pubkey))];
+
+ base32_encode(ed_id, sizeof(ed_id), (const char *)key->pubkey,
+ sizeof(key->pubkey));
+ if (BUG(old == node)) {
+ /* Actual bug: all callers of this function call
+ * node_remove_from_ed25519_map first. */
+ log_err(LD_BUG,
+ "Unexpectedly found deleted node with ed25519_id %s", ed_id);
+ } else {
+ /* Distinct nodes sharing a ed25519 id, possibly due to relay
+ * misconfiguration. The key pinning might not catch this,
+ * possibly due to downloading a missing descriptor during
+ * consensus voting. */
+ node_log_dup_ed_id(old, node, ed_id);
memset(&node->ed25519_id, 0, sizeof(node->ed25519_id));
+ }
return 0;
}