CVS commit: src/sys

2017-07-10 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Tue Jul 11 05:03:45 UTC 2017

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

Log Message:
l2tp(4): fix mbuf leak when tunnel nested over the limit

XXX need pullup -8 branch


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/netinet/in_l2tp.c
cvs rdiff -u -r1.5 -r1.6 src/sys/netinet6/in6_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.2 src/sys/netinet/in_l2tp.c:1.3
--- src/sys/netinet/in_l2tp.c:1.2	Thu Mar 30 23:13:54 2017
+++ src/sys/netinet/in_l2tp.c	Tue Jul 11 05:03:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_l2tp.c,v 1.2 2017/03/30 23:13:54 knakahara Exp $	*/
+/*	$NetBSD: in_l2tp.c,v 1.3 2017/07/11 05:03:45 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.2 2017/03/30 23:13:54 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.3 2017/07/11 05:03:45 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -108,8 +108,10 @@ in_l2tp_output(struct l2tp_variant *var,
 
 	ifp = >l2tp_ec.ec_if;
 	error = l2tp_check_nesting(ifp, m);
-	if (error)
+	if (error) {
+		m_freem(m);
 		goto looped;
+	}
 
 #ifdef NETYET
 /* TODO: support ALTQ for innner frame */

Index: src/sys/netinet6/in6_l2tp.c
diff -u src/sys/netinet6/in6_l2tp.c:1.5 src/sys/netinet6/in6_l2tp.c:1.6
--- src/sys/netinet6/in6_l2tp.c:1.5	Tue Apr  4 23:49:18 2017
+++ src/sys/netinet6/in6_l2tp.c	Tue Jul 11 05:03:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_l2tp.c,v 1.5 2017/04/04 23:49:18 knakahara Exp $	*/
+/*	$NetBSD: in6_l2tp.c,v 1.6 2017/07/11 05:03:45 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.5 2017/04/04 23:49:18 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.6 2017/07/11 05:03:45 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -108,8 +108,10 @@ in6_l2tp_output(struct l2tp_variant *var
 	sc = var->lv_softc;
 	ifp = >l2tp_ec.ec_if;
 	error = l2tp_check_nesting(ifp, m);
-	if (error)
+	if (error) {
+		m_freem(m);
 		goto looped;
+	}
 
 #ifdef NOTYET
 /* TODO: support ALTQ for innner frame */



CVS commit: src/sys/netipsec

2017-07-10 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jul 11 04:55:39 UTC 2017

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

Log Message:
Let key_getsavbyspi take a reference of a returning sav


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/sys/netipsec/key.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/key.c
diff -u src/sys/netipsec/key.c:1.173 src/sys/netipsec/key.c:1.174
--- src/sys/netipsec/key.c:1.173	Tue Jul 11 04:50:59 2017
+++ src/sys/netipsec/key.c	Tue Jul 11 04:55:39 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.173 2017/07/11 04:50:59 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.174 2017/07/11 04:55:39 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.173 2017/07/11 04:50:59 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.174 2017/07/11 04:55:39 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -427,7 +427,7 @@ static struct secasvar *key_newsav(struc
 	key_newsav(m, sadb, e, __func__, __LINE__)
 static void key_delsav (struct secasvar *);
 static struct secashead *key_getsah(const struct secasindex *, int);
-static struct secasvar *key_checkspidup (const struct secasindex *, u_int32_t);
+static bool key_checkspidup(const struct secasindex *, u_int32_t);
 static struct secasvar *key_getsavbyspi (struct secashead *, u_int32_t);
 static int key_setsaval (struct secasvar *, struct mbuf *,
 	const struct sadb_msghdr *);
@@ -3033,7 +3033,7 @@ key_getsah(const struct secasindex *said
  *	NULL	: not found
  *	others	: found, pointer to a SA.
  */
-static struct secasvar *
+static bool
 key_checkspidup(const struct secasindex *saidx, u_int32_t spi)
 {
 	struct secashead *sah;
@@ -3042,7 +3042,7 @@ key_checkspidup(const struct secasindex 
 	/* check address family */
 	if (saidx->src.sa.sa_family != saidx->dst.sa.sa_family) {
 		IPSECLOG(LOG_DEBUG, "address family mismatched.\n");
-		return NULL;
+		return false;
 	}
 
 	/* check all SAD */
@@ -3050,11 +3050,13 @@ key_checkspidup(const struct secasindex 
 		if (!key_ismyaddr((struct sockaddr *)>saidx.dst))
 			continue;
 		sav = key_getsavbyspi(sah, spi);
-		if (sav != NULL)
-			return sav;
+		if (sav != NULL) {
+			KEY_FREESAV();
+			return true;
+		}
 	}
 
-	return NULL;
+	return false;
 }
 
 /*
@@ -3081,8 +3083,10 @@ key_getsavbyspi(struct secashead *sah, u
 continue;
 			}
 
-			if (sav->spi == spi)
+			if (sav->spi == spi) {
+SA_ADDREF(sav);
 return sav;
+			}
 		}
 	}
 
@@ -4995,7 +4999,7 @@ key_do_getnewspi(const struct sadb_spira
 	}
 
 	if (spmin == spmax) {
-		if (key_checkspidup(saidx, htonl(spmin)) != NULL) {
+		if (key_checkspidup(saidx, htonl(spmin))) {
 			IPSECLOG(LOG_DEBUG, "SPI %u exists already.\n", spmin);
 			return 0;
 		}
@@ -5013,7 +5017,7 @@ key_do_getnewspi(const struct sadb_spira
 			/* generate pseudo-random SPI value ranged. */
 			newspi = spmin + (key_random() % (spmax - spmin + 1));
 
-			if (key_checkspidup(saidx, htonl(newspi)) == NULL)
+			if (!key_checkspidup(saidx, htonl(newspi)))
 break;
 		}
 
@@ -5265,20 +5269,23 @@ key_api_update(struct socket *so, struct
 	if (sav->sah->saidx.proto != proto) {
 		IPSECLOG(LOG_DEBUG, "protocol mismatched (DB=%u param=%u)\n",
 		sav->sah->saidx.proto, proto);
-		return key_senderror(so, m, EINVAL);
+		error = EINVAL;
+		goto error;
 	}
 #ifdef IPSEC_DOSEQCHECK
 	if (sav->spi != sa0->sadb_sa_spi) {
 		IPSECLOG(LOG_DEBUG, "SPI mismatched (DB:%u param:%u)\n",
 		(u_int32_t)ntohl(sav->spi),
 		(u_int32_t)ntohl(sa0->sadb_sa_spi));
-		return key_senderror(so, m, EINVAL);
+		error = EINVAL;
+		goto error;
 	}
 #endif
 	if (sav->pid != mhp->msg->sadb_msg_pid) {
 		IPSECLOG(LOG_DEBUG, "pid mismatched (DB:%u param:%u)\n",
 		sav->pid, mhp->msg->sadb_msg_pid);
-		return key_senderror(so, m, EINVAL);
+		error = EINVAL;
+		goto error;
 	}
 
 	/*
@@ -5297,19 +5304,19 @@ key_api_update(struct socket *so, struct
 	error = key_setsaval(newsav, m, mhp);
 	if (error) {
 		key_delsav(newsav);
-		return key_senderror(so, m, error);
+		goto error;
 	}
 
 	error = key_handle_natt_info(newsav, mhp);
 	if (error != 0) {
 		key_delsav(newsav);
-		return key_senderror(so, m, error);
+		goto error;
 	}
 
 	error = key_init_xform(newsav);
 	if (error != 0) {
 		key_delsav(newsav);
-		return key_senderror(so, m, error);
+		goto error;
 	}
 
 	/* add to satree */
@@ -5320,6 +5327,7 @@ key_api_update(struct socket *so, struct
 
 	key_sa_chgstate(sav, SADB_SASTATE_DEAD);
 	KEY_FREESAV();
+	KEY_FREESAV();
 
 {
 	struct mbuf *n;
@@ -5334,6 +5342,9 @@ key_api_update(struct socket *so, struct
 	m_freem(m);
 	return key_sendup_mbuf(so, n, KEY_SENDUP_ALL);
 }
+error:
+	KEY_FREESAV();
+	return key_senderror(so, m, error);
 }
 
 /*
@@ -5465,12 

CVS commit: src/sys/netipsec

2017-07-10 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jul 11 04:50:59 UTC 2017

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

Log Message:
Correct wrong assumption of sav->refcnt in key_delsah

A sav in a list is basically not to be sav->refcnt == 0. And also
KEY_FREESAV assumes sav->refcnt > 0.


To generate a diff of this commit:
cvs rdiff -u -r1.172 -r1.173 src/sys/netipsec/key.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/key.c
diff -u src/sys/netipsec/key.c:1.172 src/sys/netipsec/key.c:1.173
--- src/sys/netipsec/key.c:1.172	Mon Jul 10 07:46:02 2017
+++ src/sys/netipsec/key.c	Tue Jul 11 04:50:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.172 2017/07/10 07:46:02 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.173 2017/07/11 04:50:59 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.172 2017/07/10 07:46:02 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.173 2017/07/11 04:50:59 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -2845,7 +2845,7 @@ key_newsah(const struct secasindex *said
 static void
 key_delsah(struct secashead *sah)
 {
-	struct secasvar *sav, *nextsav;
+	struct secasvar *sav;
 	u_int state;
 	int s;
 	int zombie = 0;
@@ -2857,15 +2857,9 @@ key_delsah(struct secashead *sah)
 
 	/* searching all SA registerd in the secindex. */
 	SASTATE_ANY_FOREACH(state) {
-		LIST_FOREACH_SAFE(sav, >savtree[state], chain, nextsav) {
-			if (sav->refcnt == 0) {
-/* sanity check */
-KEY_CHKSASTATE(state, sav->state);
-KEY_FREESAV();
-			} else {
-/* give up to delete this sa */
-zombie++;
-			}
+		LIST_FOREACH(sav, >savtree[state], chain) {
+			/* give up to delete this sa */
+			zombie++;
 		}
 	}
 



CVS commit: src/sys/arch/powerpc/oea

2017-07-10 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue Jul 11 03:07:22 UTC 2017

Modified Files:
src/sys/arch/powerpc/oea: cpu_subr.c

Log Message:
inline HAVE_64BIT_HID0 and remove macro definition.

Fixes llvm INSTALL kernel build, which failed with:
error: macro expansion producing 'defined' has undefined behavior


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/powerpc/oea/cpu_subr.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/powerpc/oea/cpu_subr.c
diff -u src/sys/arch/powerpc/oea/cpu_subr.c:1.84 src/sys/arch/powerpc/oea/cpu_subr.c:1.85
--- src/sys/arch/powerpc/oea/cpu_subr.c:1.84	Fri Jul  7 23:45:53 2017
+++ src/sys/arch/powerpc/oea/cpu_subr.c	Tue Jul 11 03:07:22 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_subr.c,v 1.84 2017/07/07 23:45:53 macallan Exp $	*/
+/*	$NetBSD: cpu_subr.c,v 1.85 2017/07/11 03:07:22 maya Exp $	*/
 
 /*-
  * Copyright (c) 2001 Matt Thomas.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.84 2017/07/07 23:45:53 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.85 2017/07/11 03:07:22 maya Exp $");
 
 #include "opt_ppcparam.h"
 #include "opt_ppccache.h"
@@ -487,8 +487,6 @@ cpu_attach_common(device_t self, int id)
 	return (ci);
 }
 
-#define HAVE_64BIT_HID0 (defined(PPC_OEA64_BRIDGE) || defined(_ARCH_PPC64))
-
 void
 cpu_setup(device_t self, struct cpu_info *ci)
 {
@@ -497,7 +495,7 @@ cpu_setup(device_t self, struct cpu_info
 	const char *bitmask;
 	char hidbuf[128];
 	char model[80];
-#if HAVE_64BIT_HID0
+#if defined(PPC_OEA64_BRIDGE) || defined(_ARCH_PPC64)
 	char hidbuf_u[128];
 	const char *bitmasku = NULL;
 #endif
@@ -663,7 +661,7 @@ cpu_setup(device_t self, struct cpu_info
 	case IBM970FX:
 	case IBM970MP:
 		bitmask = HID0_970_BITMASK;
-#if HAVE_64BIT_HID0
+#if defined(PPC_OEA64_BRIDGE) || defined(_ARCH_PPC64)
 		bitmasku = HID0_970_BITMASK_U;
 #endif
 		break;
@@ -672,7 +670,7 @@ cpu_setup(device_t self, struct cpu_info
 		break;
 	}
 	
-#if HAVE_64BIT_HID0
+#if defined(PPC_OEA64_BRIDGE) || defined(_ARCH_PPC64)
 	if (bitmasku != NULL) {
 		snprintb(hidbuf, sizeof hidbuf, bitmask, hid0 & 0x);
 		snprintb(hidbuf_u, sizeof hidbuf_u, bitmasku, hid0 >> 32);



CVS commit: src/lib/libc/stdio

2017-07-10 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Mon Jul 10 22:49:40 UTC 2017

Modified Files:
src/lib/libc/stdio: vfwprintf.c

Log Message:
Do not use thousands grouping when none is specified by the locale.
Fixes PR standards/52282.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/libc/stdio/vfwprintf.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/stdio/vfwprintf.c
diff -u src/lib/libc/stdio/vfwprintf.c:1.34 src/lib/libc/stdio/vfwprintf.c:1.35
--- src/lib/libc/stdio/vfwprintf.c:1.34	Mon Jan 20 14:11:03 2014
+++ src/lib/libc/stdio/vfwprintf.c	Mon Jul 10 22:49:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfwprintf.c,v 1.34 2014/01/20 14:11:03 yamt Exp $	*/
+/*	$NetBSD: vfwprintf.c,v 1.35 2017/07/10 22:49:40 perseant Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -38,7 +38,7 @@
 static char sccsid[] = "@(#)vfprintf.c	8.1 (Berkeley) 6/4/93";
 __FBSDID("$FreeBSD: src/lib/libc/stdio/vfwprintf.c,v 1.27 2007/01/09 00:28:08 imp Exp $");
 #else
-__RCSID("$NetBSD: vfwprintf.c,v 1.34 2014/01/20 14:11:03 yamt Exp $");
+__RCSID("$NetBSD: vfwprintf.c,v 1.35 2017/07/10 22:49:40 perseant Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -923,15 +923,15 @@ reswitch:	switch (ch) {
 			sign = '+';
 			goto rflag;
 		case '\'':
-			flags |= GROUPING;
 			thousands_sep = *(localeconv_l(loc)->thousands_sep);
 			grouping = localeconv_l(loc)->grouping;
-			/* If the locale doesn't define the above, use sane
-			 * defaults - otherwise silly things happen! */
-			if (thousands_sep == 0)
-thousands_sep = ',';
-			if (!grouping || !*grouping)
-grouping = "\3";
+			/* Use grouping if defined by locale */
+			if (thousands_sep && grouping && *grouping)
+flags |= GROUPING;
+			else {
+thousands_sep = '\0';
+grouping = "";
+			}
 			goto rflag;
 		case '.':
 			if ((ch = *fmt++) == '*') {



CVS commit: src/share/man/man7

2017-07-10 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Jul 10 22:41:46 UTC 2017

Modified Files:
src/share/man/man7: sysctl.7

Log Message:
Document vm.guard_size and vm.thread_guard_size


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/share/man/man7/sysctl.7

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/man7/sysctl.7
diff -u src/share/man/man7/sysctl.7:1.114 src/share/man/man7/sysctl.7:1.115
--- src/share/man/man7/sysctl.7:1.114	Mon Jul  3 21:30:59 2017
+++ src/share/man/man7/sysctl.7	Mon Jul 10 22:41:46 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sysctl.7,v 1.114 2017/07/03 21:30:59 wiz Exp $
+.\"	$NetBSD: sysctl.7,v 1.115 2017/07/10 22:41:46 joerg Exp $
 .\"
 .\" Copyright (c) 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	@(#)sysctl.3	8.4 (Berkeley) 5/9/95
 .\"
-.Dd March 25, 2017
+.Dd July 2, 2017
 .Dt SYSCTL 7
 .Os
 .Sh NAME
@@ -2381,6 +2381,8 @@ privilege may change the value.
 .It vm.uvmexp2	struct uvmexp_sysctl	no
 .It vm.vmmeter	struct vmtotal	no
 .It vm.proc.map	struct kinfo_vmentry	no
+.It vm.guard_size	unsigned int	no
+.It vm.thread_guard_size	unsigned int	yes
 .El
 .Bl -tag -width "123456"
 .It Li vm.anonmax ( Dv VM_ANONMAX )
@@ -2443,6 +2445,11 @@ The returned data consists of a
 Return system wide virtual memory statistics.
 The returned data consists of a
 .Vt struct uvmexp_sysctl .
+.It Li vm.guard_size
+Return system wide guard size for the main thread of a program.
+.It Li vm.thread_guard_size
+Return system wide default size for the guard area of all other threads
+of a program.
 .\" XXX vm.idlezero
 .El
 .Ss The ddb.* subtree ( Dv CTL_DDB )



CVS commit: src/tests/lib/libc/stdlib

2017-07-10 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Jul 10 21:43:33 UTC 2017

Modified Files:
src/tests/lib/libc/stdlib: t_atexit.sh

Log Message:
Reference correct binary in error messages.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/stdlib/t_atexit.sh

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

Modified files:

Index: src/tests/lib/libc/stdlib/t_atexit.sh
diff -u src/tests/lib/libc/stdlib/t_atexit.sh:1.1 src/tests/lib/libc/stdlib/t_atexit.sh:1.2
--- src/tests/lib/libc/stdlib/t_atexit.sh:1.1	Wed Jan 12 19:44:08 2011
+++ src/tests/lib/libc/stdlib/t_atexit.sh	Mon Jul 10 21:43:33 2017
@@ -1,4 +1,4 @@
-# $NetBSD: t_atexit.sh,v 1.1 2011/01/12 19:44:08 pgoyette Exp $
+# $NetBSD: t_atexit.sh,v 1.2 2017/07/10 21:43:33 joerg Exp $
 #
 # Copyright (c) 2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -33,7 +33,7 @@ atexit_head()
 atexit_body()
 {
 	$(atf_get_srcdir)/h_atexit >out \
-		|| atf_fail "h_exit failed, see output of the test for details"
+		|| atf_fail "h_atexit failed, see output of the test for details"
 
 	cat >exp <

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

2017-07-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 10 13:16:27 UTC 2017

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

Log Message:
Ticket #1451


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.46 -r1.1.2.47 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.46 src/doc/CHANGES-7.0.3:1.1.2.47
--- src/doc/CHANGES-7.0.3:1.1.2.46	Sat Jul  8 17:17:41 2017
+++ src/doc/CHANGES-7.0.3	Mon Jul 10 13:16:27 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.0.3,v 1.1.2.46 2017/07/08 17:17:41 snj Exp $
+# $NetBSD: CHANGES-7.0.3,v 1.1.2.47 2017/07/10 13:16:27 martin Exp $
 
 A complete list of changes from the NetBSD 7.0.2 release to the NetBSD 7.0.3
 release:
@@ -2987,3 +2987,9 @@ xsrc/xfree/xc/programs/Xserver/Xi/sendex
 	Fix CVE-2017-10971 and CVE-2017-10972.
 	[mrg, ticket #1446]
 
+sys/kern/vfs_lookup.c1.208
+
+	Fix vnode leak on error, introduced by the openat family changes
+	in -r1.200.
+	[dh, ticket #1451]
+



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

2017-07-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 10 13:15:00 UTC 2017

Modified Files:
src/sys/kern [netbsd-7-0]: vfs_lookup.c

Log Message:
Pull up following revision(s) (requested by dh in ticket #1451):
sys/kern/vfs_lookup.c: revision 1.208
Fix vnode leak on error, introduced by the openat family changes in -r1.200.
>From mjg@freebsd.


To generate a diff of this commit:
cvs rdiff -u -r1.201 -r1.201.8.1 src/sys/kern/vfs_lookup.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/vfs_lookup.c
diff -u src/sys/kern/vfs_lookup.c:1.201 src/sys/kern/vfs_lookup.c:1.201.8.1
--- src/sys/kern/vfs_lookup.c:1.201	Fri Feb  7 15:29:22 2014
+++ src/sys/kern/vfs_lookup.c	Mon Jul 10 13:15:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_lookup.c,v 1.201 2014/02/07 15:29:22 hannken Exp $	*/
+/*	$NetBSD: vfs_lookup.c,v 1.201.8.1 2017/07/10 13:15:00 martin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.201 2014/02/07 15:29:22 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.201.8.1 2017/07/10 13:15:00 martin Exp $");
 
 #include "opt_magiclinks.h"
 
@@ -678,8 +678,10 @@ namei_start(struct namei_state *state, i
 	}
 
 	/* NDAT may feed us with a non directory namei_getstartdir */
-	if (startdir->v_type != VDIR)
+	if (startdir->v_type != VDIR) {
+		vrele(startdir);
 		return ENOTDIR;
+	}
 
 	vn_lock(startdir, LK_EXCLUSIVE | LK_RETRY);
 



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

2017-07-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 10 13:14:21 UTC 2017

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

Log Message:
Ticket #1451


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.13 -r1.1.2.14 src/doc/CHANGES-7.1.1

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.1
diff -u src/doc/CHANGES-7.1.1:1.1.2.13 src/doc/CHANGES-7.1.1:1.1.2.14
--- src/doc/CHANGES-7.1.1:1.1.2.13	Sat Jul  8 17:17:58 2017
+++ src/doc/CHANGES-7.1.1	Mon Jul 10 13:14:21 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.1.1,v 1.1.2.13 2017/07/08 17:17:58 snj Exp $
+# $NetBSD: CHANGES-7.1.1,v 1.1.2.14 2017/07/10 13:14:21 martin Exp $
 
 A complete list of changes from the NetBSD 7.1 release to the NetBSD 7.1.1
 release:
@@ -1680,3 +1680,9 @@ xsrc/xfree/xc/programs/Xserver/Xi/sendex
 	Fix CVE-2017-10971 and CVE-2017-10972.
 	[mrg, ticket #1446]
 
+sys/kern/vfs_lookup.c1.208
+
+	Fix vnode leak on error, introduced by the openat family changes
+	in -r1.200.
+	[dh, ticket #1451]
+



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

2017-07-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 10 13:13:16 UTC 2017

Modified Files:
src/sys/kern [netbsd-7-1]: vfs_lookup.c

Log Message:
Pull up following revision(s) (requested by dh in ticket #1451):
sys/kern/vfs_lookup.c: revision 1.208
Fix vnode leak on error, introduced by the openat family changes in -r1.200.
>From mjg@freebsd.


To generate a diff of this commit:
cvs rdiff -u -r1.201 -r1.201.12.1 src/sys/kern/vfs_lookup.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/vfs_lookup.c
diff -u src/sys/kern/vfs_lookup.c:1.201 src/sys/kern/vfs_lookup.c:1.201.12.1
--- src/sys/kern/vfs_lookup.c:1.201	Fri Feb  7 15:29:22 2014
+++ src/sys/kern/vfs_lookup.c	Mon Jul 10 13:13:15 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_lookup.c,v 1.201 2014/02/07 15:29:22 hannken Exp $	*/
+/*	$NetBSD: vfs_lookup.c,v 1.201.12.1 2017/07/10 13:13:15 martin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.201 2014/02/07 15:29:22 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.201.12.1 2017/07/10 13:13:15 martin Exp $");
 
 #include "opt_magiclinks.h"
 
@@ -678,8 +678,10 @@ namei_start(struct namei_state *state, i
 	}
 
 	/* NDAT may feed us with a non directory namei_getstartdir */
-	if (startdir->v_type != VDIR)
+	if (startdir->v_type != VDIR) {
+		vrele(startdir);
 		return ENOTDIR;
+	}
 
 	vn_lock(startdir, LK_EXCLUSIVE | LK_RETRY);
 



CVS commit: [netbsd-7] src/doc

2017-07-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 10 13:12:40 UTC 2017

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

Log Message:
Ticket #1451


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.26 -r1.1.2.27 src/doc/CHANGES-7.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.2
diff -u src/doc/CHANGES-7.2:1.1.2.26 src/doc/CHANGES-7.2:1.1.2.27
--- src/doc/CHANGES-7.2:1.1.2.26	Sun Jul  9 04:37:40 2017
+++ src/doc/CHANGES-7.2	Mon Jul 10 13:12:40 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.2,v 1.1.2.26 2017/07/09 04:37:40 snj Exp $
+# $NetBSD: CHANGES-7.2,v 1.1.2.27 2017/07/10 13:12:40 martin Exp $
 
 A complete list of changes from the NetBSD 7.1 release to the NetBSD 7.2
 release:
@@ -2477,3 +2477,9 @@ libexec/ld.elf_so/reloc.c			1.110
 	bogus relocations.
 	[uwe, ticket #1411]
 
+sys/kern/vfs_lookup.c1.208
+
+	Fix vnode leak on error, introduced by the openat family changes
+	in -r1.200.
+	[dh, ticket #1451]
+



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

2017-07-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 10 13:12:04 UTC 2017

Modified Files:
src/sys/kern [netbsd-7]: vfs_lookup.c

Log Message:
Pull up following revision(s) (requested by dh in ticket #1451):
sys/kern/vfs_lookup.c: revision 1.208
Fix vnode leak on error, introduced by the openat family changes in -r1.200.
>From mjg@freebsd.


To generate a diff of this commit:
cvs rdiff -u -r1.201 -r1.201.4.1 src/sys/kern/vfs_lookup.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/vfs_lookup.c
diff -u src/sys/kern/vfs_lookup.c:1.201 src/sys/kern/vfs_lookup.c:1.201.4.1
--- src/sys/kern/vfs_lookup.c:1.201	Fri Feb  7 15:29:22 2014
+++ src/sys/kern/vfs_lookup.c	Mon Jul 10 13:12:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_lookup.c,v 1.201 2014/02/07 15:29:22 hannken Exp $	*/
+/*	$NetBSD: vfs_lookup.c,v 1.201.4.1 2017/07/10 13:12:04 martin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.201 2014/02/07 15:29:22 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.201.4.1 2017/07/10 13:12:04 martin Exp $");
 
 #include "opt_magiclinks.h"
 
@@ -678,8 +678,10 @@ namei_start(struct namei_state *state, i
 	}
 
 	/* NDAT may feed us with a non directory namei_getstartdir */
-	if (startdir->v_type != VDIR)
+	if (startdir->v_type != VDIR) {
+		vrele(startdir);
 		return ENOTDIR;
+	}
 
 	vn_lock(startdir, LK_EXCLUSIVE | LK_RETRY);
 



CVS commit: [netbsd-8] src/doc

2017-07-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 10 13:09:24 UTC 2017

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

Log Message:
Tickets #110, #111, #112, #115, #116 and #117


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.21 -r1.1.2.22 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.21 src/doc/CHANGES-8.0:1.1.2.22
--- src/doc/CHANGES-8.0:1.1.2.21	Fri Jul  7 14:12:21 2017
+++ src/doc/CHANGES-8.0	Mon Jul 10 13:09:24 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.0,v 1.1.2.21 2017/07/07 14:12:21 martin Exp $
+# $NetBSD: CHANGES-8.0,v 1.1.2.22 2017/07/10 13:09:24 martin Exp $
 
 A complete list of changes from the initial NetBSD 8.0 branch on 2017-06-04
 until the 8.0 release:
@@ -1888,3 +1888,42 @@ xsrc/external/mit/xorg-server/dist/dix/s
 	CVE-2017-10971 and CVE-2017-10972: apply fixes to the event loop.
 	[mrg, ticket #109]
 
+sys/arch/x86/x86/lapic.c			1.59
+
+	PR/52266: use rdmsr_safe(9) instead of rdmsr(9) for compatibility
+	with old machines.
+	[nonaka, ticket #110]
+
+sys/dev/sdmmc/ld_sdmmc.c			1.29
+
+	The config_* APIs are not MPSAFE, so make sure the deferred attach
+	thread holds KERNEL_LOCK.
+	[jmcneill, ticket #111]
+
+common/lib/libc/stdlib/_strtol.h		1.11
+common/lib/libc/stdlib/_strtoul.h		1.11
+tests/lib/libc/stdlib/t_strtol.c		1.7
+
+	Fix ISO C compliance: strtol of "0xX" should give the largest valid
+	numeric prefix, which is 0.
+	[joerg, ticket #112]
+
+tests/lib/libc/db/h_lfsr.c			1.2
+
+	Reduce the number of iterations in the bsize_torture test from 65535
+	to 1000 to make the ATF test suite as a whole take less time.  Before
+	the change, this single test case could take more than two hours to
+	run on a qemu emulated ARM.
+	[jmcneill, ticket #115]
+
+sys/kern/vfs_lookup.c1.208
+
+	Fix vnode leak on error, introduced by the openat family changes
+	in -r1.200.
+	[dh, ticket #116]
+
+usr.sbin/postinstall/postinstall		1.216
+
+	Add npfd to the list of rc.d scripts to check.
+	[simonb, ticket #117]
+



CVS commit: [netbsd-8] src/usr.sbin/postinstall

2017-07-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 10 13:06:45 UTC 2017

Modified Files:
src/usr.sbin/postinstall [netbsd-8]: postinstall

Log Message:
Pull up following revision(s) (requested by simonb in ticket #117):
usr.sbin/postinstall/postinstall: revision 1.216
Add npfd to the list of rc.d scripts to check.
--


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.214.4.1 src/usr.sbin/postinstall/postinstall

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

Modified files:

Index: src/usr.sbin/postinstall/postinstall
diff -u src/usr.sbin/postinstall/postinstall:1.214 src/usr.sbin/postinstall/postinstall:1.214.4.1
--- src/usr.sbin/postinstall/postinstall:1.214	Mon Apr 17 18:41:48 2017
+++ src/usr.sbin/postinstall/postinstall	Mon Jul 10 13:06:45 2017
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall,v 1.214 2017/04/17 18:41:48 martin Exp $
+# $NetBSD: postinstall,v 1.214.4.1 2017/07/10 13:06:45 martin Exp $
 #
 # Copyright (c) 2002-2015 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1427,6 +1427,7 @@ newsyslog
 nfsd
 nfslocking
 npf
+npfd
 ntpd
 ntpdate
 perusertmp



CVS commit: [netbsd-8] src/sys/kern

2017-07-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 10 13:02:47 UTC 2017

Modified Files:
src/sys/kern [netbsd-8]: vfs_lookup.c

Log Message:
Pull up following revision(s) (requested by dh in ticket #116):
sys/kern/vfs_lookup.c: revision 1.208
Fix vnode leak on error, introduced by the openat family changes in -r1.200.
>From mjg@freebsd.


To generate a diff of this commit:
cvs rdiff -u -r1.207 -r1.207.2.1 src/sys/kern/vfs_lookup.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/vfs_lookup.c
diff -u src/sys/kern/vfs_lookup.c:1.207 src/sys/kern/vfs_lookup.c:1.207.2.1
--- src/sys/kern/vfs_lookup.c:1.207	Thu Jun  1 02:45:13 2017
+++ src/sys/kern/vfs_lookup.c	Mon Jul 10 13:02:47 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_lookup.c,v 1.207 2017/06/01 02:45:13 chs Exp $	*/
+/*	$NetBSD: vfs_lookup.c,v 1.207.2.1 2017/07/10 13:02:47 martin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.207 2017/06/01 02:45:13 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.207.2.1 2017/07/10 13:02:47 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_magiclinks.h"
@@ -673,8 +673,10 @@ namei_start(struct namei_state *state, i
 	}
 
 	/* NDAT may feed us with a non directory namei_getstartdir */
-	if (startdir->v_type != VDIR)
+	if (startdir->v_type != VDIR) {
+		vrele(startdir);
 		return ENOTDIR;
+	}
 
 	vn_lock(startdir, LK_EXCLUSIVE | LK_RETRY);
 



CVS commit: [netbsd-8] src/tests/lib/libc/db

2017-07-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 10 13:01:13 UTC 2017

Modified Files:
src/tests/lib/libc/db [netbsd-8]: h_lfsr.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #115):
tests/lib/libc/db/h_lfsr.c: revision 1.2
Reduce the number of iterations in the bsize_torture test from 65535
to 1000 to make the ATF test suite as a whole take less time.  Before
the change, this single test case could take more than two hours to
run on a qemu emulated ARM.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.1.8.1 src/tests/lib/libc/db/h_lfsr.c

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

Modified files:

Index: src/tests/lib/libc/db/h_lfsr.c
diff -u src/tests/lib/libc/db/h_lfsr.c:1.1 src/tests/lib/libc/db/h_lfsr.c:1.1.8.1
--- src/tests/lib/libc/db/h_lfsr.c:1.1	Wed Nov 18 18:35:35 2015
+++ src/tests/lib/libc/db/h_lfsr.c	Mon Jul 10 13:01:13 2017
@@ -27,7 +27,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: h_lfsr.c,v 1.1 2015/11/18 18:35:35 christos Exp $");
+__RCSID("$NetBSD: h_lfsr.c,v 1.1.8.1 2017/07/10 13:01:13 martin Exp $");
 
 #include 
 #include 
@@ -37,7 +37,7 @@ __RCSID("$NetBSD: h_lfsr.c,v 1.1 2015/11
 #include 
 #include 
 
-#define MAXKEY 0x
+#define MAXKEY 1000
 #ifdef DEBUG
 #define DPRINTF(...)	printf(__VA_ARGS__)
 #else



CVS commit: [netbsd-8] src

2017-07-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 10 12:40:23 UTC 2017

Modified Files:
src/common/lib/libc/stdlib [netbsd-8]: _strtol.h _strtoul.h
src/tests/lib/libc/stdlib [netbsd-8]: t_strtol.c

Log Message:
Pull up following revision(s) (requested by joerg in ticket #112):
common/lib/libc/stdlib/_strtol.h: revision 1.11
common/lib/libc/stdlib/_strtoul.h: revision 1.11
tests/lib/libc/stdlib/t_strtol.c: revision 1.7
Fix ISO C compliance: strtol of "0xX" should give the largest valid
numeric prefix, which is 0.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.8.1 src/common/lib/libc/stdlib/_strtol.h
cvs rdiff -u -r1.10 -r1.10.6.1 src/common/lib/libc/stdlib/_strtoul.h
cvs rdiff -u -r1.6 -r1.6.8.1 src/tests/lib/libc/stdlib/t_strtol.c

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

Modified files:

Index: src/common/lib/libc/stdlib/_strtol.h
diff -u src/common/lib/libc/stdlib/_strtol.h:1.10 src/common/lib/libc/stdlib/_strtol.h:1.10.8.1
--- src/common/lib/libc/stdlib/_strtol.h:1.10	Fri Nov 13 16:02:07 2015
+++ src/common/lib/libc/stdlib/_strtol.h	Mon Jul 10 12:40:23 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtol.h,v 1.10 2015/11/13 16:02:07 christos Exp $ */
+/* $NetBSD: _strtol.h,v 1.10.8.1 2017/07/10 12:40:23 martin Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -101,13 +101,17 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const
 			c = *s++;
 	}
 	if ((base == 0 || base == 16) &&
-	c == '0' && (*s == 'x' || *s == 'X')) {
+	c == '0' && (*s == 'x' || *s == 'X') &&
+	((s[1] >= '0' && s[1] <= '9') ||
+	 (s[1] >= 'a' && s[1] <= 'f') ||
+	 (s[1] >= 'A' && s[1] <= 'F'))) {
 		c = s[1];
 		s += 2;
 		base = 16;
 #if 0
 	} else if ((base == 0 || base == 2) &&
-	c == '0' && (*s == 'b' || *s == 'B')) {
+	c == '0' && (*s == 'b' || *s == 'B') &&
+	(s[1] >= '0' && s[1] <= '1')) {
 		c = s[1];
 		s += 2;
 		base = 2;

Index: src/common/lib/libc/stdlib/_strtoul.h
diff -u src/common/lib/libc/stdlib/_strtoul.h:1.10 src/common/lib/libc/stdlib/_strtoul.h:1.10.6.1
--- src/common/lib/libc/stdlib/_strtoul.h:1.10	Sat Nov  5 21:11:30 2016
+++ src/common/lib/libc/stdlib/_strtoul.h	Mon Jul 10 12:40:23 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtoul.h,v 1.10 2016/11/05 21:11:30 riastradh Exp $ */
+/* $NetBSD: _strtoul.h,v 1.10.6.1 2017/07/10 12:40:23 martin Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -101,13 +101,17 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const
 			c = *s++;
 	}
 	if ((base == 0 || base == 16) &&
-	c == '0' && (*s == 'x' || *s == 'X')) {
+	c == '0' && (*s == 'x' || *s == 'X') &&
+	((s[1] >= '0' && s[1] <= '9') ||
+	 (s[1] >= 'a' && s[1] <= 'f') ||
+	 (s[1] >= 'A' && s[1] <= 'F'))) {
 		c = s[1];
 		s += 2;
 		base = 16;
 #if 0
 	} else if ((base == 0 || base == 2) &&
-	c == '0' && (*s == 'b' || *s == 'B')) {
+	c == '0' && (*s == 'b' || *s == 'B') &&
+	(s[1] >= '0' && s[1] <= '1')) {
 		c = s[1];
 		s += 2;
 		base = 2;

Index: src/tests/lib/libc/stdlib/t_strtol.c
diff -u src/tests/lib/libc/stdlib/t_strtol.c:1.6 src/tests/lib/libc/stdlib/t_strtol.c:1.6.8.1
--- src/tests/lib/libc/stdlib/t_strtol.c:1.6	Wed Jun  1 01:12:02 2016
+++ src/tests/lib/libc/stdlib/t_strtol.c	Mon Jul 10 12:40:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_strtol.c,v 1.6 2016/06/01 01:12:02 pgoyette Exp $ */
+/*	$NetBSD: t_strtol.c,v 1.6.8.1 2017/07/10 12:40:23 martin Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_strtol.c,v 1.6 2016/06/01 01:12:02 pgoyette Exp $");
+__RCSID("$NetBSD: t_strtol.c,v 1.6.8.1 2017/07/10 12:40:23 martin Exp $");
 
 #include 
 #include 
@@ -61,8 +61,8 @@ check(struct test *t, long int li, long 
 
 	if ((t->end != NULL && strcmp(t->end, end) != 0) ||
 	(t->end == NULL && *end != '\0'))
-		atf_tc_fail_nonfatal("invalid end pointer ('%s') from "
-		"strtol(%s, , %d)", end, t->str, t->base);
+		atf_tc_fail_nonfatal("invalid end pointer (%p) from "
+		"strtol(%p, , %d)", end, t->str, t->base);
 }
 
 ATF_TC(strtol_base);
@@ -93,12 +93,18 @@ ATF_TC_BODY(strtol_base, tc)
 		{ "1234567",			342391,  8, NULL	},
 		{ "01234567",			342391,  0, NULL	},
 		{ "0123456789",			 123456789, 10, NULL	},
-		{ "0x75bcd15",		 123456789,  0, NULL	},
+		{ "0x75bcd15",			 123456789,  0, NULL	},
+		{ " 0xX",			 0,  0, "xX"	},
+		{ " 0xX",			 0, 16, "xX"	},
+		{ " 0XX",			 0,  0, "XX"	},
+		{ " 0XX",			 0, 16, "XX"	},
 	};
 
 	long long int lli;
 	long int li;
-	char *end;
+	long long int ulli;
+	long int uli;
+	char *end, *end2;
 	size_t i;
 
 	for (i = 0; i < __arraycount(t); i++) {
@@ -106,7 +112,20 @@ ATF_TC_BODY(strtol_base, tc)
 		li = strtol(t[i].str, , t[i].base);
 		lli = strtoll(t[i].str, NULL, t[i].base);
 
+		uli = strtoul(t[i].str, , t[i].base);
+		ulli = strtoull(t[i].str, NULL, t[i].base);
+
 		check([i], li, lli, end);
+

CVS commit: [netbsd-8] src/sys/dev/sdmmc

2017-07-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 10 12:29:47 UTC 2017

Modified Files:
src/sys/dev/sdmmc [netbsd-8]: ld_sdmmc.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #111):
sys/dev/sdmmc/ld_sdmmc.c: revision 1.29
The config_* APIs are not MPSAFE, so make sure the deferred attach
thread holds KERNEL_LOCK.


To generate a diff of this commit:
cvs rdiff -u -r1.26.4.2 -r1.26.4.3 src/sys/dev/sdmmc/ld_sdmmc.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/sdmmc/ld_sdmmc.c
diff -u src/sys/dev/sdmmc/ld_sdmmc.c:1.26.4.2 src/sys/dev/sdmmc/ld_sdmmc.c:1.26.4.3
--- src/sys/dev/sdmmc/ld_sdmmc.c:1.26.4.2	Sat Jul  1 08:45:03 2017
+++ src/sys/dev/sdmmc/ld_sdmmc.c	Mon Jul 10 12:29:47 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_sdmmc.c,v 1.26.4.2 2017/07/01 08:45:03 snj Exp $	*/
+/*	$NetBSD: ld_sdmmc.c,v 1.26.4.3 2017/07/10 12:29:47 martin Exp $	*/
 
 /*
  * Copyright (c) 2008 KIYOHARA Takashi
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.26.4.2 2017/07/01 08:45:03 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.26.4.3 2017/07/10 12:29:47 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -157,7 +157,7 @@ ld_sdmmc_attach(device_t parent, device_
 	 * when wedge is supported.
 	 */
 	config_pending_incr(self);
-	if (kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL,
+	if (kthread_create(PRI_NONE, 0, NULL,
 	ld_sdmmc_doattach, sc, , "%sattach", device_xname(self))) {
 		aprint_error_dev(self, "couldn't create thread\n");
 	}



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

2017-07-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 10 12:26:21 UTC 2017

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: lapic.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #110):
sys/arch/x86/x86/lapic.c: revision 1.59
PR/52266: use rdmsr_safe(9) instead of rdmsr(9) for old machine.
tested by simonb@


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.58.2.1 src/sys/arch/x86/x86/lapic.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/x86/lapic.c
diff -u src/sys/arch/x86/x86/lapic.c:1.58 src/sys/arch/x86/x86/lapic.c:1.58.2.1
--- src/sys/arch/x86/x86/lapic.c:1.58	Tue May 23 08:54:39 2017
+++ src/sys/arch/x86/x86/lapic.c	Mon Jul 10 12:26:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lapic.c,v 1.58 2017/05/23 08:54:39 nonaka Exp $	*/
+/*	$NetBSD: lapic.c,v 1.58.2.1 2017/07/10 12:26:21 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.58 2017/05/23 08:54:39 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.58.2.1 2017/07/10 12:26:21 martin Exp $");
 
 #include "acpica.h"
 #include "ioapic.h"
@@ -235,10 +235,12 @@ lapic_enable_x2apic(void)
 bool
 lapic_is_x2apic(void)
 {
-	uint64_t r;
+	uint64_t msr;
 
-	r = rdmsr(MSR_APICBASE);
-	return (r & (APICBASE_EN | APICBASE_EXTD)) == (APICBASE_EN | APICBASE_EXTD);
+	if (rdmsr_safe(MSR_APICBASE, ) == EFAULT)
+		return false;
+	return (msr & (APICBASE_EN | APICBASE_EXTD)) ==
+	(APICBASE_EN | APICBASE_EXTD);
 }
 
 /*



CVS commit: src/sys/dev/sdmmc

2017-07-10 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Jul 10 10:35:08 UTC 2017

Modified Files:
src/sys/dev/sdmmc: ld_sdmmc.c

Log Message:
Decrypt comment about the attach thread. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/sdmmc/ld_sdmmc.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/sdmmc/ld_sdmmc.c
diff -u src/sys/dev/sdmmc/ld_sdmmc.c:1.29 src/sys/dev/sdmmc/ld_sdmmc.c:1.30
--- src/sys/dev/sdmmc/ld_sdmmc.c:1.29	Sat Jul  8 18:38:57 2017
+++ src/sys/dev/sdmmc/ld_sdmmc.c	Mon Jul 10 10:35:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_sdmmc.c,v 1.29 2017/07/08 18:38:57 jmcneill Exp $	*/
+/*	$NetBSD: ld_sdmmc.c,v 1.30 2017/07/10 10:35:07 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2008 KIYOHARA Takashi
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.29 2017/07/08 18:38:57 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.30 2017/07/10 10:35:07 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -153,8 +153,13 @@ ld_sdmmc_attach(device_t parent, device_
 	ld->sc_discard = ld_sdmmc_discard;
 
 	/*
-	 * It is avoided that the error occurs when the card attaches it,
-	 * when wedge is supported.
+	 * Defer attachment of ld + disk subsystem to a thread.
+	 *
+	 * This is necessary because wedge autodiscover needs to
+	 * open and call into the ld driver, which could deadlock
+	 * when the sdmmc driver isn't ready in early bootstrap.
+	 *
+	 * Don't mark thread as MPSAFE to keep aprint output sane.
 	 */
 	config_pending_incr(self);
 	if (kthread_create(PRI_NONE, 0, NULL,



CVS commit: src/doc

2017-07-10 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Mon Jul 10 10:28:23 UTC 2017

Modified Files:
src/doc: CHANGES

Log Message:
Note the new additions to MAKEDEV(8) after regen.


To generate a diff of this commit:
cvs rdiff -u -r1.2298 -r1.2299 src/doc/CHANGES

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
diff -u src/doc/CHANGES:1.2298 src/doc/CHANGES:1.2299
--- src/doc/CHANGES:1.2298	Fri Jul  7 22:22:11 2017
+++ src/doc/CHANGES	Mon Jul 10 10:28:23 2017
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2298 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2299 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -39,3 +39,5 @@ Changes from NetBSD 8.0 to NetBSD 9.0:
 		W83667HGB, W83687THF, W83697UG,	Nuvoton NCT5104D, NCT6775,
 		NCT6779, NCT6791, NCT6792 and NCT6793. [msaitoh 20170707]
 	arm: Add support for Allwinner A83T SoC. [jmcneill 20170707]
+	MAKEDEV(8): Regenerate, documenting lua, dk, plcom, wmcom, hdmicec, mfi,
+		nvme, nvme ns, tpm, and dtrace devices. [sevan 20170710]



CVS commit: src/sys/arch/evbarm/fdt

2017-07-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jul 10 09:44:14 UTC 2017

Modified Files:
src/sys/arch/evbarm/fdt: fdt_machdep.c

Log Message:
port-evbarm/52388: Fix number of args to a debug printf.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/evbarm/fdt/fdt_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/evbarm/fdt/fdt_machdep.c
diff -u src/sys/arch/evbarm/fdt/fdt_machdep.c:1.9 src/sys/arch/evbarm/fdt/fdt_machdep.c:1.10
--- src/sys/arch/evbarm/fdt/fdt_machdep.c:1.9	Wed Jul  5 19:30:51 2017
+++ src/sys/arch/evbarm/fdt/fdt_machdep.c	Mon Jul 10 09:44:14 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.9 2017/07/05 19:30:51 chs Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.10 2017/07/10 09:44:14 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.9 2017/07/05 19:30:51 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.10 2017/07/10 09:44:14 jmcneill Exp $");
 
 #include "opt_machdep.h"
 #include "opt_ddb.h"
@@ -186,7 +186,7 @@ fdt_add_reserved_memory_range(uint64_t a
 	if (error != 0)
 		printf("MEM ERROR: add %llx-%llx failed: %d\n",
 		addr, size, error);
-	DPRINTF("MEM: res %llx-%llx: %d\n", addr, size);
+	DPRINTF("MEM: res %llx-%llx: %d\n", addr, size, error);
 }
 
 /*



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

2017-07-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jul 10 09:30:58 UTC 2017

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

Log Message:
No need for '\n' in UVMHIST_LOG


To generate a diff of this commit:
cvs rdiff -u -r1.349 -r1.350 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.349 src/sys/arch/arm/arm32/pmap.c:1.350
--- src/sys/arch/arm/arm32/pmap.c:1.349	Wed May 24 06:31:07 2017
+++ src/sys/arch/arm/arm32/pmap.c	Mon Jul 10 09:30:58 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.349 2017/05/24 06:31:07 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.350 2017/07/10 09:30:58 skrll Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -217,7 +217,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.349 2017/05/24 06:31:07 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.350 2017/07/10 09:30:58 skrll Exp $");
 
 //#define PMAP_DEBUG
 #ifdef PMAP_DEBUG
@@ -3361,7 +3361,7 @@ pmap_enter(pmap_t pm, vaddr_t va, paddr_
 #endif /* !ARM_MMU_EXTENDED */
 
 #ifndef ARM_MMU_EXTENDED
-		UVMHIST_LOG(maphist, "  is_cached %d cs 0x%08x\n",
+		UVMHIST_LOG(maphist, "  is_cached %d cs 0x%08x",
 		is_cached, pm->pm_cstate.cs_all, 0, 0);
 
 		if (pg != NULL) {



CVS commit: src/share/man/man8

2017-07-10 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Mon Jul 10 08:41:35 UTC 2017

Modified Files:
src/share/man/man8: MAKEDEV.8

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/share/man/man8/MAKEDEV.8

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/man8/MAKEDEV.8
diff -u src/share/man/man8/MAKEDEV.8:1.45 src/share/man/man8/MAKEDEV.8:1.46
--- src/share/man/man8/MAKEDEV.8:1.45	Mon Feb 24 07:23:41 2014
+++ src/share/man/man8/MAKEDEV.8	Mon Jul 10 08:41:35 2017
@@ -6,7 +6,7 @@
 .\" *** DO NOT EDIT - any changes will be lost!!!
 .\" *** --
 .\"
-.\" $NetBSD: MAKEDEV.8,v 1.45 2014/02/24 07:23:41 skrll Exp $
+.\" $NetBSD: MAKEDEV.8,v 1.46 2017/07/10 08:41:35 sevan Exp $
 .\"
 .\" Copyright (c) 2001, 2003, 2007, 2008 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -35,7 +35,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 25, 2012
+.Dd July  9, 2017
 .Dt MAKEDEV 8
 .Os
 .Sh NAME
@@ -238,6 +238,8 @@ Devices to be put into INSTALL kernel ra
 Standard devices
 .It Ar local
 Configuration specific devices
+.It Ar lua
+Lua device
 .It Ar wscons
 Make wscons devices
 .It Ar usbs
@@ -283,6 +285,9 @@ TU58 cassettes on DL11 controller, see
 . El
 .It Disks :
 . Bl -tag -width 0123456789 -compact
+. It Ar dk#
+Wedge disk slices, see
+.Xr \ 4
 . It Ar ccd#
 Concatenated disk devices, see
 .Xr \ 4
@@ -442,6 +447,10 @@ UART on first 68901 (formerly mdm01) (at
 IXP12x0 COM ports
 . It Ar epcom
 EP93xx COM ports
+. It Ar plcom
+ARM PL01[01] serial ports
+. It Ar wmcom
+EPOC Windermere COM ports
 . It Ar ttyM?
 HP200/300 4 port serial mux interface (hp300)
 . It Ar ttya
@@ -736,6 +745,8 @@ Graphics frame buffer device, see
 . It Ar hdaudio#
 High Definition audio control device, see
 .Xr \ 4
+. It Ar hdmicec#
+HDMI CEC devices
 . It Ar hil
 HP300 HIL input devices, see
 .Xr \ 4
@@ -774,6 +785,9 @@ Magma multiport serial/parallel cards, s
 . It Ar midi#
 MIDI, see
 .Xr \ 4
+. It Ar mfi#
+LSI MegaRAID/MegaSAS control interface, see
+.Xr \ 4
 . It Ar mlx#
 Mylex DAC960 control interface, see
 .Xr \ 4
@@ -788,6 +802,11 @@ NPF packet filter
 . It Ar nsmb#
 SMB requester, see
 .Xr \ 4
+. It Ar nvme#
+Non-Volatile Memory Host Controller Interface device driver, see
+.Xr \ 4
+. It Ar nvme#ns*
+Non-Volatile Memory namespace
 . It Ar openfirm
 OpenFirmware accessor
 . It Ar pad#
@@ -875,6 +894,17 @@ Xen event interface
 . It Ar iscsi#
 ISCSI driver and /sbin/iscsid communication
 . El
+.It Trusted Computing devices
+. Bl -tag -width 0123456789 -compact
+. It Ar tpm
+Trusted Platform Module, see
+.Xr \ 4
+. El
+.It Debugging and tracing
+. Bl -tag -width 0123456789 -compact
+. It Ar dtrace
+Dynamic tracing framework
+. El
 .El
 .Sh ENVIRONMENT
 The following environment variables affect the execution of
@@ -997,6 +1027,6 @@ this can be done on a
 .Nx
 host, or can be done in a cross-build environment using
 .Sy TOOLDIR Ns Pa /bin/nbpax .
-Finally, use apropriate tools on the foreign server
+Finally, use appropriate tools on the foreign server
 to unpack the archive and create the device nodes.
 .El



CVS commit: src/sys/netipsec

2017-07-10 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jul 10 07:46:02 UTC 2017

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

Log Message:
Remove unnecessary zero-clearing codes from key_setsaval

key_setsaval is now used only for a newly-allocated sav. (It was
used to reset variables of an existing sav.)


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/sys/netipsec/key.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/key.c
diff -u src/sys/netipsec/key.c:1.171 src/sys/netipsec/key.c:1.172
--- src/sys/netipsec/key.c:1.171	Mon Jul 10 07:45:10 2017
+++ src/sys/netipsec/key.c	Mon Jul 10 07:46:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.171 2017/07/10 07:45:10 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.172 2017/07/10 07:46:02 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.171 2017/07/10 07:45:10 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.172 2017/07/10 07:46:02 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -3154,15 +3154,6 @@ key_setsaval(struct secasvar *sav, struc
 	/* We shouldn't initialize sav variables while someone uses it. */
 	KASSERT(sav->refcnt == 0);
 
-	/* initialization */
-	key_freesaval(sav);
-	sav->tdb_xform = NULL;		/* transform */
-	sav->tdb_encalgxform = NULL;	/* encoding algorithm */
-	sav->tdb_authalgxform = NULL;	/* authentication algorithm */
-	sav->tdb_compalgxform = NULL;	/* compression algorithm */
-	sav->natt_type = 0;
-	sav->esp_frag = 0;
-
 	/* SA */
 	if (mhp->ext[SADB_EXT_SA] != NULL) {
 		const struct sadb_sa *sa0;



CVS commit: src/sys/netipsec

2017-07-10 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jul 10 07:45:10 UTC 2017

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

Log Message:
Make sure a sav is inserted to a sah list after its initialization completes


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/sys/netipsec/key.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/key.c
diff -u src/sys/netipsec/key.c:1.170 src/sys/netipsec/key.c:1.171
--- src/sys/netipsec/key.c:1.170	Mon Jul 10 07:40:23 2017
+++ src/sys/netipsec/key.c	Mon Jul 10 07:45:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.170 2017/07/10 07:40:23 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.171 2017/07/10 07:45:10 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.170 2017/07/10 07:40:23 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.171 2017/07/10 07:45:10 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -421,11 +421,10 @@ static u_int key_getspreqmsglen (const s
 static int key_spdexpire (struct secpolicy *);
 static struct secashead *key_newsah (const struct secasindex *);
 static void key_delsah (struct secashead *);
-static struct secasvar *key_newsav (struct mbuf *,
-	const struct sadb_msghdr *, struct secashead *, int *,
-	const char*, int);
-#define	KEY_NEWSAV(m, sadb, sah, e)\
-	key_newsav(m, sadb, sah, e, __func__, __LINE__)
+static struct secasvar *key_newsav(struct mbuf *,
+	const struct sadb_msghdr *, int *, const char*, int);
+#define	KEY_NEWSAV(m, sadb, e)\
+	key_newsav(m, sadb, e, __func__, __LINE__)
 static void key_delsav (struct secasvar *);
 static struct secashead *key_getsah(const struct secasindex *, int);
 static struct secasvar *key_checkspidup (const struct secasindex *, u_int32_t);
@@ -433,7 +432,7 @@ static struct secasvar *key_getsavbyspi 
 static int key_setsaval (struct secasvar *, struct mbuf *,
 	const struct sadb_msghdr *);
 static void key_freesaval(struct secasvar *);
-static int key_mature (struct secasvar *);
+static int key_init_xform(struct secasvar *);
 static void key_clear_xform(struct secasvar *);
 static struct mbuf *key_setdumpsa (struct secasvar *, u_int8_t,
 	u_int8_t, u_int32_t, u_int32_t);
@@ -1375,6 +1374,11 @@ key_freesav(struct secasvar **psav, cons
 
 	if (nv == 0) {
 		*psav = NULL;
+
+		/* remove from SA header */
+		KASSERT(__LIST_CHAINED(sav));
+		LIST_REMOVE(sav, chain);
+
 		key_delsav(sav);
 	}
 }
@@ -2903,8 +2907,7 @@ key_delsah(struct secashead *sah)
  */
 static struct secasvar *
 key_newsav(struct mbuf *m, const struct sadb_msghdr *mhp,
-	   struct secashead *sah, int *errp,
-	   const char* where, int tag)
+int *errp, const char* where, int tag)
 {
 	struct secasvar *newsav;
 	const struct sadb_sa *xsa;
@@ -2913,7 +2916,6 @@ key_newsav(struct mbuf *m, const struct 
 	KASSERT(m != NULL);
 	KASSERT(mhp != NULL);
 	KASSERT(mhp->msg != NULL);
-	KASSERT(sah != NULL);
 
 	newsav = kmem_zalloc(sizeof(struct secasvar), KM_SLEEP);
 
@@ -2958,12 +2960,6 @@ key_newsav(struct mbuf *m, const struct 
 	newsav->created = time_uptime;
 	newsav->pid = mhp->msg->sadb_msg_pid;
 
-	/* add to satree */
-	newsav->sah = sah;
-	newsav->refcnt = 1;
-	newsav->state = SADB_SASTATE_LARVAL;
-	LIST_INSERT_TAIL(>savtree[SADB_SASTATE_LARVAL], newsav,
-	secasvar, chain);
 	KEYDEBUG_PRINTF(KEYDEBUG_IPSEC_STAMP,
 	"DP from %s:%u return SA:%p\n", where, tag, newsav);
 	return newsav;
@@ -3008,10 +3004,6 @@ key_delsav(struct secasvar *sav)
 	KASSERT(sav != NULL);
 	KASSERTMSG(sav->refcnt == 0, "reference count %u > 0", sav->refcnt);
 
-	/* remove from SA header */
-	KASSERT(__LIST_CHAINED(sav));
-	LIST_REMOVE(sav, chain);
-
 	key_clear_xform(sav);
 	key_freesaval(sav);
 	kmem_intr_free(sav, sizeof(*sav));
@@ -3348,10 +3340,13 @@ key_setsaval(struct secasvar *sav, struc
  *	other:	errno
  */
 static int
-key_mature(struct secasvar *sav)
+key_init_xform(struct secasvar *sav)
 {
 	int error;
 
+	/* We shouldn't initialize sav variables while someone uses it. */
+	KASSERT(sav->refcnt == 0);
+
 	/* check SPI value */
 	switch (sav->sah->saidx.proto) {
 	case IPPROTO_ESP:
@@ -3416,9 +3411,8 @@ key_mature(struct secasvar *sav)
 		error = EPROTONOSUPPORT;
 		break;
 	}
-	if (error == 0)
-		key_sa_chgstate(sav, SADB_SASTATE_MATURE);
-	return (error);
+
+	return error;
 }
 
 /*
@@ -4887,7 +4881,7 @@ key_api_getspi(struct socket *so, struct
 
 	/* get a new SA */
 	/* XXX rewrite */
-	newsav = KEY_NEWSAV(m, mhp, newsah, );
+	newsav = KEY_NEWSAV(m, mhp, );
 	if (newsav == NULL) {
 		/* XXX don't free new SA index allocated in above. */
 		return key_senderror(so, m, error);
@@ -4896,6 +4890,13 @@ key_api_getspi(struct socket *so, struct
 	/* set spi */
 	newsav->spi = htonl(spi);
 
+	/* add to satree */
+	

CVS commit: src/sys/netipsec

2017-07-10 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jul 10 07:40:23 UTC 2017

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

Log Message:
Add missing KEY_FREESAV


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/sys/netipsec/key.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/key.c
diff -u src/sys/netipsec/key.c:1.169 src/sys/netipsec/key.c:1.170
--- src/sys/netipsec/key.c:1.169	Mon Jul 10 07:27:35 2017
+++ src/sys/netipsec/key.c	Mon Jul 10 07:40:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.169 2017/07/10 07:27:35 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.170 2017/07/10 07:40:23 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.169 2017/07/10 07:27:35 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.170 2017/07/10 07:40:23 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -5492,8 +5492,10 @@ key_api_add(struct socket *so, struct mb
 	}
 
 	error = key_handle_natt_info(newsav, mhp);
-	if (error != 0)
+	if (error != 0) {
+		KEY_FREESAV();
 		return key_senderror(so, m, EINVAL);
+	}
 
 	/* check SA values to be mature. */
 	error = key_mature(newsav);



CVS commit: src/sys/netipsec

2017-07-10 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jul 10 07:27:35 UTC 2017

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

Log Message:
Make sure to clear keys on error paths of key_setsaval


To generate a diff of this commit:
cvs rdiff -u -r1.168 -r1.169 src/sys/netipsec/key.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/key.c
diff -u src/sys/netipsec/key.c:1.168 src/sys/netipsec/key.c:1.169
--- src/sys/netipsec/key.c:1.168	Fri Jul  7 01:37:34 2017
+++ src/sys/netipsec/key.c	Mon Jul 10 07:27:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.168 2017/07/07 01:37:34 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.169 2017/07/10 07:27:35 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.168 2017/07/07 01:37:34 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.169 2017/07/10 07:27:35 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -434,6 +434,7 @@ static int key_setsaval (struct secasvar
 	const struct sadb_msghdr *);
 static void key_freesaval(struct secasvar *);
 static int key_mature (struct secasvar *);
+static void key_clear_xform(struct secasvar *);
 static struct mbuf *key_setdumpsa (struct secasvar *, u_int8_t,
 	u_int8_t, u_int32_t, u_int32_t);
 static struct mbuf *key_setsadbxport (u_int16_t, u_int16_t);
@@ -2975,20 +2976,11 @@ error:
 	return NULL;
 }
 
-/*
- * free() SA variable entry.
- */
+
 static void
-key_delsav(struct secasvar *sav)
+key_clear_xform(struct secasvar *sav)
 {
 
-	KASSERT(sav != NULL);
-	KASSERTMSG(sav->refcnt == 0, "reference count %u > 0", sav->refcnt);
-
-	/* remove from SA header */
-	KASSERT(__LIST_CHAINED(sav));
-	LIST_REMOVE(sav, chain);
-
 	/*
 	 * Cleanup xform state.  Note that zeroize'ing causes the
 	 * keys to be cleared; otherwise we must do it ourself.
@@ -3004,7 +2996,23 @@ key_delsav(struct secasvar *sav)
 			explicit_memset(_KEYBUF(sav->key_enc), 0,
 			_KEYLEN(sav->key_enc));
 	}
+}
+
+/*
+ * free() SA variable entry.
+ */
+static void
+key_delsav(struct secasvar *sav)
+{
+
+	KASSERT(sav != NULL);
+	KASSERTMSG(sav->refcnt == 0, "reference count %u > 0", sav->refcnt);
 
+	/* remove from SA header */
+	KASSERT(__LIST_CHAINED(sav));
+	LIST_REMOVE(sav, chain);
+
+	key_clear_xform(sav);
 	key_freesaval(sav);
 	kmem_intr_free(sav, sizeof(*sav));
 
@@ -3328,7 +3336,7 @@ key_setsaval(struct secasvar *sav, struc
 	return 0;
 
  fail:
-	/* initialization */
+	key_clear_xform(sav);
 	key_freesaval(sav);
 
 	return error;



CVS commit: src/sys/netipsec

2017-07-10 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jul 10 07:17:12 UTC 2017

Modified Files:
src/sys/netipsec: xform_ah.c xform_esp.c xform_tcp.c

Log Message:
Use explicit_memset to surely zero-clear key_auth and key_enc


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.58 -r1.59 src/sys/netipsec/xform_esp.c
cvs rdiff -u -r1.12 -r1.13 src/sys/netipsec/xform_tcp.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/xform_ah.c
diff -u src/sys/netipsec/xform_ah.c:1.57 src/sys/netipsec/xform_ah.c:1.58
--- src/sys/netipsec/xform_ah.c:1.57	Fri Jul  7 01:37:34 2017
+++ src/sys/netipsec/xform_ah.c	Mon Jul 10 07:17:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_ah.c,v 1.57 2017/07/07 01:37:34 ozaki-r Exp $	*/
+/*	$NetBSD: xform_ah.c,v 1.58 2017/07/10 07:17:12 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */
 /*
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.57 2017/07/07 01:37:34 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.58 2017/07/10 07:17:12 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -249,8 +249,10 @@ ah_zeroize(struct secasvar *sav)
 {
 	int err;
 
-	if (sav->key_auth)
-		memset(_KEYBUF(sav->key_auth), 0, _KEYLEN(sav->key_auth));
+	if (sav->key_auth) {
+		explicit_memset(_KEYBUF(sav->key_auth), 0,
+		_KEYLEN(sav->key_auth));
+	}
 
 	err = crypto_freesession(sav->tdb_cryptoid);
 	sav->tdb_cryptoid = 0;

Index: src/sys/netipsec/xform_esp.c
diff -u src/sys/netipsec/xform_esp.c:1.58 src/sys/netipsec/xform_esp.c:1.59
--- src/sys/netipsec/xform_esp.c:1.58	Fri Jul  7 01:37:34 2017
+++ src/sys/netipsec/xform_esp.c	Mon Jul 10 07:17:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_esp.c,v 1.58 2017/07/07 01:37:34 ozaki-r Exp $	*/
+/*	$NetBSD: xform_esp.c,v 1.59 2017/07/10 07:17:12 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.58 2017/07/07 01:37:34 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.59 2017/07/10 07:17:12 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -283,8 +283,10 @@ esp_zeroize(struct secasvar *sav)
 	/* NB: ah_zerorize free's the crypto session state */
 	int error = ah_zeroize(sav);
 
-	if (sav->key_enc)
-		memset(_KEYBUF(sav->key_enc), 0, _KEYLEN(sav->key_enc));
+	if (sav->key_enc) {
+		explicit_memset(_KEYBUF(sav->key_enc), 0,
+		_KEYLEN(sav->key_enc));
+	}
 	sav->tdb_encalgxform = NULL;
 	sav->tdb_xform = NULL;
 	return error;

Index: src/sys/netipsec/xform_tcp.c
diff -u src/sys/netipsec/xform_tcp.c:1.12 src/sys/netipsec/xform_tcp.c:1.13
--- src/sys/netipsec/xform_tcp.c:1.12	Thu Jun 29 07:13:41 2017
+++ src/sys/netipsec/xform_tcp.c	Mon Jul 10 07:17:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_tcp.c,v 1.12 2017/06/29 07:13:41 ozaki-r Exp $ */
+/*	$NetBSD: xform_tcp.c,v 1.13 2017/07/10 07:17:12 ozaki-r Exp $ */
 /*	$FreeBSD: sys/netipsec/xform_tcp.c,v 1.1.2.1 2004/02/14 22:24:09 bms Exp $ */
 
 /*
@@ -31,7 +31,7 @@
 /* TCP MD5 Signature Option (RFC2385) */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_tcp.c,v 1.12 2017/06/29 07:13:41 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_tcp.c,v 1.13 2017/07/10 07:17:12 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -123,8 +123,10 @@ static int
 tcpsignature_zeroize(struct secasvar *sav)
 {
 
-	if (sav->key_auth)
-		memset(_KEYBUF(sav->key_auth), 0, _KEYLEN(sav->key_auth));
+	if (sav->key_auth) {
+		explicit_memset(_KEYBUF(sav->key_auth), 0,
+		_KEYLEN(sav->key_auth));
+	}
 
 	sav->tdb_cryptoid = 0;
 	sav->tdb_authalgxform = NULL;