Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Jun 2014 16:38:06 +0000 (UTC)
From:      Michael Tuexen <tuexen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r267729 - stable/10/sys/netinet
Message-ID:  <201406221638.s5MGc6jK040268@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tuexen
Date: Sun Jun 22 16:38:06 2014
New Revision: 267729
URL: http://svnweb.freebsd.org/changeset/base/267729

Log:
  MFC r264679:
  
  Send the correct error cause, when a DATA chunk with no user data
  is received. This bug was reported by Irene Ruengeler.

Modified:
  stable/10/sys/netinet/sctp.h
  stable/10/sys/netinet/sctp_indata.c
  stable/10/sys/netinet/sctputil.c
  stable/10/sys/netinet/sctputil.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netinet/sctp.h
==============================================================================
--- stable/10/sys/netinet/sctp.h	Sun Jun 22 16:36:14 2014	(r267728)
+++ stable/10/sys/netinet/sctp.h	Sun Jun 22 16:38:06 2014	(r267729)
@@ -408,6 +408,11 @@ struct sctp_error_unrecognized_chunk {
 	struct sctp_chunkhdr ch;/* header from chunk in error */
 }                             SCTP_PACKED;
 
+struct sctp_error_no_user_data {
+	struct sctp_error_cause cause;	/* code=SCTP_CAUSE_NO_USER_DATA */
+	uint32_t tsn;		/* TSN of the empty data chunk */
+}                       SCTP_PACKED;
+
 /*
  * Main SCTP chunk types we place these here so natd and f/w's in user land
  * can find them.

Modified: stable/10/sys/netinet/sctp_indata.c
==============================================================================
--- stable/10/sys/netinet/sctp_indata.c	Sun Jun 22 16:36:14 2014	(r267728)
+++ stable/10/sys/netinet/sctp_indata.c	Sun Jun 22 16:38:06 2014	(r267729)
@@ -2323,7 +2323,7 @@ sctp_process_data(struct mbuf **mm, int 
 			continue;
 		}
 		if (ch->ch.chunk_type == SCTP_DATA) {
-			if ((size_t)chk_length < sizeof(struct sctp_data_chunk) + 1) {
+			if ((size_t)chk_length < sizeof(struct sctp_data_chunk)) {
 				/*
 				 * Need to send an abort since we had a
 				 * invalid data chunk.
@@ -2341,6 +2341,21 @@ sctp_process_data(struct mbuf **mm, int 
 				    vrf_id, port);
 				return (2);
 			}
+			if ((size_t)chk_length == sizeof(struct sctp_data_chunk)) {
+				/*
+				 * Need to send an abort since we had an
+				 * empty data chunk.
+				 */
+				struct mbuf *op_err;
+
+				op_err = sctp_generate_no_user_data_cause(ch->dp.tsn);
+				stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_19;
+				sctp_abort_association(inp, stcb, m, iphlen,
+				    src, dst, sh, op_err,
+				    use_mflowid, mflowid,
+				    vrf_id, port);
+				return (2);
+			}
 #ifdef SCTP_AUDITING_ENABLED
 			sctp_audit_log(0xB1, 0);
 #endif

Modified: stable/10/sys/netinet/sctputil.c
==============================================================================
--- stable/10/sys/netinet/sctputil.c	Sun Jun 22 16:36:14 2014	(r267728)
+++ stable/10/sys/netinet/sctputil.c	Sun Jun 22 16:38:06 2014	(r267729)
@@ -4654,6 +4654,25 @@ sctp_generate_cause(uint16_t code, char 
 	return (m);
 }
 
+struct mbuf *
+sctp_generate_no_user_data_cause(uint32_t tsn)
+{
+	struct mbuf *m;
+	struct sctp_error_no_user_data *no_user_data_cause;
+	size_t len;
+
+	len = sizeof(struct sctp_error_no_user_data);
+	m = sctp_get_mbuf_for_msg(len, 0, M_NOWAIT, 1, MT_DATA);
+	if (m != NULL) {
+		SCTP_BUF_LEN(m) = len;
+		no_user_data_cause = mtod(m, struct sctp_error_no_user_data *);
+		no_user_data_cause->cause.code = htons(SCTP_CAUSE_NO_USER_DATA);
+		no_user_data_cause->cause.length = htons((uint16_t) len);
+		no_user_data_cause->tsn = tsn;	/* tsn is passed in as NBO */
+	}
+	return (m);
+}
+
 #ifdef SCTP_MBCNT_LOGGING
 void
 sctp_free_bufspace(struct sctp_tcb *stcb, struct sctp_association *asoc,

Modified: stable/10/sys/netinet/sctputil.h
==============================================================================
--- stable/10/sys/netinet/sctputil.h	Sun Jun 22 16:36:14 2014	(r267728)
+++ stable/10/sys/netinet/sctputil.h	Sun Jun 22 16:38:06 2014	(r267729)
@@ -254,6 +254,7 @@ sctp_release_pr_sctp_chunk(struct sctp_t
 );
 
 struct mbuf *sctp_generate_cause(uint16_t, char *);
+struct mbuf *sctp_generate_no_user_data_cause(uint32_t);
 
 void 
 sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406221638.s5MGc6jK040268>