-
Notifications
You must be signed in to change notification settings - Fork 38.7k
net: Add missing lock in ProcessHeadersMessage(...) #11578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Friendly ping @sdaftuar: does this look correct? :-) |
sdaftuar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this! We should tag for backport.
Left a small suggestion for simplifying that block a little.
src/net_processing.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can move this up to above the if (nDoS > 0) line, and then remove the LOCK(cs_main) that's inside that block?
|
bitcoin/src/net_processing.cpp Line 2524 in bb9ab0f
Edit: sorry, after all none of the calls have the lock. |
|
@promag I think neither caller of |
|
Maybe |
|
@promag The first invalid block header may not have been added to mapBlockIndex. |
|
Right. Anyway, something like #11041 can easily prevent these cases. |
Reading the variable mapBlockIndex requires holding the mutex cs_main. The new "Disconnect outbound peers relaying invalid headers" code added in commit 37886d5 and merged as part of bitcoin#11568 two days ago did not lock cs_main prior to accessing mapBlockIndex.
042831e to
2530bf2
Compare
|
@sdaftuar Thanks for the review. The two locks are now merged into one as suggested :-) |
|
utACK 2530bf2 |
sdaftuar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 2530bf2
|
utACK 2530bf2 |
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 37886d5 and merged as part of #11568 two days ago did not lock `cs_main` prior to accessing `mapBlockIndex`. Tree-SHA512: b799c234be8043d036183a00bc7867bbf3bd7ffe3baa94c88529da3b3cd0571c31ed11dadfaf29c5b8498341d6d0a3c928029a43b69f3267ef263682c91563a3
|
This should be backported after #11568. |
Reading the variable mapBlockIndex requires holding the mutex cs_main. The new "Disconnect outbound peers relaying invalid headers" code added in commit 37886d5 and merged as part of bitcoin#11568 two days ago did not lock cs_main prior to accessing mapBlockIndex. Github-Pull: bitcoin#11578 Rebased-From: 2530bf2
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 37886d5 and merged as part of bitcoin#11568 two days ago did not lock `cs_main` prior to accessing `mapBlockIndex`. Tree-SHA512: b799c234be8043d036183a00bc7867bbf3bd7ffe3baa94c88529da3b3cd0571c31ed11dadfaf29c5b8498341d6d0a3c928029a43b69f3267ef263682c91563a3
Add missing lock in
ProcessHeadersMessage(...).Reading the variable
mapBlockIndexrequires holding the mutexcs_main.The new "Disconnect outbound peers relaying invalid headers" code added in commit 37886d5 and merged as part of #11568 two days ago did not lock
cs_mainprior to accessingmapBlockIndex.