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
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jasonbcox created this revision.Apr 29 2019, 23:51
Herald added a reviewer: Restricted Project. · View Herald TranscriptApr 29 2019, 23:51
jasonbcox edited the summary of this revision. (Show Details)Apr 29 2019, 23:52
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
jasonbcox edited the test plan for this revision. (Show Details)May 8 2019, 22:29
jasonbcox updated this revision to Diff 8531.May 8 2019, 22:38

Rebase + added test_runner.py to test plan

jasonbcox edited the summary of this revision. (Show Details)May 9 2019, 00:14
Fabien accepted this revision.May 9 2019, 06:23
This revision is now accepted and ready to land.May 9 2019, 06:23
This revision was automatically updated to reflect the committed changes.