Skip to content

Commit 09e50ac

Browse files
catenacybervictorjulien
authored andcommitted
stream/tcp: check new last_ack stays within base_seq bounds
If we have - stream->last_ack 0x40021 Then, we call StreamTcpUpdateLastAck with 0x8000fc21 Then we satisfy SEQ_GT((ack), (stream)->last_ack) But we do not satisfy SEQ_GT(ack, (stream)->base_seq)) and the new last_ack will be compared to base_seq So, refuse to make such a big update Ticket: 6865
1 parent 973ab60 commit 09e50ac

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

src/stream-tcp.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,22 +1065,26 @@ void StreamTcpSetOSPolicy(TcpStream *stream, Packet *p)
10651065
* \param stream stream to update
10661066
* \param ack ACK value to test and set
10671067
*/
1068-
#define StreamTcpUpdateLastAck(ssn, stream, ack) { \
1069-
if (SEQ_GT((ack), (stream)->last_ack)) \
1070-
{ \
1071-
SCLogDebug("ssn %p: last_ack set to %"PRIu32", moved %u forward", (ssn), (ack), (ack) - (stream)->last_ack); \
1072-
if ((SEQ_LEQ((stream)->last_ack, (stream)->next_seq) && SEQ_GT((ack),(stream)->next_seq))) { \
1073-
SCLogDebug("last_ack just passed next_seq: %u (was %u) > %u", (ack), (stream)->last_ack, (stream)->next_seq); \
1074-
} else { \
1075-
SCLogDebug("next_seq (%u) <> last_ack now %d", (stream)->next_seq, (int)(stream)->next_seq - (ack)); \
1076-
}\
1077-
(stream)->last_ack = (ack); \
1078-
StreamTcpSackPruneList((stream)); \
1079-
} else { \
1080-
SCLogDebug("ssn %p: no update: ack %u, last_ack %"PRIu32", next_seq %u (state %u)", \
1081-
(ssn), (ack), (stream)->last_ack, (stream)->next_seq, (ssn)->state); \
1082-
}\
1083-
}
1068+
#define StreamTcpUpdateLastAck(ssn, stream, ack) \
1069+
{ \
1070+
if (SEQ_GT((ack), (stream)->last_ack) && SEQ_GT(ack, (stream)->base_seq)) { \
1071+
SCLogDebug("ssn %p: last_ack set to %" PRIu32 ", moved %u forward", (ssn), (ack), \
1072+
(ack) - (stream)->last_ack); \
1073+
if ((SEQ_LEQ((stream)->last_ack, (stream)->next_seq) && \
1074+
SEQ_GT((ack), (stream)->next_seq))) { \
1075+
SCLogDebug("last_ack just passed next_seq: %u (was %u) > %u", (ack), \
1076+
(stream)->last_ack, (stream)->next_seq); \
1077+
} else { \
1078+
SCLogDebug("next_seq (%u) <> last_ack now %d", (stream)->next_seq, \
1079+
(int)(stream)->next_seq - (ack)); \
1080+
} \
1081+
(stream)->last_ack = (ack); \
1082+
StreamTcpSackPruneList((stream)); \
1083+
} else { \
1084+
SCLogDebug("ssn %p: no update: ack %u, last_ack %" PRIu32 ", next_seq %u (state %u)", \
1085+
(ssn), (ack), (stream)->last_ack, (stream)->next_seq, (ssn)->state); \
1086+
} \
1087+
}
10841088

10851089
#define StreamTcpAsyncLastAckUpdate(ssn, stream) { \
10861090
if ((ssn)->flags & STREAMTCP_FLAG_ASYNC) { \

0 commit comments

Comments
 (0)