Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Feb 2017 05:14:20 +0000 (UTC)
From:      Eric van Gyzen <vangyzen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r313523 - stable/11/sys/netinet
Message-ID:  <201702100514.v1A5EK91068223@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vangyzen
Date: Fri Feb 10 05:14:19 2017
New Revision: 313523
URL: https://svnweb.freebsd.org/changeset/base/313523

Log:
  MFC r313401
  
  Fix garbage IP addresses in UDP log_in_vain messages
  
  If multiple threads emit a UDP log_in_vain message concurrently,
  or indeed call inet_ntoa() for any other reason,
  the IP addresses could be garbage due to concurrent usage of a
  single string buffer inside inet_ntoa().  Use inet_ntoa_r() with
  two stack buffers instead.
  
  Relnotes:	yes
  Sponsored by:	Dell EMC

Modified:
  stable/11/sys/netinet/udp_usrreq.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netinet/udp_usrreq.c
==============================================================================
--- stable/11/sys/netinet/udp_usrreq.c	Fri Feb 10 04:28:44 2017	(r313522)
+++ stable/11/sys/netinet/udp_usrreq.c	Fri Feb 10 05:14:19 2017	(r313523)
@@ -674,13 +674,13 @@ udp_input(struct mbuf **mp, int *offp, i
 		    INPLOOKUP_RLOCKPCB, ifp, m);
 	if (inp == NULL) {
 		if (udp_log_in_vain) {
-			char buf[4*sizeof "123"];
+			char src[INET_ADDRSTRLEN];
+			char dst[INET_ADDRSTRLEN];
 
-			strcpy(buf, inet_ntoa(ip->ip_dst));
 			log(LOG_INFO,
 			    "Connection attempt to UDP %s:%d from %s:%d\n",
-			    buf, ntohs(uh->uh_dport), inet_ntoa(ip->ip_src),
-			    ntohs(uh->uh_sport));
+			    inet_ntoa_r(ip->ip_dst, dst), ntohs(uh->uh_dport),
+			    inet_ntoa_r(ip->ip_src, src), ntohs(uh->uh_sport));
 		}
 		UDPSTAT_INC(udps_noport);
 		if (m->m_flags & (M_BCAST | M_MCAST)) {



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