mirror of
https://github.com/slackhq/nebula.git
synced 2026-11-15 17:16:52 +01:00
multiport: carry a lost install race's counter to the surviving lane window
Two routines can race on a lane's first packet and derive a session each. Only one gets installed, and the loser was dropped along with the replay-window entry for the packet it had just accepted, leaving that one counter replayable. The two sessions hold identical keys, so the winner's window is the same window in every respect that matters: mark the counter seen on it instead. Closes the gap without putting a lock on the decrypt path.
This commit is contained in:
1 parent
8c5c740571
commit
e3efe0c53d
4 files changed
+31
-14
No files matched your search
@@ -168,6 +168,15 @@ func (cs *ConnectionState) Decrypt(l *slog.Logger, messageCounter uint64, packet
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// noteSeen records a counter that some other session for the same keys already
|
||||
// accepted, so a packet doesn't become replayable just because the session that
|
||||
// decrypted it was thrown away. See laneSet.installSession, its only caller.
|
||||
func (cs *ConnectionState) noteSeen(l *slog.Logger, messageCounter uint64) {
|
||||
cs.decryptLock.Lock()
|
||||
cs.window.Update(l, messageCounter)
|
||||
cs.decryptLock.Unlock()
|
||||
}
|
||||
|
||||
func (cs *ConnectionState) VerifyRelay(l *slog.Logger, messageCounter uint64, packet []byte, nb []byte) error {
|
||||
cs.decryptLock.Lock()
|
||||
result := cs.window.Check(l, messageCounter)
|
||||
|
||||
Reference in new issue
Block a user