Skip to content

Commit f282df0

Browse files
lxindavem330
authored andcommitted
sctp: fix a SCTP_MIB_CURRESTAB leak in sctp_sf_do_dupcook_b
Normally SCTP_MIB_CURRESTAB is always incremented once asoc enter into ESTABLISHED from the state < ESTABLISHED and decremented when the asoc is being deleted. However, in sctp_sf_do_dupcook_b(), the asoc's state can be changed to ESTABLISHED from the state >= ESTABLISHED where it shouldn't increment SCTP_MIB_CURRESTAB. Otherwise, one asoc may increment MIB_CURRESTAB multiple times but only decrement once at the end. I was able to reproduce it by using scapy to do the 4-way shakehands, after that I replayed the COOKIE-ECHO chunk with 'peer_vtag' field changed to different values, and SCTP_MIB_CURRESTAB was incremented multiple times and never went back to 0 even when the asoc was freed. This patch is to fix it by only incrementing SCTP_MIB_CURRESTAB when the state < ESTABLISHED in sctp_sf_do_dupcook_b(). Fixes: 1da177e ("Linux-2.6.12-rc2") Reported-by: Marcelo Ricardo Leitner <[email protected]> Signed-off-by: Xin Long <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a52445a commit f282df0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/sctp/sm_statefuns.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1953,7 +1953,8 @@ static enum sctp_disposition sctp_sf_do_dupcook_b(
19531953

19541954
sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
19551955
SCTP_STATE(SCTP_STATE_ESTABLISHED));
1956-
SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB);
1956+
if (asoc->state < SCTP_STATE_ESTABLISHED)
1957+
SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB);
19571958
sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL());
19581959

19591960
/* Update the content of current association. */

0 commit comments

Comments
 (0)