Skip to content

Commit 85c5ed4

Browse files
Shan Weidavem330
authored andcommitted
sctp: handle ootb packet in chunk order as defined
Changed the order of processing SHUTDOWN ACK and COOKIE ACK refer to section 8.4:Handle "Out of the Blue" Packets. SHUTDOWN ACK chunk should be processed before processing "Stale Cookie" ERROR or a COOKIE ACK. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Shan Wei <shanwei@cn.fujitsu.com> Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent deb85a6 commit 85c5ed4

2 files changed

Lines changed: 21 additions & 15 deletions

File tree

‎net/sctp/input.c‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,6 @@ static int sctp_rcv_ootb(struct sk_buff *skb)
661661
{
662662
sctp_chunkhdr_t *ch;
663663
__u8 *ch_end;
664-
sctp_errhdr_t *err;
665664

666665
ch = (sctp_chunkhdr_t *) skb->data;
667666

@@ -697,20 +696,6 @@ static int sctp_rcv_ootb(struct sk_buff *skb)
697696
if (SCTP_CID_INIT == ch->type && (void *)ch != skb->data)
698697
goto discard;
699698

700-
/* RFC 8.4, 7) If the packet contains a "Stale cookie" ERROR
701-
* or a COOKIE ACK the SCTP Packet should be silently
702-
* discarded.
703-
*/
704-
if (SCTP_CID_COOKIE_ACK == ch->type)
705-
goto discard;
706-
707-
if (SCTP_CID_ERROR == ch->type) {
708-
sctp_walk_errors(err, ch) {
709-
if (SCTP_ERROR_STALE_COOKIE == err->cause)
710-
goto discard;
711-
}
712-
}
713-
714699
ch = (sctp_chunkhdr_t *) ch_end;
715700
} while (ch_end < skb_tail_pointer(skb));
716701

‎net/sctp/sm_statefuns.c‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3332,8 +3332,10 @@ sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep,
33323332
struct sctp_chunk *chunk = arg;
33333333
struct sk_buff *skb = chunk->skb;
33343334
sctp_chunkhdr_t *ch;
3335+
sctp_errhdr_t *err;
33353336
__u8 *ch_end;
33363337
int ootb_shut_ack = 0;
3338+
int ootb_cookie_ack = 0;
33373339

33383340
SCTP_INC_STATS(SCTP_MIB_OUTOFBLUES);
33393341

@@ -3358,6 +3360,23 @@ sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep,
33583360
if (SCTP_CID_ABORT == ch->type)
33593361
return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
33603362

3363+
/* RFC 8.4, 7) If the packet contains a "Stale cookie" ERROR
3364+
* or a COOKIE ACK the SCTP Packet should be silently
3365+
* discarded.
3366+
*/
3367+
3368+
if (SCTP_CID_COOKIE_ACK == ch->type)
3369+
ootb_cookie_ack = 1;
3370+
3371+
if (SCTP_CID_ERROR == ch->type) {
3372+
sctp_walk_errors(err, ch) {
3373+
if (SCTP_ERROR_STALE_COOKIE == err->cause) {
3374+
ootb_cookie_ack = 1;
3375+
break;
3376+
}
3377+
}
3378+
}
3379+
33613380
/* Report violation if chunk len overflows */
33623381
ch_end = ((__u8 *)ch) + WORD_ROUND(ntohs(ch->length));
33633382
if (ch_end > skb_tail_pointer(skb))
@@ -3369,6 +3388,8 @@ sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep,
33693388

33703389
if (ootb_shut_ack)
33713390
return sctp_sf_shut_8_4_5(ep, asoc, type, arg, commands);
3391+
else if (ootb_cookie_ack)
3392+
return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
33723393
else
33733394
return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands);
33743395
}

0 commit comments

Comments
 (0)