A RST segment can be sent in response to
(a) received segment or
(b) by the upper layer protocol.
The SEG.SEQ validation consists of two checks: the in-window check of SEG.SEQ and the exact match check of SEG.SEQ.
For the in-window check, the left edge of the window needs to be based on tp->last_ack_sent to cover the delayed ACK case, where as the right edge needs to be based on tp->rcv_nxt + tp->rcv_wnd. This both assumes that tp->rcv_wnd is not zero. For the special case of tp->rcv_wnd being zero, add checks against tp->last_ack_sent for (a) and on tp->rcv_nxt for (b). This applies to all TCP stacks.
When the exact match of SEG.SEQ is performed, it should be based on tp->last_ack_sent for (a) and on tp->rcv_nxt for (b). To cover both, check for both. Add this to the base stack, since the RACK and BBR stack already did this.
This fixes PR 296594.