aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSridhar Samudrala <sri@us.ibm.com>2004-12-28 00:03:30 -0800
committerSridhar Samudrala <sri@us.ibm.com>2004-12-28 00:03:30 -0800
commit66b133f9863f5c350ca5ddef3b2d14d5940ca006 (patch)
tree7dd30f4b4cef72bea44dcf52c6312075a4a3c811 /net
parent43e7f663b688f65867f4bb4b777ae166ac0cc693 (diff)
downloadhistory-66b133f9863f5c350ca5ddef3b2d14d5940ca006.tar.gz
[SCTP] Implementation of SCTP Implementer's Guide Section 2.35.
This code checks that the verification tag, source port and destination port in the SCTP header matches the information contained in the state cookie. Signed-off-by: Vladislav Yasevich <vladislav.yasevich@hp.com> Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
Diffstat (limited to 'net')
-rw-r--r--net/sctp/associola.c1
-rw-r--r--net/sctp/sm_make_chunk.c18
2 files changed, 19 insertions, 0 deletions
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 8e2cbbd189aee1..116ac0f986aa2a 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -179,6 +179,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
asoc->c.peer_vtag = 0;
asoc->c.my_ttag = 0;
asoc->c.peer_ttag = 0;
+ asoc->c.my_port = ep->base.bind_addr.port;
asoc->c.initial_tsn = sctp_generate_tsn(ep);
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 3b2246fa652e93..7a0c6fa4c33c11 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1401,6 +1401,24 @@ struct sctp_association *sctp_unpack_cookie(
}
no_hmac:
+ /* IG Section 2.35.2:
+ * 3) Compare the port numbers and the verification tag contained
+ * within the COOKIE ECHO chunk to the actual port numbers and the
+ * verification tag within the SCTP common header of the received
+ * packet. If these values do not match the packet MUST be silently
+ * discarded,
+ */
+ if (ntohl(chunk->sctp_hdr->vtag) != bear_cookie->my_vtag) {
+ *error = -SCTP_IERROR_BAD_TAG;
+ goto fail;
+ }
+
+ if (ntohs(chunk->sctp_hdr->source) != bear_cookie->peer_addr.v4.sin_port ||
+ ntohs(chunk->sctp_hdr->dest) != bear_cookie->my_port) {
+ *error = -SCTP_IERROR_BAD_PORTS;
+ goto fail;
+ }
+
/* Check to see if the cookie is stale. If there is already
* an association, there is no need to check cookie's expiration
* for init collision case of lost COOKIE ACK.