Skip to content

Commit f4ad85c

Browse files
guijianfengdavem330
authored andcommitted
[SCTP]: Fix protocol violation when receiving an error lenght INIT-ACK
When receiving an error length INIT-ACK during COOKIE-WAIT, a 0-vtag ABORT will be responsed. This action violates the protocol apparently. This patch achieves the following things. 1 If the INIT-ACK contains all the fixed parameters, use init-tag recorded from INIT-ACK as vtag. 2 If the INIT-ACK doesn't contain all the fixed parameters, just reflect its vtag. Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com> Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 72da7b3 commit f4ad85c

4 files changed

Lines changed: 25 additions & 0 deletions

File tree

‎include/net/sctp/command.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ typedef enum {
104104
SCTP_CMD_ADAPTATION_IND, /* generate and send adaptation event */
105105
SCTP_CMD_ASSOC_SHKEY, /* generate the association shared keys */
106106
SCTP_CMD_T1_RETRAN, /* Mark for retransmission after T1 timeout */
107+
SCTP_CMD_UPDATE_INITTAG, /* Update peer inittag */
107108
SCTP_CMD_LAST
108109
} sctp_verb_t;
109110

‎net/sctp/outqueue.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,9 @@ int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout)
793793
break;
794794

795795
case SCTP_CID_ABORT:
796+
if (sctp_test_T_bit(chunk)) {
797+
packet->vtag = asoc->c.my_vtag;
798+
}
796799
case SCTP_CID_SACK:
797800
case SCTP_CID_HEARTBEAT:
798801
case SCTP_CID_HEARTBEAT_ACK:

‎net/sctp/sm_sideeffect.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,9 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
15361536
error = sctp_auth_asoc_init_active_key(asoc,
15371537
GFP_ATOMIC);
15381538
break;
1539+
case SCTP_CMD_UPDATE_INITTAG:
1540+
asoc->peer.i.init_tag = cmd->obj.u32;
1541+
break;
15391542

15401543
default:
15411544
printk(KERN_WARNING "Impossible command: %u, %p\n",

‎net/sctp/sm_statefuns.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4144,6 +4144,24 @@ static sctp_disposition_t sctp_sf_abort_violation(
41444144
goto nomem;
41454145

41464146
if (asoc) {
4147+
/* Treat INIT-ACK as a special case during COOKIE-WAIT. */
4148+
if (chunk->chunk_hdr->type == SCTP_CID_INIT_ACK &&
4149+
!asoc->peer.i.init_tag) {
4150+
sctp_initack_chunk_t *initack;
4151+
4152+
initack = (sctp_initack_chunk_t *)chunk->chunk_hdr;
4153+
if (!sctp_chunk_length_valid(chunk,
4154+
sizeof(sctp_initack_chunk_t)))
4155+
abort->chunk_hdr->flags |= SCTP_CHUNK_FLAG_T;
4156+
else {
4157+
unsigned int inittag;
4158+
4159+
inittag = ntohl(initack->init_hdr.init_tag);
4160+
sctp_add_cmd_sf(commands, SCTP_CMD_UPDATE_INITTAG,
4161+
SCTP_U32(inittag));
4162+
}
4163+
}
4164+
41474165
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort));
41484166
SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS);
41494167

0 commit comments

Comments
 (0)