PQ: fix membership for post-quantum nodes (three control-plane defects)
A PQ node could complete the hybrid handshake and still never join the network: status ACCESS_DENIED, peers [], frames dropped. Three separate defects, none in the key exchange itself. 1. EmbeddedNetworkController::_request gated known members with Identity(haveIdStr) != identity. HELLO carries only the classic projection (Identity::serializeClassic), so peer->identity() stays type 0 while a stored record is type 1, and operator== -- which compares PQ material -- always reported a mismatch. Use the existing sameClassicalIdentity(); PQ key rotation stays detectable via VERB_PQ_KEYS. 2. Peer::setPQPublicKeys() cached the received PQ keys for the crypto path only and never wrote them into _id. The controller's identity therefore stayed type 0 in every table, com.verify() returned 1, and Membership deferred for WHOIS forever -- a WHOIS cannot help, the keys arrive in VERB_PQ_KEYS. Add Identity::attachPQPublicKeys() and call it so the peer's Identity is complete once keys arrive. 3. OneServiceImpl::run constructed an EmbeddedNetworkController unconditionally, so a member-only node answered its own NETWORK_CONFIG_REQUESTs and self-signed a local config, never contacting the node that owned the network. Add settings.disableController (default false, so existing installs are unchanged) for member-only nodes. Verified live on two hosts with pqcMode: hybrid on both sides: status OK, peer DIRECT over 192.168.122.85/9993, pqcCapable and pqcHybridActive true both directions, ping 0% loss both ways, selftest exit 0. The selftest regression covers the controller match and keeps rejecting an impostor identity at the same address. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ad01fbcccb
commit
a224dbbc53
24 files changed
+1423
-168
No files matched your search
@@ -261,6 +261,20 @@ public:
|
||||
inline void operator()(Topology &t,const SharedPtr<Peer> &p)
|
||||
{
|
||||
const std::vector<InetAddress> *const alwaysContactEndpoints = _alwaysContact.get(p->address());
|
||||
// The PQ key exchange must not sit behind the ping guards below: a peer
|
||||
// that has completed a HELLO handshake but has no live path yet is exactly
|
||||
// the peer that still needs to be offered keys. Switch::send queues the
|
||||
// packet if no path exists, so this is safe to run unconditionally.
|
||||
//
|
||||
// The send itself is deferred to sendPQKeysNow() below. eachPeer holds
|
||||
// Topology::_peers_m for the whole iteration and Peer::sendPQKeys
|
||||
// reaches Switch::send -> Topology::getPeer, which takes that same
|
||||
// non-recursive lock, so calling it inline self-deadlocks the main
|
||||
// thread and stalls the control plane with it.
|
||||
if ((p->hybridCapable()) && (RR->node->pqcMode() != ZT_PQC_MODE_CLASSIC) && (RR->identity.hasPQ()) && p->pqKeysDue(_now)) {
|
||||
_pendingPQKeys.push_back(p);
|
||||
}
|
||||
|
||||
if (alwaysContactEndpoints) {
|
||||
|
||||
ZT_PeerRole role = RR->topology->role(p->address());
|
||||
@@ -314,12 +328,26 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the PQ key offers collected during the peer iteration.
|
||||
*
|
||||
* Must be called after eachPeer() has released Topology::_peers_m.
|
||||
*/
|
||||
inline void sendPQKeysNow()
|
||||
{
|
||||
for(std::vector< SharedPtr<Peer> >::iterator p(_pendingPQKeys.begin());p!=_pendingPQKeys.end();++p) {
|
||||
(*p)->sendPQKeys(_tPtr,_now);
|
||||
}
|
||||
_pendingPQKeys.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
const RuntimeEnvironment *RR;
|
||||
void *_tPtr;
|
||||
Hashtable< Address,std::vector<InetAddress> > &_alwaysContact;
|
||||
const int64_t _now;
|
||||
const SharedPtr<Peer> _bestCurrentUpstream;
|
||||
std::vector< SharedPtr<Peer> > _pendingPQKeys;
|
||||
};
|
||||
|
||||
ZT_ResultCode Node::processBackgroundTasks(void *tptr,int64_t now,volatile int64_t *nextBackgroundTaskDeadline)
|
||||
@@ -403,6 +431,10 @@ ZT_ResultCode Node::processBackgroundTasks(void *tptr,int64_t now,volatile int64
|
||||
_PingPeersThatNeedPing pfunc(RR,tptr,alwaysContact,now);
|
||||
RR->topology->eachPeer<_PingPeersThatNeedPing &>(pfunc);
|
||||
|
||||
// Topology::_peers_m is released here, so the deferred PQ key
|
||||
// offers can now go out without re-entering that lock.
|
||||
pfunc.sendPQKeysNow();
|
||||
|
||||
// Run WHOIS to create Peer for alwaysContact addresses that could not be contacted
|
||||
{
|
||||
Hashtable< Address,std::vector<InetAddress> >::Iterator i(alwaysContact);
|
||||
@@ -586,6 +618,12 @@ ZT_PeerList *Node::peers() const
|
||||
p->latency = -1;
|
||||
}
|
||||
p->role = RR->topology->role(pi->second->identity().address());
|
||||
p->pqcCapable = pi->second->hybridCapable();
|
||||
// "Active" must mean the hybrid key is installed, not merely that the
|
||||
// preconditions hold: the encapsulator derives its key before the peer
|
||||
// ever sees the ciphertext, so hybridEligible() reports True a full
|
||||
// round trip early and the decapsulator's failure goes unnoticed.
|
||||
p->pqcHybridActive = pi->second->hybridSessionKeyInstalled();
|
||||
|
||||
std::vector< SharedPtr<Path> > paths(pi->second->paths(_now));
|
||||
SharedPtr<Path> bestp(pi->second->getAppropriatePath(_now,false));
|
||||
|
||||
Reference in new issue
Block a user