Skip to content

Commit 8c1fdee

Browse files
tuexenmibrunin
authored andcommitted
[Backport] CVE-2020-16044: Use after free in WebRTC [3/3]
Manual cherry-pick of patch originally committed to usrsctp https://chromium.googlesource.com/external/github.com/sctplab/usrsctp/+/a3c3ef666b7a5e4c93ebae5a7462add6f86f5cf2 : Harden the handling of outgoing streams in case of an restart or INIT collision. This avouds an out-of-bounce access in case the peer can break the cookie signature. Thanks to Felix Wilhelm from Google for reporting the issue. Related to Chromium bug 1163228 Change-Id: I822efccda75287e1b6cbd4c8c4c143ce0231b6ec Reviewed-by: Allan Sandfeld Jensen <[email protected]>
1 parent 9c2ef65 commit 8c1fdee

File tree

1 file changed

+7
-5
lines changed
  • chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet

1 file changed

+7
-5
lines changed

chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
#ifdef __FreeBSD__
3636
#include <sys/cdefs.h>
37-
__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 368593 2020-12-12 22:23:45Z tuexen $");
37+
__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 368622 2020-12-13 23:51:51Z tuexen $");
3838
#endif
3939

4040
#include <netinet/sctp_os.h>
@@ -1898,7 +1898,9 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
18981898
NULL);
18991899
}
19001900
asoc->my_rwnd = ntohl(initack_cp->init.a_rwnd);
1901-
asoc->pre_open_streams = ntohs(initack_cp->init.num_outbound_streams);
1901+
if (asoc->pre_open_streams < asoc->streamoutcnt) {
1902+
asoc->pre_open_streams = asoc->streamoutcnt;
1903+
}
19021904

19031905
if (ntohl(init_cp->init.initiate_tag) != asoc->peer_vtag) {
19041906
/* Ok the peer probably discarded our
@@ -2052,8 +2054,9 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
20522054
/* move to OPEN state, if not in SHUTDOWN_SENT */
20532055
SCTP_SET_STATE(stcb, SCTP_STATE_OPEN);
20542056
}
2055-
asoc->pre_open_streams =
2056-
ntohs(initack_cp->init.num_outbound_streams);
2057+
if (asoc->pre_open_streams < asoc->streamoutcnt) {
2058+
asoc->pre_open_streams = asoc->streamoutcnt;
2059+
}
20572060
asoc->init_seq_number = ntohl(initack_cp->init.initial_tsn);
20582061
asoc->sending_seq = asoc->asconf_seq_out = asoc->str_reset_seq_out = asoc->init_seq_number;
20592062
asoc->asconf_seq_out_acked = asoc->asconf_seq_out - 1;
@@ -2373,7 +2376,6 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset,
23732376
/* process the INIT-ACK info (my info) */
23742377
asoc->my_vtag = ntohl(initack_cp->init.initiate_tag);
23752378
asoc->my_rwnd = ntohl(initack_cp->init.a_rwnd);
2376-
asoc->pre_open_streams = ntohs(initack_cp->init.num_outbound_streams);
23772379
asoc->init_seq_number = ntohl(initack_cp->init.initial_tsn);
23782380
asoc->sending_seq = asoc->asconf_seq_out = asoc->str_reset_seq_out = asoc->init_seq_number;
23792381
asoc->asconf_seq_out_acked = asoc->asconf_seq_out - 1;

0 commit comments

Comments
 (0)