From edf0313b70885f86bf08cedaf6dc417bb2676dc5 Mon Sep 17 00:00:00 2001 From: Eric van Gyzen Date: Tue, 7 Feb 2017 18:57:57 +0000 Subject: [PATCH 1/2] Fix garbage IP addresses in UDP log_in_vain messages If multiple threads emit a UDP log_in_vain message concurrently, 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. Reported by: Mark Martinec MFC after: 3 days Relnotes: yes Sponsored by: Dell EMC --- sys/netinet/udp_usrreq.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 259fe0d22cc0..f24499dbd7f3 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -667,13 +667,13 @@ udp_input(struct mbuf **mp, int *offp, int proto) 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)) { From 58256cf76e583bbc2670d017900d97c3e6394754 Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Tue, 7 Feb 2017 19:28:32 +0000 Subject: [PATCH 2/2] Rename timer.c to a10_timer.c Requested by: andrew --- sys/arm/allwinner/{timer.c => a10_timer.c} | 0 sys/arm/allwinner/files.allwinner_up | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename sys/arm/allwinner/{timer.c => a10_timer.c} (100%) diff --git a/sys/arm/allwinner/timer.c b/sys/arm/allwinner/a10_timer.c similarity index 100% rename from sys/arm/allwinner/timer.c rename to sys/arm/allwinner/a10_timer.c diff --git a/sys/arm/allwinner/files.allwinner_up b/sys/arm/allwinner/files.allwinner_up index d90f99d53bcd..c776c3de791e 100644 --- a/sys/arm/allwinner/files.allwinner_up +++ b/sys/arm/allwinner/files.allwinner_up @@ -1,3 +1,3 @@ # $FreeBSD$ -arm/allwinner/timer.c standard +arm/allwinner/a10_timer.c standard