CVS commit: src/sys/netinet

2018-01-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Jan 23 07:33:49 UTC 2018

Modified Files:
src/sys/netinet: ip_icmp.c

Log Message:
Don't use global variables, that's obviously incorrect on MP systems.
One remains, because it is imported in tcp_timer.c, and I'm not totally
sure of how it interacts with icmp_mtudisc().


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/sys/netinet/ip_icmp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/ip_icmp.c
diff -u src/sys/netinet/ip_icmp.c:1.165 src/sys/netinet/ip_icmp.c:1.166
--- src/sys/netinet/ip_icmp.c:1.165	Tue Jan 23 07:15:04 2018
+++ src/sys/netinet/ip_icmp.c	Tue Jan 23 07:33:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_icmp.c,v 1.165 2018/01/23 07:15:04 maxv Exp $	*/
+/*	$NetBSD: ip_icmp.c,v 1.166 2018/01/23 07:33:49 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.165 2018/01/23 07:15:04 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.166 2018/01/23 07:33:49 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -403,21 +403,9 @@ freeit:
 }
 
 struct sockaddr_in icmpsrc = {
-	.sin_len = sizeof (struct sockaddr_in),
+	.sin_len = sizeof(struct sockaddr_in),
 	.sin_family = AF_INET,
 };
-static struct sockaddr_in icmpdst = {
-	.sin_len = sizeof (struct sockaddr_in),
-	.sin_family = AF_INET,
-};
-static struct sockaddr_in icmpgw = {
-	.sin_len = sizeof (struct sockaddr_in),
-	.sin_family = AF_INET,
-};
-struct sockaddr_in icmpmask = { 
-	.sin_len = 8,
-	.sin_family = 0,
-};
 
 /*
  * Process a received ICMP message.
@@ -433,6 +421,14 @@ _icmp_input(struct mbuf *m, int hlen, in
 	void *(*ctlfunc)(int, const struct sockaddr *, void *);
 	int code;
 	struct rtentry *rt;
+	struct sockaddr_in icmpdst = {
+		.sin_len = sizeof(struct sockaddr_in),
+		.sin_family = AF_INET,
+	};
+	struct sockaddr_in icmpgw = {
+		.sin_len = sizeof(struct sockaddr_in),
+		.sin_family = AF_INET,
+	};
 
 	/*
 	 * Locate icmp structure in mbuf, and check
@@ -799,8 +795,6 @@ icmp_reflect(struct mbuf *m)
 
 	sin = ia ? >ia_addr : NULL;
 
-	icmpdst.sin_addr = t;
-
 	/*
 	 * if the packet is addressed somewhere else, compute the
 	 * source address for packets routed back to the source, and



CVS commit: src/sys/net

2018-01-22 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jan 23 07:20:10 UTC 2018

Modified Files:
src/sys/net: route.c

Log Message:
Fix a return value of rt_update_prepare

Callers expect it to be an errno.


To generate a diff of this commit:
cvs rdiff -u -r1.204 -r1.205 src/sys/net/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/route.c
diff -u src/sys/net/route.c:1.204 src/sys/net/route.c:1.205
--- src/sys/net/route.c:1.204	Fri Jan 19 08:01:05 2018
+++ src/sys/net/route.c	Tue Jan 23 07:20:10 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.204 2018/01/19 08:01:05 ozaki-r Exp $	*/
+/*	$NetBSD: route.c,v 1.205 2018/01/23 07:20:10 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.204 2018/01/19 08:01:05 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.205 2018/01/23 07:20:10 ozaki-r Exp $");
 
 #include 
 #ifdef RTFLUSH_DEBUG
@@ -747,7 +747,7 @@ rt_update_prepare(struct rtentry *rt)
 	/* If the entry is being destroyed, don't proceed the update. */
 	if (!ISSET(rt->rt_flags, RTF_UP)) {
 		RT_UNLOCK();
-		return -1;
+		return ESRCH;
 	}
 	rt->rt_flags |= RTF_UPDATING;
 	RT_UNLOCK();



CVS commit: src/sys/netinet

2018-01-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Jan 23 07:15:04 UTC 2018

Modified Files:
src/sys/netinet: ip_icmp.c ip_icmp.h

Log Message:
Style, localify icmp_send, and add a clear KASSERT (that replaces a vague
comment).


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/sys/netinet/ip_icmp.c
cvs rdiff -u -r1.37 -r1.38 src/sys/netinet/ip_icmp.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/ip_icmp.c
diff -u src/sys/netinet/ip_icmp.c:1.164 src/sys/netinet/ip_icmp.c:1.165
--- src/sys/netinet/ip_icmp.c:1.164	Mon Jan 22 06:56:25 2018
+++ src/sys/netinet/ip_icmp.c	Tue Jan 23 07:15:04 2018
@@ -1,35 +1,6 @@
-/*	$NetBSD: ip_icmp.c,v 1.164 2018/01/22 06:56:25 maxv Exp $	*/
+/*	$NetBSD: ip_icmp.c,v 1.165 2018/01/23 07:15:04 maxv Exp $	*/
 
 /*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- *may be used to endorse or promote products derived from this software
- *without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
@@ -63,6 +34,35 @@
  */
 
 /*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
  * Copyright (c) 1982, 1986, 1988, 1993
  *	The Regents of the University of California.  All rights reserved.
  *
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.164 2018/01/22 06:56:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.165 2018/01/23 07:15:04 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -130,7 +130,7 @@ __KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 
 #ifdef IPSEC
 #include 
 #include 
-#endif	/* IPSEC*/
+#endif
 
 /*
  * ICMP routines: error generation, receive packet processing, and
@@ -138,12 +138,12 @@ __KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 
  * host table maintenance routines.
  */
 
-int	icmpmaskrepl = 0;
-int	icmpbmcastecho = 0;
+int icmpmaskrepl = 0;
+int icmpbmcastecho = 0;
 #ifdef 

CVS commit: src/sys/netinet6

2018-01-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Jan 23 07:02:57 UTC 2018

Modified Files:
src/sys/netinet6: icmp6.c

Log Message:
Style, and four fixes:

 * Remove the (disabled) IPPROTO_ESP check. If the packet was decrypted it
   will have M_DECRYPTED, and this is already checked.

 * Memory leaks in icmp6_error2. They seem hardly triggerable.

 * Fix miscomputation in _icmp6_input, the ICMP6 header is not guaranteed
   to be located right after the IP6 header. ok mlelstv@

 * Memory leak in _icmp6_input. This one seems to be impossible to trigger.


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/sys/netinet6/icmp6.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet6/icmp6.c
diff -u src/sys/netinet6/icmp6.c:1.214 src/sys/netinet6/icmp6.c:1.215
--- src/sys/netinet6/icmp6.c:1.214	Sun Nov  5 07:03:37 2017
+++ src/sys/netinet6/icmp6.c	Tue Jan 23 07:02:57 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: icmp6.c,v 1.214 2017/11/05 07:03:37 ozaki-r Exp $	*/
+/*	$NetBSD: icmp6.c,v 1.215 2018/01/23 07:02:57 maxv Exp $	*/
 /*	$KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.214 2017/11/05 07:03:37 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.215 2018/01/23 07:02:57 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -292,8 +292,7 @@ icmp6_error2(struct mbuf *m, int type, i
 {
 	struct ip6_hdr *ip6;
 
-	if (ifp == NULL)
-		return;
+	KASSERT(ifp != NULL);
 
 	if (m->m_len < sizeof(struct ip6_hdr)) {
 		m = m_pullup(m, sizeof(struct ip6_hdr));
@@ -304,11 +303,15 @@ icmp6_error2(struct mbuf *m, int type, i
 	ip6 = mtod(m, struct ip6_hdr *);
 
 	if (in6_setscope(>ip6_src, ifp, NULL) != 0)
-		return;
+		goto out;
 	if (in6_setscope(>ip6_dst, ifp, NULL) != 0)
-		return;
+		goto out;
 
 	icmp6_error(m, type, code, param);
+	return;
+
+out:
+	m_freem(m);
 }
 
 /*
@@ -344,7 +347,7 @@ icmp6_error(struct mbuf *m, int type, in
 	 * we should basically suppress sending an error (RFC 2463, Section
 	 * 2.4).
 	 * We have two exceptions (the item e.2 in that section):
-	 * - the Pakcet Too Big message can be sent for path MTU discovery.
+	 * - the Packet Too Big message can be sent for path MTU discovery.
 	 * - the Parameter Problem Message that can be allowed an icmp6 error
 	 *   in the option type field.  This check has been done in
 	 *   ip6_unknown_opt(), so we can just check the type and code.
@@ -391,18 +394,7 @@ icmp6_error(struct mbuf *m, int type, in
 		} else {
 			/* ICMPv6 informational - send the error */
 		}
-	}
-#if 0 /* controversial */
-	else if (off >= 0 && nxt == IPPROTO_ESP) {
-		/*
-		 * It could be ICMPv6 error inside ESP.  Take a safer side,
-		 * don't respond.
-		 */
-		ICMP6_STATINC(ICMP6_STAT_CANTERROR);
-		goto freeit;
-	}
-#endif
-	else {
+	} else {
 		/* non-ICMPv6 - send the error */
 	}
 
