Skip to content

Conversation

theuni
Copy link
Member

@theuni theuni commented Oct 1, 2016

Noticed these in #8708, which turns them into crashes. PRing separately here as I believe it needs a 0.13.1 backport.

…n disconnection

75ead758 turned these into crashes in the event of a handshake failure, most
notably when a peer does not offer the expected services.

There are likely other cases that these assertions will find as well.
@fanquake fanquake added this to the 0.13.1 milestone Oct 1, 2016
@maflcko maflcko added the P2P label Oct 2, 2016
@sipa
Copy link
Member

sipa commented Oct 3, 2016

Looks harmless at worst. utACK.

@gmaxwell
Copy link
Contributor

gmaxwell commented Oct 3, 2016

utACK. Seems like it would be easy to introduce more of these issues in the future, this fix seems fine though we might want to consider something more comprehensive for later.

@theuni
Copy link
Member Author

theuni commented Oct 3, 2016

@gmaxwell Agreed. As mentioned above, #8708 adds an assert to catch a specific form of this case (sending a post-handshake message before the handshake is complete), so a more comprehensive fix will be required for sure, and is coming as part of the disconnection logic cleanup. These two were just added because they're low-hanging fruit and are easily backported, and because they were the only ones actually observed while testing.

@rebroad
Copy link
Contributor

rebroad commented Oct 3, 2016

Why not put this logic at the start of SendMessages - where it checks if Version is non zero?

@theuni
Copy link
Member Author

theuni commented Oct 3, 2016

@rebroad I believe that may inhibit the send of some valid reject messages. Generally speaking, I don't like the idea of relying on a stateful difference in SendMessages, as I think the goal should be generally async responses as opposed to the current model of "check all connections for all eligible broadcasts all the time".

It's a good makeshift suggestion though, I'll have a look.

@laanwj
Copy link
Member

laanwj commented Oct 3, 2016

utACK

Noticed these in #8708, which turns them into crashes

Ouch. I hope we can avoid this in a consistent way. To avoid DoSes, in network code it's always preferable to continue and (if its state is messed up) just boot a peer to crashing. Even in case of bugs.

@laanwj laanwj merged commit 905bc68 into bitcoin:master Oct 4, 2016
laanwj added a commit that referenced this pull request Oct 4, 2016
… disconnect

905bc68 net: fix a few cases where messages were sent rather than dropped upon disconnection (Cory Fields)
laanwj pushed a commit to laanwj/bitcoin that referenced this pull request Oct 13, 2016
…n disconnection

75ead758 turned these into crashes in the event of a handshake failure, most
notably when a peer does not offer the expected services.

There are likely other cases that these assertions will find as well.

Github-Pull: bitcoin#8862
Rebased-From: 905bc68
codablock pushed a commit to codablock/dash that referenced this pull request Jan 12, 2018
…quested disconnect

905bc68 net: fix a few cases where messages were sent rather than dropped upon disconnection (Cory Fields)
lateminer pushed a commit to lateminer/bitcoin that referenced this pull request Oct 24, 2018
…n disconnection

75ead758 turned these into crashes in the event of a handshake failure, most
notably when a peer does not offer the expected services.

There are likely other cases that these assertions will find as well.

Github-Pull: bitcoin#8862
Rebased-From: 905bc68
andvgal pushed a commit to energicryptocurrency/gen2-energi that referenced this pull request Jan 6, 2019
…quested disconnect

905bc68 net: fix a few cases where messages were sent rather than dropped upon disconnection (Cory Fields)
random-zebra added a commit to PIVX-Project/PIVX that referenced this pull request Aug 2, 2020
b954796 include missing atomic to make CMake linux happy. (furszy)
c452676 Make the cs_sendProcessing a LOCK instead of a TRY_LOCK (Matt Corallo)
ec23964 Split CNode::cs_vSend: message processing and message sending (Matt Corallo)
f9c458a Remove double brackets in addrman (Matt Corallo)
e48c0d3 Fix AddrMan locking (Matt Corallo)
2d71f05 Make fDisconnect an std::atomic (Matt Corallo)
0544cc6 net: fix a few cases where messages were sent rather than dropped upon disconnection (furszy)

Pull request description:

  Running 4.2 branch with `enable-debug`.
  Fixing:
  ```
  POTENTIAL DEADLOCK DETECTED
  Previous lock order was:
  pnode->cs_vRecvMsg net.cpp:1830 (TRY) (in thread )
  (1) cs_main main.cpp:5275 (in thread )
  (2) cs_vSend net.cpp:2465 (in thread )
  Current lock order is:
  (2) pnode->cs_vSend net.cpp:1846 (TRY) (in thread )
  (1) cs_main main.cpp:6018 (TRY) (in thread )
  ```

  Plus, added few more minor possible races fixes too.

  Back porting:
  bitcoin#8862
  bitcoin#9225
  bitcoin#9535

ACKs for top commit:
  Fuzzbawls:
    ACK b954796
  random-zebra:
    ACK b954796

Tree-SHA512: e15bd81e51282771ca4cb40689229d54787d72d7ed0ebc5f6f0058d3e252cc6691d8ebfc4670207bcd835d32b7898863651fd2ac74704d6cb4fdd30554d8a83a
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants