Page MenuHomePhabricator

Merge #11578: net: Add missing lock in ProcessHeadersMessage(...)
ClosedPublic

Authored by jasonbcox on Apr 29 2019, 23:51.

Details

Summary

2530bf2 net: Add missing lock in ProcessHeadersMessage(...) (practicalswift)

Pull request description:

Add missing lock in `ProcessHeadersMessage(...)`.

Reading the variable `mapBlockIndex` requires holding the mutex `cs_main`.

The new "Disconnect outbound peers relaying invalid headers" code added in commit 37886d5e2f9992678dea4b1bd893f4f10d61d3ad and merged as part of #11568 two days ago did not lock `cs_main` prior to accessing `mapBlockIndex`.

Tree-SHA512: b799c234be8043d036183a00bc7867bbf3bd7ffe3baa94c88529da3b3cd0571c31ed11dadfaf29c5b8498341d6d0a3c928029a43b69f3267ef263682c91563a3

Backport of Core PR11578
https://github.com/bitcoin/bitcoin/pull/11578/files

Test Plan

ninja check
make check
test_runner.py
bitcoind # sanity check

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested changes to this revision.Apr 30 2019, 12:15

LookupBlockIndex()'s first line is an AssertLockHeld(cs_main), so whether the lock is already held or the path is not covered by any test.

This revision now requires changes to proceed.Apr 30 2019, 12:15

Rebase + added test_runner.py to test plan

This revision is now accepted and ready to land.May 9 2019, 06:23