@@ -452,11 +444,13 @@ icmp6_error(struct mbuf *m, int type, in
 	m_reset_rcvif(m);
 
 	ICMP6_STATINC(ICMP6_STAT_OUTHIST + type);
-	icmp6_reflect(m, sizeof(struct ip6_hdr)); /* header order: IPv6 - ICMPv6 */
+
+	/* header order: IPv6 - ICMPv6 */
+	icmp6_reflect(m, sizeof(struct ip6_hdr));
 
 	return;
 
-  freeit:
+freeit:
 	/*
 	 * If we can't tell whether or not we can generate ICMP6, free it.
 	 */
@@ -473,7 +467,7 @@ _icmp6_input(struct mbuf *m, int off, in
 	struct ip6_hdr *ip6, *nip6;
 	struct icmp6_hdr *icmp6, *nicmp6;
 	int icmp6len = m->m_pkthdr.len - off;
-	int code, sum, noff;
+	int code, sum;
 	struct ifnet *rcvif;
 	struct psref psref;
 	char ip6buf[INET6_ADDRSTRLEN], ip6buf2[INET6_ADDRSTRLEN];
@@ -513,6 +507,7 @@ _icmp6_input(struct mbuf *m, int off, in
 		icmp6_ifstat_inc(rcvif, ifs6_in_error);
 		goto freeit;
 	}
+
 	/*
 	 * Enforce alignment requirements that are violated in
 	 * some cases, see kern/50766 for details.
@@ -525,7 +520,7 @@ _icmp6_input(struct mbuf *m, int off, in
 			goto freeit;
 		}
 		ip6 = mtod(m, struct ip6_hdr *);
-		icmp6 = (struct icmp6_hdr *)(ip6 + 1);
+		icmp6 = (struct icmp6_hdr *)(mtod(m, char *) + off);
 	}
 	KASSERT(IP6_HDR_ALIGNED_P(icmp6));
 
@@ -739,8 +734,6 @@ _icmp6_input(struct mbuf *m, int off, in
 			n = m_copym(m, 0, M_COPYALL, M_DONTWAIT);
 			if (n)
 n = ni6_input(n, off);
-			/* XXX meaningless if n == NULL */
-			noff = sizeof(struct ip6_hdr);
 		} else {
 			u_char *p;
 			int maxhlen;
@@ -765,34 +758,36 @@ _icmp6_input(struct mbuf *m, int off, in
 			m_reset_rcvif(n);
 			n->m_len = 0;
 			maxhlen = M_TRAILINGSPACE(n) - ICMP6_MAXLEN;
-			if (maxhlen < 0)
+			if (maxhlen < 0) {
+m_free(n);
 break;
+			}
 			if (maxhlen > hostnamelen)
 maxhlen = hostnamelen;
 			/*
 			 * Copy IPv6 and ICMPv6 only.
 			 */
 			nip6 = mtod(n, struct ip6_hdr *);
-			bcopy(ip6, nip6, sizeof(struct ip6_hdr));
+			memcpy(nip6, ip6, sizeof(struct ip6_hdr));
 			nicmp6 = (struct icmp6_hdr *)(nip6 + 1);
-			bcopy(icmp6, 

CVS commit: src/sys/arch/mips/cavium

2018-01-22 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue Jan 23 06:57:49 UTC 2018

Modified Files:
src/sys/arch/mips/cavium: octeon_cpunode.c

Log Message:
if 0 out unused code which is currently breaking my local builds


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/mips/cavium/octeon_cpunode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/mips/cavium/octeon_cpunode.c
diff -u src/sys/arch/mips/cavium/octeon_cpunode.c:1.11 src/sys/arch/mips/cavium/octeon_cpunode.c:1.12
--- src/sys/arch/mips/cavium/octeon_cpunode.c:1.11	Mon Jan 22 21:56:46 2018
+++ src/sys/arch/mips/cavium/octeon_cpunode.c	Tue Jan 23 06:57:49 2018
@@ -29,7 +29,7 @@
 #define __INTR_PRIVATE
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: octeon_cpunode.c,v 1.11 2018/01/22 21:56:46 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_cpunode.c,v 1.12 2018/01/23 06:57:49 maya Exp $");
 
 #include "locators.h"
 #include "cpunode.h"
@@ -453,10 +453,12 @@ wdog_cpunode_attach(device_t parent, dev
 	 * We need one softint per cpu.  It's to tickle the softints on
 	 * other CPUs.
 	 */
+#if 0 /* XXX unused? */
 	CPU_INFO_ITERATOR cii;
 	struct cpu_info *ci;
 	for (CPU_INFO_FOREACH(cii, ci)) {
 	}
+#endif
 
 aprint_normal(": default period is %u second%s\n",
 sc->sc_wdog_period, sc->sc_wdog_period == 1 ? "" : "s");



CVS commit: [perseant-stdc-iso10646] src

2018-01-22 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Tue Jan 23 03:12:11 UTC 2018

Modified Files:
src/lib/libc/citrus [perseant-stdc-iso10646]: citrus_ctype.h
citrus_none.c
src/tests/lib/libc/locale [perseant-stdc-iso10646]: t_toupper.c

Log Message:
Make the tests pass once more when __STDC_ISO_10646__ is not defined.


To generate a diff of this commit:
cvs rdiff -u -r1.3.22.2 -r1.3.22.3 src/lib/libc/citrus/citrus_ctype.h
cvs rdiff -u -r1.22.2.2 -r1.22.2.3 src/lib/libc/citrus/citrus_none.c
cvs rdiff -u -r1.1 -r1.1.4.1 src/tests/lib/libc/locale/t_toupper.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/citrus/citrus_ctype.h
diff -u src/lib/libc/citrus/citrus_ctype.h:1.3.22.2 src/lib/libc/citrus/citrus_ctype.h:1.3.22.3
--- src/lib/libc/citrus/citrus_ctype.h:1.3.22.2	Mon Jul 31 04:23:35 2017
+++ src/lib/libc/citrus/citrus_ctype.h	Tue Jan 23 03:12:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: citrus_ctype.h,v 1.3.22.2 2017/07/31 04:23:35 perseant Exp $	*/
+/*	$NetBSD: citrus_ctype.h,v 1.3.22.3 2018/01/23 03:12:11 perseant Exp $	*/
 
 /*-
  * Copyright (c)2002 Citrus Project,
@@ -206,8 +206,8 @@ _citrus_ctype_kt2ucs(_citrus_ctype_t cc,
 }
 #else
 /* Define away the calls to these functions */
-#define _citrus_ctype_ucs2kt(cl, ktp, wc) do {} while (0)
-#define _citrus_ctype_kt2ucs(cl, up, kt) do {} while (0)
+#define _citrus_ctype_ucs2kt(cl, ktp, wc) do { *ktp = wc; } while (0)
+#define _citrus_ctype_kt2ucs(cl, up, kt) do { *up = kt; } while (0)
 #endif
 
 extern _citrus_ctype_rec_t _citrus_ctype_default;

Index: src/lib/libc/citrus/citrus_none.c
diff -u src/lib/libc/citrus/citrus_none.c:1.22.2.2 src/lib/libc/citrus/citrus_none.c:1.22.2.3
--- src/lib/libc/citrus/citrus_none.c:1.22.2.2	Fri Jul 21 20:22:29 2017
+++ src/lib/libc/citrus/citrus_none.c	Tue Jan 23 03:12:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: citrus_none.c,v 1.22.2.2 2017/07/21 20:22:29 perseant Exp $	*/
+/*	$NetBSD: citrus_none.c,v 1.22.2.3 2018/01/23 03:12:11 perseant Exp $	*/
 
 /*-
  * Copyright (c)2002 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_none.c,v 1.22.2.2 2017/07/21 20:22:29 perseant Exp $");
+__RCSID("$NetBSD: citrus_none.c,v 1.22.2.3 2018/01/23 03:12:11 perseant Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include 
@@ -493,6 +493,10 @@ _citrus_NONE_ctype_ucs2kt(void * __restr
 			  wchar_kuten_t * __restrict ktp,
 			  wchar_ucs4_t wc)
 {
+#ifndef __STDC_ISO_10646__
+	*ktp = wc;
+	return 0;
+#else /* __STDC_ISO_10646__ */
 	struct _NONE_Info *nip = (struct _NONE_Info *)cl;
 	struct unicode2kuten_lookup *uk = NULL;
 
@@ -514,6 +518,7 @@ _citrus_NONE_ctype_ucs2kt(void * __restr
 	else
 		*ktp = WEOF;
 	return 0;
+#endif /* __STDC_ISO_10646__ */
 }
 
 static int
@@ -522,6 +527,10 @@ _citrus_NONE_ctype_kt2ucs(void * __restr
 			  wchar_ucs4_t * __restrict up,
 			  wchar_kuten_t kt)
 {
+#ifndef __STDC_ISO_10646__
+	*up = kt;
+	return 0;
+#else /* __STDC_ISO_10646__ */
 	if (cl == NULL) {
 		*up = kt;
 		return 0;
@@ -529,6 +538,7 @@ _citrus_NONE_ctype_kt2ucs(void * __restr
 
 	*up = ((struct _NONE_Info *)cl)->forward[kt];
 	return 0;
+#endif /* __STDC_ISO_10646__ */
 }
 
 /* -- */

Index: src/tests/lib/libc/locale/t_toupper.c
diff -u src/tests/lib/libc/locale/t_toupper.c:1.1 src/tests/lib/libc/locale/t_toupper.c:1.1.4.1
--- src/tests/lib/libc/locale/t_toupper.c:1.1	Tue May 30 02:11:03 2017
+++ src/tests/lib/libc/locale/t_toupper.c	Tue Jan 23 03:12:11 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: t_toupper.c,v 1.1 2017/05/30 02:11:03 perseant Exp $ */
+/* $NetBSD: t_toupper.c,v 1.1.4.1 2018/01/23 03:12:11 perseant Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2017\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_toupper.c,v 1.1 2017/05/30 02:11:03 perseant Exp $");
+__RCSID("$NetBSD: t_toupper.c,v 1.1.4.1 2018/01/23 03:12:11 perseant Exp $");
 
 #include 
 #include 
@@ -71,6 +71,7 @@ h_swapcase(const struct test *t, int upp
 	ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
 	printf("Trying locale %s...\n", t->locale);
 	ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL);
+	printf("Using locale: %s\n", setlocale(LC_ALL, NULL));
 
 	for (i = 0; i < strlen(t->lower); i++) {
 		printf("Comparing char %d, lower %2.2x, with upper %2.2x\n",



CVS commit: src/sys/netipsec

2018-01-22 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jan 23 02:21:49 UTC 2018

Modified Files:
src/sys/netipsec: ipsec_input.c

Log Message:
Add missing NULL-checking for m_pullup (CID 1427770: Null pointer dereferences 
(NULL_RETURNS))


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/netipsec/ipsec_input.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netipsec/ipsec_input.c
diff -u src/sys/netipsec/ipsec_input.c:1.52 src/sys/netipsec/ipsec_input.c:1.53
--- src/sys/netipsec/ipsec_input.c:1.52	Tue Jan 23 02:18:57 2018
+++ src/sys/netipsec/ipsec_input.c	Tue Jan 23 02:21:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsec_input.c,v 1.52 2018/01/23 02:18:57 ozaki-r Exp $	*/
+/*	$NetBSD: ipsec_input.c,v 1.53 2018/01/23 02:21:49 ozaki-r Exp $	*/
 /*	$FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec_input.c,v 1.2.4.2 2003/03/28 20:32:53 sam Exp $	*/
 /*	$OpenBSD: ipsec_input.c,v 1.63 2003/02/20 18:35:43 deraadt Exp $	*/
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.52 2018/01/23 02:18:57 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.53 2018/01/23 02:21:49 ozaki-r Exp $");
 
 /*
  * IPsec input processing.
@@ -133,8 +133,11 @@ ipsec4_fixup_checksum(struct mbuf *m)
 	int poff, off;
 	int plen;
 
-	if (m->m_len < sizeof(*ip))
+	if (m->m_len < sizeof(*ip)) {
 		m = m_pullup(m, sizeof(*ip));
+		if (m == NULL)
+			return NULL;
+	}
 	ip = mtod(m, struct ip *); 
 	poff = ip->ip_hl << 2;
 	plen = ntohs(ip->ip_len) - poff;



CVS commit: src/sys/netipsec

2018-01-22 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jan 23 02:18:57 UTC 2018

Modified Files:
src/sys/netipsec: ipsec_input.c

Log Message:
KNF: replace soft tabs with hard tabs


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/netipsec/ipsec_input.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netipsec/ipsec_input.c
diff -u src/sys/netipsec/ipsec_input.c:1.51 src/sys/netipsec/ipsec_input.c:1.52
--- src/sys/netipsec/ipsec_input.c:1.51	Thu Aug  3 06:32:51 2017
+++ src/sys/netipsec/ipsec_input.c	Tue Jan 23 02:18:57 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsec_input.c,v 1.51 2017/08/03 06:32:51 ozaki-r Exp $	*/
+/*	$NetBSD: ipsec_input.c,v 1.52 2018/01/23 02:18:57 ozaki-r Exp $	*/
 /*	$FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec_input.c,v 1.2.4.2 2003/03/28 20:32:53 sam Exp $	*/
 /*	$OpenBSD: ipsec_input.c,v 1.63 2003/02/20 18:35:43 deraadt Exp $	*/
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.51 2017/08/03 06:32:51 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.52 2018/01/23 02:18:57 ozaki-r Exp $");
 
 /*
  * IPsec input processing.
@@ -127,49 +127,49 @@ do {	\
 static struct mbuf *
 ipsec4_fixup_checksum(struct mbuf *m)
 {
-   struct ip *ip;
-   struct tcphdr *th;
-   struct udphdr *uh;
-   int poff, off;
-   int plen;
-
-   if (m->m_len < sizeof(*ip))
-   m = m_pullup(m, sizeof(*ip));
-   ip = mtod(m, struct ip *); 
-   poff = ip->ip_hl << 2;
-   plen = ntohs(ip->ip_len) - poff;
-
-   switch (ip->ip_p) {
-   case IPPROTO_TCP:
-   IP6_EXTHDR_GET(th, struct tcphdr *, m, poff, sizeof(*th));
-   if (th == NULL)
-   return NULL;
-   off = th->th_off << 2;
-   if (off < sizeof(*th) || off > plen) {
-   m_freem(m);
-   return NULL;
-   }
-   th->th_sum = 0;
-   th->th_sum = in4_cksum(m, IPPROTO_TCP, poff, plen);
-   break;
-   case IPPROTO_UDP:
-   IP6_EXTHDR_GET(uh, struct udphdr *, m, poff, sizeof(*uh));
-   if (uh == NULL)
-   return NULL;
-   off = sizeof(*uh); 
-   if (off > plen) {  
-   m_freem(m);
-   return NULL;
-   }
-   uh->uh_sum = 0;
-   uh->uh_sum = in4_cksum(m, IPPROTO_UDP, poff, plen);
-   break;
-   default:
-   /* no checksum */  
-   return m;
-   }
+	struct ip *ip;
+	struct tcphdr *th;
+	struct udphdr *uh;
+	int poff, off;
+	int plen;
+
+	if (m->m_len < sizeof(*ip))
+		m = m_pullup(m, sizeof(*ip));
+	ip = mtod(m, struct ip *); 
+	poff = ip->ip_hl << 2;
+	plen = ntohs(ip->ip_len) - poff;
+
+	switch (ip->ip_p) {
+	case IPPROTO_TCP:
+		IP6_EXTHDR_GET(th, struct tcphdr *, m, poff, sizeof(*th));
+		if (th == NULL)
+			return NULL;
+		off = th->th_off << 2;
+		if (off < sizeof(*th) || off > plen) {
+			m_freem(m);
+			return NULL;
+		}
+		th->th_sum = 0;
+		th->th_sum = in4_cksum(m, IPPROTO_TCP, poff, plen);
+		break;
+	case IPPROTO_UDP:
+		IP6_EXTHDR_GET(uh, struct udphdr *, m, poff, sizeof(*uh));
+		if (uh == NULL)
+			return NULL;
+		off = sizeof(*uh); 
+		if (off > plen) {  
+			m_freem(m);
+			return NULL;
+		}
+		uh->uh_sum = 0;
+		uh->uh_sum = in4_cksum(m, IPPROTO_UDP, poff, plen);
+		break;
+	default:
+		/* no checksum */  
+		return m;
+	}
 
-   return m;
+	return m;
 }
 
 /*



CVS commit: src/sys/netipsec

2018-01-22 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jan 23 02:17:32 UTC 2018

Modified Files:
src/sys/netipsec: ipsec.c

Log Message:
Fix late NULL-checking (CID 1427782: Null pointer dereferences (REVERSE_INULL))


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/netipsec/ipsec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netipsec/ipsec.c
diff -u src/sys/netipsec/ipsec.c:1.123 src/sys/netipsec/ipsec.c:1.124
--- src/sys/netipsec/ipsec.c:1.123	Tue Nov 21 07:03:08 2017
+++ src/sys/netipsec/ipsec.c	Tue Jan 23 02:17:32 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsec.c,v 1.123 2017/11/21 07:03:08 ozaki-r Exp $	*/
+/*	$NetBSD: ipsec.c,v 1.124 2018/01/23 02:17:32 ozaki-r Exp $	*/
 /*	$FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec.c,v 1.2.2.2 2003/07/01 01:38:13 sam Exp $	*/
 /*	$KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.123 2017/11/21 07:03:08 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.124 2018/01/23 02:17:32 ozaki-r Exp $");
 
 /*
  * IPsec controller part.
@@ -1444,11 +1444,10 @@ ipsec4_set_policy(struct inpcb *inp, int
 	struct secpolicy **policy;
 
 	KASSERT(!cpu_softintr_p());
+	KASSERT(inp != NULL);
 	KASSERT(inp_locked(inp));
+	KASSERT(request != NULL);
 
-	/* sanity check. */
-	if (inp == NULL || request == NULL)
-		return EINVAL;
 	if (len < sizeof(*xpl))
 		return EINVAL;
 	xpl = (const struct sadb_x_policy *)request;



CVS commit: src/sys/arch/mips/include

2018-01-22 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Jan 22 23:20:26 UTC 2018

Modified Files:
src/sys/arch/mips/include: cpu.h

Log Message:
Don't attempt to dereference cpu_infos if ncpus == 0.
Instead use the already initialized cpu_info_store.

(Also, now we assume all ncpus have cpu_infos initialized. seems to work.)

fixes PR port-mips/52940: ERLITE multiprocessor hangs early


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/arch/mips/include/cpu.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/mips/include/cpu.h
diff -u src/sys/arch/mips/include/cpu.h:1.122 src/sys/arch/mips/include/cpu.h:1.123
--- src/sys/arch/mips/include/cpu.h:1.122	Sat Dec 16 00:37:52 2017
+++ src/sys/arch/mips/include/cpu.h	Mon Jan 22 23:20:26 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.122 2017/12/16 00:37:52 mrg Exp $	*/
+/*	$NetBSD: cpu.h,v 1.123 2018/01/22 23:20:26 maya Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -160,7 +160,9 @@ struct cpu_info {
 #ifdef MULTIPROCESSOR
 #define	CPU_INFO_ITERATOR		int
 #define	CPU_INFO_FOREACH(cii, ci)	\
-cii = 0, ci = cpu_infos[0]; cii < (ncpu ? ncpu : 1) && (ci = cpu_infos[cii]) != NULL; cii++
+cii = 0, ci = (ncpu ? cpu_infos[0] : _info_store); \
+cii < (ncpu ? ncpu : 1); \
+++cii
 #else
 #define	CPU_INFO_ITERATOR		int __unused
 #define	CPU_INFO_FOREACH(cii, ci)	\



CVS commit: src/sys/arch/xen/conf

2018-01-22 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Jan 22 22:36:11 UTC 2018

Modified Files:
src/sys/arch/xen/conf: files.xen

Log Message:
xen has separate list, update here also for x86/pmap_tlb.c -> x86/x86_tlb.c


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/sys/arch/xen/conf/files.xen

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/conf/files.xen
diff -u src/sys/arch/xen/conf/files.xen:1.164 src/sys/arch/xen/conf/files.xen:1.165
--- src/sys/arch/xen/conf/files.xen:1.164	Sat Dec  2 13:03:15 2017
+++ src/sys/arch/xen/conf/files.xen	Mon Jan 22 22:36:11 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.xen,v 1.164 2017/12/02 13:03:15 maxv Exp $
+#	$NetBSD: files.xen,v 1.165 2018/01/22 22:36:11 jdolecek Exp $
 #	NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp 
 #	NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp 
 
@@ -143,7 +143,7 @@ file	arch/xen/x86/xen_ipi.c		multiproces
 file	arch/x86/x86/intr.c		machdep
 file	arch/x86/x86/idt.c		machdep
 file	arch/x86/x86/pmap.c		machdep
-file	arch/x86/x86/pmap_tlb.c		machdep
+file	arch/x86/x86/x86_tlb.c		machdep
 file	arch/x86/x86/procfs_machdep.c	procfs
 file	arch/x86/x86/sys_machdep.c	machdep
 file	arch/x86/x86/tsc.c		machdep



CVS commit: src/sys/arch/mips/cavium

2018-01-22 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Jan 22 21:56:47 UTC 2018

Modified Files:
src/sys/arch/mips/cavium: octeon_cpunode.c

Log Message:
Fix RCSID (hopefully)


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/mips/cavium/octeon_cpunode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/mips/cavium/octeon_cpunode.c
diff -u src/sys/arch/mips/cavium/octeon_cpunode.c:1.10 src/sys/arch/mips/cavium/octeon_cpunode.c:1.11
--- src/sys/arch/mips/cavium/octeon_cpunode.c:1.10	Fri Aug 19 10:20:42 2016
+++ src/sys/arch/mips/cavium/octeon_cpunode.c	Mon Jan 22 21:56:46 2018
@@ -29,7 +29,7 @@
 #define __INTR_PRIVATE
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD");
+__KERNEL_RCSID(0, "$NetBSD: octeon_cpunode.c,v 1.11 2018/01/22 21:56:46 maya Exp $");
 
 #include "locators.h"
 #include "cpunode.h"



CVS commit: [netbsd-7-1] src/doc

2018-01-22 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Jan 22 20:03:06 UTC 2018

Modified Files:
src/doc [netbsd-7-1]: CHANGES-7.1.2

Log Message:
1550, 1554


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/doc/CHANGES-7.1.2

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES-7.1.2
diff -u src/doc/CHANGES-7.1.2:1.1.2.2 src/doc/CHANGES-7.1.2:1.1.2.3
--- src/doc/CHANGES-7.1.2:1.1.2.2	Wed Jan  3 21:56:04 2018
+++ src/doc/CHANGES-7.1.2	Mon Jan 22 20:03:06 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.1.2,v 1.1.2.2 2018/01/03 21:56:04 snj Exp $
+# $NetBSD: CHANGES-7.1.2,v 1.1.2.3 2018/01/22 20:03:06 snj Exp $
 
 A complete list of changes from the NetBSD 7.1.1 release to the NetBSD 7.1.2
 release:
@@ -64,3 +64,17 @@ sys/kern/subr_kobj.c1.52
 	return an error status.  PR kern/45125
 	[pgoyette, ticket #1539]
 
+sys/arch/amd64/amd64/machdep.c			1.280 via patch
+sys/arch/amd64/include/segments.h		1.34 via patch
+sys/arch/i386/i386/machdep.c			1.800 via patch
+sys/arch/i386/include/segments.h		1.64 via patch
+sys/arch/x86/x86/vm_machdep.c			1.30 via patch
+
+	Prevent unrestricted userland access to I/O ports in XEN.
+	[maxv, ticket #1550]
+
+bin/ksh/history.c1.18 via patch
+
+	Create HISTFILE with mode 0600, not 777.  PR bin/52480.
+	[maya, ticket #1554]
+



CVS commit: [netbsd-7-0] src/doc

2018-01-22 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Jan 22 19:59:50 UTC 2018

Modified Files:
src/doc [netbsd-7-0]: CHANGES-7.0.3

Log Message:
1550, 1554


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.72 -r1.1.2.73 src/doc/CHANGES-7.0.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES-7.0.3
diff -u src/doc/CHANGES-7.0.3:1.1.2.72 src/doc/CHANGES-7.0.3:1.1.2.73
--- src/doc/CHANGES-7.0.3:1.1.2.72	Wed Jan  3 21:53:50 2018
+++ src/doc/CHANGES-7.0.3	Mon Jan 22 19:59:49 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.0.3,v 1.1.2.72 2018/01/03 21:53:50 snj Exp $
+# $NetBSD: CHANGES-7.0.3,v 1.1.2.73 2018/01/22 19:59:49 snj Exp $
 
 A complete list of changes from the NetBSD 7.0.2 release to the NetBSD 7.0.3
 release:
@@ -5176,3 +5176,17 @@ sys/kern/subr_kobj.c1.52
 	return an error status.  PR kern/45125
 	[pgoyette, ticket #1539]
 
+sys/arch/amd64/amd64/machdep.c			1.280 via patch
+sys/arch/amd64/include/segments.h		1.34 via patch
+sys/arch/i386/i386/machdep.c			1.800 via patch
+sys/arch/i386/include/segments.h		1.64 via patch
+sys/arch/x86/x86/vm_machdep.c			1.30 via patch
+
+	Prevent unrestricted userland access to I/O ports in XEN.
+	[maxv, ticket #1550]
+
+bin/ksh/history.c1.18 via patch
+
+	Create HISTFILE with mode 0600, not 777.  PR bin/52480.
+	[maya, ticket #1554]
+



CVS commit: [netbsd-7] src/bin/ksh

2018-01-22 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Jan 22 19:59:06 UTC 2018

Modified Files:
src/bin/ksh [netbsd-7]: history.c

Log Message:
Pull up following revision(s) (requested by maya in ticket #1554):
bin/ksh/history.c: revision 1.18 via patch
Use 0600 as the mode for histfile here too.
pointed out by John D. Baker in PR bin/52480


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.11.22.1 src/bin/ksh/history.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/ksh/history.c
diff -u src/bin/ksh/history.c:1.11 src/bin/ksh/history.c:1.11.22.1
--- src/bin/ksh/history.c:1.11	Wed Aug 31 16:24:54 2011
+++ src/bin/ksh/history.c	Mon Jan 22 19:59:06 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: history.c,v 1.11 2011/08/31 16:24:54 plunky Exp $	*/
+/*	$NetBSD: history.c,v 1.11.22.1 2018/01/22 19:59:06 snj Exp $	*/
 
 /*
  * command history
@@ -19,7 +19,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: history.c,v 1.11 2011/08/31 16:24:54 plunky Exp $");
+__RCSID("$NetBSD: history.c,v 1.11.22.1 2018/01/22 19:59:06 snj Exp $");
 #endif
 
 
@@ -757,7 +757,7 @@ hist_finish()
   else
 hp = histlist;
 
-  fd = open(hname, O_WRONLY | O_CREAT | O_TRUNC | O_EXLOCK, 0777);
+  fd = open(hname, O_WRONLY | O_CREAT | O_TRUNC | O_EXLOCK, 0600);
   /* Remove anything written before we got the lock */
   ftruncate(fd, 0);
   if (fd >= 0 && (fh = fdopen(fd, "w"))) {



CVS commit: [netbsd-7-1] src/bin/ksh

2018-01-22 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Jan 22 19:58:38 UTC 2018

Modified Files:
src/bin/ksh [netbsd-7-1]: history.c

Log Message:
Pull up following revision(s) (requested by maya in ticket #1554):
bin/ksh/history.c: revision 1.18 via patch
Use 0600 as the mode for histfile here too.
pointed out by John D. Baker in PR bin/52480


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.11.30.1 src/bin/ksh/history.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/ksh/history.c
diff -u src/bin/ksh/history.c:1.11 src/bin/ksh/history.c:1.11.30.1
--- src/bin/ksh/history.c:1.11	Wed Aug 31 16:24:54 2011
+++ src/bin/ksh/history.c	Mon Jan 22 19:58:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: history.c,v 1.11 2011/08/31 16:24:54 plunky Exp $	*/
+/*	$NetBSD: history.c,v 1.11.30.1 2018/01/22 19:58:38 snj Exp $	*/
 
 /*
  * command history
@@ -19,7 +19,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: history.c,v 1.11 2011/08/31 16:24:54 plunky Exp $");
+__RCSID("$NetBSD: history.c,v 1.11.30.1 2018/01/22 19:58:38 snj Exp $");
 #endif
 
 
@@ -757,7 +757,7 @@ hist_finish()
   else
 hp = histlist;
 
-  fd = open(hname, O_WRONLY | O_CREAT | O_TRUNC | O_EXLOCK, 0777);
+  fd = open(hname, O_WRONLY | O_CREAT | O_TRUNC | O_EXLOCK, 0600);
   /* Remove anything written before we got the lock */
   ftruncate(fd, 0);
   if (fd >= 0 && (fh = fdopen(fd, "w"))) {



CVS commit: [netbsd-7-0] src/bin/ksh

2018-01-22 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Jan 22 19:57:17 UTC 2018

Modified Files:
src/bin/ksh [netbsd-7-0]: history.c

Log Message:
Pull up following revision(s) (requested by maya in ticket #1554):
bin/ksh/history.c: revision 1.18 via patch
Use 0600 as the mode for histfile here too.
pointed out by John D. Baker in PR bin/52480


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.11.24.1 src/bin/ksh/history.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/ksh/history.c
diff -u src/bin/ksh/history.c:1.11 src/bin/ksh/history.c:1.11.24.1
--- src/bin/ksh/history.c:1.11	Wed Aug 31 16:24:54 2011
+++ src/bin/ksh/history.c	Mon Jan 22 19:57:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: history.c,v 1.11 2011/08/31 16:24:54 plunky Exp $	*/
+/*	$NetBSD: history.c,v 1.11.24.1 2018/01/22 19:57:17 snj Exp $	*/
 
 /*
  * command history
@@ -19,7 +19,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: history.c,v 1.11 2011/08/31 16:24:54 plunky Exp $");
+__RCSID("$NetBSD: history.c,v 1.11.24.1 2018/01/22 19:57:17 snj Exp $");
 #endif
 
 
@@ -757,7 +757,7 @@ hist_finish()
   else
 hp = histlist;
 
-  fd = open(hname, O_WRONLY | O_CREAT | O_TRUNC | O_EXLOCK, 0777);
+  fd = open(hname, O_WRONLY | O_CREAT | O_TRUNC | O_EXLOCK, 0600);
   /* Remove anything written before we got the lock */
   ftruncate(fd, 0);
   if (fd >= 0 && (fh = fdopen(fd, "w"))) {



CVS commit: [netbsd-7] src/sys/arch

2018-01-22 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Jan 22 19:41:08 UTC 2018

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-7]: machdep.c
src/sys/arch/amd64/include [netbsd-7]: segments.h
src/sys/arch/i386/i386 [netbsd-7]: machdep.c
src/sys/arch/i386/include [netbsd-7]: segments.h
src/sys/arch/x86/x86 [netbsd-7]: vm_machdep.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1550):
sys/arch/amd64/amd64/machdep.c: revision 1.280 via patch
sys/arch/amd64/include/segments.h: revision 1.34 via patch
sys/arch/i386/i386/machdep.c: revision 1.800 via patch
sys/arch/i386/include/segments.h: revision 1.64 via patch
sys/arch/x86/x86/vm_machdep.c: revision 1.30 via patch
Fix a huge privilege separation vulnerability in Xen-amd64.
On amd64 the kernel runs in ring3, like userland, and therefore SEL_KPL
equals SEL_UPL. While Xen can make a distinction between usermode and
kernelmode in %cs, it can't when it comes to iopl. Since we set SEL_KPL
in iopl, Xen sees SEL_UPL, and allows (unprivileged) userland processes
to read and write to the CPU ports.
It is easy, then, to completely escalate privileges; by reprogramming the
PIC, by reading the ATA disks, by intercepting the keyboard interrupts
(keylogger), etc.
Declare IOPL_KPL, set to 1 on Xen-amd64, which allows the kernel to use
the ports but not userland. I didn't test this change on i386, but it
seems fine enough.


To generate a diff of this commit:
cvs rdiff -u -r1.211.2.1 -r1.211.2.2 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.24 -r1.24.12.1 src/sys/arch/amd64/include/segments.h
cvs rdiff -u -r1.752.4.1 -r1.752.4.2 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.54 -r1.54.30.1 src/sys/arch/i386/include/segments.h
cvs rdiff -u -r1.25.4.1 -r1.25.4.2 src/sys/arch/x86/x86/vm_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.211.2.1 src/sys/arch/amd64/amd64/machdep.c:1.211.2.2
--- src/sys/arch/amd64/amd64/machdep.c:1.211.2.1	Wed Apr 26 14:52:50 2017
+++ src/sys/arch/amd64/amd64/machdep.c	Mon Jan 22 19:41:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.211.2.1 2017/04/26 14:52:50 martin Exp $	*/
+/*	$NetBSD: machdep.c,v 1.211.2.2 2018/01/22 19:41:08 snj Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.211.2.1 2017/04/26 14:52:50 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.211.2.2 2018/01/22 19:41:08 snj Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -468,7 +468,7 @@ x86_64_proc0_tss_ldt_init(void)
 	pcb->pcb_fs = 0;
 	pcb->pcb_gs = 0;
 	pcb->pcb_rsp0 = (uvm_lwp_getuarea(l) + USPACE - 16) & ~0xf;
-	pcb->pcb_iopl = SEL_KPL;
+	pcb->pcb_iopl = IOPL_KPL;
 
 	pmap_kernel()->pm_ldt_sel = GSYSSEL(GLDT_SEL, SEL_KPL);
 	pcb->pcb_cr0 = rcr0() & ~CR0_TS;

Index: src/sys/arch/amd64/include/segments.h
diff -u src/sys/arch/amd64/include/segments.h:1.24 src/sys/arch/amd64/include/segments.h:1.24.12.1
--- src/sys/arch/amd64/include/segments.h:1.24	Mon Jan  7 17:03:06 2013
+++ src/sys/arch/amd64/include/segments.h	Mon Jan 22 19:41:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: segments.h,v 1.24 2013/01/07 17:03:06 chs Exp $	*/
+/*	$NetBSD: segments.h,v 1.24.12.1 2018/01/22 19:41:08 snj Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -107,6 +107,12 @@
 #define	ISLDT(s)	((s) & SEL_LDT)	/* is it local or global */
 #define	SEL_LDT		4		/* local descriptor table */	
 
+#ifdef XEN
+#define IOPL_KPL	1
+#else
+#define IOPL_KPL	SEL_KPL
+#endif
+
 /* Dynamically allocated TSSs and LDTs start (byte offset) */
 #define SYSSEL_START	(NGDT_MEM << 3)
 #define DYNSEL_START	(SYSSEL_START + (NGDT_SYS << 4))

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.752.4.1 src/sys/arch/i386/i386/machdep.c:1.752.4.2
--- src/sys/arch/i386/i386/machdep.c:1.752.4.1	Thu Jul 20 01:43:40 2017
+++ src/sys/arch/i386/i386/machdep.c	Mon Jan 22 19:41:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.752.4.1 2017/07/20 01:43:40 snj Exp $	*/
+/*	$NetBSD: machdep.c,v 1.752.4.2 2018/01/22 19:41:08 snj Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.752.4.1 2017/07/20 01:43:40 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.752.4.2 2018/01/22 19:41:08 snj Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_ibcs2.h"
@@ -502,7 +502,7 @@ i386_proc0_tss_ldt_init(void)
 	pmap_kernel()->pm_ldt_sel = GSEL(GLDT_SEL, SEL_KPL);
 	pcb->pcb_cr0 = rcr0() & ~CR0_TS;
 	pcb->pcb_esp0 = uvm_lwp_getuarea(l) + USPACE - 16;
-	pcb->pcb_iopl = SEL_KPL;
+	pcb->pcb_iopl = IOPL_KPL;
 	l->l_md.md_regs = (struct trapframe *)pcb->pcb_esp0 - 1;
 	

CVS commit: [netbsd-7-1] src/sys/arch

2018-01-22 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Jan 22 19:40:59 UTC 2018

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-7-1]: machdep.c
src/sys/arch/amd64/include [netbsd-7-1]: segments.h
src/sys/arch/i386/i386 [netbsd-7-1]: machdep.c
src/sys/arch/i386/include [netbsd-7-1]: segments.h
src/sys/arch/x86/x86 [netbsd-7-1]: vm_machdep.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1550):
sys/arch/amd64/amd64/machdep.c: revision 1.280 via patch
sys/arch/amd64/include/segments.h: revision 1.34 via patch
sys/arch/i386/i386/machdep.c: revision 1.800 via patch
sys/arch/i386/include/segments.h: revision 1.64 via patch
sys/arch/x86/x86/vm_machdep.c: revision 1.30 via patch
Fix a huge privilege separation vulnerability in Xen-amd64.
On amd64 the kernel runs in ring3, like userland, and therefore SEL_KPL
equals SEL_UPL. While Xen can make a distinction between usermode and
kernelmode in %cs, it can't when it comes to iopl. Since we set SEL_KPL
in iopl, Xen sees SEL_UPL, and allows (unprivileged) userland processes
to read and write to the CPU ports.
It is easy, then, to completely escalate privileges; by reprogramming the
PIC, by reading the ATA disks, by intercepting the keyboard interrupts
(keylogger), etc.
Declare IOPL_KPL, set to 1 on Xen-amd64, which allows the kernel to use
the ports but not userland. I didn't test this change on i386, but it
seems fine enough.


To generate a diff of this commit:
cvs rdiff -u -r1.211.10.1 -r1.211.10.2 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.24 -r1.24.22.1 src/sys/arch/amd64/include/segments.h
cvs rdiff -u -r1.752.12.1 -r1.752.12.2 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.54 -r1.54.38.1 src/sys/arch/i386/include/segments.h
cvs rdiff -u -r1.25.4.1 -r1.25.4.1.2.1 src/sys/arch/x86/x86/vm_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.211.10.1 src/sys/arch/amd64/amd64/machdep.c:1.211.10.2
--- src/sys/arch/amd64/amd64/machdep.c:1.211.10.1	Wed Apr 26 14:51:58 2017
+++ src/sys/arch/amd64/amd64/machdep.c	Mon Jan 22 19:40:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.211.10.1 2017/04/26 14:51:58 martin Exp $	*/
+/*	$NetBSD: machdep.c,v 1.211.10.2 2018/01/22 19:40:58 snj Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.211.10.1 2017/04/26 14:51:58 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.211.10.2 2018/01/22 19:40:58 snj Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -468,7 +468,7 @@ x86_64_proc0_tss_ldt_init(void)
 	pcb->pcb_fs = 0;
 	pcb->pcb_gs = 0;
 	pcb->pcb_rsp0 = (uvm_lwp_getuarea(l) + USPACE - 16) & ~0xf;
-	pcb->pcb_iopl = SEL_KPL;
+	pcb->pcb_iopl = IOPL_KPL;
 
 	pmap_kernel()->pm_ldt_sel = GSYSSEL(GLDT_SEL, SEL_KPL);
 	pcb->pcb_cr0 = rcr0() & ~CR0_TS;

Index: src/sys/arch/amd64/include/segments.h
diff -u src/sys/arch/amd64/include/segments.h:1.24 src/sys/arch/amd64/include/segments.h:1.24.22.1
--- src/sys/arch/amd64/include/segments.h:1.24	Mon Jan  7 17:03:06 2013
+++ src/sys/arch/amd64/include/segments.h	Mon Jan 22 19:40:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: segments.h,v 1.24 2013/01/07 17:03:06 chs Exp $	*/
+/*	$NetBSD: segments.h,v 1.24.22.1 2018/01/22 19:40:58 snj Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -107,6 +107,12 @@
 #define	ISLDT(s)	((s) & SEL_LDT)	/* is it local or global */
 #define	SEL_LDT		4		/* local descriptor table */	
 
+#ifdef XEN
+#define IOPL_KPL	1
+#else
+#define IOPL_KPL	SEL_KPL
+#endif
+
 /* Dynamically allocated TSSs and LDTs start (byte offset) */
 #define SYSSEL_START	(NGDT_MEM << 3)
 #define DYNSEL_START	(SYSSEL_START + (NGDT_SYS << 4))

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.752.12.1 src/sys/arch/i386/i386/machdep.c:1.752.12.2
--- src/sys/arch/i386/i386/machdep.c:1.752.12.1	Thu Jul 20 01:43:10 2017
+++ src/sys/arch/i386/i386/machdep.c	Mon Jan 22 19:40:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.752.12.1 2017/07/20 01:43:10 snj Exp $	*/
+/*	$NetBSD: machdep.c,v 1.752.12.2 2018/01/22 19:40:58 snj Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.752.12.1 2017/07/20 01:43:10 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.752.12.2 2018/01/22 19:40:58 snj Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_ibcs2.h"
@@ -502,7 +502,7 @@ i386_proc0_tss_ldt_init(void)
 	pmap_kernel()->pm_ldt_sel = GSEL(GLDT_SEL, SEL_KPL);
 	pcb->pcb_cr0 = rcr0() & ~CR0_TS;
 	pcb->pcb_esp0 = uvm_lwp_getuarea(l) + USPACE - 16;
-	pcb->pcb_iopl = SEL_KPL;
+	pcb->pcb_iopl = IOPL_KPL;
 	l->l_md.md_regs = (struct 

CVS commit: [netbsd-7-0] src/sys/arch

2018-01-22 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Jan 22 19:40:25 UTC 2018

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-7-0]: machdep.c
src/sys/arch/amd64/include [netbsd-7-0]: segments.h
src/sys/arch/i386/i386 [netbsd-7-0]: machdep.c
src/sys/arch/i386/include [netbsd-7-0]: segments.h
src/sys/arch/x86/x86 [netbsd-7-0]: vm_machdep.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1550):
sys/arch/amd64/amd64/machdep.c: revision 1.280 via patch
sys/arch/amd64/include/segments.h: revision 1.34 via patch
sys/arch/i386/i386/machdep.c: revision 1.800 via patch
sys/arch/i386/include/segments.h: revision 1.64 via patch
sys/arch/x86/x86/vm_machdep.c: revision 1.30 via patch
Fix a huge privilege separation vulnerability in Xen-amd64.
On amd64 the kernel runs in ring3, like userland, and therefore SEL_KPL
equals SEL_UPL. While Xen can make a distinction between usermode and
kernelmode in %cs, it can't when it comes to iopl. Since we set SEL_KPL
in iopl, Xen sees SEL_UPL, and allows (unprivileged) userland processes
to read and write to the CPU ports.
It is easy, then, to completely escalate privileges; by reprogramming the
PIC, by reading the ATA disks, by intercepting the keyboard interrupts
(keylogger), etc.
Declare IOPL_KPL, set to 1 on Xen-amd64, which allows the kernel to use
the ports but not userland. I didn't test this change on i386, but it
seems fine enough.


To generate a diff of this commit:
cvs rdiff -u -r1.211.6.1 -r1.211.6.2 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.24 -r1.24.16.1 src/sys/arch/amd64/include/segments.h
cvs rdiff -u -r1.752.8.1 -r1.752.8.2 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.54 -r1.54.34.1 src/sys/arch/i386/include/segments.h
cvs rdiff -u -r1.25.8.1 -r1.25.8.2 src/sys/arch/x86/x86/vm_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.211.6.1 src/sys/arch/amd64/amd64/machdep.c:1.211.6.2
--- src/sys/arch/amd64/amd64/machdep.c:1.211.6.1	Wed Apr 26 14:50:51 2017
+++ src/sys/arch/amd64/amd64/machdep.c	Mon Jan 22 19:40:25 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.211.6.1 2017/04/26 14:50:51 martin Exp $	*/
+/*	$NetBSD: machdep.c,v 1.211.6.2 2018/01/22 19:40:25 snj Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.211.6.1 2017/04/26 14:50:51 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.211.6.2 2018/01/22 19:40:25 snj Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -468,7 +468,7 @@ x86_64_proc0_tss_ldt_init(void)
 	pcb->pcb_fs = 0;
 	pcb->pcb_gs = 0;
 	pcb->pcb_rsp0 = (uvm_lwp_getuarea(l) + USPACE - 16) & ~0xf;
-	pcb->pcb_iopl = SEL_KPL;
+	pcb->pcb_iopl = IOPL_KPL;
 
 	pmap_kernel()->pm_ldt_sel = GSYSSEL(GLDT_SEL, SEL_KPL);
 	pcb->pcb_cr0 = rcr0() & ~CR0_TS;

Index: src/sys/arch/amd64/include/segments.h
diff -u src/sys/arch/amd64/include/segments.h:1.24 src/sys/arch/amd64/include/segments.h:1.24.16.1
--- src/sys/arch/amd64/include/segments.h:1.24	Mon Jan  7 17:03:06 2013
+++ src/sys/arch/amd64/include/segments.h	Mon Jan 22 19:40:25 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: segments.h,v 1.24 2013/01/07 17:03:06 chs Exp $	*/
+/*	$NetBSD: segments.h,v 1.24.16.1 2018/01/22 19:40:25 snj Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -107,6 +107,12 @@
 #define	ISLDT(s)	((s) & SEL_LDT)	/* is it local or global */
 #define	SEL_LDT		4		/* local descriptor table */	
 
+#ifdef XEN
+#define IOPL_KPL	1
+#else
+#define IOPL_KPL	SEL_KPL
+#endif
+
 /* Dynamically allocated TSSs and LDTs start (byte offset) */
 #define SYSSEL_START	(NGDT_MEM << 3)
 #define DYNSEL_START	(SYSSEL_START + (NGDT_SYS << 4))

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.752.8.1 src/sys/arch/i386/i386/machdep.c:1.752.8.2
--- src/sys/arch/i386/i386/machdep.c:1.752.8.1	Thu Jul 20 01:42:39 2017
+++ src/sys/arch/i386/i386/machdep.c	Mon Jan 22 19:40:25 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.752.8.1 2017/07/20 01:42:39 snj Exp $	*/
+/*	$NetBSD: machdep.c,v 1.752.8.2 2018/01/22 19:40:25 snj Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.752.8.1 2017/07/20 01:42:39 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.752.8.2 2018/01/22 19:40:25 snj Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_ibcs2.h"
@@ -502,7 +502,7 @@ i386_proc0_tss_ldt_init(void)
 	pmap_kernel()->pm_ldt_sel = GSEL(GLDT_SEL, SEL_KPL);
 	pcb->pcb_cr0 = rcr0() & ~CR0_TS;
 	pcb->pcb_esp0 = uvm_lwp_getuarea(l) + USPACE - 16;
-	pcb->pcb_iopl = SEL_KPL;
+	pcb->pcb_iopl = IOPL_KPL;
 	l->l_md.md_regs = (struct trapframe *)pcb->pcb_esp0 - 

CVS commit: src/sys/arch/x86

2018-01-22 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Jan 22 19:37:45 UTC 2018

Modified Files:
src/sys/arch/x86/conf: files.x86
Added Files:
src/sys/arch/x86/x86: x86_tlb.c
Removed Files:
src/sys/arch/x86/x86: pmap_tlb.c

Log Message:
rename sys/arch/x86/x86/pmap_tlb.c to sys/arch/x86/x86/x86_tlb.c, so that
x86 can eventually use uvm/pmap/pmap_tlb.c; step to future PCID support


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/x86/conf/files.x86
cvs rdiff -u -r1.8 -r0 src/sys/arch/x86/x86/pmap_tlb.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/x86/x86_tlb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/conf/files.x86
diff -u src/sys/arch/x86/conf/files.x86:1.91 src/sys/arch/x86/conf/files.x86:1.92
--- src/sys/arch/x86/conf/files.x86:1.91	Mon Jan  8 01:41:34 2018
+++ src/sys/arch/x86/conf/files.x86	Mon Jan 22 19:37:45 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.x86,v 1.91 2018/01/08 01:41:34 christos Exp $
+#	$NetBSD: files.x86,v 1.92 2018/01/22 19:37:45 jdolecek Exp $
 
 # options for MP configuration through the MP spec
 defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI
@@ -94,7 +94,7 @@ file	arch/x86/x86/mtrr_i686.c	mtrr
 file 	arch/x86/x86/patch.c		machdep
 file	arch/x86/x86/platform.c		machdep
 file 	arch/x86/x86/pmap.c		machdep
-file 	arch/x86/x86/pmap_tlb.c		machdep
+file 	arch/x86/x86/x86_tlb.c		machdep
 file 	arch/x86/x86/pmc.c		machdep
 file	arch/x86/x86/procfs_machdep.c	procfs
 file	arch/x86/x86/sys_machdep.c	machdep

Added files:

Index: src/sys/arch/x86/x86/x86_tlb.c
diff -u /dev/null src/sys/arch/x86/x86/x86_tlb.c:1.1
--- /dev/null	Mon Jan 22 19:37:45 2018
+++ src/sys/arch/x86/x86/x86_tlb.c	Mon Jan 22 19:37:45 2018
@@ -0,0 +1,478 @@
+/*	$NetBSD: x86_tlb.c,v 1.1 2018/01/22 19:37:45 jdolecek Exp $	*/
+
+/*-
+ * Copyright (c) 2008-2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Doran and Mindaugas Rasiukevicius.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * x86 pmap(9) module: TLB shootdowns.
+ *
+ * TLB shootdowns are hard interrupts that operate outside the SPL framework.
+ * They do not need to be blocked, provided that the pmap module gets the
+ * order of events correct.  The calls are made by poking the LAPIC directly.
+ * The interrupt handler is short and does one of the following: invalidate
+ * a set of pages, all user TLB entries or the entire TLB.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: x86_tlb.c,v 1.1 2018/01/22 19:37:45 jdolecek Exp $");
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#ifdef XEN
+#include 
+#endif /* XEN */
+#include 
+#include 
+
+/*
+ * TLB shootdown structures.
+ */
+
+typedef struct {
+#ifdef _LP64
+	uintptr_t		tp_va[14];	/* whole struct: 128 bytes */
+#else
+	uintptr_t		tp_va[13];	/* whole struct: 64 bytes */
+#endif
+	uint16_t		tp_count;
+	uint16_t		tp_pte;
+	int			tp_userpmap;
+	kcpuset_t *		tp_cpumask;
+} pmap_tlb_packet_t;
+
+/*
+ * No more than N separate invlpg.
+ *
+ * Statistically, a value of six is big enough to cover the requested number
+ * of pages in ~ 95% of the TLB shootdowns we are getting. We therefore rarely
+ * reach the limit, and increasing it can actually reduce the performance due
+ * to the high cost of invlpg.
+ */
+#define	TP_MAXVA		6
+
+/*
+ * TLB shootdown state.
+ */
+static pmap_tlb_packet_t	pmap_tlb_packet		__cacheline_aligned;
+static volatile u_int		pmap_tlb_pendcount	__cacheline_aligned;
+static volatile u_int		pmap_tlb_gen		

CVS commit: src/sys/arch/mips/mips

2018-01-22 Thread Felix Deichmann
Module Name:src
Committed By:   flxd
Date:   Mon Jan 22 18:15:57 UTC 2018

Modified Files:
src/sys/arch/mips/mips: bus_space_alignstride_chipdep.c

Log Message:
Use right variable as revealed by previous typo...


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 \
src/sys/arch/mips/mips/bus_space_alignstride_chipdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/mips/mips/bus_space_alignstride_chipdep.c
diff -u src/sys/arch/mips/mips/bus_space_alignstride_chipdep.c:1.30 src/sys/arch/mips/mips/bus_space_alignstride_chipdep.c:1.31
--- src/sys/arch/mips/mips/bus_space_alignstride_chipdep.c:1.30	Sun Jan 21 16:38:25 2018
+++ src/sys/arch/mips/mips/bus_space_alignstride_chipdep.c	Mon Jan 22 18:15:56 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_space_alignstride_chipdep.c,v 1.30 2018/01/21 16:38:25 flxd Exp $ */
+/* $NetBSD: bus_space_alignstride_chipdep.c,v 1.31 2018/01/22 18:15:56 flxd Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -86,7 +86,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bus_space_alignstride_chipdep.c,v 1.30 2018/01/21 16:38:25 flxd Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_space_alignstride_chipdep.c,v 1.31 2018/01/22 18:15:56 flxd Exp $");
 
 #ifdef CHIP_EXTENT
 #include 
@@ -842,9 +842,9 @@ __BS(write_2)(void *v, bus_space_handle_
 	h &= ~((bus_space_handle_t)(CHIP_ACCESS_SIZE - 1));
 	CHIP_TYPE cval = ((CHIP_TYPE)CHIP_SWAP16(val)) << shift;
 # if CHIP_ACCESS_SIZE == 8
-	mips3_sd(h, val);
+	mips3_sd(h, cval);
 # else
-	mips_sw(h, val);
+	mips_sw(h, cval);
 # endif
 #endif
 }



CVS commit: src/sys/conf

2018-01-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jan 22 17:38:46 UTC 2018

Modified Files:
src/sys/conf: Makefile.kern.inc

Log Message:
- Coverity does not like -std=gnu99
- Another lose is that you need to manually edit the compiler XML to add
  all the kernel options because cov-configure barfs because it tries to
  test the compilation environment thinking that we are userland even
  when options like -ffreestanding are present.


To generate a diff of this commit:
cvs rdiff -u -r1.261 -r1.262 src/sys/conf/Makefile.kern.inc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/conf/Makefile.kern.inc
diff -u src/sys/conf/Makefile.kern.inc:1.261 src/sys/conf/Makefile.kern.inc:1.262
--- src/sys/conf/Makefile.kern.inc:1.261	Mon Dec  4 04:44:33 2017
+++ src/sys/conf/Makefile.kern.inc	Mon Jan 22 12:38:46 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.kern.inc,v 1.261 2017/12/04 09:44:33 martin Exp $
+#	$NetBSD: Makefile.kern.inc,v 1.262 2018/01/22 17:38:46 christos Exp $
 #
 # This file contains common `MI' targets and definitions and it is included
 # at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}.
@@ -63,7 +63,9 @@ S!=	cd ../../../.. && pwd
 INCLUDES?=	-I. ${EXTRA_INCLUDES} -I${S}/../common/include -I$S/arch \
 		-I$S -nostdinc
 CPPFLAGS+=	${INCLUDES} ${IDENT} -D_KERNEL -D_KERNEL_OPT
+.if !defined(COVERITY_TOP_CONFIG)
 CPPFLAGS+=	-std=gnu99
+.endif
 DEFCOPTS?=	-O2
 COPTS?=		${DEFCOPTS}
 DBG=		# might contain unwanted -Ofoo



CVS commit: src/share/mk

2018-01-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jan 22 17:34:01 UTC 2018

Modified Files:
src/share/mk: bsd.sys.mk

Log Message:
white space for readability.


To generate a diff of this commit:
cvs rdiff -u -r1.273 -r1.274 src/share/mk/bsd.sys.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/mk/bsd.sys.mk
diff -u src/share/mk/bsd.sys.mk:1.273 src/share/mk/bsd.sys.mk:1.274
--- src/share/mk/bsd.sys.mk:1.273	Mon Jan 22 12:33:01 2018
+++ src/share/mk/bsd.sys.mk	Mon Jan 22 12:34:01 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.sys.mk,v 1.273 2018/01/22 17:33:01 christos Exp $
+#	$NetBSD: bsd.sys.mk,v 1.274 2018/01/22 17:34:01 christos Exp $
 #
 # Build definitions used for NetBSD source tree builds.
 
@@ -134,9 +134,9 @@ CFLAGS+=	${${_NOWERROR} == "no" :?-Werro
 LINTFLAGS+=	${DESTDIR:D-d ${DESTDIR}/usr/include}
 
 .if !defined(NOSSP) && (${USE_SSP:Uno} != "no") && (${BINDIR:Ux} != "/usr/mdec")
-.if !defined(KERNSRCDIR) && !defined(KERN) # not for kernels nor kern modules
+.   if !defined(KERNSRCDIR) && !defined(KERN) # not for kernels / kern modules
 CPPFLAGS+=	-D_FORTIFY_SOURCE=2
-.endif
+.   endif
 .   if !defined(COVERITY_TOP_CONFIG)
 COPTS+=	-fstack-protector -Wstack-protector 
 
@@ -146,7 +146,7 @@ COPTS+=	-fstack-protector -Wstack-protec
 # (the underlying issue for sh and vax may be different, needs more
 # investigation, symptoms are similar but for different sources)
 # also true for GCC 5.3
-.if "${ACTIVE_CC}" == "gcc" && \
+.	if "${ACTIVE_CC}" == "gcc" && \
  ( ${HAVE_GCC} == "48" || \
${HAVE_GCC} == "53" ) && \
  ( ${MACHINE_CPU} == "sh3" || \
@@ -154,11 +154,11 @@ COPTS+=	-fstack-protector -Wstack-protec
${MACHINE_CPU} == "m68k" || \
${MACHINE_CPU} == "or1k" )
 COPTS+=	-Wno-error=stack-protector 
-.endif
+.	endif
 
 COPTS+=	${${ACTIVE_CC} == "clang":? --param ssp-buffer-size=1 :}
 COPTS+=	${${ACTIVE_CC} == "gcc":? --param ssp-buffer-size=1 :}
-.endif
+.   endif
 .endif
 
 .if ${MKSOFTFLOAT:Uno} != "no"



CVS commit: src/share/mk

2018-01-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jan 22 17:33:01 UTC 2018

Modified Files:
src/share/mk: bsd.own.mk bsd.sys.mk

Log Message:
Disgusting and evil hack to elide coverity options that break production
of coverity output when present [userland portion]

- --sysroot
- -fstack-protector
- -std=gnu99
- --nostdinc
- -fPIE

The critical one here being --sysroot because this means that we need to
use the actual system headers while building (or chroot/sandbox appropriately)


To generate a diff of this commit:
cvs rdiff -u -r1.1026 -r1.1027 src/share/mk/bsd.own.mk
cvs rdiff -u -r1.272 -r1.273 src/share/mk/bsd.sys.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/mk/bsd.own.mk
diff -u src/share/mk/bsd.own.mk:1.1026 src/share/mk/bsd.own.mk:1.1027
--- src/share/mk/bsd.own.mk:1.1026	Sun Jan  7 15:59:25 2018
+++ src/share/mk/bsd.own.mk	Mon Jan 22 12:33:01 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.own.mk,v 1.1026 2018/01/07 20:59:25 jmcneill Exp $
+#	$NetBSD: bsd.own.mk,v 1.1027 2018/01/22 17:33:01 christos Exp $
 
 # This needs to be before bsd.init.mk
 .if defined(BSD_MK_COMPAT_FILE)
@@ -116,7 +116,9 @@ HAVE_LIBGCC_EH?=	no
 HAVE_LIBGCC_EH?=	yes
 .endif
 
-.if ${MACHINE} == "alpha" || \
+# Coverity does not like SSP
+.if defined(COVERITY_TOP_CONFIG) || \
+${MACHINE} == "alpha" || \
 ${MACHINE} == "hppa" || \
 ${MACHINE} == "ia64" || \
 ${MACHINE_CPU} == "mips"
@@ -310,12 +312,17 @@ TOOL_CXX.pcc=		${TOOLDIR}/bin/${MACHINE_
 #
 DESTDIR?=
 
+# Coverity does not like --sysroot
 .if !defined(HOSTPROG) && !defined(HOSTLIB)
 .  if ${DESTDIR} != ""
+.	if !defined(COVERITY_TOP_CONFIG)
 CPPFLAGS+=	--sysroot=${DESTDIR}
+.	endif
 LDFLAGS+=	--sysroot=${DESTDIR}
 .  else
+.	if !defined(COVERITY_TOP_CONFIG)
 CPPFLAGS+=	--sysroot=/
+.	endif
 LDFLAGS+=	--sysroot=/
 .  endif
 .endif
@@ -995,13 +1002,15 @@ MKCTF?=		yes
 #
 # PIE is enabled on many platforms by default.
 #
-.if ${MACHINE_ARCH} == "i386" || \
+# Coverity does not like PIE
+.if !defined(COVERITY_TOP_CONFIG) && \
+(${MACHINE_ARCH} == "i386" || \
 ${MACHINE_ARCH} == "x86_64" || \
 ${MACHINE_CPU} == "arm" || \
 ${MACHINE_CPU} == "m68k" || \
 ${MACHINE_CPU} == "mips" || \
 ${MACHINE_CPU} == "sh3" || \
-${MACHINE} == "sparc64"
+${MACHINE} == "sparc64")
 MKPIE?=		yes
 .else
 MKPIE?=		no
@@ -1073,6 +1082,12 @@ MKKMOD=		no
 MKRUMP=		no
 .endif
 
+# RUMP uses -nostdinc which coverity does not like
+# It also does not use many new files, so disable it
+.if defined(COVERITY_TOP_CONFIG)
+MKRUMP=		no
+.endif
+
 #
 # Build a dynamically linked /bin and /sbin, with the necessary shared
 # libraries moved from /usr/lib to /lib and the shared linker moved

Index: src/share/mk/bsd.sys.mk
diff -u src/share/mk/bsd.sys.mk:1.272 src/share/mk/bsd.sys.mk:1.273
--- src/share/mk/bsd.sys.mk:1.272	Tue Aug  1 17:50:36 2017
+++ src/share/mk/bsd.sys.mk	Mon Jan 22 12:33:01 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.sys.mk,v 1.272 2017/08/01 21:50:36 mrg Exp $
+#	$NetBSD: bsd.sys.mk,v 1.273 2018/01/22 17:33:01 christos Exp $
 #
 # Build definitions used for NetBSD source tree builds.
 
@@ -38,9 +38,12 @@ CXXFLAGS+=	${REPROFLAGS}
 .endif
 
 # NetBSD sources use C99 style, with some GCC extensions.
+# Coverity does not like -std=gnu99
+.if !defined(COVERITY_TOP_CONFIG)
 CFLAGS+=	${${ACTIVE_CC} == "clang":? -std=gnu99 :}
 CFLAGS+=	${${ACTIVE_CC} == "gcc":? -std=gnu99 :}
 CFLAGS+=	${${ACTIVE_CC} == "pcc":? -std=gnu99 :}
+.endif
 
 .if defined(WARNS)
 CFLAGS+=	${${ACTIVE_CC} == "clang":? -Wno-sign-compare -Wno-pointer-sign :}
@@ -134,6 +137,7 @@ LINTFLAGS+=	${DESTDIR:D-d ${DESTDIR}/usr
 .if !defined(KERNSRCDIR) && !defined(KERN) # not for kernels nor kern modules
 CPPFLAGS+=	-D_FORTIFY_SOURCE=2
 .endif
+.   if !defined(COVERITY_TOP_CONFIG)
 COPTS+=	-fstack-protector -Wstack-protector 
 
 # GCC 4.8 on m68k erroneously does not protect functions with
@@ -154,6 +158,7 @@ COPTS+=	-Wno-error=stack-protector 
 
 COPTS+=	${${ACTIVE_CC} == "clang":? --param ssp-buffer-size=1 :}
 COPTS+=	${${ACTIVE_CC} == "gcc":? --param ssp-buffer-size=1 :}
+.endif
 .endif
 
 .if ${MKSOFTFLOAT:Uno} != "no"



CVS commit: src/sys/kern

2018-01-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Jan 22 15:05:28 UTC 2018

Modified Files:
src/sys/kern: uipc_mbuf.c

Log Message:
Style and clarify.


To generate a diff of this commit:
cvs rdiff -u -r1.180 -r1.181 src/sys/kern/uipc_mbuf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.180 src/sys/kern/uipc_mbuf.c:1.181
--- src/sys/kern/uipc_mbuf.c:1.180	Mon Jan 22 10:26:38 2018
+++ src/sys/kern/uipc_mbuf.c	Mon Jan 22 15:05:27 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.180 2018/01/22 10:26:38 maxv Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.181 2018/01/22 15:05:27 maxv Exp $	*/
 
 /*
  * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.180 2018/01/22 10:26:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.181 2018/01/22 15:05:27 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -103,7 +103,7 @@ static void	sysctl_kern_mbuf_setup(void)
 static struct sysctllog *mbuf_sysctllog;
 
 static struct mbuf *m_copym0(struct mbuf *, int, int, int, bool);
-static struct mbuf *m_split0(struct mbuf *, int, int, int);
+static struct mbuf *m_split0(struct mbuf *, int, int, bool);
 static int m_copyback0(struct mbuf **, int, int, const void *, int, int);
 
 /* flags for m_copyback0 */
@@ -772,12 +772,8 @@ m_copym0(struct mbuf *m, int off0, int l
 MCLADDREFERENCE(m, n);
 			} else {
 /*
- * we are unsure about the way m was allocated.
- * copy into multiple MCLBYTES cluster mbufs.
- *
- * recompute m_len, it is no longer valid if MCLGET()
- * fails to allocate a cluster. Then we try to split
- * the source into normal sized mbufs.
+ * We don't care if MCLGET fails. n->m_len is
+ * recomputed and handles that.
  */
 MCLGET(n, wait);
 n->m_len = 0;
@@ -819,7 +815,7 @@ nospace:
 
 /*
  * Copy an entire packet, including header (which must be present).
- * An optimization of the common case `m_copym(m, 0, M_COPYALL, how)'.
+ * An optimization of the common case 'm_copym(m, 0, M_COPYALL, how)'.
  */
 struct mbuf *
 m_copypacket(struct mbuf *m, int how)
@@ -862,6 +858,7 @@ m_copypacket(struct mbuf *m, int how)
 		m = m->m_next;
 	}
 	return top;
+
 nospace:
 	m_freem(top);
 	MCFail++;
@@ -959,9 +956,8 @@ m_adj(struct mbuf *mp, int req_len)
 len = 0;
 			}
 		}
-		m = mp;
 		if (mp->m_flags & M_PKTHDR)
-			m->m_pkthdr.len -= (req_len - len);
+			mp->m_pkthdr.len -= (req_len - len);
 	} else {
 		/*
 		 * Trim from tail.  Scan the mbuf chain,
@@ -974,7 +970,7 @@ m_adj(struct mbuf *mp, int req_len)
 		count = 0;
 		for (;;) {
 			count += m->m_len;
-			if (m->m_next == (struct mbuf *)0)
+			if (m->m_next == NULL)
 break;
 			m = m->m_next;
 		}
@@ -984,9 +980,11 @@ m_adj(struct mbuf *mp, int req_len)
 mp->m_pkthdr.len -= len;
 			return;
 		}
+
 		count -= len;
 		if (count < 0)
 			count = 0;
+
 		/*
 		 * Correct length for chain is "count".
 		 * Find the mbuf with last data, adjust its length,
@@ -1002,9 +1000,10 @@ m_adj(struct mbuf *mp, int req_len)
 			}
 			count -= m->m_len;
 		}
-		if (m)
+		if (m) {
 			while (m->m_next)
 (m = m->m_next)->m_len = 0;
+		}
 	}
 }
 
@@ -1149,11 +1148,11 @@ struct mbuf *
 m_split(struct mbuf *m0, int len0, int wait)
 {
 
-	return m_split0(m0, len0, wait, 1);
+	return m_split0(m0, len0, wait, true);
 }
 
 static struct mbuf *
-m_split0(struct mbuf *m0, int len0, int wait, int copyhdr)
+m_split0(struct mbuf *m0, int len0, int wait, bool copyhdr)
 {
 	struct mbuf *m, *n;
 	unsigned len = len0, remain, len_save;
@@ -1161,44 +1160,50 @@ m_split0(struct mbuf *m0, int len0, int 
 	KASSERT(len0 != M_COPYALL);
 	for (m = m0; m && len > m->m_len; m = m->m_next)
 		len -= m->m_len;
-	if (m == 0)
-		return (NULL);
+	if (m == NULL)
+		return NULL;
+
 	remain = m->m_len - len;
 	if (copyhdr && (m0->m_flags & M_PKTHDR)) {
 		n = m_gethdr(wait, m0->m_type);
 		if (n == NULL)
 			return NULL;
+
 		MCLAIM(n, m0->m_owner);
 		m_copy_rcvif(n, m0);
 		n->m_pkthdr.len = m0->m_pkthdr.len - len0;
 		len_save = m0->m_pkthdr.len;
 		m0->m_pkthdr.len = len0;
+
 		if (m->m_flags & M_EXT)
 			goto extpacket;
+
 		if (remain > MHLEN) {
 			/* m can't be the lead packet */
 			MH_ALIGN(n, 0);
 			n->m_len = 0;
 			n->m_next = m_split(m, len, wait);
-			if (n->m_next == 0) {
-(void) m_free(n);
+			if (n->m_next == NULL) {
+(void)m_free(n);
 m0->m_pkthdr.len = len_save;
-return (NULL);
-			} else
-return (n);
-		} else
+return NULL;
+			}
+			return n;
+		} else {
 			MH_ALIGN(n, remain);
+		}
 	} else if (remain == 0) {
 		n = m->m_next;
-		m->m_next = 0;
-		return (n);
+		m->m_next = NULL;
+		return n;
 	} else {
 		n = m_get(wait, m->m_type);
-		if (n == 0)
-			return (NULL);
+		if (n == NULL)
+			return NULL;
 		MCLAIM(n, m->m_owner);
 		M_ALIGN(n, 

CVS commit: src/sys/dev/pcmcia

2018-01-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Jan 22 14:40:53 UTC 2018

Modified Files:
src/sys/dev/pcmcia: if_malo_pcmcia.c

Log Message:
Fix memory leak, looks like there is still something wrong here.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/pcmcia/if_malo_pcmcia.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pcmcia/if_malo_pcmcia.c
diff -u src/sys/dev/pcmcia/if_malo_pcmcia.c:1.15 src/sys/dev/pcmcia/if_malo_pcmcia.c:1.16
--- src/sys/dev/pcmcia/if_malo_pcmcia.c:1.15	Mon Oct 23 09:24:34 2017
+++ src/sys/dev/pcmcia/if_malo_pcmcia.c	Mon Jan 22 14:40:53 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_malo_pcmcia.c,v 1.15 2017/10/23 09:24:34 msaitoh Exp $	*/
+/*	$NetBSD: if_malo_pcmcia.c,v 1.16 2018/01/22 14:40:53 maxv Exp $	*/
 /*  $OpenBSD: if_malo.c,v 1.65 2009/03/29 21:53:53 sthen Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_malo_pcmcia.c,v 1.15 2017/10/23 09:24:34 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_malo_pcmcia.c,v 1.16 2018/01/22 14:40:53 maxv Exp $");
 
 #ifdef _MODULE
 #include 
@@ -1053,8 +1053,12 @@ cmalo_rx(struct malo_softc *sc)
 	}
 
 	/* push the frame up to the network stack if not in monitor mode */
-	if (ic->ic_opmode != IEEE80211_M_MONITOR)
+	if (ic->ic_opmode != IEEE80211_M_MONITOR) {
 		if_percpuq_enqueue(ifp->if_percpuq, m);
+	} else {
+		/* XXX: we don't do anything with it? */
+		m_freem(m);
+	}
 }
 
 static int



CVS commit: src/sys/arch/arm/arm32

2018-01-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jan 22 13:29:29 UTC 2018

Modified Files:
src/sys/arch/arm/arm32: armv7_generic_space.c

Log Message:
Pass PMAP_WRITE_COMBINE as appropriate in armv7_generic_bs_map, i.e.
same fix as bcm283x_bs_map just got.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/arm32/armv7_generic_space.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/arm32/armv7_generic_space.c
diff -u src/sys/arch/arm/arm32/armv7_generic_space.c:1.5 src/sys/arch/arm/arm32/armv7_generic_space.c:1.6
--- src/sys/arch/arm/arm32/armv7_generic_space.c:1.5	Mon Jan 22 13:28:00 2018
+++ src/sys/arch/arm/arm32/armv7_generic_space.c	Mon Jan 22 13:29:28 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: armv7_generic_space.c,v 1.5 2018/01/22 13:28:00 skrll Exp $	*/
+/*	$NetBSD: armv7_generic_space.c,v 1.6 2018/01/22 13:29:28 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: armv7_generic_space.c,v 1.5 2018/01/22 13:28:00 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: armv7_generic_space.c,v 1.6 2018/01/22 13:29:28 skrll Exp $");
 
 #include 
 #include 
@@ -290,6 +290,7 @@ armv7_generic_bs_map(void *t, bus_addr_t
 {
 	u_long startpa, endpa, pa;
 	const struct pmap_devmap *pd;
+	int pmapflags;
 	vaddr_t va;
 
 	if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) {
@@ -310,10 +311,13 @@ armv7_generic_bs_map(void *t, bus_addr_t
 
 	*bshp = (bus_space_handle_t)(va + (bpa - startpa));
 
-	const int pmapflags =
-	(flag & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE))
-		? 0
-		: PMAP_NOCACHE;
+	if (flag & BUS_SPACE_MAP_PREFETCHABLE)
+		pmapflags = PMAP_WRITE_COMBINE;
+	else if (flag & BUS_SPACE_MAP_CACHEABLE)
+		pmapflags = 0;
+	else
+		pmapflags = PMAP_NOCACHE;
+
 	for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
 		pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags);
 	}



CVS commit: src/sys/arch/arm/arm32

2018-01-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jan 22 13:28:00 UTC 2018

Modified Files:
src/sys/arch/arm/arm32: armv7_generic_space.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/arm32/armv7_generic_space.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/arm32/armv7_generic_space.c
diff -u src/sys/arch/arm/arm32/armv7_generic_space.c:1.4 src/sys/arch/arm/arm32/armv7_generic_space.c:1.5
--- src/sys/arch/arm/arm32/armv7_generic_space.c:1.4	Mon Nov 27 07:44:27 2017
+++ src/sys/arch/arm/arm32/armv7_generic_space.c	Mon Jan 22 13:28:00 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: armv7_generic_space.c,v 1.4 2017/11/27 07:44:27 skrll Exp $	*/
+/*	$NetBSD: armv7_generic_space.c,v 1.5 2018/01/22 13:28:00 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: armv7_generic_space.c,v 1.4 2017/11/27 07:44:27 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: armv7_generic_space.c,v 1.5 2018/01/22 13:28:00 skrll Exp $");
 
 #include 
 #include 
@@ -365,7 +365,7 @@ armv7_generic_bs_barrier(void *t, bus_sp
 bus_size_t len, int flags)
 {
 	flags &= BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE;
-	
+
 	if (flags)
 		arm_dsb();
 }



CVS commit: src/sys/arch/arm/broadcom

2018-01-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jan 22 13:23:56 UTC 2018

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_space.c

Log Message:
Pass PMAP_WRITE_COMBINE as appropriate in bcm283x_bs_map.

RPI2 FB console now updates properly again


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/broadcom/bcm2835_space.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/broadcom/bcm2835_space.c
diff -u src/sys/arch/arm/broadcom/bcm2835_space.c:1.14 src/sys/arch/arm/broadcom/bcm2835_space.c:1.15
--- src/sys/arch/arm/broadcom/bcm2835_space.c:1.14	Sun Dec 10 21:38:26 2017
+++ src/sys/arch/arm/broadcom/bcm2835_space.c	Mon Jan 22 13:23:56 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_space.c,v 1.14 2017/12/10 21:38:26 skrll Exp $	*/
+/*	$NetBSD: bcm2835_space.c,v 1.15 2018/01/22 13:23:56 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_space.c,v 1.14 2017/12/10 21:38:26 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_space.c,v 1.15 2018/01/22 13:23:56 skrll Exp $");
 
 #include 
 #include 
@@ -533,6 +533,7 @@ bcm283x_bs_map(void *t, bus_addr_t ba, b
 bus_space_handle_t *bshp)
 {
 	u_long startpa, endpa, pa;
+	int pmapflags;
 	vaddr_t va;
 
 	/* Convert BA to PA */
@@ -550,10 +551,13 @@ bcm283x_bs_map(void *t, bus_addr_t ba, b
 
 	*bshp = (bus_space_handle_t)(va + (pa - startpa));
 
-	const int pmapflags =
-	(flag & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE))
-		? 0
-		: PMAP_NOCACHE;
+	if (flag & BUS_SPACE_MAP_PREFETCHABLE)
+		pmapflags = PMAP_WRITE_COMBINE;
+	else if (flag & BUS_SPACE_MAP_CACHEABLE)
+		pmapflags = 0;
+	else
+		pmapflags = PMAP_NOCACHE;
+
 	for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
 		pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags);
 	}



CVS commit: src/sys/arch/arm/arm32

2018-01-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jan 22 13:22:40 UTC 2018

Modified Files:
src/sys/arch/arm/arm32: pmap.c

Log Message:
Add PMAP_WRITE_COMBINE: to the list of flags supported by pmap_kenter_pa


To generate a diff of this commit:
cvs rdiff -u -r1.363 -r1.364 src/sys/arch/arm/arm32/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/arm32/pmap.c
diff -u src/sys/arch/arm/arm32/pmap.c:1.363 src/sys/arch/arm/arm32/pmap.c:1.364
--- src/sys/arch/arm/arm32/pmap.c:1.363	Mon Jan 22 13:21:35 2018
+++ src/sys/arch/arm/arm32/pmap.c	Mon Jan 22 13:22:40 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.363 2018/01/22 13:21:35 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.364 2018/01/22 13:22:40 skrll Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -217,7 +217,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.363 2018/01/22 13:21:35 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.364 2018/01/22 13:22:40 skrll Exp $");
 
 //#define PMAP_DEBUG
 #ifdef PMAP_DEBUG
@@ -3704,12 +3704,24 @@ pmap_kenter_pa(vaddr_t va, paddr_t pa, v
 		}
 	}
 	pmap_release_pmap_lock(kpm);
+	pt_entry_t npte = L2_S_PROTO | pa | L2_S_PROT(PTE_KERNEL, prot);
 
-	pt_entry_t npte = L2_S_PROTO | pa | L2_S_PROT(PTE_KERNEL, prot)
-	| ((flags & PMAP_NOCACHE)
-		? 0
-		: ((flags & PMAP_PTE)
-		? pte_l2_s_cache_mode_pt : pte_l2_s_cache_mode));
+	if (flags & PMAP_PTE) {
+		KASSERT((flags & PMAP_CACHE_MASK) == 0);
+		if (!(flags & PMAP_NOCACHE))
+			npte |= pte_l2_s_cache_mode_pt;
+	} else {
+		switch (flags & PMAP_CACHE_MASK) {
+		case PMAP_NOCACHE:
+			break;
+		case PMAP_WRITE_COMBINE:
+			npte |= pte_l2_s_wc_mode;
+			break;
+		default:
+			npte |= pte_l2_s_cache_mode;
+			break;
+		}
+	}
 #ifdef ARM_MMU_EXTENDED
 	if (prot & VM_PROT_EXECUTE)
 		npte &= ~L2_XS_XN;



CVS commit: src/sys/arch/arm/arm32

2018-01-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jan 22 13:21:35 UTC 2018

Modified Files:
src/sys/arch/arm/arm32: pmap.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.362 -r1.363 src/sys/arch/arm/arm32/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/arm32/pmap.c
diff -u src/sys/arch/arm/arm32/pmap.c:1.362 src/sys/arch/arm/arm32/pmap.c:1.363
--- src/sys/arch/arm/arm32/pmap.c:1.362	Wed Jan 17 20:30:16 2018
+++ src/sys/arch/arm/arm32/pmap.c	Mon Jan 22 13:21:35 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.362 2018/01/17 20:30:16 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.363 2018/01/22 13:21:35 skrll Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -217,7 +217,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.362 2018/01/17 20:30:16 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.363 2018/01/22 13:21:35 skrll Exp $");
 
 //#define PMAP_DEBUG
 #ifdef PMAP_DEBUG
@@ -4304,7 +4304,7 @@ pmap_fault_fixup(pmap_t pm, vaddr_t va, 
 	(uintptr_t)pm, va, ftype, user);
 #ifdef ARM_MMU_EXTENDED
 	UVMHIST_LOG(maphist, " ti=%#jx pai=%#jx asid=%#jx",
-	(uintptr_t)cpu_tlb_info(curcpu()), 
+	(uintptr_t)cpu_tlb_info(curcpu()),
 	(uintptr_t)PMAP_PAI(pm, cpu_tlb_info(curcpu())),
 	(uintptr_t)PMAP_PAI(pm, cpu_tlb_info(curcpu()))->pai_asid, 0);
 #endif



CVS commit: [netbsd-8] src/doc

2018-01-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 22 12:36:02 UTC 2018

Modified Files:
src/doc [netbsd-8]: CHANGES-8.0

Log Message:
Tickets #505 - #508


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.105 -r1.1.2.106 src/doc/CHANGES-8.0

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES-8.0
diff -u src/doc/CHANGES-8.0:1.1.2.105 src/doc/CHANGES-8.0:1.1.2.106
--- src/doc/CHANGES-8.0:1.1.2.105	Tue Jan 16 14:08:56 2018
+++ src/doc/CHANGES-8.0	Mon Jan 22 12:36:02 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.0,v 1.1.2.105 2018/01/16 14:08:56 martin Exp $
+# $NetBSD: CHANGES-8.0,v 1.1.2.106 2018/01/22 12:36:02 martin Exp $
 
 A complete list of changes from the initial NetBSD 8.0 branch on 2017-06-04
 until the 8.0 release:
@@ -9148,3 +9148,30 @@ sys/kern/kern_event.c1.103
 	Set EV_ONESHOT to prevent rescheduling
 	[christos, ticket #501]
 
+bin/ksh/history.c1.18
+
+	Use 0600 as the mode for histfile here too.
+	[maya, ticket #505]
+
+sys/kern/kern_softint.c1.45
+sys/kern/subr_pserialize.c			1.10
+sys/kern/subr_psref.c1.10
+sys/rump/librump/rumpkern/rump.c		1.331
+
+	Prevent panic or hangup in softint_disestablish(),
+	pserialize_perform() or psref_target_destroy() while
+	mp_online == false.
+	Set mp_online = true in rump kernels.
+	[jdolecek, ticket #506]
+
+sys/arch/arm/arm/cpufunc_asm_arm11x6.S		1.10
+
+	Apply the erratum fix that was applied to wbinv_range
+	to isync_range.
+	[skrll, ticket #507]
+
+sys/fs/msdosfs/msdosfs_vfsops.c			1.129
+
+	Relax sanity check. It's ok to have more FAT sectors than needed.
+	[mlelstv, ticket #508]
+



CVS commit: [netbsd-8] src/sys/fs/msdosfs

2018-01-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 22 12:34:25 UTC 2018

Modified Files:
src/sys/fs/msdosfs [netbsd-8]: msdosfs_vfsops.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #508):
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.129
relax sanity check. It's ok to have more FAT sectors than needed.


To generate a diff of this commit:
cvs rdiff -u -r1.127.4.1 -r1.127.4.2 src/sys/fs/msdosfs/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.127.4.1 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.127.4.2
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.127.4.1	Sat Sep 23 17:58:25 2017
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Mon Jan 22 12:34:25 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.127.4.1 2017/09/23 17:58:25 snj Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.127.4.2 2018/01/22 12:34:25 martin Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.127.4.1 2017/09/23 17:58:25 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.127.4.2 2018/01/22 12:34:25 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -724,8 +724,8 @@ msdosfs_mountfs(struct vnode *devvp, str
 	fatbytes = (pmp->pm_maxcluster+1) * pmp->pm_fatmult / pmp->pm_fatdiv;
 	fatblocksecs = howmany(fatbytes, pmp->pm_BytesPerSec);
 
-	if (pmp->pm_FATsecs != fatblocksecs) {
-		DPRINTF("FATsecs %lu != real %lu\n", pmp->pm_FATsecs,
+	if (pmp->pm_FATsecs < fatblocksecs) {
+		DPRINTF("FATsecs %lu < real %lu\n", pmp->pm_FATsecs,
 			fatblocksecs);
 		error = EINVAL;
 		goto error_exit;



CVS commit: [netbsd-8] src/sys/arch/arm/arm

2018-01-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 22 12:32:38 UTC 2018

Modified Files:
src/sys/arch/arm/arm [netbsd-8]: cpufunc_asm_arm11x6.S

Log Message:
Pull up following revision(s) (requested by skrll in ticket #507):
sys/arch/arm/arm/cpufunc_asm_arm11x6.S: revision 1.10
PR/52934: Yasushi Oshima: Apply the erratum fix that was applied to wbinv_range
to isync_range so that we don't hang when we try to sync from execcmd_readvn().
XXX: pullup 8


To generate a diff of this commit:
cvs rdiff -u -r1.7.20.1 -r1.7.20.2 src/sys/arch/arm/arm/cpufunc_asm_arm11x6.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/arm/cpufunc_asm_arm11x6.S
diff -u src/sys/arch/arm/arm/cpufunc_asm_arm11x6.S:1.7.20.1 src/sys/arch/arm/arm/cpufunc_asm_arm11x6.S:1.7.20.2
--- src/sys/arch/arm/arm/cpufunc_asm_arm11x6.S:1.7.20.1	Wed Jul 12 13:44:47 2017
+++ src/sys/arch/arm/arm/cpufunc_asm_arm11x6.S	Mon Jan 22 12:32:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc_asm_arm11x6.S,v 1.7.20.1 2017/07/12 13:44:47 martin Exp $	*/
+/*	$NetBSD: cpufunc_asm_arm11x6.S,v 1.7.20.2 2018/01/22 12:32:38 martin Exp $	*/
 
 /*
  * Copyright (c) 2007 Microsoft
@@ -63,7 +63,7 @@
 #include 
 #include 
 
-RCSID("$NetBSD: cpufunc_asm_arm11x6.S,v 1.7.20.1 2017/07/12 13:44:47 martin Exp $")
+RCSID("$NetBSD: cpufunc_asm_arm11x6.S,v 1.7.20.2 2018/01/22 12:32:38 martin Exp $")
 
 #if 0
 #define Invalidate_I_cache(Rtmp1, Rtmp2) \
@@ -137,6 +137,11 @@ ENTRY_NP(arm11x6_flush_prefetchbuf)
 END(arm11x6_flush_prefetchbuf)
 
 ENTRY_NP(arm11x6_icache_sync_range)
+	ldr	r2, .Larm_pcache
+	ldr	r2, [r2, #DCACHE_SIZE]
+	cmp	r1, r2
+	bge	arm11x6_icache_sync_all
+
 	add	r1, r1, r0
 	sub	r1, r1, #1
 	/* Erratum ARM1136 371025, workaround #2 */



CVS commit: [netbsd-8] src/sys

2018-01-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 22 12:30:20 UTC 2018

Modified Files:
src/sys/kern [netbsd-8]: kern_softint.c subr_pserialize.c subr_psref.c
src/sys/rump/librump/rumpkern [netbsd-8]: rump.c

Log Message:
Pull up following revision(s) (requested by jdolecek in ticket #506):
sys/kern/kern_softint.c: revision 1.45
sys/rump/librump/rumpkern/rump.c: revision 1.331
sys/kern/subr_pserialize.c: revision 1.10
sys/kern/subr_psref.c: revision 1.10
Prevent panic or hangup in softint_disestablish(), pserialize_perform() or
psref_target_destroy() while mp_online == false.
 See http://mail-index.netbsd.org/tech-kern/2017/12/25/msg022829.html
Set mp_online = true. This change might fix PR#52886.


To generate a diff of this commit:
cvs rdiff -u -r1.43.10.1 -r1.43.10.2 src/sys/kern/kern_softint.c
cvs rdiff -u -r1.8.10.1 -r1.8.10.2 src/sys/kern/subr_pserialize.c
cvs rdiff -u -r1.7.2.1 -r1.7.2.2 src/sys/kern/subr_psref.c
cvs rdiff -u -r1.329.10.1 -r1.329.10.2 src/sys/rump/librump/rumpkern/rump.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_softint.c
diff -u src/sys/kern/kern_softint.c:1.43.10.1 src/sys/kern/kern_softint.c:1.43.10.2
--- src/sys/kern/kern_softint.c:1.43.10.1	Thu Nov 23 13:40:22 2017
+++ src/sys/kern/kern_softint.c	Mon Jan 22 12:30:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_softint.c,v 1.43.10.1 2017/11/23 13:40:22 martin Exp $	*/
+/*	$NetBSD: kern_softint.c,v 1.43.10.2 2018/01/22 12:30:20 martin Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
@@ -170,13 +170,14 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.43.10.1 2017/11/23 13:40:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.43.10.2 2018/01/22 12:30:20 martin Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -430,8 +431,10 @@ softint_disestablish(void *arg)
 	 * it again.  So, we are only looking for handler records with
 	 * SOFTINT_ACTIVE already set.
 	 */
-	where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
-	xc_wait(where);
+	if (__predict_true(mp_online)) {
+		where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
+		xc_wait(where);
+	}
 
 	for (;;) {
 		/* Collect flag values from each CPU. */

Index: src/sys/kern/subr_pserialize.c
diff -u src/sys/kern/subr_pserialize.c:1.8.10.1 src/sys/kern/subr_pserialize.c:1.8.10.2
--- src/sys/kern/subr_pserialize.c:1.8.10.1	Thu Nov 30 14:40:46 2017
+++ src/sys/kern/subr_pserialize.c	Mon Jan 22 12:30:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pserialize.c,v 1.8.10.1 2017/11/30 14:40:46 martin Exp $	*/
+/*	$NetBSD: subr_pserialize.c,v 1.8.10.2 2018/01/22 12:30:20 martin Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.8.10.1 2017/11/30 14:40:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.8.10.2 2018/01/22 12:30:20 martin Exp $");
 
 #include 
 
@@ -157,6 +157,11 @@ pserialize_perform(pserialize_t psz)
 	KASSERT(psz->psz_owner == NULL);
 	KASSERT(ncpu > 0);
 
+	if (__predict_false(mp_online == false)) {
+		psz_ev_excl.ev_count++;
+		return;
+	}
+
 	/*
 	 * Set up the object and put it onto the queue.  The lock
 	 * activity here provides the necessary memory barrier to

Index: src/sys/kern/subr_psref.c
diff -u src/sys/kern/subr_psref.c:1.7.2.1 src/sys/kern/subr_psref.c:1.7.2.2
--- src/sys/kern/subr_psref.c:1.7.2.1	Tue Jan  2 10:36:12 2018
+++ src/sys/kern/subr_psref.c	Mon Jan 22 12:30:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_psref.c,v 1.7.2.1 2018/01/02 10:36:12 snj Exp $	*/
+/*	$NetBSD: subr_psref.c,v 1.7.2.2 2018/01/22 12:30:20 martin Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_psref.c,v 1.7.2.1 2018/01/02 10:36:12 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_psref.c,v 1.7.2.2 2018/01/22 12:30:20 martin Exp $");
 
 #include 
 #include 
@@ -429,8 +429,14 @@ psreffed_p(struct psref_target *target, 
 		.ret = false,
 	};
 
-	/* Ask all CPUs to say whether they hold a psref to the target.  */
-	xc_wait(xc_broadcast(0, _p_xc, , NULL));
+	if (__predict_true(mp_online)) {
+		/*
+		 * Ask all CPUs to say whether they hold a psref to the
+		 * target.
+		 */
+		xc_wait(xc_broadcast(0, _p_xc, , NULL));
+	} else
+		psreffed_p_xc(, NULL);
 
 	return P.ret;
 }

Index: src/sys/rump/librump/rumpkern/rump.c
diff -u src/sys/rump/librump/rumpkern/rump.c:1.329.10.1 src/sys/rump/librump/rumpkern/rump.c:1.329.10.2
--- src/sys/rump/librump/rumpkern/rump.c:1.329.10.1	Thu Nov 30 14:40:46 2017
+++ src/sys/rump/librump/rumpkern/rump.c	Mon Jan 22 12:30:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rump.c,v 1.329.10.1 2017/11/30 14:40:46 martin Exp $	*/
+/*	$NetBSD: rump.c,v 1.329.10.2 2018/01/22 12:30:20 

CVS commit: [netbsd-8] src/bin/ksh

2018-01-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 22 12:13:15 UTC 2018

Modified Files:
src/bin/ksh [netbsd-8]: history.c

Log Message:
Pull up following revision(s) (requested by maya in ticket #505):
bin/ksh/history.c: revision 1.18
Use 0600 as the mode for histfile here too.
pointed out by John D. Baker in PR bin/52480


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.12.6.1 src/bin/ksh/history.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/ksh/history.c
diff -u src/bin/ksh/history.c:1.12 src/bin/ksh/history.c:1.12.6.1
--- src/bin/ksh/history.c:1.12	Sat Jan 14 18:35:43 2017
+++ src/bin/ksh/history.c	Mon Jan 22 12:13:15 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: history.c,v 1.12 2017/01/14 18:35:43 maya Exp $	*/
+/*	$NetBSD: history.c,v 1.12.6.1 2018/01/22 12:13:15 martin Exp $	*/
 
 /*
  * command history
@@ -19,7 +19,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: history.c,v 1.12 2017/01/14 18:35:43 maya Exp $");
+__RCSID("$NetBSD: history.c,v 1.12.6.1 2018/01/22 12:13:15 martin Exp $");
 #endif
 
 
@@ -757,7 +757,7 @@ hist_finish()
   else
 hp = histlist;
 
-  if ((fd = open(hname, O_WRONLY | O_CREAT | O_TRUNC | O_EXLOCK, 0777)) != -1) {
+  if ((fd = open(hname, O_WRONLY | O_CREAT | O_TRUNC | O_EXLOCK, 0600)) != -1) {
 /* Remove anything written before we got the lock */
 ftruncate(fd, 0);
 if ((fh = fdopen(fd, "w")) != NULL) {



CVS commit: src/sbin/mount_autofs

2018-01-22 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Jan 22 10:41:18 UTC 2018

Modified Files:
src/sbin/mount_autofs: mount_autofs.8 mount_autofs.c

Log Message:
Sync usage with man page.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/mount_autofs/mount_autofs.8
cvs rdiff -u -r1.1 -r1.2 src/sbin/mount_autofs/mount_autofs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/mount_autofs/mount_autofs.8
diff -u src/sbin/mount_autofs/mount_autofs.8:1.3 src/sbin/mount_autofs/mount_autofs.8:1.4
--- src/sbin/mount_autofs/mount_autofs.8:1.3	Mon Jan 22 10:40:22 2018
+++ src/sbin/mount_autofs/mount_autofs.8	Mon Jan 22 10:41:18 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: mount_autofs.8,v 1.3 2018/01/22 10:40:22 wiz Exp $
+.\" $NetBSD: mount_autofs.8,v 1.4 2018/01/22 10:41:18 wiz Exp $
 .\"
 .\" Copyright (c) 2018 The DragonFly Project
 .\" All rights reserved.
@@ -35,7 +35,7 @@
 .Op Fl f Ar from
 .Op Fl O Ar master_options
 .Op Fl o Ar options
-.Op Fl p Ar master_prefix
+.Op Fl p Ar prefix
 .Ar autofs
 .Ar mount_point
 .Sh DESCRIPTION

Index: src/sbin/mount_autofs/mount_autofs.c
diff -u src/sbin/mount_autofs/mount_autofs.c:1.1 src/sbin/mount_autofs/mount_autofs.c:1.2
--- src/sbin/mount_autofs/mount_autofs.c:1.1	Sun Jan 14 22:44:04 2018
+++ src/sbin/mount_autofs/mount_autofs.c	Mon Jan 22 10:41:18 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: mount_autofs.c,v 1.1 2018/01/14 22:44:04 christos Exp $	*/
+/*	$NetBSD: mount_autofs.c,v 1.2 2018/01/22 10:41:18 wiz Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 #include 
 #ifndef lint
-__RCSID("$NetBSD: mount_autofs.c,v 1.1 2018/01/14 22:44:04 christos Exp $");
+__RCSID("$NetBSD: mount_autofs.c,v 1.2 2018/01/22 10:41:18 wiz Exp $");
 #endif /* not lint */
 
 #include 
@@ -140,7 +140,7 @@ static void
 usage(void)
 {
 	(void)fprintf(stderr,
-	"Usage: %s [-o options] [-O autofs_options] [-p ] "
-		"[-f ] autofs mount_point\n", getprogname());
+	"Usage: %s [-f from] [-O autofs_options] [-o options] [-p prefix] "
+		"autofs mount_point\n", getprogname());
 	exit(EXIT_FAILURE);
 }



CVS commit: src/share/man/man9

2018-01-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Jan 22 10:40:36 UTC 2018

Modified Files:
src/share/man/man9: mbuf.9

Log Message:
m_split does not 'attempt' to restore the chain, it just restores it plain
and simple.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/share/man/man9/mbuf.9

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man9/mbuf.9
diff -u src/share/man/man9/mbuf.9:1.54 src/share/man/man9/mbuf.9:1.55
--- src/share/man/man9/mbuf.9:1.54	Mon Jan 22 10:26:38 2018
+++ src/share/man/man9/mbuf.9	Mon Jan 22 10:40:36 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mbuf.9,v 1.54 2018/01/22 10:26:38 maxv Exp $
+.\"	$NetBSD: mbuf.9,v 1.55 2018/01/22 10:40:36 maxv Exp $
 .\"
 .\" Copyright (c) 1997 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -516,8 +516,7 @@ which is all but the first
 bytes.
 In case of failure, it returns
 .Dv NULL
-and attempts to
-restore the chain to its original state.
+and restores the chain to its original state.
 .It Fn m_adj "struct mbuf *mp" "int req_len"
 Shaves off
 .Fa req_len



CVS commit: src/sbin/mount_autofs

2018-01-22 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Jan 22 10:40:22 UTC 2018

Modified Files:
src/sbin/mount_autofs: mount_autofs.8

Log Message:
Add RCS Id, simplify wording, sort.

The option arguments need to be properly described.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sbin/mount_autofs/mount_autofs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/mount_autofs/mount_autofs.8
diff -u src/sbin/mount_autofs/mount_autofs.8:1.2 src/sbin/mount_autofs/mount_autofs.8:1.3
--- src/sbin/mount_autofs/mount_autofs.8:1.2	Mon Jan 22 10:34:20 2018
+++ src/sbin/mount_autofs/mount_autofs.8	Mon Jan 22 10:40:22 2018
@@ -1,3 +1,5 @@
+.\" $NetBSD: mount_autofs.8,v 1.3 2018/01/22 10:40:22 wiz Exp $
+.\"
 .\" Copyright (c) 2018 The DragonFly Project
 .\" All rights reserved.
 .\"
@@ -31,8 +33,8 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl f Ar from
-.Op Fl o Ar options
 .Op Fl O Ar master_options
+.Op Fl o Ar options
 .Op Fl p Ar master_prefix
 .Ar autofs
 .Ar mount_point
@@ -54,25 +56,19 @@ This command is normally executed by
 at boot time.
 The options are as follows:
 .Bl -tag -width Ds
+.It Fl f
+Set the automount
+.Ar from
+parameter.
 .It Fl o
-Options are specified with a
-.Fl o
-flag followed by a comma separated string of options.
+Set the mount options.
 See the
 .Xr mount 8
 man page for possible options and their meanings.
 .It Fl O
-automounter options are specified with a
-.Fl O
-flag.
+Set the automounter options.
 .It Fl p
-automounter prefix is specified with a
-.Fl p
-flag.
-.It Fl f
-automounter parameter from is specified with a
-.Fl f
-flag.
+Set the automounter prefix.
 .El
 .Sh SEE ALSO
 .Xr autofs 5 ,



CVS commit: src/sbin/mount_autofs

2018-01-22 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jan 22 10:34:20 UTC 2018

Modified Files:
src/sbin/mount_autofs: mount_autofs.8

Log Message:
Improve the mount_autofs(8) stub documentation

Improve DESCRIPTION and NAME.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/mount_autofs/mount_autofs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/mount_autofs/mount_autofs.8
diff -u src/sbin/mount_autofs/mount_autofs.8:1.1 src/sbin/mount_autofs/mount_autofs.8:1.2
--- src/sbin/mount_autofs/mount_autofs.8:1.1	Mon Jan 22 09:45:32 2018
+++ src/sbin/mount_autofs/mount_autofs.8	Mon Jan 22 10:34:20 2018
@@ -22,12 +22,12 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd January 15, 2018
+.Dd January 22, 2018
 .Dt MOUNT_AUTOFS 8
 .Os
 .Sh NAME
 .Nm mount_autofs
-.Nd mount autofs
+.Nd mount automounter filesystem
 .Sh SYNOPSIS
 .Nm
 .Op Fl f Ar from
@@ -39,8 +39,41 @@
 .Sh DESCRIPTION
 The
 .Nm
-command is ported from
-.Nx .
+command attaches the automounter filesystem on the
+.Ar autofs
+device on to the file system tree at point
+.Ar mount_point .
+Both
+.Ar autofs
+and
+.Ar mount_point
+are converted to absolute paths before use.
+.Pp
+This command is normally executed by
+.Xr mount 8
+at boot time.
+The options are as follows:
+.Bl -tag -width Ds
+.It Fl o
+Options are specified with a
+.Fl o
+flag followed by a comma separated string of options.
+See the
+.Xr mount 8
+man page for possible options and their meanings.
+.It Fl O
+automounter options are specified with a
+.Fl O
+flag.
+.It Fl p
+automounter prefix is specified with a
+.Fl p
+flag.
+.It Fl f
+automounter parameter from is specified with a
+.Fl f
+flag.
+.El
 .Sh SEE ALSO
 .Xr autofs 5 ,
 .Xr fstab 5 ,



CVS commit: src

2018-01-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Jan 22 10:26:38 UTC 2018

Modified Files:
src/share/man/man9: mbuf.9
src/sys/kern: uipc_mbuf.c

Log Message:
m_prepend does not tolerate being given len > MHLEN, so add a panic, and
document this behavior.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/share/man/man9/mbuf.9
cvs rdiff -u -r1.179 -r1.180 src/sys/kern/uipc_mbuf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man9/mbuf.9
diff -u src/share/man/man9/mbuf.9:1.53 src/share/man/man9/mbuf.9:1.54
--- src/share/man/man9/mbuf.9:1.53	Mon Jan  1 12:46:49 2018
+++ src/share/man/man9/mbuf.9	Mon Jan 22 10:26:38 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mbuf.9,v 1.53 2018/01/01 12:46:49 wiz Exp $
+.\"	$NetBSD: mbuf.9,v 1.54 2018/01/22 10:26:38 maxv Exp $
 .\"
 .\" Copyright (c) 1997 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 1, 2018
+.Dd January 22, 2018
 .Dt MBUF 9
 .Os
 .Sh NAME
@@ -431,6 +431,10 @@ The
 parameter is a choice of
 .Dv M_WAIT / M_DONTWAIT
 from caller.
+It is illegal for the
+.Fa len
+parameter to be greater than
+.Dv MHLEN .
 .It Fn m_pulldown "struct mbuf *m" "int off" "int len" "int *offp"
 Rearranges an mbuf chain so that
 .Fa len

Index: src/sys/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.179 src/sys/kern/uipc_mbuf.c:1.180
--- src/sys/kern/uipc_mbuf.c:1.179	Mon Jan 22 09:06:40 2018
+++ src/sys/kern/uipc_mbuf.c	Mon Jan 22 10:26:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.179 2018/01/22 09:06:40 maxv Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.180 2018/01/22 10:26:38 maxv Exp $	*/
 
 /*
  * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.179 2018/01/22 09:06:40 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.180 2018/01/22 10:26:38 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -661,6 +661,10 @@ m_prepend(struct mbuf *m, int len, int h
 {
 	struct mbuf *mn;
 
+	if (__predict_false(len > MHLEN)) {
+		panic("%s: len > MHLEN", __func__);
+	}
+
 	KASSERT(len != M_COPYALL);
 	mn = m_get(how, m->m_type);
 	if (mn == NULL) {



CVS commit: src/sys/netinet

2018-01-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Jan 22 09:51:06 UTC 2018

Modified Files:
src/sys/netinet: in_l2tp.c

Log Message:
Fix null deref, m could be NULL if M_PREPEND fails.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/netinet/in_l2tp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/in_l2tp.c
diff -u src/sys/netinet/in_l2tp.c:1.9 src/sys/netinet/in_l2tp.c:1.10
--- src/sys/netinet/in_l2tp.c:1.9	Mon Dec 18 03:21:44 2017
+++ src/sys/netinet/in_l2tp.c	Mon Jan 22 09:51:06 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_l2tp.c,v 1.9 2017/12/18 03:21:44 knakahara Exp $	*/
+/*	$NetBSD: in_l2tp.c,v 1.10 2018/01/22 09:51:06 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.9 2017/12/18 03:21:44 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.10 2018/01/22 09:51:06 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -196,11 +196,14 @@ in_l2tp_output(struct l2tp_variant *var,
 
 	/* prepend new IP header */
 	M_PREPEND(m, sizeof(struct ip), M_DONTWAIT);
+	if (m == NULL) {
+		error = ENOBUFS;
+		goto out;
+	}
 	if (IP_HDR_ALIGNED_P(mtod(m, void *)) == 0) {
-		if (m)
-			m = m_copyup(m, sizeof(struct ip), 0);
+		m = m_copyup(m, sizeof(struct ip), 0);
 	} else {
-		if (m && m->m_len < sizeof(struct ip))
+		if (m->m_len < sizeof(struct ip))
 			m = m_pullup(m, sizeof(struct ip));
 	}
 	if (m == NULL) {



CVS commit: src

2018-01-22 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jan 22 09:45:32 UTC 2018

Modified Files:
src/distrib/sets/lists/man: mi
src/sbin/mount_autofs: Makefile
src/share/man/man5: autofs.5
Added Files:
src/sbin/mount_autofs: mount_autofs.8

Log Message:
Add mount_autofs(8) from DragonFly BSD


To generate a diff of this commit:
cvs rdiff -u -r1.1570 -r1.1571 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.1 -r1.2 src/sbin/mount_autofs/Makefile
cvs rdiff -u -r0 -r1.1 src/sbin/mount_autofs/mount_autofs.8
cvs rdiff -u -r1.3 -r1.4 src/share/man/man5/autofs.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1570 src/distrib/sets/lists/man/mi:1.1571
--- src/distrib/sets/lists/man/mi:1.1570	Wed Jan 10 11:08:55 2018
+++ src/distrib/sets/lists/man/mi	Mon Jan 22 09:45:32 2018
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1570 2018/01/10 11:08:55 knakahara Exp $
+# $NetBSD: mi,v 1.1571 2018/01/22 09:45:32 kamil Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -2726,6 +2726,7 @@
 ./usr/share/man/cat8/mount.0			man-sysutil-catman	.cat
 ./usr/share/man/cat8/mount_9p.0			man-puffs-catman	.cat
 ./usr/share/man/cat8/mount_ados.0		man-adosfs-catman	.cat
+./usr/share/man/cat8/mount_autofs.0		man-sysutil-catman	.cat
 ./usr/share/man/cat8/mount_cd9660.0		man-sysutil-catman	.cat
 ./usr/share/man/cat8/mount_chfs.0		man-sysutil-catman	.cat
 ./usr/share/man/cat8/mount_efs.0		man-efs-catman		.cat
@@ -5655,6 +5656,7 @@
 ./usr/share/man/html8/mount.html		man-sysutil-htmlman	html
 ./usr/share/man/html8/mount_9p.html		man-puffs-htmlman	html
 ./usr/share/man/html8/mount_ados.html		man-adosfs-htmlman	html
+./usr/share/man/html8/mount_autofs.html		man-sysutil-htmlman	html
 ./usr/share/man/html8/mount_cd9660.html		man-sysutil-htmlman	html
 ./usr/share/man/html8/mount_chfs.html		man-sysutil-htmlman	html
 ./usr/share/man/html8/mount_efs.html		man-efs-htmlman		html
@@ -8764,6 +8766,7 @@
 ./usr/share/man/man8/mount.8			man-sysutil-man		.man
 ./usr/share/man/man8/mount_9p.8			man-puffs-man		.man
 ./usr/share/man/man8/mount_ados.8		man-adosfs-man		.man
+./usr/share/man/man8/mount_autofs.8		man-sysutil-man		.man
 ./usr/share/man/man8/mount_cd9660.8		man-sysutil-man		.man
 ./usr/share/man/man8/mount_chfs.8		man-sysutil-man		.man
 ./usr/share/man/man8/mount_efs.8		man-efs-man		.man

Index: src/sbin/mount_autofs/Makefile
diff -u src/sbin/mount_autofs/Makefile:1.1 src/sbin/mount_autofs/Makefile:1.2
--- src/sbin/mount_autofs/Makefile:1.1	Sun Jan 14 22:44:04 2018
+++ src/sbin/mount_autofs/Makefile	Mon Jan 22 09:45:32 2018
@@ -1,12 +1,11 @@
-#	$NetBSD: Makefile,v 1.1 2018/01/14 22:44:04 christos Exp $
+#	$NetBSD: Makefile,v 1.2 2018/01/22 09:45:32 kamil Exp $
 #	@(#)Makefile	8.2 (Berkeley) 3/27/94
 
-NOMAN=
 .include 
 
 PROG=	mount_autofs
 SRCS=	mount_autofs.c
-#MAN=	mount_autofs.8
+MAN=	mount_autofs.8
 
 DPADD+=${LIBUTIL}
 LDADD+=-lutil

Index: src/share/man/man5/autofs.5
diff -u src/share/man/man5/autofs.5:1.3 src/share/man/man5/autofs.5:1.4
--- src/share/man/man5/autofs.5:1.3	Sun Jan 14 03:17:28 2018
+++ src/share/man/man5/autofs.5	Mon Jan 22 09:45:32 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: autofs.5,v 1.3 2018/01/14 03:17:28 uwe Exp $
+.\" $NetBSD: autofs.5,v 1.4 2018/01/22 09:45:32 kamil Exp $
 .\"
 .\" Copyright (c) 2017 The NetBSD Foundation, Inc.
 .\" Copyright (c) 2016 The DragonFly Project
@@ -92,7 +92,8 @@ filesystems specified in
 .Xr auto_master 5 ,
 .Xr automount 8 ,
 .Xr automountd 8 ,
-.Xr autounmountd 8
+.Xr autounmountd 8 ,
+.Xr mount_autofs 8
 .Sh HISTORY
 The
 .Nm

Added files:

Index: src/sbin/mount_autofs/mount_autofs.8
diff -u /dev/null src/sbin/mount_autofs/mount_autofs.8:1.1
--- /dev/null	Mon Jan 22 09:45:32 2018
+++ src/sbin/mount_autofs/mount_autofs.8	Mon Jan 22 09:45:32 2018
@@ -0,0 +1,62 @@
+.\" Copyright (c) 2018 The DragonFly Project
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT 

CVS commit: src/sys/kern

2018-01-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Jan 22 09:06:40 UTC 2018

Modified Files:
src/sys/kern: uipc_mbuf.c

Log Message:
Style, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.178 -r1.179 src/sys/kern/uipc_mbuf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.178 src/sys/kern/uipc_mbuf.c:1.179
--- src/sys/kern/uipc_mbuf.c:1.178	Mon Jan 22 07:22:52 2018
+++ src/sys/kern/uipc_mbuf.c	Mon Jan 22 09:06:40 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.178 2018/01/22 07:22:52 maxv Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.179 2018/01/22 09:06:40 maxv Exp $	*/
 
 /*
  * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.178 2018/01/22 07:22:52 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.179 2018/01/22 09:06:40 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -102,7 +102,7 @@ static void	sysctl_kern_mbuf_setup(void)
 
 static struct sysctllog *mbuf_sysctllog;
 
-static struct mbuf *m_copym0(struct mbuf *, int, int, int, int);
+static struct mbuf *m_copym0(struct mbuf *, int, int, int, bool);
 static struct mbuf *m_split0(struct mbuf *, int, int, int);
 static int m_copyback0(struct mbuf **, int, int, const void *, int, int);
 
@@ -459,7 +459,8 @@ mb_ctor(void *arg, void *object, int fla
  * Add mbuf to the end of a chain
  */
 struct mbuf *
-m_add(struct mbuf *c, struct mbuf *m) {
+m_add(struct mbuf *c, struct mbuf *m)
+{
 	struct mbuf *n;
 
 	if (c == NULL)
@@ -620,10 +621,10 @@ m_getclr(int nowait, int type)
 	struct mbuf *m;
 
 	m = m_get(nowait, type);
-	if (m == 0)
-		return (NULL);
+	if (m == NULL)
+		return NULL;
 	memset(mtod(m, void *), 0, MLEN);
-	return (m);
+	return m;
 }
 
 void
@@ -664,7 +665,7 @@ m_prepend(struct mbuf *m, int len, int h
 	mn = m_get(how, m->m_type);
 	if (mn == NULL) {
 		m_freem(m);
-		return (NULL);
+		return NULL;
 	}
 
 	if (m->m_flags & M_PKTHDR) {
@@ -684,7 +685,7 @@ m_prepend(struct mbuf *m, int len, int h
 	}
 
 	m->m_len = len;
-	return (m);
+	return m;
 }
 
 /*
@@ -698,23 +699,24 @@ struct mbuf *
 m_copym(struct mbuf *m, int off0, int len, int wait)
 {
 
-	return m_copym0(m, off0, len, wait, 0);	/* shallow copy on M_EXT */
+	return m_copym0(m, off0, len, wait, false); /* shallow copy on M_EXT */
 }
 
 struct mbuf *
 m_dup(struct mbuf *m, int off0, int len, int wait)
 {
 
-	return m_copym0(m, off0, len, wait, 1);	/* deep copy */
+	return m_copym0(m, off0, len, wait, true); /* deep copy */
 }
 
 static inline int
-m_copylen(int len, int copylen) {
-return len == M_COPYALL ? copylen : min(len, copylen);
+m_copylen(int len, int copylen)
+{
+	return (len == M_COPYALL) ? copylen : min(len, copylen);
 }
 
 static struct mbuf *
-m_copym0(struct mbuf *m, int off0, int len, int wait, int deep)
+m_copym0(struct mbuf *m, int off0, int len, int wait, bool deep)
 {
 	struct mbuf *n, **np;
 	int off = off0;
@@ -726,27 +728,30 @@ m_copym0(struct mbuf *m, int off0, int l
 	if (off == 0 && m->m_flags & M_PKTHDR)
 		copyhdr = 1;
 	while (off > 0) {
-		if (m == 0)
+		if (m == NULL)
 			panic("m_copym: m == 0, off %d", off);
 		if (off < m->m_len)
 			break;
 		off -= m->m_len;
 		m = m->m_next;
 	}
+
 	np = 
-	top = 0;
+	top = NULL;
 	while (len == M_COPYALL || len > 0) {
-		if (m == 0) {
+		if (m == NULL) {
 			if (len != M_COPYALL)
 panic("m_copym: m == 0, len %d [!COPYALL]",
 len);
 			break;
 		}
+
 		n = m_get(wait, m->m_type);
 		*np = n;
-		if (n == 0)
+		if (n == NULL)
 			goto nospace;
 		MCLAIM(n, m->m_owner);
+
 		if (copyhdr) {
 			M_COPY_PKTHDR(n, m);
 			if (len == M_COPYALL)
@@ -756,6 +761,7 @@ m_copym0(struct mbuf *m, int off0, int l
 			copyhdr = 0;
 		}
 		n->m_len = m_copylen(len, m->m_len - off);
+
 		if (m->m_flags & M_EXT) {
 			if (!deep) {
 n->m_data = m->m_data + off;
@@ -777,9 +783,11 @@ m_copym0(struct mbuf *m, int off0, int l
 memcpy(mtod(n, void *), mtod(m, char *) + off,
 (unsigned)n->m_len);
 			}
-		} else
+		} else {
 			memcpy(mtod(n, void *), mtod(m, char *) + off,
 			(unsigned)n->m_len);
+		}
+
 		if (len != M_COPYALL)
 			len -= n->m_len;
 		off += n->m_len;
@@ -793,13 +801,16 @@ m_copym0(struct mbuf *m, int off0, int l
 		}
 		np = >m_next;
 	}
-	if (top == 0)
+
+	if (top == NULL)
 		MCFail++;
-	return (top);
+
+	return top;
+
 nospace:
 	m_freem(top);
 	MCFail++;
-	return (NULL);
+	return NULL;
 }
 
 /*
@@ -860,12 +871,12 @@ nospace:
 void
 m_copydata(struct mbuf *m, int off, int len, void *vp)
 {
-	unsigned	count;
-	void *		cp = vp;
-	struct mbuf	*m0 = m;
-	int		len0 = len;
-	int		off0 = off;
-	void		*vp0 = vp;
+	unsigned count;
+	void *cp = vp;
+	struct mbuf *m0 = m;
+	int len0 = len;
+	int off0 = off;
+	void *vp0 = vp;
 
 	KASSERT(len != M_COPYALL);
 	if (off < 0 || len < 0)



CVS commit: src/sys/arch/amd64/amd64

2018-01-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Jan 22 08:14:09 UTC 2018

Modified Files:
src/sys/arch/amd64/amd64: locore.S

Log Message:
Ah, remove duplicate SVS_LEAVE. Fixes 32bit binaries. While here remove
duplicate 'cli', but that's harmless.


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 src/sys/arch/amd64/amd64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.148 src/sys/arch/amd64/amd64/locore.S:1.149
--- src/sys/arch/amd64/amd64/locore.S:1.148	Sun Jan 21 11:21:40 2018
+++ src/sys/arch/amd64/amd64/locore.S	Mon Jan 22 08:14:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.148 2018/01/21 11:21:40 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.149 2018/01/22 08:14:09 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1534,14 +1534,12 @@ LABEL(intrfastexit)
 #endif
 
 .Luexit32:
-	NOT_XEN(cli;)
 do_mov_es:
 	movw	TF_ES(%rsp),%es
 do_mov_ds:
 	movw	TF_DS(%rsp),%ds
 do_mov_fs:
 	movw	TF_FS(%rsp),%fs
-	SVS_LEAVE
 	SWAPGS
 #ifndef XEN
 do_mov_gs:
@@ -1550,7 +1548,6 @@ do_mov_gs:
 	jmp	.Lkexit
 
 .Luexit64:
-	NOT_XEN(cli;)
 	SWAPGS
 
 .Lkexit: