security: add option to disable accept event to app layer on PCB allocation failure #78
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This MR introduces a new configuration option DISABLE_TCPIP_EVENT_ACCEPT_AT_MEM_ERR to improve stack stability during PCB memory exhaustion scenarios, especially to SYN Storm test
Problem Statement
When the TCP stack exhausts available PCBs (reaches [MEMP_NUM_TCP_PCB], the current behavior calls [TCP_EVENT_ACCEPT] with ERR_MEM to notify the application layer. This can cause significant instability because:
Resource Exhaustion Feedback Loop: The stack is already at its resource limits, having attempted multiple recovery strategies (killing TIME-WAIT, LAST-ACK, CLOSING, and lower-priority connections)
An anormal behavior was noticed with an attempt to remove queues or blocking if application don't handle it.
Application-Layer Interference: The application may attempt connection or memory management operations during this critical state
Unnecessary Complexity: Applications that don't handle ERR_MEM in accept callbacks receive unexpected callbacks with no practical benefit
Security/Stability: Prevents instability during high connection load or resource exhaustion attacks or tests as TCP SYN stom