svn commit: r353395 - stable/12/sys/netinet

Michael Tuexen tuexen at FreeBSD.org
Thu Oct 10 14:46:00 UTC 2019


Author: tuexen
Date: Thu Oct 10 14:45:59 2019
New Revision: 353395
URL: https://svnweb.freebsd.org/changeset/base/353395

Log:
  MFC r353060:
  
  Add missing input validation. This could result in reading from
  uninitialized memory.
  The issue was found by OSS-Fuzz for usrsctp  and reported in
  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17780

Modified:
  stable/12/sys/netinet/sctp_asconf.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netinet/sctp_asconf.c
==============================================================================
--- stable/12/sys/netinet/sctp_asconf.c	Thu Oct 10 13:44:12 2019	(r353394)
+++ stable/12/sys/netinet/sctp_asconf.c	Thu Oct 10 14:45:59 2019	(r353395)
@@ -169,10 +169,16 @@ sctp_process_asconf_add_ip(struct sockaddr *src, struc
 #endif
 
 	aparam_length = ntohs(aph->ph.param_length);
+	if (aparam_length < sizeof(struct sctp_asconf_paramhdr) + sizeof(struct sctp_paramhdr)) {
+		return (NULL);
+	}
 	ph = (struct sctp_paramhdr *)(aph + 1);
 	param_type = ntohs(ph->param_type);
 #if defined(INET) || defined(INET6)
 	param_length = ntohs(ph->param_length);
+	if (param_length + sizeof(struct sctp_asconf_paramhdr) != aparam_length) {
+		return (NULL);
+	}
 #endif
 	sa = &store.sa;
 	switch (param_type) {
@@ -325,8 +331,14 @@ sctp_process_asconf_delete_ip(struct sockaddr *src,
 	aparam_length = ntohs(aph->ph.param_length);
 	ph = (struct sctp_paramhdr *)(aph + 1);
 	param_type = ntohs(ph->param_type);
+	if (aparam_length < sizeof(struct sctp_asconf_paramhdr) + sizeof(struct sctp_paramhdr)) {
+		return (NULL);
+	}
 #if defined(INET) || defined(INET6)
 	param_length = ntohs(ph->param_length);
+	if (param_length + sizeof(struct sctp_asconf_paramhdr) != aparam_length) {
+		return (NULL);
+	}
 #endif
 	sa = &store.sa;
 	switch (param_type) {
@@ -454,10 +466,16 @@ sctp_process_asconf_set_primary(struct sockaddr *src,
 #endif
 
 	aparam_length = ntohs(aph->ph.param_length);
+	if (aparam_length < sizeof(struct sctp_asconf_paramhdr) + sizeof(struct sctp_paramhdr)) {
+		return (NULL);
+	}
 	ph = (struct sctp_paramhdr *)(aph + 1);
 	param_type = ntohs(ph->param_type);
 #if defined(INET) || defined(INET6)
 	param_length = ntohs(ph->param_length);
+	if (param_length + sizeof(struct sctp_asconf_paramhdr) != aparam_length) {
+		return (NULL);
+	}
 #endif
 	sa = &store.sa;
 	switch (param_type) {


More information about the svn-src-stable-12 mailing list