CVS commit: src/doc

2018-04-01 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Apr  2 05:52:31 UTC 2018

Modified Files:
src/doc: CHANGES

Log Message:
Add support for aarch64


To generate a diff of this commit:
cvs rdiff -u -r1.2368 -r1.2369 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.2368 src/doc/CHANGES:1.2369
--- src/doc/CHANGES:1.2368	Tue Mar 27 06:34:25 2018
+++ src/doc/CHANGES	Mon Apr  2 05:52:31 2018
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2368 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2369 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -131,3 +131,4 @@ Changes from NetBSD 8.0 to NetBSD 9.0:
 		[sevan 20180316]
 	tzdata updated to 2017d [kre 20180324]
 	dhcpcd: Import 7.0.2. [roy 20180327]
+	aarch64: Add initial support for aarch64. [ryo 20180401]



CVS commit: src/sys/dev/pci/ixgbe

2018-04-01 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Apr  2 05:02:55 UTC 2018

Modified Files:
src/sys/dev/pci/ixgbe: ix_txrx.c ixgbe.c ixgbe.h

Log Message:
Avoid issues caused by sending old packets at next link-up time.

This modification consists by the following two parts.
- drain packets in if_snd queue or corresponding txr->txr_interq
  when link_active == false in ifp->if_start(), ifp->if_transmit(),
  and deferred Tx processing
- drain packets in if_snd queue and all of txr->txr_interq's
  at link-down time

ok by msaitoh@n.o.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/pci/ixgbe/ix_txrx.c
cvs rdiff -u -r1.140 -r1.141 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/pci/ixgbe/ixgbe.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/dev/pci/ixgbe/ix_txrx.c
diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.37 src/sys/dev/pci/ixgbe/ix_txrx.c:1.38
--- src/sys/dev/pci/ixgbe/ix_txrx.c:1.37	Fri Mar 30 03:58:20 2018
+++ src/sys/dev/pci/ixgbe/ix_txrx.c	Mon Apr  2 05:02:55 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.37 2018/03/30 03:58:20 knakahara Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.38 2018/04/02 05:02:55 knakahara Exp $ */
 
 /**
 
@@ -103,6 +103,7 @@ static void  ixgbe_free_receive_
 static void  ixgbe_rx_checksum(u32, struct mbuf *, u32,
struct ixgbe_hw_stats *);
 static void  ixgbe_refresh_mbufs(struct rx_ring *, int);
+static void  ixgbe_drain(struct ifnet *, struct tx_ring *);
 static int   ixgbe_xmit(struct tx_ring *, struct mbuf *);
 static int   ixgbe_tx_ctx_setup(struct tx_ring *,
 struct mbuf *, u32 *, u32 *);
@@ -135,9 +136,15 @@ ixgbe_legacy_start_locked(struct ifnet *
 
 	IXGBE_TX_LOCK_ASSERT(txr);
 
-	if ((ifp->if_flags & IFF_RUNNING) == 0)
+	if (!adapter->link_active) {
+		/*
+		 * discard all packets buffered in IFQ to avoid
+		 * sending old packets at next link up timing.
+		 */
+		ixgbe_drain(ifp, txr);
 		return (ENETDOWN);
-	if (!adapter->link_active)
+	}
+	if ((ifp->if_flags & IFF_RUNNING) == 0)
 		return (ENETDOWN);
 
 	while (!IFQ_IS_EMPTY(>if_snd)) {
@@ -271,9 +278,15 @@ ixgbe_mq_start_locked(struct ifnet *ifp,
 	struct mbuf*next;
 	intenqueued = 0, err = 0;
 
-	if ((ifp->if_flags & IFF_RUNNING) == 0)
+	if (!txr->adapter->link_active) {
+		/*
+		 * discard all packets buffered in txr_interq to avoid
+		 * sending old packets at next link up timing.
+		 */
+		ixgbe_drain(ifp, txr);
 		return (ENETDOWN);
-	if (txr->adapter->link_active == 0)
+	}
+	if ((ifp->if_flags & IFF_RUNNING) == 0)
 		return (ENETDOWN);
 
 	/* Process the queue */
@@ -342,6 +355,23 @@ ixgbe_deferred_mq_start_work(struct work
 	ixgbe_deferred_mq_start(txr);
 } /* ixgbe_deferred_mq_start */
 
+/
+ * ixgbe_drain_all
+ /
+void
+ixgbe_drain_all(struct adapter *adapter)
+{
+	struct ifnet *ifp = adapter->ifp;
+	struct ix_queue *que = adapter->queues;
+
+	for (int i = 0; i < adapter->num_queues; i++, que++) {
+		struct tx_ring  *txr = que->txr;
+
+		IXGBE_TX_LOCK(txr);
+		ixgbe_drain(ifp, txr);
+		IXGBE_TX_UNLOCK(txr);
+	}
+}
 
 /
  * ixgbe_xmit
@@ -515,6 +545,29 @@ retry:
 	return (0);
 } /* ixgbe_xmit */
 
+/
+ * ixgbe_drain
+ /
+static void
+ixgbe_drain(struct ifnet *ifp, struct tx_ring *txr)
+{
+	struct mbuf *m;
+
+	IXGBE_TX_LOCK_ASSERT(txr);
+
+	if (txr->me == 0) {
+		while (!IFQ_IS_EMPTY(>if_snd)) {
+			IFQ_DEQUEUE(>if_snd, m);
+			m_freem(m);
+			IF_DROP(>if_snd);
+		}
+	}
+
+	while ((m = pcq_get(txr->txr_interq)) != NULL) {
+		m_freem(m);
+		txr->pcq_drops.ev_count++;
+	}
+}
 
 /
  * ixgbe_allocate_transmit_buffers

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.140 src/sys/dev/pci/ixgbe/ixgbe.c:1.141
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.140	Fri Mar 30 06:44:30 2018
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Mon Apr  2 05:02:55 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.140 2018/03/30 06:44:30 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.141 2018/04/02 05:02:55 knakahara Exp $ */
 
 /**
 
@@ -4600,6 +4600,7 @@ ixgbe_update_link_status(struct adapter 
 			adapter->link_active = FALSE;
 			if (adapter->feat_en & IXGBE_FEATURE_SRIOV)
 ixgbe_ping_all_vfs(adapter);
+			ixgbe_drain_all(adapter);
 	

CVS commit: src/usr.bin/make

2018-04-01 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Apr  2 04:26:17 UTC 2018

Modified Files:
src/usr.bin/make: make.1

Log Message:
Fix bad markup.


To generate a diff of this commit:
cvs rdiff -u -r1.271 -r1.272 src/usr.bin/make/make.1

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

Modified files:

Index: src/usr.bin/make/make.1
diff -u src/usr.bin/make/make.1:1.271 src/usr.bin/make/make.1:1.272
--- src/usr.bin/make/make.1:1.271	Mon Jul  3 21:34:20 2017
+++ src/usr.bin/make/make.1	Mon Apr  2 04:26:17 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.271 2017/07/03 21:34:20 wiz Exp $
+.\"	$NetBSD: make.1,v 1.272 2018/04/02 04:26:17 dholland Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -1864,7 +1864,8 @@ expression is applied.
 Similarly, if the form is
 .Ql Ic .ifmake
 or
-.Ql Ic .ifnmake , the
+.Ql Ic .ifnmake ,
+the
 .Dq make
 expression is applied.
 .Pp



CVS commit: src/sbin/dmesg

2018-04-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Apr  2 01:15:32 UTC 2018

Modified Files:
src/sbin/dmesg: dmesg.c

Log Message:
eat NUL's first so that the state machine is not altered by them.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sbin/dmesg/dmesg.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/dmesg/dmesg.c
diff -u src/sbin/dmesg/dmesg.c:1.29 src/sbin/dmesg/dmesg.c:1.30
--- src/sbin/dmesg/dmesg.c:1.29	Sun Apr  1 15:36:13 2018
+++ src/sbin/dmesg/dmesg.c	Sun Apr  1 21:15:31 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: dmesg.c,v 1.29 2018/04/01 19:36:13 christos Exp $	*/
+/*	$NetBSD: dmesg.c,v 1.30 2018/04/02 01:15:31 christos Exp $	*/
 /*-
  * Copyright (c) 1991, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -38,7 +38,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)dmesg.c	8.1 (Berkeley) 6/5/93";
 #else
-__RCSID("$NetBSD: dmesg.c,v 1.29 2018/04/01 19:36:13 christos Exp $");
+__RCSID("$NetBSD: dmesg.c,v 1.30 2018/04/02 01:15:31 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -187,6 +187,8 @@ main(int argc, char *argv[])
 #define ADDC(c)
 #endif
 		ch = *p;
+		if (ch == '\0')
+			continue;
 		/* Skip "\n<.*>" syslog sequences. */
 		/* Gather timestamp sequences */
 		if (newl) {
@@ -239,8 +241,6 @@ main(int argc, char *argv[])
 			}
 			newl = 0;
 		}
-		if (ch == '\0')
-			continue;
 		newl = ch == '\n';
 		(void)vis(buf, ch, VIS_NOSLASH, 0);
 #ifndef SMALL



CVS commit: src/sys/dev/usb

2018-04-01 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Mon Apr  2 00:45:06 UTC 2018

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
Add Linux Foundation vendor ID, and their root hub device IDs.


To generate a diff of this commit:
cvs rdiff -u -r1.746 -r1.747 src/sys/dev/usb/usbdevs

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/usb/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.746 src/sys/dev/usb/usbdevs:1.747
--- src/sys/dev/usb/usbdevs:1.746	Sat Mar 17 19:37:11 2018
+++ src/sys/dev/usb/usbdevs	Mon Apr  2 00:45:06 2018
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.746 2018/03/17 19:37:11 jdolecek Exp $
+$NetBSD: usbdevs,v 1.747 2018/04/02 00:45:06 jakllsch Exp $
 
 /*
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -547,6 +547,7 @@ vendor MPMAN		0x1cae	MPMan
 vendor 4GSYSTEMS	0x1c9e	4G Systems
 vendor PEGATRON		0x1d4d	Pegatron
 vendor FUTUREBITS	0x1d50	Future Bits
+vendor LINUXFOUNDATION	0x1d6b  Linux Foundation
 vendor AIRTIES		0x1eda	AirTies
 vendor DLINK		0x2001	D-Link
 vendor PLANEX2		0x2019	Planex Communications
@@ -2068,6 +2069,10 @@ product LINKSYS4 WUSB54GC_3	0x0077	WUSB5
 product LINKSYS4 RT3070		0x0078	RT3070
 product LINKSYS4 WUSB600NV2	0x0079	WUSB600N v2
 
+product LINUXFOUNDATION ROOT_HUB_11	0x0001	1.1 root hub
+product LINUXFOUNDATION ROOT_HUB_20	0x0002	2.0 root hub
+product LINUXFOUNDATION ROOT_HUB_30	0x0003	3.0 root hub
+
 /* Lite-On Technology */
 product LITEON AR9271		0x4605	AR9271
 



CVS commit: [pgoyette-compat] src/sys/kern

2018-04-01 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Apr  2 00:18:43 UTC 2018

Modified Files:
src/sys/kern [pgoyette-compat]: kern_module.c

Log Message:
Typos (new = old, not old = new!), whitespace, and consistency in
references to the dynamically allocated array of required modules.


To generate a diff of this commit:
cvs rdiff -u -r1.130.2.7 -r1.130.2.8 src/sys/kern/kern_module.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_module.c
diff -u src/sys/kern/kern_module.c:1.130.2.7 src/sys/kern/kern_module.c:1.130.2.8
--- src/sys/kern/kern_module.c:1.130.2.7	Sun Apr  1 23:06:11 2018
+++ src/sys/kern/kern_module.c	Mon Apr  2 00:18:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_module.c,v 1.130.2.7 2018/04/01 23:06:11 pgoyette Exp $	*/
+/*	$NetBSD: kern_module.c,v 1.130.2.8 2018/04/02 00:18:43 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.7 2018/04/01 23:06:11 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.8 2018/04/02 00:18:43 pgoyette Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -787,10 +787,10 @@ alloc_required(module_t *mod)
 
 	if (mod->mod_nrequired >= mod->mod_arequired) {
 		areq = mod->mod_arequired + MAXMODDEPS;
-		old= mod->mod_required;
-		new= kmem_alloc(areq * sizeof(module_t *), KM_SLEEP);
+		old = mod->mod_required;
+		new = kmem_zalloc(areq * sizeof(module_t *), KM_SLEEP);
 		for (i = 0; i< mod->mod_arequired; i++)
-			(*old)[i] = (*new)[i];
+			(*new)[i] = (*old)[i];
 		mod->mod_required = new;
 		if (old)
 			kmem_free(old, mod->mod_arequired * sizeof(module_t *));
@@ -870,7 +870,7 @@ module_do_builtin(const module_t *pmod, 
 			error = module_do_builtin(mod, buf, , NULL);
 			if (error != 0)
 goto fail;
-			*mod->mod_required[mod->mod_nrequired++] = mod2;
+			(*mod->mod_required)[mod->mod_nrequired++] = mod2;
 		}
 	}
 
@@ -1172,7 +1172,7 @@ module_do_load(const char *name, bool is
 buf, error);
 goto fail;
 			}
-			*mod->mod_required[mod->mod_nrequired++] = mod2;
+			(*mod->mod_required)[mod->mod_nrequired++] = mod2;
 		}
 	}
 



CVS commit: src/crypto/external/bsd/netpgp/dist/include

2018-04-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Apr  1 23:38:02 UTC 2018

Modified Files:
src/crypto/external/bsd/netpgp/dist/include: netpgp.h

Log Message:
remove unused struct tag.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 \
src/crypto/external/bsd/netpgp/dist/include/netpgp.h

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

Modified files:

Index: src/crypto/external/bsd/netpgp/dist/include/netpgp.h
diff -u src/crypto/external/bsd/netpgp/dist/include/netpgp.h:1.21 src/crypto/external/bsd/netpgp/dist/include/netpgp.h:1.22
--- src/crypto/external/bsd/netpgp/dist/include/netpgp.h:1.21	Mon Sep  6 14:19:38 2010
+++ src/crypto/external/bsd/netpgp/dist/include/netpgp.h	Sun Apr  1 19:38:02 2018
@@ -42,7 +42,7 @@
 __BEGIN_DECLS
 
 /* structure used to hold (key,value) pair information */
-typedef struct netpgp_t {
+typedef struct {
 	unsigned	  c;		/* # of elements used */
 	unsigned	  size;		/* size of array */
 	char		**name;		/* key names */



CVS commit: src/crypto/external/bsd/netpgp/dist/src/lib

2018-04-01 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Sun Apr  1 23:25:28 UTC 2018

Modified Files:
src/crypto/external/bsd/netpgp/dist/src/lib: libnetpgp.3

Log Message:
netpgp_t is a structure


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 \
src/crypto/external/bsd/netpgp/dist/src/lib/libnetpgp.3

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

Modified files:

Index: src/crypto/external/bsd/netpgp/dist/src/lib/libnetpgp.3
diff -u src/crypto/external/bsd/netpgp/dist/src/lib/libnetpgp.3:1.16 src/crypto/external/bsd/netpgp/dist/src/lib/libnetpgp.3:1.17
--- src/crypto/external/bsd/netpgp/dist/src/lib/libnetpgp.3:1.16	Mon Feb 17 07:23:18 2014
+++ src/crypto/external/bsd/netpgp/dist/src/lib/libnetpgp.3	Sun Apr  1 23:25:27 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: libnetpgp.3,v 1.16 2014/02/17 07:23:18 agc Exp $
+.\" $NetBSD: libnetpgp.3,v 1.17 2018/04/01 23:25:27 sevan Exp $
 .\"
 .\" Copyright (c) 2009,2010 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 February 16, 2014
+.Dd April 02, 2018
 .Dt LIBNETPGP 3
 .Os
 .Sh NAME
@@ -41,11 +41,11 @@
 The following functions relate to initialisations and finalisations:
 .Ft int
 .Fo netpgp_init
-.Fa "netpgp_t *netpgp"
+.Fa "struct netpgp_t *netpgp"
 .Fc
 .Ft int
 .Fo netpgp_end
-.Fa "netpgp_t *netpgp"
+.Fa "struct netpgp_t *netpgp"
 .Fc
 .Pp
 The following functions are for debugging, reflection and information:
@@ -63,99 +63,99 @@ The following functions are for debuggin
 .Fc
 .Ft int
 .Fo netpgp_list_packets
-.Fa "netpgp_t *netpgp" "char *filename" "int armour" "char *pubringname"
+.Fa "struct netpgp_t *netpgp" "char *filename" "int armour" "char *pubringname"
 .Fc
 .Pp
 The following functions are for variable management:
 .Ft int
 .Fo netpgp_setvar
-.Fa "netpgp_t *netpgp" "const char *name" "const char *value"
+.Fa "struct netpgp_t *netpgp" "const char *name" "const char *value"
 .Fc
 .Ft char *
 .Fo netpgp_getvar
-.Fa "netpgp_t *netpgp" "const char *name"
+.Fa "struct netpgp_t *netpgp" "const char *name"
 .Fc
 .Ft int
 .Fo netpgp_incvar
-.Fa "netpgp_t *netpgp" "const char *name" "const int delta"
+.Fa "struct netpgp_t *netpgp" "const char *name" "const int delta"
 .Fc
 .Pp
 The following function sets the home directory:
 .Ft int
 .Fo netpgp_set_homedir
-.Fa "netpgp_t *netpgp" "char *homedir" "char *subdir" "const int quiet"
+.Fa "struct netpgp_t *netpgp" "char *homedir" "char *subdir" "const int quiet"
 .Fc
 .Pp
 The following functions are used for key management:
 .Ft int
 .Fo netpgp_list_keys
-.Fa "netpgp_t *netpgp" "const int printsigs"
+.Fa "struct netpgp_t *netpgp" "const int printsigs"
 .Fc
 .Ft int
 .Fo netpgp_match_list_keys
-.Fa "netpgp_t *netpgp" "char *pattern"
+.Fa "struct netpgp_t *netpgp" "char *pattern"
 .Fc
 .Ft int
 .Fo netpgp_find_key
-.Fa "netpgp_t *netpgp" "char *userid"
+.Fa "struct netpgp_t *netpgp" "char *userid"
 .Fc
 .Ft char *
 .Fo netpgp_get_key
-.Fa "netpgp_t *netpgp" "const char *id"
+.Fa "struct netpgp_t *netpgp" "const char *id"
 .Fc
 .Ft int
 .Fo netpgp_export_key
-.Fa "netpgp_t *netpgp" "char *userid"
+.Fa "struct netpgp_t *netpgp" "char *userid"
 .Fc
 .Ft int
 .Fo netpgp_import_key
-.Fa "netpgp_t *netpgp" "char *file"
+.Fa "struct netpgp_t *netpgp" "char *file"
 .Fc
 .Ft int
 .Fo netpgp_generate_key
-.Fa "netpgp_t *netpgp" "char *userid" "int numbits"
+.Fa "struct netpgp_t *netpgp" "char *userid" "int numbits"
 .Fc
 .Pp
 The following functions are used for file management:
 .Ft int
 .Fo netpgp_encrypt_file
-.Fa "netpgp_t *netpgp" "char *userid" "char *filename" "char *out"
+.Fa "struct netpgp_t *netpgp" "char *userid" "char *filename" "char *out"
 .Fa "int armored"
 .Fc
 .Ft int
 .Fo netpgp_decrypt_file
-.Fa "netpgp_t *netpgp" "char *filename" "char *out" "int armored"
+.Fa "struct netpgp_t *netpgp" "char *filename" "char *out" "int armored"
 .Fc
 .Ft int
 .Fo netpgp_sign_file
-.Fa "netpgp_t *netpgp" "char *userid" "char *filename" "char *out"
+.Fa "struct netpgp_t *netpgp" "char *userid" "char *filename" "char *out"
 .Fa "int armored" "int cleartext" "int detached"
 .Fc
 .Ft int
 .Fo netpgp_verify_file
-.Fa "netpgp_t *netpgp" "char *f" "int armored"
+.Fa "struct netpgp_t *netpgp" "char *f" "int armored"
 .Fc
 .Pp
 The following functions are used for memory signing and encryption:
 .Ft int
 .Fo netpgp_encrypt_memory
-.Fa "netpgp_t *netpgp" "char *userid" "void *in" "const size_t insize"
+.Fa "struct netpgp_t *netpgp" "char *userid" "void *in" "const size_t insize"
 .Fa "char *out" "size_t outsize" "int armored"
 .Fc
 .Ft int
 .Fo netpgp_decrypt_memory
-.Fa "netpgp_t *netpgp" "const void *input" "const size_t insize"
+.Fa "struct netpgp_t *netpgp" "const void *input" "const size_t insize"
 .Fa "char *out" "size_t outsize" "const int armored"
 .Fc
 .Ft int
 .Fo netpgp_sign_memory
-.Fa 

CVS commit: [pgoyette-compat] src/sys/compat/common

2018-04-01 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sun Apr  1 23:07:57 UTC 2018

Modified Files:
src/sys/compat/common [pgoyette-compat]: compat_12_mod.c
compat_13_mod.c

Log Message:
Update modules' required lists to take advantage of the new unlimited
number of requirements permitted.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/compat/common/compat_12_mod.c \
src/sys/compat/common/compat_13_mod.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/compat/common/compat_12_mod.c
diff -u src/sys/compat/common/compat_12_mod.c:1.1.2.1 src/sys/compat/common/compat_12_mod.c:1.1.2.2
--- src/sys/compat/common/compat_12_mod.c:1.1.2.1	Sat Mar 31 09:17:35 2018
+++ src/sys/compat/common/compat_12_mod.c	Sun Apr  1 23:07:57 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_12_mod.c,v 1.1.2.1 2018/03/31 09:17:35 pgoyette Exp $	*/
+/*	$NetBSD: compat_12_mod.c,v 1.1.2.2 2018/04/01 23:07:57 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: compat_12_mod.c,v 1.1.2.1 2018/03/31 09:17:35 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_12_mod.c,v 1.1.2.2 2018/04/01 23:07:57 pgoyette Exp $");
 
 #include 
 #include 
@@ -98,10 +98,11 @@ compat_12_fini(void)
 
 #ifdef _MODULE
 
-#define REQD_12_1	"compat_60,compat_50,compat_40,compat_30,"
-#define REQD_12_2	"compat_20,compat_16,compat_14,compat_13"
+#define REQD_12_1	"compat_80,compat_70,compat_60,compat_50,"
+#define REQD_12_2	"compat_40,compat_30,compat_20,compat_16,"
+#define REQD_12_3	"compat_14,compat_13"
 
-MODULE(MODULE_CLASS_EXEC, compat_12, REQD_12_1 REQD_12_2);
+MODULE(MODULE_CLASS_EXEC, compat_12, REQD_12_1 REQD_12_2 REQD_12_3);
 
 static int
 compat_12_modcmd(modcmd_t cmd, void *arg)
Index: src/sys/compat/common/compat_13_mod.c
diff -u src/sys/compat/common/compat_13_mod.c:1.1.2.1 src/sys/compat/common/compat_13_mod.c:1.1.2.2
--- src/sys/compat/common/compat_13_mod.c:1.1.2.1	Fri Mar 30 11:18:34 2018
+++ src/sys/compat/common/compat_13_mod.c	Sun Apr  1 23:07:57 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_13_mod.c,v 1.1.2.1 2018/03/30 11:18:34 pgoyette Exp $	*/
+/*	$NetBSD: compat_13_mod.c,v 1.1.2.2 2018/04/01 23:07:57 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: compat_13_mod.c,v 1.1.2.1 2018/03/30 11:18:34 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_13_mod.c,v 1.1.2.2 2018/04/01 23:07:57 pgoyette Exp $");
 
 #include 
 #include 
@@ -76,10 +76,11 @@ compat_13_fini(void)
 
 #ifdef _MODULE
 
-#define REQD_13_1	"compat_70,compat_60,compat_50,compat_40,"
-#define REQD_13_2	"compat_30,compat_20,compat_16,compat_14"
+#define REQD_13_1	"compat_80,compat_70,compat_60,compat_50,"
+#define REQD_13_2	"compat_40,compat_30,compat_20,compat_16,"
+#define REQD_13_3	"compat_14"
 
-MODULE(MODULE_CLASS_EXEC, compat_13, REQD_13_1 REQD_13_2);
+MODULE(MODULE_CLASS_EXEC, compat_13, REQD_13_1 REQD_13_2 REQD_13_3);
 
 static int
 compat_13_modcmd(modcmd_t cmd, void *arg)



CVS commit: [pgoyette-compat] src/external/cddl/osnet/dev/fbt

2018-04-01 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sun Apr  1 23:06:51 UTC 2018

Modified Files:
src/external/cddl/osnet/dev/fbt [pgoyette-compat]: fbt.c

Log Message:
Adapt to new dynamically-allocate required-module array


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.23.2.1 src/external/cddl/osnet/dev/fbt/fbt.c

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

Modified files:

Index: src/external/cddl/osnet/dev/fbt/fbt.c
diff -u src/external/cddl/osnet/dev/fbt/fbt.c:1.23 src/external/cddl/osnet/dev/fbt/fbt.c:1.23.2.1
--- src/external/cddl/osnet/dev/fbt/fbt.c:1.23	Mon Nov  6 04:43:50 2017
+++ src/external/cddl/osnet/dev/fbt/fbt.c	Sun Apr  1 23:06:51 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: fbt.c,v 1.23 2017/11/06 04:43:50 christos Exp $	*/
+/*	$NetBSD: fbt.c,v 1.23.2.1 2018/04/01 23:06:51 pgoyette Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -957,7 +957,7 @@ fbt_provide_module(void *arg, dtrace_mod
 	 * dependency are ineligible for FBT tracing.
 	 */
 	for (i = 0; i < mod->mod_nrequired; i++) {
-		if (strncmp(mod->mod_required[i]->mod_info->mi_name,
+		if (strncmp((*mod->mod_required)[i]->mod_info->mi_name,
 			"dtrace", 6) == 0)
 			return;
 	}



CVS commit: [pgoyette-compat] src/sys

2018-04-01 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sun Apr  1 23:06:11 UTC 2018

Modified Files:
src/sys/kern [pgoyette-compat]: kern_module.c sys_module.c
src/sys/sys [pgoyette-compat]: module.h

Log Message:
Remove fixed limit on number of modules which can be "required" by
a module.  Instead, allocate the array dynamically, and expand it
when needed.

XXX Note the modctl(2)'s MODCTL_STAT routine needs to be updated
(and versioned) to handle the unlimited size.  For now, the kernel
will simply truncate the required list if it doesn't fit in the
existing export structure.


To generate a diff of this commit:
cvs rdiff -u -r1.130.2.6 -r1.130.2.7 src/sys/kern/kern_module.c
cvs rdiff -u -r1.23.2.4 -r1.23.2.5 src/sys/kern/sys_module.c
cvs rdiff -u -r1.41.14.6 -r1.41.14.7 src/sys/sys/module.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/kern/kern_module.c
diff -u src/sys/kern/kern_module.c:1.130.2.6 src/sys/kern/kern_module.c:1.130.2.7
--- src/sys/kern/kern_module.c:1.130.2.6	Sat Mar 31 08:34:17 2018
+++ src/sys/kern/kern_module.c	Sun Apr  1 23:06:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_module.c,v 1.130.2.6 2018/03/31 08:34:17 pgoyette Exp $	*/
+/*	$NetBSD: kern_module.c,v 1.130.2.7 2018/04/01 23:06:11 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.6 2018/03/31 08:34:17 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.7 2018/04/01 23:06:11 pgoyette Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -765,8 +765,8 @@ module_enqueue(module_t *mod)
 
 		/* Add references to the requisite modules. */
 		for (i = 0; i < mod->mod_nrequired; i++) {
-			KASSERT(mod->mod_required[i] != NULL);
-			mod->mod_required[i]->mod_refcnt++;
+			KASSERT((*mod->mod_required)[i] != NULL);
+			(*mod->mod_required)[i]->mod_refcnt++;
 		}
 	}
 	module_count++;
@@ -774,6 +774,31 @@ module_enqueue(module_t *mod)
 }
 
 /*
+ * Our array of required module pointers starts with zero entries.  If we
+ * need to add a new entry, and the list is already full, we reallocate a
+ * larger array, adding MAXMODDEPS entries.
+ */
+static void
+alloc_required(module_t *mod)
+{
+	module_t *(*new)[], *(*old)[];
+	int areq;
+	int i;
+
+	if (mod->mod_nrequired >= mod->mod_arequired) {
+		areq = mod->mod_arequired + MAXMODDEPS;
+		old= mod->mod_required;
+		new= kmem_alloc(areq * sizeof(module_t *), KM_SLEEP);
+		for (i = 0; i< mod->mod_arequired; i++)
+			(*old)[i] = (*new)[i];
+		mod->mod_required = new;
+		if (old)
+			kmem_free(old, mod->mod_arequired * sizeof(module_t *));
+		mod->mod_arequired = areq;
+	}
+}
+
+/*
  * module_do_builtin:
  *
  *	Initialize a module from the list of modules that are
@@ -830,6 +855,7 @@ module_do_builtin(const module_t *pmod, 
 	 * Initialize pre-requisites.
 	 */
 	if (mi->mi_required != NULL) {
+		mod->mod_arequired = 0;
 		for (s = mi->mi_required; *s != '\0'; s = p) {
 			if (*s == ',')
 s++;
@@ -840,17 +866,11 @@ module_do_builtin(const module_t *pmod, 
 			strlcpy(buf, s, len);
 			if (buf[0] == '\0')
 break;
-			if (mod->mod_nrequired == MAXMODDEPS - 1) {
-module_error("%s: too many required modules "
-"%d >= %d", pmod->mod_info->mi_name,
-mod->mod_nrequired, MAXMODDEPS - 1);
-return EINVAL;
-			}
+			alloc_required(mod);
 			error = module_do_builtin(mod, buf, , NULL);
-			if (error != 0) {
-return error;
-			}
-			mod->mod_required[mod->mod_nrequired++] = mod2;
+			if (error != 0)
+goto fail;
+			*mod->mod_required[mod->mod_nrequired++] = mod2;
 		}
 	}
 
@@ -863,7 +883,8 @@ module_do_builtin(const module_t *pmod, 
 			if ((mod2 = module_lookup(*aliasp++)) != NULL) {
 if (modp != NULL)
 	*modp = mod2;
-return EEXIST;
+error = EEXIST;
+goto fail;
 			}
 		}
 	}
@@ -877,7 +898,7 @@ module_do_builtin(const module_t *pmod, 
 	if (error != 0) {
 		module_error("builtin module `%s' "
 		"failed to init, error %d", mi->mi_name, error);
-		return error;
+		goto fail;
 	}
 
 	/* load always succeeds after this point */
@@ -889,6 +910,12 @@ module_do_builtin(const module_t *pmod, 
 	}
 	module_enqueue(mod);
 	return 0;
+
+ fail:
+	if (mod->mod_required)
+		kmem_free(mod->mod_required, mod->mod_arequired *
+		sizeof(module_t *));
+	return error;
 }
 
 /*
@@ -1112,6 +1139,7 @@ module_do_load(const char *name, bool is
 	 * Now try to load any requisite modules.
 	 */
 	if (mi->mi_required != NULL) {
+		mod->mod_arequired = 0;
 		for (s = mi->mi_required; *s != '\0'; s = p) {
 			if (*s == ',')
 s++;
@@ -1129,13 +1157,7 @@ module_do_load(const char *name, bool is
 			strlcpy(buf, s, len);
 			if (buf[0] == '\0')
 break;
-			if (mod->mod_nrequired == MAXMODDEPS - 1) {
-error = EINVAL;
-module_error("too many required modules "
-"%d >= %d", mod->mod_nrequired,
-MAXMODDEPS 

CVS commit: src/usr.sbin/racoon

2018-04-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Apr  1 23:00:40 UTC 2018

Modified Files:
src/usr.sbin/racoon: Makefile

Log Message:
add commented out debugging options.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/racoon/Makefile

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/racoon/Makefile
diff -u src/usr.sbin/racoon/Makefile:1.34 src/usr.sbin/racoon/Makefile:1.35
--- src/usr.sbin/racoon/Makefile:1.34	Sat Feb 24 19:16:49 2018
+++ src/usr.sbin/racoon/Makefile	Sun Apr  1 19:00:40 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.34 2018/02/25 00:16:49 mrg Exp $
+# $NetBSD: Makefile,v 1.35 2018/04/01 23:00:40 christos Exp $
 
 WARNS?=	0	# XXX third-party program, many issues
 NOCLANGERROR=	# defined
@@ -61,6 +61,12 @@ CPPFLAGS+=-DINET6
 LDADD+= -lcrypto -lcrypt
 DPADD+= ${LIBIPSEC} ${LIBCRYPT}
 
+#CPPFLAGS+= -DDEBUG_RECORD_MALLOCATION
+#SRCS+= debugrm.c
+
+#CFLAGS+=-fsanitize=address
+#LDFLAGS+=-fsanitize=address
+
 .PATH:  ${NETBSDSRCDIR}/lib/libipsec ${DIST}/src/racoon
 
 prsa_tok.c: ${DIST}/src/racoon/prsa_tok.l



CVS commit: src/crypto/dist/ipsec-tools/src/racoon

2018-04-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Apr  1 22:59:58 UTC 2018

Modified Files:
src/crypto/dist/ipsec-tools/src/racoon: crypto_openssl.c

Log Message:
Avoid double frees (thanks asan)


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 \
src/crypto/dist/ipsec-tools/src/racoon/crypto_openssl.c

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

Modified files:

Index: src/crypto/dist/ipsec-tools/src/racoon/crypto_openssl.c
diff -u src/crypto/dist/ipsec-tools/src/racoon/crypto_openssl.c:1.27 src/crypto/dist/ipsec-tools/src/racoon/crypto_openssl.c:1.28
--- src/crypto/dist/ipsec-tools/src/racoon/crypto_openssl.c:1.27	Tue Feb  6 22:59:03 2018
+++ src/crypto/dist/ipsec-tools/src/racoon/crypto_openssl.c	Sun Apr  1 18:59:57 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypto_openssl.c,v 1.27 2018/02/07 03:59:03 christos Exp $	*/
+/*	$NetBSD: crypto_openssl.c,v 1.28 2018/04/01 22:59:57 christos Exp $	*/
 
 /* Id: crypto_openssl.c,v 1.47 2006/05/06 20:42:09 manubsd Exp */
 
@@ -2331,6 +2331,7 @@ eay_dh_generate(prime, ig, publen, pub, 
 		goto end;
 	if (!DH_set0_pqg(dh, p, NULL, g))
 		goto end;
+	p = g = NULL;
 
 	if (publen != 0)
 		DH_set_length(dh, publen);
@@ -2395,9 +2396,11 @@ eay_dh_compute(prime, ig, pub, priv, pub
 
 	if (!DH_set0_pqg(dh, p, NULL, g))
 		goto end;
+	p = g = NULL;
 
 	if (!DH_set0_key(dh, pub_key, priv_key))
 		goto end;
+	pub_key = priv_key = NULL;
 
 	if ((v = racoon_calloc(prime->l, sizeof(u_char))) == NULL)
 		goto end;
@@ -2565,7 +2568,6 @@ binbuf_pubkey2rsa(vchar_t *binbuf)
 	return rsa_pub;
 out:
 	BN_free(exp);
-	BN_free(exp);
 	RSA_free(rsa_pub);
 	return NULL;
 }



CVS commit: src/crypto/dist/ipsec-tools/src/racoon

2018-04-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Apr  1 22:35:22 UTC 2018

Modified Files:
src/crypto/dist/ipsec-tools/src/racoon: debugrm.c debugrm.h

Log Message:
make debugrm compile again.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/crypto/dist/ipsec-tools/src/racoon/debugrm.c
cvs rdiff -u -r1.4 -r1.5 src/crypto/dist/ipsec-tools/src/racoon/debugrm.h

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

Modified files:

Index: src/crypto/dist/ipsec-tools/src/racoon/debugrm.c
diff -u src/crypto/dist/ipsec-tools/src/racoon/debugrm.c:1.3 src/crypto/dist/ipsec-tools/src/racoon/debugrm.c:1.4
--- src/crypto/dist/ipsec-tools/src/racoon/debugrm.c:1.3	Sat Sep  9 12:22:09 2006
+++ src/crypto/dist/ipsec-tools/src/racoon/debugrm.c	Sun Apr  1 18:35:22 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: debugrm.c,v 1.3 2006/09/09 16:22:09 manu Exp $	*/
+/*	$NetBSD: debugrm.c,v 1.4 2018/04/01 22:35:22 christos Exp $	*/
 
 /*	$KAME: debugrm.c,v 1.6 2001/12/13 16:07:46 sakane Exp $	*/
 
@@ -51,37 +51,38 @@
 #define DRMLISTSIZE 1024
 
 struct drm_list_t {
-	void *ptr;
+	const void *ptr;
 	char msg[100];
 };
 static struct drm_list_t drmlist[DRMLISTSIZE];
 
 static int drm_unknown;
 
-static void DRM_add __P((void *, char *));
-static void DRM_del __P((void *));
-static void DRM_setmsg __P((char *, int, void *, int, char *, int, char *));
+static void DRM_add(const void *, const char *);
+static void DRM_del(const void *);
+static void DRM_setmsg(char *, size_t, const void *, size_t, const char *,
+size_t, const char *);
 
 void 
-DRM_init()
+DRM_init(void)
 {
-	int i;
+	size_t i;
 	drm_unknown = 0;
-	for (i = 0; i < sizeof(drmlist)/sizeof(drmlist[0]); i++)
+	for (i = 0; i < __arraycount(drmlist); i++)
 		drmlist[i].ptr = 0;
 }
 
 void
-DRM_dump()
+DRM_dump(void)
 {
 	FILE *fp;
-	int i;
+	size_t i;
 
 	fp = fopen(DRMDUMPFILE, "w");
 	if (fp == NULL)
 		err(1, "fopen");	/*XXX*/
 	fprintf(fp, "drm_unknown=%d\n", drm_unknown);
-	for (i = 0; i < sizeof(drmlist)/sizeof(drmlist[0]); i++) {
+	for (i = 0; i < __arraycount(drmlist); i++) {
 		if (drmlist[i].ptr)
 			fprintf(fp, "%s\n", drmlist[i].msg);
 	}
@@ -89,12 +90,10 @@ DRM_dump()
 }
 
 static void 
-DRM_add(p, msg)
-	void *p;
-	char *msg;
+DRM_add(const void *p, const char *msg)
 {
-	int i;
-	for (i = 0; i < sizeof(drmlist)/sizeof(drmlist[0]); i++) {
+	size_t i;
+	for (i = 0; i < __arraycount(drmlist); i++) {
 		if (!drmlist[i].ptr) {
 			drmlist[i].ptr = p;
 			strlcpy(drmlist[i].msg, msg, sizeof(drmlist[i].msg));
@@ -104,15 +103,14 @@ DRM_add(p, msg)
 }
 
 static void
-DRM_del(p)
-	void *p;
+DRM_del(const void *p)
 {
-	int i;
+	size_t i;
 
 	if (!p)
 		return;
 
-	for (i = 0; i < sizeof(drmlist)/sizeof(drmlist[0]); i++) {
+	for (i = 0; i < __arraycount(drmlist); i++) {
 		if (drmlist[i].ptr == p) {
 			drmlist[i].ptr = 0;
 			return;
@@ -122,10 +120,8 @@ DRM_del(p)
 }
 
 static void
-DRM_setmsg(buf, buflen, ptr, size, file, line, func)
-	char *buf, *file, *func;
-	int buflen, size, line;
-	void *ptr;
+DRM_setmsg(char *buf, size_t buflen, const void *ptr, size_t size,
+const char *file, size_t line, const char *func)
 {
 	time_t t;
 	struct tm *tm;
@@ -136,14 +132,11 @@ DRM_setmsg(buf, buflen, ptr, size, file,
 	len = strftime(buf, buflen, "%Y/%m/%d:%T ", tm);
 
 	snprintf(buf + len, buflen - len, "%p %6d %s:%d:%s",
-		ptr, size, file , line, func);
+		ptr, size, file, line, func);
 }
 
 void *
-DRM_malloc(file, line, func, size)
-	char *file, *func;
-	int line;
-	size_t size;
+DRM_malloc(const char *file, size_t line, const char *func, size_t size)
 {
 	void *p;
 
@@ -158,10 +151,8 @@ DRM_malloc(file, line, func, size)
 }
 
 void *
-DRM_calloc(file, line, func, number, size)
-	char *file, *func;
-	int line;
-	size_t number, size;
+DRM_calloc(const char *file, size_t line, const char *func, size_t number,
+size_t size)
 {
 	void *p;
 
@@ -175,11 +166,8 @@ DRM_calloc(file, line, func, number, siz
 }
 
 void *
-DRM_realloc(file, line, func, ptr, size)
-	char *file, *func;
-	int line;
-	void *ptr;
-	size_t size;
+DRM_realloc(const char *file, size_t line, const char *func, void *ptr,
+size_t size)
 {
 	void *p;
 
@@ -197,20 +185,14 @@ DRM_realloc(file, line, func, ptr, size)
 }
 
 void
-DRM_free(file, line, func, ptr)
-	char *file, *func;
-	int line;
-	void *ptr;
+DRM_free(const char *file, size_t line, const char *func, void *ptr)
 {
 	DRM_del(ptr);
 	free(ptr);
 }
 
 char *
-DRM_strdup(file, line, func, str)
-	char *file, *func;
-	int line;
-	const char *str;
+DRM_strdup(const char *file, size_t line, const char *func, const char *str)
 {
 	char *p;
 
@@ -218,7 +200,7 @@ DRM_strdup(file, line, func, str)
 
 	if (p) {
 		char buf[1024];
-		DRM_setmsg(buf, sizeof(buf), p, size, file, line, func);
+		DRM_setmsg(buf, sizeof(buf), p, strlen(p), file, line, func);
 		DRM_add(p, buf);
 	}
 
@@ -229,10 +211,7 @@ DRM_strdup(file, line, func, str)
  * mask vmbuf.c functions.
  */
 

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

2018-04-01 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Apr  1 21:19:18 UTC 2018

Modified Files:
src/sys/arch/arm/sunxi: files.sunxi sun4i_a10_ccu.c sunxi_ccu.c
sunxi_ccu.h sunxi_ccu_fractional.c
Added Files:
src/sys/arch/arm/sunxi: sunxi_ccu_display.c

Log Message:
Add a round_rate() callback for the sunxi clock domain.
Add a sunxi_ccu_display.c file with helpers for setting up display engine
clocks.
for fractional clocks, rename frac_en to div_en, I got the logic inverted.
Adjust tcon0-ch0, tcon0-ch1, tcon1-ch0 and tcon1-ch1 definitions to
automatically select a parent. tcon0 hardcoded to pll3 and tcon1 to pll7.
Define a round_rate() callback for these clocks, as well as fractional clocks.
Hardcode debe clocks parent to pll5.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/arm/sunxi/files.sunxi
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sun4i_a10_ccu.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sunxi/sunxi_ccu.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/sunxi/sunxi_ccu.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/sunxi/sunxi_ccu_display.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sunxi_ccu_fractional.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/sunxi/files.sunxi
diff -u src/sys/arch/arm/sunxi/files.sunxi:1.46 src/sys/arch/arm/sunxi/files.sunxi:1.47
--- src/sys/arch/arm/sunxi/files.sunxi:1.46	Sun Apr  1 04:35:04 2018
+++ src/sys/arch/arm/sunxi/files.sunxi	Sun Apr  1 21:19:17 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sunxi,v 1.46 2018/04/01 04:35:04 ryo Exp $
+#	$NetBSD: files.sunxi,v 1.47 2018/04/01 21:19:17 bouyer Exp $
 #
 # Configuration info for Allwinner sunxi family SoCs
 #
@@ -17,6 +17,7 @@ file	arch/arm/sunxi/sunxi_ccu_nm.c		sunx
 file	arch/arm/sunxi/sunxi_ccu_nkmp.c		sunxi_ccu
 file	arch/arm/sunxi/sunxi_ccu_phase.c	sunxi_ccu
 file	arch/arm/sunxi/sunxi_ccu_prediv.c	sunxi_ccu
+file	arch/arm/sunxi/sunxi_ccu_display.c	sunxi_ccu
 
 # CCU (A10/A20)
 device	sun4ia10ccu: sunxi_ccu

Index: src/sys/arch/arm/sunxi/sun4i_a10_ccu.c
diff -u src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.7 src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.8
--- src/sys/arch/arm/sunxi/sun4i_a10_ccu.c:1.7	Mon Mar 19 16:18:30 2018
+++ src/sys/arch/arm/sunxi/sun4i_a10_ccu.c	Sun Apr  1 21:19:17 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: sun4i_a10_ccu.c,v 1.7 2018/03/19 16:18:30 bouyer Exp $ */
+/* $NetBSD: sun4i_a10_ccu.c,v 1.8 2018/04/01 21:19:17 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sun4i_a10_ccu.c,v 1.7 2018/03/19 16:18:30 bouyer Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun4i_a10_ccu.c,v 1.8 2018/04/01 21:19:17 bouyer Exp $");
 
 #include 
 #include 
@@ -116,10 +116,7 @@ static const char *apb1_parents[] = { "o
 static const char *mod_parents[] = { "osc24m", "pll_periph", "pll_ddr_other" };
 static const char *sata_parents[] = { "pll6_periph_sata", "external" };
 static const char *de_parents[] = { "pll_video0", "pll_video1", "pll_ddr_other" };
-static const char *lcd0_parents[] = { "pll_video0", "pll_video1", "pll_video0x2" };
-static const char *lcd1_parents[] = { "pll_video0", "pll_video1", "pll_video0x2", "pll_video1x2" };
-static const char *lcd0ch1c2[] = { "tcon0-ch1-clk2" };
-static const char *lcd1ch1c2[] = { "tcon1-ch1-clk2" };
+static const char *lcd_parents[] = { "pll_video0", "pll_video1", "pll_video0x2", "pll_video1x2" };
 
 static const struct sunxi_ccu_nkmp_tbl sun4i_a10_pll1_table[] = {
 	{ 100800, 21, 1, 0, 0 },
@@ -139,6 +136,25 @@ static const struct sunxi_ccu_nkmp_tbl s
 	{ 0 }
 };
 
+/*
+ * some special cases
+ * hardcode lcd0 (tcon0) to pll3 and lcd1 (tcon1) to pll7.
+ * compute pll rate based on desired pixel clock
+ */
+
+static int sun4i_a10_ccu_lcd0ch0_set_rate(struct sunxi_ccu_softc *,
+struct sunxi_ccu_clk *, u_int);
+static int sun4i_a10_ccu_lcd1ch0_set_rate(struct sunxi_ccu_softc *,
+struct sunxi_ccu_clk *, u_int);
+static u_int sun4i_a10_ccu_lcd0ch0_round_rate(struct sunxi_ccu_softc *,
+struct sunxi_ccu_clk *, u_int);
+static u_int sun4i_a10_ccu_lcd1ch0_round_rate(struct sunxi_ccu_softc *,
+struct sunxi_ccu_clk *, u_int);
+static int sun4i_a10_ccu_lcd0ch1_set_rate(struct sunxi_ccu_softc *,
+struct sunxi_ccu_clk *, u_int);
+static int sun4i_a10_ccu_lcd1ch1_set_rate(struct sunxi_ccu_softc *,
+struct sunxi_ccu_clk *, u_int);
+
 static struct sunxi_ccu_clk sun4i_a10_ccu_clks[] = {
 	SUNXI_CCU_GATE(A10_CLK_HOSC, "osc24m", "hosc",
 	OSC24M_CFG_REG, 0),
@@ -302,7 +318,7 @@ static struct sunxi_ccu_clk sun4i_a10_cc
 	__BITS(7,0),		/* m */
 	9,/* m_min */
 	127,			/* m_max */
-	__BIT(15),			/* frac_en */
+	__BIT(15),			/* div_en */
 	__BIT(14),			/* frac_sel */
 	27000, 29700,	/* frac values */
 	8,/* prediv */
@@ -313,7 +329,7 @@ static struct sunxi_ccu_clk sun4i_a10_cc
 

CVS commit: src/sys/dev/clk

2018-04-01 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Apr  1 21:11:01 UTC 2018

Modified Files:
src/sys/dev/clk: clk.c clk.h clk_backend.h

Log Message:
As discussed on tech-kern@ 10 days ago, add a clk_round_rate() method,
which returns the rate that would be used by this clock if clk_set_rate()
was called. Used by drivers (or other clocks) which have their own divider
and need to know the parent's clock capabilities to compute the best
parameters.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/clk/clk.c src/sys/dev/clk/clk.h \
src/sys/dev/clk/clk_backend.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/dev/clk/clk.c
diff -u src/sys/dev/clk/clk.c:1.2 src/sys/dev/clk/clk.c:1.3
--- src/sys/dev/clk/clk.c:1.2	Sun Apr 16 12:28:21 2017
+++ src/sys/dev/clk/clk.c	Sun Apr  1 21:11:01 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: clk.c,v 1.2 2017/04/16 12:28:21 jmcneill Exp $ */
+/* $NetBSD: clk.c,v 1.3 2018/04/01 21:11:01 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: clk.c,v 1.2 2017/04/16 12:28:21 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clk.c,v 1.3 2018/04/01 21:11:01 bouyer Exp $");
 
 #include 
 
@@ -65,6 +65,16 @@ clk_set_rate(struct clk *clk, u_int rate
 	}
 }
 
+u_int
+clk_round_rate(struct clk *clk, u_int rate)
+{
+	if (clk->domain->funcs->round_rate) {
+		return clk->domain->funcs->round_rate(clk->domain->priv,
+		clk, rate);
+	}
+	return 0;
+}
+
 int
 clk_enable(struct clk *clk)
 {
Index: src/sys/dev/clk/clk.h
diff -u src/sys/dev/clk/clk.h:1.2 src/sys/dev/clk/clk.h:1.3
--- src/sys/dev/clk/clk.h:1.2	Sun Apr 16 12:28:21 2017
+++ src/sys/dev/clk/clk.h	Sun Apr  1 21:11:01 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: clk.h,v 1.2 2017/04/16 12:28:21 jmcneill Exp $ */
+/* $NetBSD: clk.h,v 1.3 2018/04/01 21:11:01 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -36,6 +36,7 @@ struct clk *	clk_get(struct clk_domain *
 void		clk_put(struct clk *);
 u_int		clk_get_rate(struct clk *);
 int		clk_set_rate(struct clk *, u_int);
+u_int		clk_round_rate(struct clk *, u_int);
 int		clk_enable(struct clk *);
 int		clk_disable(struct clk *);
 int		clk_set_parent(struct clk *, struct clk *);
Index: src/sys/dev/clk/clk_backend.h
diff -u src/sys/dev/clk/clk_backend.h:1.2 src/sys/dev/clk/clk_backend.h:1.3
--- src/sys/dev/clk/clk_backend.h:1.2	Sun Apr 16 12:28:21 2017
+++ src/sys/dev/clk/clk_backend.h	Sun Apr  1 21:11:01 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: clk_backend.h,v 1.2 2017/04/16 12:28:21 jmcneill Exp $ */
+/* $NetBSD: clk_backend.h,v 1.3 2018/04/01 21:11:01 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -49,6 +49,7 @@ struct clk_funcs {
 
 	u_int (*get_rate)(void *, struct clk *);
 	int (*set_rate)(void *, struct clk *, u_int);
+	u_int (*round_rate)(void *, struct clk *, u_int);
 	int (*enable)(void *, struct clk *);
 	int (*disable)(void *, struct clk *);
 	int (*set_parent)(void *, struct clk *, struct clk *);



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

2018-04-01 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Apr  1 21:05:55 UTC 2018

Modified Files:
src/sys/arch/arm/sunxi: sun7i_a20_gpio.c

Log Message:
Fix lvds output: PD10->19 are for lvds1, not lvds0. But they may be used
by tcon0 when it is set to dual-LVDS mode.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sunxi/sun7i_a20_gpio.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/sunxi/sun7i_a20_gpio.c
diff -u src/sys/arch/arm/sunxi/sun7i_a20_gpio.c:1.1 src/sys/arch/arm/sunxi/sun7i_a20_gpio.c:1.2
--- src/sys/arch/arm/sunxi/sun7i_a20_gpio.c:1.1	Fri Oct  6 21:20:59 2017
+++ src/sys/arch/arm/sunxi/sun7i_a20_gpio.c	Sun Apr  1 21:05:55 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: sun7i_a20_gpio.c,v 1.1 2017/10/06 21:20:59 jmcneill Exp $ */
+/* $NetBSD: sun7i_a20_gpio.c,v 1.2 2018/04/01 21:05:55 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2016 Emmanuel Vadot 
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun7i_a20_gpio.c,v 1.1 2017/10/06 21:20:59 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun7i_a20_gpio.c,v 1.2 2018/04/01 21:05:55 bouyer Exp $");
 
 #include 
 #include 
@@ -118,16 +118,16 @@ static const struct sunxi_gpio_pins a20_
 	{"PD7",  3, 7,  {"gpio_in", "gpio_out", "lcd0", "lvds0", NULL, NULL, NULL, NULL}},
 	{"PD8",  3, 8,  {"gpio_in", "gpio_out", "lcd0", "lvds0", NULL, NULL, NULL, NULL}},
 	{"PD9",  3, 9,  {"gpio_in", "gpio_out", "lcd0", "lvds0", NULL, NULL, NULL, NULL}},
-	{"PD10", 3, 10, {"gpio_in", "gpio_out", "lcd0", "lvds0", NULL, NULL, NULL, NULL}},
-	{"PD11", 3, 11, {"gpio_in", "gpio_out", "lcd0", "lvds0", NULL, NULL, NULL, NULL}},
-	{"PD12", 3, 12, {"gpio_in", "gpio_out", "lcd0", "lvds0", NULL, NULL, NULL, NULL}},
-	{"PD13", 3, 13, {"gpio_in", "gpio_out", "lcd0", "lvds0", NULL, NULL, NULL, NULL}},
-	{"PD14", 3, 14, {"gpio_in", "gpio_out", "lcd0", "lvds0", NULL, NULL, NULL, NULL}},
-	{"PD15", 3, 15, {"gpio_in", "gpio_out", "lcd0", "lvds0", NULL, NULL, NULL, NULL}},
-	{"PD16", 3, 16, {"gpio_in", "gpio_out", "lcd0", "lvds0", NULL, NULL, NULL, NULL}},
-	{"PD17", 3, 17, {"gpio_in", "gpio_out", "lcd0", "lvds0", NULL, NULL, NULL, NULL}},
-	{"PD18", 3, 18, {"gpio_in", "gpio_out", "lcd0", "lvds0", NULL, NULL, NULL, NULL}},
-	{"PD19", 3, 19, {"gpio_in", "gpio_out", "lcd0", "lvds0", NULL, NULL, NULL, NULL}},
+	{"PD10", 3, 10, {"gpio_in", "gpio_out", "lcd0", "lvds1", NULL, NULL, NULL, NULL}},
+	{"PD11", 3, 11, {"gpio_in", "gpio_out", "lcd0", "lvds1", NULL, NULL, NULL, NULL}},
+	{"PD12", 3, 12, {"gpio_in", "gpio_out", "lcd0", "lvds1", NULL, NULL, NULL, NULL}},
+	{"PD13", 3, 13, {"gpio_in", "gpio_out", "lcd0", "lvds1", NULL, NULL, NULL, NULL}},
+	{"PD14", 3, 14, {"gpio_in", "gpio_out", "lcd0", "lvds1", NULL, NULL, NULL, NULL}},
+	{"PD15", 3, 15, {"gpio_in", "gpio_out", "lcd0", "lvds1", NULL, NULL, NULL, NULL}},
+	{"PD16", 3, 16, {"gpio_in", "gpio_out", "lcd0", "lvds1", NULL, NULL, NULL, NULL}},
+	{"PD17", 3, 17, {"gpio_in", "gpio_out", "lcd0", "lvds1", NULL, NULL, NULL, NULL}},
+	{"PD18", 3, 18, {"gpio_in", "gpio_out", "lcd0", "lvds1", NULL, NULL, NULL, NULL}},
+	{"PD19", 3, 19, {"gpio_in", "gpio_out", "lcd0", "lvds1", NULL, NULL, NULL, NULL}},
 	{"PD20", 3, 20, {"gpio_in", "gpio_out", "lcd0", "csi1", NULL, NULL, NULL, NULL}},
 	{"PD21", 3, 21, {"gpio_in", "gpio_out", "lcd0", "sim", NULL, NULL, NULL, NULL}},
 	{"PD22", 3, 22, {"gpio_in", "gpio_out", "lcd0", "sim", NULL, NULL, NULL, NULL}},



CVS commit: src/sbin/dmesg

2018-04-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Apr  1 19:36:13 UTC 2018

Modified Files:
src/sbin/dmesg: dmesg.c

Log Message:
handle log being before timestamp...


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sbin/dmesg/dmesg.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/dmesg/dmesg.c
diff -u src/sbin/dmesg/dmesg.c:1.28 src/sbin/dmesg/dmesg.c:1.29
--- src/sbin/dmesg/dmesg.c:1.28	Sun Apr  1 15:31:16 2018
+++ src/sbin/dmesg/dmesg.c	Sun Apr  1 15:36:13 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: dmesg.c,v 1.28 2018/04/01 19:31:16 christos Exp $	*/
+/*	$NetBSD: dmesg.c,v 1.29 2018/04/01 19:36:13 christos Exp $	*/
 /*-
  * Copyright (c) 1991, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -38,7 +38,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)dmesg.c	8.1 (Berkeley) 6/5/93";
 #else
-__RCSID("$NetBSD: dmesg.c,v 1.28 2018/04/01 19:31:16 christos Exp $");
+__RCSID("$NetBSD: dmesg.c,v 1.29 2018/04/01 19:36:13 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -198,7 +198,7 @@ main(int argc, char *argv[])
 log = 1;
 continue;
 			case '>':
-log = newl = 0;
+log = 0;
 continue;
 			case ']':
 ADDC(ch);
@@ -237,6 +237,7 @@ main(int argc, char *argv[])
 	continue;
 break;
 			}
+			newl = 0;
 		}
 		if (ch == '\0')
 			continue;



CVS commit: src/sbin/dmesg

2018-04-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Apr  1 19:31:16 UTC 2018

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

Log Message:
Handle new timestamp sequences.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sbin/dmesg/dmesg.8
cvs rdiff -u -r1.27 -r1.28 src/sbin/dmesg/dmesg.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/dmesg/dmesg.8
diff -u src/sbin/dmesg/dmesg.8:1.17 src/sbin/dmesg/dmesg.8:1.18
--- src/sbin/dmesg/dmesg.8:1.17	Sat Sep 10 22:24:00 2016
+++ src/sbin/dmesg/dmesg.8	Sun Apr  1 15:31:16 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: dmesg.8,v 1.17 2016/09/11 02:24:00 sevan Exp $
+.\"	$NetBSD: dmesg.8,v 1.18 2018/04/01 19:31:16 christos Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)dmesg.8	8.1 (Berkeley) 6/5/93
 .\"
-.Dd September 11, 2016
+.Dd March 31, 2018
 .Dt DMESG 8
 .Os
 .Sh NAME
@@ -37,6 +37,7 @@
 .Nd "display the system message buffer"
 .Sh SYNOPSIS
 .Nm
+.Op Fl qt
 .Op Fl M Ar core
 .Op Fl N Ar system
 .Sh DESCRIPTION
@@ -51,6 +52,10 @@ instead of the default ``/dev/mem''.
 .It Fl N
 Extract the name list from the specified system instead of the default
 ``/netbsd''.
+.It Fl q
+Quiet printing, don't print timestamps.
+.It Fl t
+Format uptime timestamps in a human readable form.
 .El
 .Pp
 The system message buffer is a circular buffer of a fixed size.

Index: src/sbin/dmesg/dmesg.c
diff -u src/sbin/dmesg/dmesg.c:1.27 src/sbin/dmesg/dmesg.c:1.28
--- src/sbin/dmesg/dmesg.c:1.27	Mon Aug 29 10:34:59 2011
+++ src/sbin/dmesg/dmesg.c	Sun Apr  1 15:31:16 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: dmesg.c,v 1.27 2011/08/29 14:34:59 joerg Exp $	*/
+/*	$NetBSD: dmesg.c,v 1.28 2018/04/01 19:31:16 christos Exp $	*/
 /*-
  * Copyright (c) 1991, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -38,7 +38,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)dmesg.c	8.1 (Berkeley) 6/5/93";
 #else
-__RCSID("$NetBSD: dmesg.c,v 1.27 2011/08/29 14:34:59 joerg Exp $");
+__RCSID("$NetBSD: dmesg.c,v 1.28 2018/04/01 19:31:16 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -48,6 +48,7 @@ __RCSID("$NetBSD: dmesg.c,v 1.27 2011/08
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -73,16 +74,27 @@ int
 main(int argc, char *argv[])
 {
 	struct kern_msgbuf cur;
-	int ch, newl, skip, i;
+	int ch, newl, log, i;
+	size_t tstamp, size;
 	char *p, *bufdata;
+	char buf[5];
 #ifndef SMALL
+	char tbuf[64];
 	char *memf, *nlistf;
-#endif
-	char buf[5];
+	struct timeval boottime;
+	int ptime = 0;
+	
+	static const int bmib[] = { CTL_KERN, KERN_BOOTTIME };
+	size = sizeof(boottime);
+
+	boottime.tv_sec = 0;
+	boottime.tv_usec = 0;
+	ptime = 0;
+
+(void)sysctl(bmib, 2, , , NULL, 0);
 
-#ifndef SMALL
 	memf = nlistf = NULL;
-	while ((ch = getopt(argc, argv, "M:N:")) != -1)
+	while ((ch = getopt(argc, argv, "M:N:qt")) != -1)
 		switch(ch) {
 		case 'M':
 			memf = optarg;
@@ -90,6 +102,12 @@ main(int argc, char *argv[])
 		case 'N':
 			nlistf = optarg;
 			break;
+		case 'q':
+			ptime = -1;
+			break;
+		case 't':
+			ptime = 1;
+			break;
 		case '?':
 		default:
 			usage();
@@ -99,15 +117,11 @@ main(int argc, char *argv[])
 
 	if (memf == NULL) {
 #endif
-		size_t size;
-		int mib[2];
+		static const int mmib[2] = { CTL_KERN, KERN_MSGBUF };
 
-		mib[0] = CTL_KERN;
-		mib[1] = KERN_MSGBUF;
-
-		if (sysctl(mib, 2, NULL, , NULL, 0) == -1 ||
+		if (sysctl(mmib, 2, NULL, , NULL, 0) == -1 ||
 		(bufdata = malloc(size)) == NULL ||
-		sysctl(mib, 2, bufdata, , NULL, 0) == -1)
+		sysctl(mmib, 2, bufdata, , NULL, 0) == -1)
 			err(1, "can't get msgbuf");
 
 		/* make a dummy struct msgbuf for the display logic */
@@ -159,22 +173,70 @@ main(int argc, char *argv[])
 	 * over cur.msg_bufs times.  Unused area is skipped since it
 	 * contains nul.
 	 */
-	for (newl = skip = i = 0, p = bufdata + cur.msg_bufx;
+	for (tstamp = 0, newl = 1, log = i = 0, p = bufdata + cur.msg_bufx;
 	i < cur.msg_bufs; i++, p++) {
 #ifndef SMALL
 		if (p == bufdata + cur.msg_bufs)
 			p = bufdata;
+#define ADDC(c)\
+do 	\
+	if (tstamp < sizeof(tbuf) - 1)	\
+		tbuf[tstamp++] = (c);	\
+while (/*CONSTCOND*/0)
+#else
+#define ADDC(c)
 #endif
 		ch = *p;
 		/* Skip "\n<.*>" syslog sequences. */
-		if (skip) {
-			if (ch == '>')
-newl = skip = 0;
-			continue;
-		}
-		if (newl && ch == '<') {
-			skip = 1;
-			continue;
+		/* Gather timestamp sequences */
+		if (newl) {
+			switch (ch) {
+			case '[':
+ADDC(ch);
+continue;
+			case '<':
+log = 1;
+continue;
+			case '>':
+log = newl = 0;
+continue;
+			case ']':
+ADDC(ch);
+ADDC('\0');
+tstamp = 0;
+#ifndef SMALL
+if (ptime == 1) {
+	intmax_t sec;
+	time_t t;
+	long nsec;
+	struct tm tm;
+
+	

CVS commit: src/sys/kern

2018-04-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Apr  1 19:29:43 UTC 2018

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

Log Message:
Add the ability to prepend a timestamp [ sec.nsec] relative to boottime
in kernel messages if KLOG_TIMESTAMP is enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/sys/kern/subr_prf.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/subr_prf.c
diff -u src/sys/kern/subr_prf.c:1.164 src/sys/kern/subr_prf.c:1.165
--- src/sys/kern/subr_prf.c:1.164	Sun Apr  1 15:28:17 2018
+++ src/sys/kern/subr_prf.c	Sun Apr  1 15:29:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_prf.c,v 1.164 2018/04/01 19:28:17 christos Exp $	*/
+/*	$NetBSD: subr_prf.c,v 1.165 2018/04/01 19:29:43 christos Exp $	*/
 
 /*-
  * Copyright (c) 1986, 1988, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.164 2018/04/01 19:28:17 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.165 2018/04/01 19:29:43 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -482,6 +482,25 @@ putlogpri(int level)
 	putone('>', TOLOG, NULL);
 }
 
+#ifdef KLOG_TIMESTAMP
+static int needtstamp = 1;
+
+static void
+addtstamp(int flags, struct tty *tp)
+{
+	char buf[64];
+	struct timespec ts;
+	int n;
+
+	getnanouptime();
+	n = snprintf(buf, sizeof(buf), "[% 9jd.%.9ld] ",
+	(intptr_t)ts.tv_sec, ts.tv_nsec);
+
+	for (int i = 0; i < n; i++)
+		putone(buf[i], flags, tp);
+}
+#endif
+
 /*
  * putchar: print a single character on console or user terminal.
  *
@@ -497,6 +516,15 @@ putchar(int c, int flags, struct tty *tp
 		return;
 	}
 
+#ifdef KLOG_TIMESTAMP
+	if (needtstamp) {
+		addtstamp(flags, tp);
+		needtstamp = 0;
+	}
+
+	if (c == '\n')
+		needtstamp++;
+#endif
 	putone(c, flags, tp);
 
 #ifdef DDB



CVS commit: src/sys/kern

2018-04-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Apr  1 19:28:17 UTC 2018

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

Log Message:
Instead of expanding the syslog level into  early, defer expansion
inside putchar; extract the actual character addition function to a separate
function.


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 src/sys/kern/subr_prf.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/subr_prf.c
diff -u src/sys/kern/subr_prf.c:1.163 src/sys/kern/subr_prf.c:1.164
--- src/sys/kern/subr_prf.c:1.163	Sat Mar 31 19:12:01 2018
+++ src/sys/kern/subr_prf.c	Sun Apr  1 15:28:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_prf.c,v 1.163 2018/03/31 23:12:01 christos Exp $	*/
+/*	$NetBSD: subr_prf.c,v 1.164 2018/04/01 19:28:17 christos Exp $	*/
 
 /*-
  * Copyright (c) 1986, 1988, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.163 2018/03/31 23:12:01 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.164 2018/04/01 19:28:17 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -93,6 +93,7 @@ static bool kprintf_inited = false;
 /*
  * defines
  */
+#define KLOG_PRI	0x8000
 
 
 /*
@@ -417,14 +418,9 @@ logpri(int level)
 void
 klogpri(int level)
 {
-	char *p;
-	char snbuf[KPRINTF_BUFSIZE];
+	KASSERT((level & KLOG_PRI) == 0);
 
-	putchar('<', TOLOG, NULL);
-	snprintf(snbuf, sizeof(snbuf), "%d", level);
-	for (p = snbuf ; *p ; p++)
-		putchar(*p, TOLOG, NULL);
-	putchar('>', TOLOG, NULL);
+	putchar(level | KLOG_PRI, TOLOG, NULL);
 }
 
 /*
@@ -452,23 +448,12 @@ addlog(const char *fmt, ...)
 	logwakeup();
 }
 
-
-/*
- * putchar: print a single character on console or user terminal.
- *
- * => if console, then the last MSGBUFS chars are saved in msgbuf
- *	for inspection later (e.g. dmesg/syslog)
- * => we must already be in the mutex!
- */
 static void
-putchar(int c, int flags, struct tty *tp)
+putone(int c, int flags, struct tty *tp)
 {
-#ifdef RND_PRINTF
-	uint8_t rbuf[SHA512_BLOCK_LENGTH];
-	static int cursor;
-#endif
 	if (panicstr)
 		constty = NULL;
+
 	if ((flags & TOCONS) && tp == NULL && constty) {
 		tp = constty;
 		flags |= TOTTY;
@@ -482,6 +467,38 @@ putchar(int c, int flags, struct tty *tp
 		logputchar(c);
 	if ((flags & TOCONS) && constty == NULL && c != '\0')
 		(*v_putc)(c);
+}
+
+static void
+putlogpri(int level)
+{
+	char *p;
+	char snbuf[KPRINTF_BUFSIZE];
+
+	putone('<', TOLOG, NULL);
+	snprintf(snbuf, sizeof(snbuf), "%d", level);
+	for (p = snbuf ; *p ; p++)
+		putone(*p, TOLOG, NULL);
+	putone('>', TOLOG, NULL);
+}
+
+/*
+ * putchar: print a single character on console or user terminal.
+ *
+ * => if console, then the last MSGBUFS chars are saved in msgbuf
+ *	for inspection later (e.g. dmesg/syslog)
+ * => we must already be in the mutex!
+ */
+static void
+putchar(int c, int flags, struct tty *tp)
+{
+	if (c & KLOG_PRI) {
+		putlogpri(c & ~KLOG_PRI);
+		return;
+	}
+
+	putone(c, flags, tp);
+
 #ifdef DDB
 	if (flags & TODDB) {
 		db_putchar(c);
@@ -491,6 +508,9 @@ putchar(int c, int flags, struct tty *tp
 
 #ifdef RND_PRINTF
 	if (__predict_true(kprintf_inited)) {
+		static uint8_t rbuf[SHA512_BLOCK_LENGTH];
+		static int cursor;
+
 		rbuf[cursor] = c;
 		if (cursor == sizeof(rbuf) - 1) {
 			SHA512_Update(_sha, rbuf, sizeof(rbuf));



CVS commit: src/sys/kern

2018-04-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Apr  1 19:01:08 UTC 2018

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

Log Message:
Move the add char portion to its own function.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/kern/subr_log.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/subr_log.c
diff -u src/sys/kern/subr_log.c:1.57 src/sys/kern/subr_log.c:1.58
--- src/sys/kern/subr_log.c:1.57	Sat Mar 31 19:12:01 2018
+++ src/sys/kern/subr_log.c	Sun Apr  1 15:01:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_log.c,v 1.57 2018/03/31 23:12:01 christos Exp $	*/
+/*	$NetBSD: subr_log.c,v 1.58 2018/04/01 19:01:08 christos Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_log.c,v 1.57 2018/03/31 23:12:01 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_log.c,v 1.58 2018/04/01 19:01:08 christos Exp $");
 
 #include 
 #include 
@@ -404,6 +404,18 @@ logskip(struct kern_msgbuf *mbp)
 	}
 }
 
+static void
+logaddchar(struct kern_msgbuf *mbp, int c)
+{
+	mbp->msg_bufc[mbp->msg_bufx++] = c;
+	if (mbp->msg_bufx < 0 || mbp->msg_bufx >= mbp->msg_bufs)
+		mbp->msg_bufx = 0;
+
+	/* If the buffer is full, keep the most recent data. */
+	if (mbp->msg_bufr == mbp->msg_bufx)
+		logskip(mbp);
+}
+
 void
 logputchar(int c)
 {
@@ -431,13 +443,7 @@ logputchar(int c)
 
 	}
 
-	mbp->msg_bufc[mbp->msg_bufx++] = c;
-	if (mbp->msg_bufx < 0 || mbp->msg_bufx >= mbp->msg_bufs)
-		mbp->msg_bufx = 0;
-
-	/* If the buffer is full, keep the most recent data. */
-	if (mbp->msg_bufr == mbp->msg_bufx)
-		logskip(mbp);
+	logaddchar(mbp, c);
 
 out:
 	if (!cold)



CVS commit: src/etc

2018-04-01 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Apr  1 18:26:51 UTC 2018

Modified Files:
src/etc: rc.subr

Log Message:
PR misc/53145 (Bruce Lilly)

Use ps -A instead of ps -ax (-A means -ax, but -A is posix, -x is not)
Use ps -o args instead of ps -o command (same reason).

This makes no difference when the ps used is /bin/ps on NetBSD, but
can make a difference when some other ps command gets invoked instead.

XXX pullup -8


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/etc/rc.subr

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

Modified files:

Index: src/etc/rc.subr
diff -u src/etc/rc.subr:1.100 src/etc/rc.subr:1.101
--- src/etc/rc.subr:1.100	Thu Apr 13 02:15:36 2017
+++ src/etc/rc.subr	Sun Apr  1 18:26:51 2018
@@ -1,4 +1,4 @@
-# $NetBSD: rc.subr,v 1.100 2017/04/13 02:15:36 christos Exp $
+# $NetBSD: rc.subr,v 1.101 2018/04/01 18:26:51 kre Exp $
 #
 # Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -235,7 +235,7 @@ check_process()
 	if [ -z "$_procname" ]; then
 		err 3 'USAGE: check_process procname [interpreter]'
 	fi
-	_find_processes $_procname ${_interpreter:-.} '-ax'
+	_find_processes $_procname ${_interpreter:-.} '-A'
 }
 
 #
@@ -294,7 +294,7 @@ _find_processes()
 	fi
 
 	_proccheck='
-		ps -o "pid,command" '"$_psargs"' |
+		ps -o "pid,args" '"$_psargs"' |
 		while read _npid '"$_fp_args"'; do
 			case "$_npid" in
 			PID)



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

2018-04-01 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sun Apr  1 14:33:53 UTC 2018

Added Files:
src/sys/arch/evbarm/fdt: genassym.cf

Log Message:
fix build error


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/evbarm/fdt/genassym.cf

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

Added files:




CVS commit: src/sys/netinet

2018-04-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Apr  1 12:58:47 UTC 2018

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

Log Message:
Change the check to be <= instead of <. This fixes one occurrence of an
apparently widespread division-by-zero bug in our TCP code: if a user adds
huge IPv6 options with setsockopt, and if the total size of the options
happens to be equal to the available space calculated for the TCP payload,
t_segsz gets set to zero, and given that we then divide several things by
it, the kernel crashes.


To generate a diff of this commit:
cvs rdiff -u -r1.203 -r1.204 src/sys/netinet/tcp_output.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/tcp_output.c
diff -u src/sys/netinet/tcp_output.c:1.203 src/sys/netinet/tcp_output.c:1.204
--- src/sys/netinet/tcp_output.c:1.203	Sun Apr  1 12:46:50 2018
+++ src/sys/netinet/tcp_output.c	Sun Apr  1 12:58:47 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_output.c,v 1.203 2018/04/01 12:46:50 maxv Exp $	*/
+/*	$NetBSD: tcp_output.c,v 1.204 2018/04/01 12:58:47 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -135,7 +135,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.203 2018/04/01 12:46:50 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.204 2018/04/01 12:58:47 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -358,9 +358,13 @@ tcp_segsize(struct tcpcb *tp, int *txseg
 #endif
 	size -= optlen;
 
-	/* there may not be any room for data if mtu is too small */
-	if (size < 0)
+	/*
+	 * There may not be any room for data if mtu is too small. This
+	 * includes zero-sized.
+	 */
+	if (size <= 0) {
 		return EMSGSIZE;
+	}
 
 	/*
 	 * *rxsegsizep holds *estimated* inbound segment size (estimation



CVS commit: src/sys/netinet

2018-04-01 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Apr  1 12:46:50 UTC 2018

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

Log Message:
Reorder and style, for clarity.


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/sys/netinet/tcp_output.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/tcp_output.c
diff -u src/sys/netinet/tcp_output.c:1.202 src/sys/netinet/tcp_output.c:1.203
--- src/sys/netinet/tcp_output.c:1.202	Fri Mar 30 08:57:32 2018
+++ src/sys/netinet/tcp_output.c	Sun Apr  1 12:46:50 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_output.c,v 1.202 2018/03/30 08:57:32 maxv Exp $	*/
+/*	$NetBSD: tcp_output.c,v 1.203 2018/04/01 12:46:50 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -135,7 +135,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.202 2018/03/30 08:57:32 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.203 2018/04/01 12:46:50 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -239,6 +239,7 @@ tcp_segsize(struct tcpcb *tp, int *txseg
 	int optlen;
 
 	*alwaysfragp = false;
+	size = tcp_mssdflt;
 
 	KASSERT(!(tp->t_inpcb && tp->t_in6pcb));
 
@@ -252,7 +253,6 @@ tcp_segsize(struct tcpcb *tp, int *txseg
 		break;
 #endif
 	default:
-		size = tcp_mssdflt;
 		goto out;
 	}
 
@@ -268,13 +268,11 @@ tcp_segsize(struct tcpcb *tp, int *txseg
 	}
 #endif
 	if (rt == NULL) {
-		size = tcp_mssdflt;
 		goto out;
 	}
 
 	ifp = rt->rt_ifp;
 
-	size = tcp_mssdflt;
 	if (tp->t_mtudisc && rt->rt_rmx.rmx_mtu != 0) {
 #ifdef INET6
 		if (in6p && rt->rt_rmx.rmx_mtu < IPV6_MMTU) {
@@ -373,15 +371,17 @@ tcp_segsize(struct tcpcb *tp, int *txseg
 	 * I'm not quite sure about this (could someone comment).
 	 */
 	*txsegsizep = min(tp->t_peermss - optlen, size);
+	*rxsegsizep = min(tp->t_ourmss - optlen, size);
+
 	/*
 	 * Never send more than half a buffer full.  This insures that we can
 	 * always keep 2 packets on the wire, no matter what SO_SNDBUF is, and
 	 * therefore acks will never be delayed unless we run out of data to
 	 * transmit.
 	 */
-	if (so)
+	if (so) {
 		*txsegsizep = min(so->so_snd.sb_hiwat >> 1, *txsegsizep);
-	*rxsegsizep = min(tp->t_ourmss - optlen, size);
+	}
 
 	if (*txsegsizep != tp->t_segsz) {
 		/*
@@ -395,9 +395,9 @@ tcp_segsize(struct tcpcb *tp, int *txseg
 		 */
 		if (*txsegsizep < tp->t_segsz) {
 			tp->snd_cwnd = max((tp->snd_cwnd / tp->t_segsz)
-	   * *txsegsizep, *txsegsizep);
+			* *txsegsizep, *txsegsizep);
 			tp->snd_ssthresh = max((tp->snd_ssthresh / tp->t_segsz)
-		* *txsegsizep, *txsegsizep);
+			* *txsegsizep, *txsegsizep);
 		}
 		tp->t_segsz = *txsegsizep;
 	}



CVS commit: [pgoyette-compat] src/sys/kern

2018-04-01 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sun Apr  1 10:47:53 UTC 2018

Modified Files:
src/sys/kern [pgoyette-compat]: sys_module.c

Log Message:
In the data returned by MODCTL_STAT, include alias information for
modules that are still on the built-in list.


To generate a diff of this commit:
cvs rdiff -u -r1.23.2.3 -r1.23.2.4 src/sys/kern/sys_module.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/sys_module.c
diff -u src/sys/kern/sys_module.c:1.23.2.3 src/sys/kern/sys_module.c:1.23.2.4
--- src/sys/kern/sys_module.c:1.23.2.3	Sun Mar 11 08:32:21 2018
+++ src/sys/kern/sys_module.c	Sun Apr  1 10:47:53 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_module.c,v 1.23.2.3 2018/03/11 08:32:21 pgoyette Exp $	*/
+/*	$NetBSD: sys_module.c,v 1.23.2.4 2018/04/01 10:47:53 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_module.c,v 1.23.2.3 2018/03/11 08:32:21 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_module.c,v 1.23.2.4 2018/04/01 10:47:53 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_modular.h"
@@ -110,6 +110,17 @@ out1:
 	return error;
 }
 
+static void
+copy_alias(modstat_t ms, const char * const *aliasp, modinfo_t mi, module_t mod)
+{
+
+	strlcpy(ms->ms_name, *aliasp, sizeof(ms->ms_name));
+	strlcpy(ms->ms_required, mi->mi_name, sizeof(ms->ms_required));
+	ms->ms_class = mi->mi_class;
+	ms->ms_source = mod->mod_source;
+	ms->ms_flags = mod->mod_flags | MODFLG_IS_ALIAS;
+}
+
 static int
 handle_modctl_stat(struct iovec *iov, void *arg)
 {
@@ -163,12 +174,7 @@ handle_modctl_stat(struct iovec *iov, vo
 		if (aliasp == NULL)
 			continue;
 		while (*aliasp) {
-			strlcpy(ms->ms_name, *aliasp, sizeof(ms->ms_name));
-			strlcpy(ms->ms_required, mi->mi_name,
-			sizeof(ms->ms_required));
-			ms->ms_class = mi->mi_class;
-			ms->ms_source = mod->mod_source;
-			ms->ms_flags = mod->mod_flags | MODFLG_IS_ALIAS;
+			copy_alias(ms, aliasp, mi, mod);
 			aliasp++;
 			ms++;
 		}
@@ -190,6 +196,14 @@ handle_modctl_stat(struct iovec *iov, vo
 		KASSERT(mod->mod_source == MODULE_SOURCE_KERNEL);
 		ms->ms_source = mod->mod_source;
 		ms++;
+		aliasp = *mi->mi_aliases;
+		if (aliasp == NULL)
+			continue;
+		while (*aliasp) {
+			copy_alias(ms, aliasp, mi, mod);
+			aliasp++;
+			ms++;
+		}
 	}
 	kernconfig_unlock();
 	error = copyout(mso, iov->iov_base,



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

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:25:09 UTC 2018

Modified Files:
src/doc [netbsd-6-0]: CHANGES-6.0.7

Log Message:
Tickets #1540 and #1541


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.136 -r1.1.2.137 src/doc/CHANGES-6.0.7

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-6.0.7
diff -u src/doc/CHANGES-6.0.7:1.1.2.136 src/doc/CHANGES-6.0.7:1.1.2.137
--- src/doc/CHANGES-6.0.7:1.1.2.136	Mon Mar 26 12:21:50 2018
+++ src/doc/CHANGES-6.0.7	Sun Apr  1 09:25:09 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-6.0.7,v 1.1.2.136 2018/03/26 12:21:50 martin Exp $
+# $NetBSD: CHANGES-6.0.7,v 1.1.2.137 2018/04/01 09:25:09 martin Exp $
 
 A complete list of changes from the NetBSD 6.0.6 release to the NetBSD 6.0.7
 release:
@@ -15421,3 +15421,13 @@ distrib/sets/lists/base/mi			1.1164
 	Updated tzdata to 2018d.
 	[kre, ticket #1539]
 
+sys/netinet6/ip6_forward.c			1.91 (patch)
+
+	Fix two IPv6 ipsec use-after-free issues.
+	[maxv, ticket #1540]
+
+sys/netinet6/raw_ip6.c1.161
+
+	Fix use-after-free.
+	[maxv, ticket #1541]
+



CVS commit: [netbsd-6-0] src/sys/netinet6

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:24:38 UTC 2018

Modified Files:
src/sys/netinet6 [netbsd-6-0]: raw_ip6.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1541):

sys/netinet6/raw_ip6.c: revision 1.161

Fix use-after-free, the first m_copyback_cow may have freed the mbuf, so
it is wrong to read ip6->ip6_nxt.


To generate a diff of this commit:
cvs rdiff -u -r1.109.6.1 -r1.109.6.2 src/sys/netinet6/raw_ip6.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/raw_ip6.c
diff -u src/sys/netinet6/raw_ip6.c:1.109.6.1 src/sys/netinet6/raw_ip6.c:1.109.6.2
--- src/sys/netinet6/raw_ip6.c:1.109.6.1	Tue Jan 30 18:47:35 2018
+++ src/sys/netinet6/raw_ip6.c	Sun Apr  1 09:24:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip6.c,v 1.109.6.1 2018/01/30 18:47:35 martin Exp $	*/
+/*	$NetBSD: raw_ip6.c,v 1.109.6.2 2018/04/01 09:24:38 martin Exp $	*/
 /*	$KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.109.6.1 2018/01/30 18:47:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.109.6.2 2018/04/01 09:24:38 martin Exp $");
 
 #include "opt_ipsec.h"
 
@@ -502,6 +502,7 @@ rip6_output(struct mbuf *m, struct socke
 
 	if (so->so_proto->pr_protocol == IPPROTO_ICMPV6 ||
 	in6p->in6p_cksum != -1) {
+		const uint8_t nxt = ip6->ip6_nxt;
 		int off;
 		u_int16_t sum;
 
@@ -523,7 +524,7 @@ rip6_output(struct mbuf *m, struct socke
 			error = ENOBUFS;
 			goto bad;
 		}
-		sum = in6_cksum(m, ip6->ip6_nxt, sizeof(*ip6), plen);
+		sum = in6_cksum(m, nxt, sizeof(*ip6), plen);
 		m = m_copyback_cow(m, off, sizeof(sum), (void *),
 		M_DONTWAIT);
 		if (m == NULL) {



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

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:24:07 UTC 2018

Modified Files:
src/doc [netbsd-6-1]: CHANGES-6.1.6

Log Message:
Tickets #1540 and #1541


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.133 -r1.1.2.134 src/doc/CHANGES-6.1.6

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-6.1.6
diff -u src/doc/CHANGES-6.1.6:1.1.2.133 src/doc/CHANGES-6.1.6:1.1.2.134
--- src/doc/CHANGES-6.1.6:1.1.2.133	Mon Mar 26 12:20:00 2018
+++ src/doc/CHANGES-6.1.6	Sun Apr  1 09:24:07 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-6.1.6,v 1.1.2.133 2018/03/26 12:20:00 martin Exp $
+# $NetBSD: CHANGES-6.1.6,v 1.1.2.134 2018/04/01 09:24:07 martin Exp $
 
 A complete list of changes from the NetBSD 6.1.5 release to the NetBSD 6.1.6
 release:
@@ -15089,3 +15089,14 @@ distrib/sets/lists/base/mi			1.1164
 
 	Updated tzdata to 2018d.
 	[kre, ticket #1539]
+
+sys/netinet6/ip6_forward.c			1.91 (patch)
+
+	Fix two IPv6 ipsec use-after-free issues.
+	[maxv, ticket #1540]
+
+sys/netinet6/raw_ip6.c1.161
+
+	Fix use-after-free.
+	[maxv, ticket #1541]
+



CVS commit: [netbsd-6-1] src/sys/netinet6

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:23:39 UTC 2018

Modified Files:
src/sys/netinet6 [netbsd-6-1]: raw_ip6.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1541):

sys/netinet6/raw_ip6.c: revision 1.161

Fix use-after-free, the first m_copyback_cow may have freed the mbuf, so
it is wrong to read ip6->ip6_nxt.


To generate a diff of this commit:
cvs rdiff -u -r1.109.8.1 -r1.109.8.2 src/sys/netinet6/raw_ip6.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/raw_ip6.c
diff -u src/sys/netinet6/raw_ip6.c:1.109.8.1 src/sys/netinet6/raw_ip6.c:1.109.8.2
--- src/sys/netinet6/raw_ip6.c:1.109.8.1	Tue Jan 30 18:45:59 2018
+++ src/sys/netinet6/raw_ip6.c	Sun Apr  1 09:23:39 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip6.c,v 1.109.8.1 2018/01/30 18:45:59 martin Exp $	*/
+/*	$NetBSD: raw_ip6.c,v 1.109.8.2 2018/04/01 09:23:39 martin Exp $	*/
 /*	$KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.109.8.1 2018/01/30 18:45:59 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.109.8.2 2018/04/01 09:23:39 martin Exp $");
 
 #include "opt_ipsec.h"
 
@@ -502,6 +502,7 @@ rip6_output(struct mbuf *m, struct socke
 
 	if (so->so_proto->pr_protocol == IPPROTO_ICMPV6 ||
 	in6p->in6p_cksum != -1) {
+		const uint8_t nxt = ip6->ip6_nxt;
 		int off;
 		u_int16_t sum;
 
@@ -523,7 +524,7 @@ rip6_output(struct mbuf *m, struct socke
 			error = ENOBUFS;
 			goto bad;
 		}
-		sum = in6_cksum(m, ip6->ip6_nxt, sizeof(*ip6), plen);
+		sum = in6_cksum(m, nxt, sizeof(*ip6), plen);
 		m = m_copyback_cow(m, off, sizeof(sum), (void *),
 		M_DONTWAIT);
 		if (m == NULL) {



CVS commit: [netbsd-6] src/doc

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:23:13 UTC 2018

Modified Files:
src/doc [netbsd-6]: CHANGES-6.2

Log Message:
Tickets #1540 and #1541


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.329 -r1.1.2.330 src/doc/CHANGES-6.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-6.2
diff -u src/doc/CHANGES-6.2:1.1.2.329 src/doc/CHANGES-6.2:1.1.2.330
--- src/doc/CHANGES-6.2:1.1.2.329	Mon Mar 26 12:18:23 2018
+++ src/doc/CHANGES-6.2	Sun Apr  1 09:23:13 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-6.2,v 1.1.2.329 2018/03/26 12:18:23 martin Exp $
+# $NetBSD: CHANGES-6.2,v 1.1.2.330 2018/04/01 09:23:13 martin Exp $
 
 A complete list of changes from the 6.1 release until the 6.2 release:
 
@@ -21195,3 +21195,13 @@ distrib/sets/lists/base/mi			1.1164
 	Updated tzdata to 2018d.
 	[kre, ticket #1539]
 
+sys/netinet6/ip6_forward.c			1.91 (patch)
+
+	Fix two IPv6 ipsec use-after-free issues.
+	[maxv, ticket #1540]
+
+sys/netinet6/raw_ip6.c1.161
+
+	Fix use-after-free.
+	[maxv, ticket #1541]
+



CVS commit: [netbsd-6] src/sys/netinet6

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:22:37 UTC 2018

Modified Files:
src/sys/netinet6 [netbsd-6]: raw_ip6.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1541):

sys/netinet6/raw_ip6.c: revision 1.161

Fix use-after-free, the first m_copyback_cow may have freed the mbuf, so
it is wrong to read ip6->ip6_nxt.


To generate a diff of this commit:
cvs rdiff -u -r1.109.2.1 -r1.109.2.2 src/sys/netinet6/raw_ip6.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/raw_ip6.c
diff -u src/sys/netinet6/raw_ip6.c:1.109.2.1 src/sys/netinet6/raw_ip6.c:1.109.2.2
--- src/sys/netinet6/raw_ip6.c:1.109.2.1	Tue Jan 30 18:44:22 2018
+++ src/sys/netinet6/raw_ip6.c	Sun Apr  1 09:22:37 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip6.c,v 1.109.2.1 2018/01/30 18:44:22 martin Exp $	*/
+/*	$NetBSD: raw_ip6.c,v 1.109.2.2 2018/04/01 09:22:37 martin Exp $	*/
 /*	$KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.109.2.1 2018/01/30 18:44:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.109.2.2 2018/04/01 09:22:37 martin Exp $");
 
 #include "opt_ipsec.h"
 
@@ -502,6 +502,7 @@ rip6_output(struct mbuf *m, struct socke
 
 	if (so->so_proto->pr_protocol == IPPROTO_ICMPV6 ||
 	in6p->in6p_cksum != -1) {
+		const uint8_t nxt = ip6->ip6_nxt;
 		int off;
 		u_int16_t sum;
 
@@ -523,7 +524,7 @@ rip6_output(struct mbuf *m, struct socke
 			error = ENOBUFS;
 			goto bad;
 		}
-		sum = in6_cksum(m, ip6->ip6_nxt, sizeof(*ip6), plen);
+		sum = in6_cksum(m, nxt, sizeof(*ip6), plen);
 		m = m_copyback_cow(m, off, sizeof(sum), (void *),
 		M_DONTWAIT);
 		if (m == NULL) {



CVS commit: [netbsd-6-0] src/sys/netinet6

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:20:23 UTC 2018

Modified Files:
src/sys/netinet6 [netbsd-6-0]: ip6_forward.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1540):

sys/netinet6/ip6_forward.c: revision 1.91 (via patch)

Fix two pretty bad mistakes. If ipsec6_check_policy fails m is not freed,
and a 'goto out' is missing after ipsec6_process_packet.


To generate a diff of this commit:
cvs rdiff -u -r1.69.6.1 -r1.69.6.2 src/sys/netinet6/ip6_forward.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/ip6_forward.c
diff -u src/sys/netinet6/ip6_forward.c:1.69.6.1 src/sys/netinet6/ip6_forward.c:1.69.6.2
--- src/sys/netinet6/ip6_forward.c:1.69.6.1	Tue Mar 13 16:43:03 2018
+++ src/sys/netinet6/ip6_forward.c	Sun Apr  1 09:20:22 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_forward.c,v 1.69.6.1 2018/03/13 16:43:03 snj Exp $	*/
+/*	$NetBSD: ip6_forward.c,v 1.69.6.2 2018/04/01 09:20:22 martin Exp $	*/
 /*	$KAME: ip6_forward.c,v 1.109 2002/09/11 08:10:17 sakane Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.69.6.1 2018/03/13 16:43:03 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.69.6.2 2018/04/01 09:20:22 martin Exp $");
 
 #include "opt_gateway.h"
 #include "opt_ipsec.h"
@@ -361,9 +361,10 @@ ip6_forward(struct mbuf *m, int srcrt)
 		 * because we asked key management for an SA and
 		 * it was delayed (e.g. kicked up to IKE).
 		 */
-	if (error == -EINVAL)
-		error = 0;
-	goto freecopy;
+		if (error == -EINVAL)
+			error = 0;
+		m_freem(m);
+		goto freecopy;
 	}
 #endif /* FAST_IPSEC */
 
@@ -467,8 +468,10 @@ ip6_forward(struct mbuf *m, int srcrt)
 		s = splsoftnet();
 		error = ipsec6_process_packet(m,sp->req);
 		splx(s);
+		/* m is freed */
 		if (mcopy)
 			goto freecopy;
+		return;
 }
 #endif   
 



CVS commit: [netbsd-6-1] src/sys/netinet6

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:19:32 UTC 2018

Modified Files:
src/sys/netinet6 [netbsd-6-1]: ip6_forward.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1540):

sys/netinet6/ip6_forward.c: revision 1.91 (via patch)

Fix two pretty bad mistakes. If ipsec6_check_policy fails m is not freed,
and a 'goto out' is missing after ipsec6_process_packet.


To generate a diff of this commit:
cvs rdiff -u -r1.69.8.1 -r1.69.8.2 src/sys/netinet6/ip6_forward.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/ip6_forward.c
diff -u src/sys/netinet6/ip6_forward.c:1.69.8.1 src/sys/netinet6/ip6_forward.c:1.69.8.2
--- src/sys/netinet6/ip6_forward.c:1.69.8.1	Tue Mar 13 16:43:04 2018
+++ src/sys/netinet6/ip6_forward.c	Sun Apr  1 09:19:32 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_forward.c,v 1.69.8.1 2018/03/13 16:43:04 snj Exp $	*/
+/*	$NetBSD: ip6_forward.c,v 1.69.8.2 2018/04/01 09:19:32 martin Exp $	*/
 /*	$KAME: ip6_forward.c,v 1.109 2002/09/11 08:10:17 sakane Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.69.8.1 2018/03/13 16:43:04 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.69.8.2 2018/04/01 09:19:32 martin Exp $");
 
 #include "opt_gateway.h"
 #include "opt_ipsec.h"
@@ -361,9 +361,10 @@ ip6_forward(struct mbuf *m, int srcrt)
 		 * because we asked key management for an SA and
 		 * it was delayed (e.g. kicked up to IKE).
 		 */
-	if (error == -EINVAL)
-		error = 0;
-	goto freecopy;
+		if (error == -EINVAL)
+			error = 0;
+		m_freem(m);
+		goto freecopy;
 	}
 #endif /* FAST_IPSEC */
 
@@ -467,8 +468,10 @@ ip6_forward(struct mbuf *m, int srcrt)
 		s = splsoftnet();
 		error = ipsec6_process_packet(m,sp->req);
 		splx(s);
+		/* m is freed */
 		if (mcopy)
 			goto freecopy;
+		return;
 }
 #endif   
 



CVS commit: [netbsd-6] src/sys/netinet6

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:18:54 UTC 2018

Modified Files:
src/sys/netinet6 [netbsd-6]: ip6_forward.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1540):

sys/netinet6/ip6_forward.c: revision 1.91 (via patch)

Fix two pretty bad mistakes. If ipsec6_check_policy fails m is not freed,
and a 'goto out' is missing after ipsec6_process_packet.


To generate a diff of this commit:
cvs rdiff -u -r1.69.2.1 -r1.69.2.2 src/sys/netinet6/ip6_forward.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/ip6_forward.c
diff -u src/sys/netinet6/ip6_forward.c:1.69.2.1 src/sys/netinet6/ip6_forward.c:1.69.2.2
--- src/sys/netinet6/ip6_forward.c:1.69.2.1	Tue Mar 13 16:43:06 2018
+++ src/sys/netinet6/ip6_forward.c	Sun Apr  1 09:18:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_forward.c,v 1.69.2.1 2018/03/13 16:43:06 snj Exp $	*/
+/*	$NetBSD: ip6_forward.c,v 1.69.2.2 2018/04/01 09:18:54 martin Exp $	*/
 /*	$KAME: ip6_forward.c,v 1.109 2002/09/11 08:10:17 sakane Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.69.2.1 2018/03/13 16:43:06 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.69.2.2 2018/04/01 09:18:54 martin Exp $");
 
 #include "opt_gateway.h"
 #include "opt_ipsec.h"
@@ -361,9 +361,10 @@ ip6_forward(struct mbuf *m, int srcrt)
 		 * because we asked key management for an SA and
 		 * it was delayed (e.g. kicked up to IKE).
 		 */
-	if (error == -EINVAL)
-		error = 0;
-	goto freecopy;
+		if (error == -EINVAL)
+			error = 0;
+		m_freem(m);
+		goto freecopy;
 	}
 #endif /* FAST_IPSEC */
 
@@ -467,8 +468,10 @@ ip6_forward(struct mbuf *m, int srcrt)
 		s = splsoftnet();
 		error = ipsec6_process_packet(m,sp->req);
 		splx(s);
+		/* m is freed */
 		if (mcopy)
 			goto freecopy;
+		return;
 }
 #endif   
 



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

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:15:43 UTC 2018

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

Log Message:
Tickets #1590 and #1591


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.96 -r1.1.2.97 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.96 src/doc/CHANGES-7.0.3:1.1.2.97
--- src/doc/CHANGES-7.0.3:1.1.2.96	Sun Mar 25 14:12:19 2018
+++ src/doc/CHANGES-7.0.3	Sun Apr  1 09:15:43 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.0.3,v 1.1.2.96 2018/03/25 14:12:19 martin Exp $
+# $NetBSD: CHANGES-7.0.3,v 1.1.2.97 2018/04/01 09:15:43 martin Exp $
 
 A complete list of changes from the NetBSD 7.0.2 release to the NetBSD 7.0.3
 release:
@@ -5357,3 +5357,13 @@ doc/3RDPARTY	1.1506 (patch)
 	Updated tzdata to 2018d.
 	[kre, ticket #1589]
 
+sys/netinet6/ip6_forward.c			1.91 (patch)
+
+	Fix two IPv6 ipsec use-after-free issues.
+	[maxv, ticket #1590]
+
+sys/netinet6/raw_ip6.c1.161
+
+	Fix use-after-free.
+	[maxv, ticket #1591]
+



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

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:14:45 UTC 2018

Modified Files:
src/sys/netinet6 [netbsd-7-0]: raw_ip6.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1591):

sys/netinet6/raw_ip6.c: revision 1.161

Fix use-after-free, the first m_copyback_cow may have freed the mbuf, so
it is wrong to read ip6->ip6_nxt.


To generate a diff of this commit:
cvs rdiff -u -r1.136.6.1 -r1.136.6.2 src/sys/netinet6/raw_ip6.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/raw_ip6.c
diff -u src/sys/netinet6/raw_ip6.c:1.136.6.1 src/sys/netinet6/raw_ip6.c:1.136.6.2
--- src/sys/netinet6/raw_ip6.c:1.136.6.1	Tue Jan 30 18:31:53 2018
+++ src/sys/netinet6/raw_ip6.c	Sun Apr  1 09:14:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip6.c,v 1.136.6.1 2018/01/30 18:31:53 martin Exp $	*/
+/*	$NetBSD: raw_ip6.c,v 1.136.6.2 2018/04/01 09:14:45 martin Exp $	*/
 /*	$KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.136.6.1 2018/01/30 18:31:53 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.136.6.2 2018/04/01 09:14:45 martin Exp $");
 
 #include "opt_ipsec.h"
 
@@ -476,6 +476,7 @@ rip6_output(struct mbuf *m, struct socke
 
 	if (so->so_proto->pr_protocol == IPPROTO_ICMPV6 ||
 	in6p->in6p_cksum != -1) {
+		const uint8_t nxt = ip6->ip6_nxt;
 		int off;
 		u_int16_t sum;
 
@@ -497,7 +498,7 @@ rip6_output(struct mbuf *m, struct socke
 			error = ENOBUFS;
 			goto bad;
 		}
-		sum = in6_cksum(m, ip6->ip6_nxt, sizeof(*ip6), plen);
+		sum = in6_cksum(m, nxt, sizeof(*ip6), plen);
 		m = m_copyback_cow(m, off, sizeof(sum), (void *),
 		M_DONTWAIT);
 		if (m == NULL) {



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

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:14:15 UTC 2018

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

Log Message:
Tickets #1590 and #1591


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/doc/CHANGES-7.1.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.1.3
diff -u src/doc/CHANGES-7.1.3:1.1.2.3 src/doc/CHANGES-7.1.3:1.1.2.4
--- src/doc/CHANGES-7.1.3:1.1.2.3	Sun Mar 25 14:10:23 2018
+++ src/doc/CHANGES-7.1.3	Sun Apr  1 09:14:15 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.1.3,v 1.1.2.3 2018/03/25 14:10:23 martin Exp $
+# $NetBSD: CHANGES-7.1.3,v 1.1.2.4 2018/04/01 09:14:15 martin Exp $
 
 A complete list of changes from the NetBSD 7.1.2 release to the NetBSD 7.1.3
 release:
@@ -49,3 +49,13 @@ doc/3RDPARTY	1.1506 (patch)
 	Updated tzdata to 2018d.
 	[kre, ticket #1589]
 
+sys/netinet6/ip6_forward.c			1.91 (patch)
+
+	Fix two IPv6 ipsec use-after-free issues.
+	[maxv, ticket #1590]
+
+sys/netinet6/raw_ip6.c1.161
+
+	Fix use-after-free.
+	[maxv, ticket #1591]
+



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

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:13:46 UTC 2018

Modified Files:
src/sys/netinet6 [netbsd-7-1]: raw_ip6.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1591):

sys/netinet6/raw_ip6.c: revision 1.161

Fix use-after-free, the first m_copyback_cow may have freed the mbuf, so
it is wrong to read ip6->ip6_nxt.


To generate a diff of this commit:
cvs rdiff -u -r1.136.2.1.2.1 -r1.136.2.1.2.2 src/sys/netinet6/raw_ip6.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/raw_ip6.c
diff -u src/sys/netinet6/raw_ip6.c:1.136.2.1.2.1 src/sys/netinet6/raw_ip6.c:1.136.2.1.2.2
--- src/sys/netinet6/raw_ip6.c:1.136.2.1.2.1	Tue Jan 30 18:30:31 2018
+++ src/sys/netinet6/raw_ip6.c	Sun Apr  1 09:13:46 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip6.c,v 1.136.2.1.2.1 2018/01/30 18:30:31 martin Exp $	*/
+/*	$NetBSD: raw_ip6.c,v 1.136.2.1.2.2 2018/04/01 09:13:46 martin Exp $	*/
 /*	$KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.136.2.1.2.1 2018/01/30 18:30:31 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.136.2.1.2.2 2018/04/01 09:13:46 martin Exp $");
 
 #include "opt_ipsec.h"
 
@@ -476,6 +476,7 @@ rip6_output(struct mbuf *m, struct socke
 
 	if (so->so_proto->pr_protocol == IPPROTO_ICMPV6 ||
 	in6p->in6p_cksum != -1) {
+		const uint8_t nxt = ip6->ip6_nxt;
 		int off;
 		u_int16_t sum;
 
@@ -497,7 +498,7 @@ rip6_output(struct mbuf *m, struct socke
 			error = ENOBUFS;
 			goto bad;
 		}
-		sum = in6_cksum(m, ip6->ip6_nxt, sizeof(*ip6), plen);
+		sum = in6_cksum(m, nxt, sizeof(*ip6), plen);
 		m = m_copyback_cow(m, off, sizeof(sum), (void *),
 		M_DONTWAIT);
 		if (m == NULL) {



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

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:12:43 UTC 2018

Modified Files:
src/sys/netinet6 [netbsd-7]: raw_ip6.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1591):

sys/netinet6/raw_ip6.c: revision 1.161

Fix use-after-free, the first m_copyback_cow may have freed the mbuf, so
it is wrong to read ip6->ip6_nxt.


To generate a diff of this commit:
cvs rdiff -u -r1.136.2.2 -r1.136.2.3 src/sys/netinet6/raw_ip6.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/raw_ip6.c
diff -u src/sys/netinet6/raw_ip6.c:1.136.2.2 src/sys/netinet6/raw_ip6.c:1.136.2.3
--- src/sys/netinet6/raw_ip6.c:1.136.2.2	Tue Jan 30 18:28:45 2018
+++ src/sys/netinet6/raw_ip6.c	Sun Apr  1 09:12:42 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip6.c,v 1.136.2.2 2018/01/30 18:28:45 martin Exp $	*/
+/*	$NetBSD: raw_ip6.c,v 1.136.2.3 2018/04/01 09:12:42 martin Exp $	*/
 /*	$KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.136.2.2 2018/01/30 18:28:45 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.136.2.3 2018/04/01 09:12:42 martin Exp $");
 
 #include "opt_ipsec.h"
 
@@ -476,6 +476,7 @@ rip6_output(struct mbuf *m, struct socke
 
 	if (so->so_proto->pr_protocol == IPPROTO_ICMPV6 ||
 	in6p->in6p_cksum != -1) {
+		const uint8_t nxt = ip6->ip6_nxt;
 		int off;
 		u_int16_t sum;
 
@@ -497,7 +498,7 @@ rip6_output(struct mbuf *m, struct socke
 			error = ENOBUFS;
 			goto bad;
 		}
-		sum = in6_cksum(m, ip6->ip6_nxt, sizeof(*ip6), plen);
+		sum = in6_cksum(m, nxt, sizeof(*ip6), plen);
 		m = m_copyback_cow(m, off, sizeof(sum), (void *),
 		M_DONTWAIT);
 		if (m == NULL) {



CVS commit: [netbsd-7] src/doc

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:13:25 UTC 2018

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

Log Message:
Tickets #1590 and #1591


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.80 -r1.1.2.81 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.80 src/doc/CHANGES-7.2:1.1.2.81
--- src/doc/CHANGES-7.2:1.1.2.80	Sun Mar 25 14:07:56 2018
+++ src/doc/CHANGES-7.2	Sun Apr  1 09:13:25 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.2,v 1.1.2.80 2018/03/25 14:07:56 martin Exp $
+# $NetBSD: CHANGES-7.2,v 1.1.2.81 2018/04/01 09:13:25 martin Exp $
 
 A complete list of changes from the NetBSD 7.1 release to the NetBSD 7.2
 release:
@@ -5389,3 +5389,13 @@ doc/3RDPARTY	1.1506 (patch)
 	Updated tzdata to 2018d.
 	[kre, ticket #1589]
 
+sys/netinet6/ip6_forward.c			1.91 (patch)
+
+	Fix two IPv6 ipsec use-after-free issues.
+	[maxv, ticket #1590]
+
+sys/netinet6/raw_ip6.c1.161
+
+	Fix use-after-free.
+	[maxv, ticket #1591]
+



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

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:09:58 UTC 2018

Modified Files:
src/sys/netinet6 [netbsd-7-0]: ip6_forward.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1590):

sys/netinet6/ip6_forward.c: revision 1.91 (via patch)

Fix two pretty bad mistakes. If ipsec6_check_policy fails m is not freed,
and a 'goto out' is missing after ipsec6_process_packet.


To generate a diff of this commit:
cvs rdiff -u -r1.73.2.1.2.1 -r1.73.2.1.2.2 src/sys/netinet6/ip6_forward.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/ip6_forward.c
diff -u src/sys/netinet6/ip6_forward.c:1.73.2.1.2.1 src/sys/netinet6/ip6_forward.c:1.73.2.1.2.2
--- src/sys/netinet6/ip6_forward.c:1.73.2.1.2.1	Mon Feb 12 18:37:48 2018
+++ src/sys/netinet6/ip6_forward.c	Sun Apr  1 09:09:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_forward.c,v 1.73.2.1.2.1 2018/02/12 18:37:48 snj Exp $	*/
+/*	$NetBSD: ip6_forward.c,v 1.73.2.1.2.2 2018/04/01 09:09:58 martin Exp $	*/
 /*	$KAME: ip6_forward.c,v 1.109 2002/09/11 08:10:17 sakane Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.73.2.1.2.1 2018/02/12 18:37:48 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.73.2.1.2.2 2018/04/01 09:09:58 martin Exp $");
 
 #include "opt_gateway.h"
 #include "opt_ipsec.h"
@@ -166,6 +166,7 @@ ip6_forward(struct mbuf *m, int srcrt)
 			 */
 			if (error == -EINVAL)
 error = 0;
+			m_freem(m);
 			goto freecopy;
 		}
 	}
@@ -264,8 +265,10 @@ ip6_forward(struct mbuf *m, int srcrt)
 		int s = splsoftnet();
 		error = ipsec6_process_packet(m, sp->req);
 		splx(s);
+		/* m is freed */
 		if (mcopy)
 			goto freecopy;
+		return;
 	}
 #endif   
 



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

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:09:20 UTC 2018

Modified Files:
src/sys/netinet6 [netbsd-7-1]: ip6_forward.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1590):

sys/netinet6/ip6_forward.c: revision 1.91 (via patch)

Fix two pretty bad mistakes. If ipsec6_check_policy fails m is not freed,
and a 'goto out' is missing after ipsec6_process_packet.


To generate a diff of this commit:
cvs rdiff -u -r1.73.2.1.6.1 -r1.73.2.1.6.2 src/sys/netinet6/ip6_forward.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/ip6_forward.c
diff -u src/sys/netinet6/ip6_forward.c:1.73.2.1.6.1 src/sys/netinet6/ip6_forward.c:1.73.2.1.6.2
--- src/sys/netinet6/ip6_forward.c:1.73.2.1.6.1	Mon Feb 12 18:37:49 2018
+++ src/sys/netinet6/ip6_forward.c	Sun Apr  1 09:09:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_forward.c,v 1.73.2.1.6.1 2018/02/12 18:37:49 snj Exp $	*/
+/*	$NetBSD: ip6_forward.c,v 1.73.2.1.6.2 2018/04/01 09:09:20 martin Exp $	*/
 /*	$KAME: ip6_forward.c,v 1.109 2002/09/11 08:10:17 sakane Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.73.2.1.6.1 2018/02/12 18:37:49 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.73.2.1.6.2 2018/04/01 09:09:20 martin Exp $");
 
 #include "opt_gateway.h"
 #include "opt_ipsec.h"
@@ -166,6 +166,7 @@ ip6_forward(struct mbuf *m, int srcrt)
 			 */
 			if (error == -EINVAL)
 error = 0;
+			m_freem(m);
 			goto freecopy;
 		}
 	}
@@ -264,8 +265,10 @@ ip6_forward(struct mbuf *m, int srcrt)
 		int s = splsoftnet();
 		error = ipsec6_process_packet(m, sp->req);
 		splx(s);
+		/* m is freed */
 		if (mcopy)
 			goto freecopy;
+		return;
 	}
 #endif   
 



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

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:09:04 UTC 2018

Modified Files:
src/sys/netinet6 [netbsd-7]: ip6_forward.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1590):

sys/netinet6/ip6_forward.c: revision 1.91 (via patch)

Fix two pretty bad mistakes. If ipsec6_check_policy fails m is not freed,
and a 'goto out' is missing after ipsec6_process_packet.


To generate a diff of this commit:
cvs rdiff -u -r1.73.2.2 -r1.73.2.3 src/sys/netinet6/ip6_forward.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/ip6_forward.c
diff -u src/sys/netinet6/ip6_forward.c:1.73.2.2 src/sys/netinet6/ip6_forward.c:1.73.2.3
--- src/sys/netinet6/ip6_forward.c:1.73.2.2	Mon Feb 12 18:37:51 2018
+++ src/sys/netinet6/ip6_forward.c	Sun Apr  1 09:09:04 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_forward.c,v 1.73.2.2 2018/02/12 18:37:51 snj Exp $	*/
+/*	$NetBSD: ip6_forward.c,v 1.73.2.3 2018/04/01 09:09:04 martin Exp $	*/
 /*	$KAME: ip6_forward.c,v 1.109 2002/09/11 08:10:17 sakane Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.73.2.2 2018/02/12 18:37:51 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.73.2.3 2018/04/01 09:09:04 martin Exp $");
 
 #include "opt_gateway.h"
 #include "opt_ipsec.h"
@@ -166,6 +166,7 @@ ip6_forward(struct mbuf *m, int srcrt)
 			 */
 			if (error == -EINVAL)
 error = 0;
+			m_freem(m);
 			goto freecopy;
 		}
 	}
@@ -264,8 +265,10 @@ ip6_forward(struct mbuf *m, int srcrt)
 		int s = splsoftnet();
 		error = ipsec6_process_packet(m, sp->req);
 		splx(s);
+		/* m is freed */
 		if (mcopy)
 			goto freecopy;
+		return;
 	}
 #endif   
 



CVS commit: [netbsd-8] src/doc

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:02:51 UTC 2018

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

Log Message:
Tickets #679, #680, #681, #682


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.158 -r1.1.2.159 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.158 src/doc/CHANGES-8.0:1.1.2.159
--- src/doc/CHANGES-8.0:1.1.2.158	Sat Mar 31 11:22:06 2018
+++ src/doc/CHANGES-8.0	Sun Apr  1 09:02:51 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.0,v 1.1.2.158 2018/03/31 11:22:06 bouyer Exp $
+# $NetBSD: CHANGES-8.0,v 1.1.2.159 2018/04/01 09:02:51 martin Exp $
 
 A complete list of changes from the initial NetBSD 8.0 branch on 2017-06-04
 until the 8.0 release:
@@ -10743,3 +10743,39 @@ lib/libm/src/s_scalbn.c1.19
 	size as long double.
 	[martin, ticket #659]
 
+sys/kern/kern_proc.c1.211
+
+	Make sysctl_doeproc() more predictable.
+	[kamil, ticket #679]
+
+
+sys/netipsec/xform_ah.c1.77,1.87
+
+	Reinforce and clarify.
+	[maxv, ticket #680]
+
+sys/arch/x86/include/cpu.h			1.90
+sys/arch/x86/x86/identcpu.c			1.71
+
+	Retrieve cpuid.7:%edx.
+	[maxv, ticket #681]
+
+external/gpl3/gcc.old/dist/gcc/config/i386/constraints.md 1.6
+external/gpl3/gcc.old/dist/gcc/config/i386/i386-opts.h 1.4
+external/gpl3/gcc.old/dist/gcc/config/i386/i386-protos.h 1.6
+external/gpl3/gcc.old/dist/gcc/config/i386/i386.c 1.10
+external/gpl3/gcc.old/dist/gcc/config/i386/i386.h 1.7
+external/gpl3/gcc.old/dist/gcc/config/i386/i386.md 1.7
+external/gpl3/gcc.old/dist/gcc/config/i386/i386.opt 1.7
+external/gpl3/gcc.old/dist/gcc/config/i386/predicates.md 1.6
+external/gpl3/gcc.old/dist/gcc/doc/extend.texi	1.7
+external/gpl3/gcc.old/dist/gcc/doc/invoke.texi	1.7
+	(with external/gpl3/gcc.old/ -> external/gpl3/gcc/)
+tools/gcc/gcc-version.mk			1.10 (patch)
+
+	Add the spectre mitigation options for x86:
+	  -mindirect-branch=
+	  -mfunction-return=
+	  -mindirect-branch-register
+	[mrg, ticket #682]
+



CVS commit: [netbsd-8] src

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 09:00:44 UTC 2018

Modified Files:
src/external/gpl3/gcc/dist/gcc/config/i386 [netbsd-8]: constraints.md
i386-opts.h i386-protos.h i386.c i386.h i386.md i386.opt
predicates.md
src/external/gpl3/gcc/dist/gcc/doc [netbsd-8]: extend.texi invoke.texi
src/tools/gcc [netbsd-8]: gcc-version.mk

Log Message:
Pull up following revision(s) (requested by mrg in ticket #682):

tools/gcc/gcc-version.mk: revision 1.10 (via patch)
external/gpl3/gcc.old/dist/gcc/config/i386/i386.c: revision 1.10
external/gpl3/gcc.old/dist/gcc/config/i386/i386-protos.h: revision 1.6
external/gpl3/gcc.old/dist/gcc/config/i386/constraints.md: revision 1.6
external/gpl3/gcc.old/dist/gcc/doc/invoke.texi: revision 1.7
external/gpl3/gcc.old/dist/gcc/config/i386/i386.md: revision 1.7
external/gpl3/gcc.old/dist/gcc/doc/extend.texi: revision 1.7
external/gpl3/gcc.old/dist/gcc/config/i386/i386-opts.h: revision 1.4
external/gpl3/gcc.old/dist/gcc/config/i386/predicates.md: revision 1.6
external/gpl3/gcc.old/dist/gcc/config/i386/i386.h: revision 1.7
external/gpl3/gcc.old/dist/gcc/config/i386/i386.opt: revision 1.7
(with external/gpl3/gcc.old/ -> external/gpl3/gcc/)

add the spectre mitigation options for x86:

  -mindirect-branch=
  -mfunction-return=
  -mindirect-branch-register

the values for 'choice' are "keep" (default, existing behaviour),
"thunk", "thunk-inline", and "thunk-extern".

as taken from the Ubuntu port of these changes in their
ubuntu:gcc-5_5.5.0-8ubuntu1.diff.  i've also included the doc
updates that are missing from ubuntu from gcc itself.
i've tested both i386 and amd64 fairly heavily with these options
enabled in both kernels and userland, atf runs and hundreds of
package builds.

bump the NetBSD GCC version.  both GCC 5 and 6 got x86 spectre
mitigation code, and both are now "nb2 20180327".


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.5 -r1.1.1.5.8.1 \
src/external/gpl3/gcc/dist/gcc/config/i386/constraints.md
cvs rdiff -u -r1.1.1.2 -r1.1.1.2.8.1 \
src/external/gpl3/gcc/dist/gcc/config/i386/i386-opts.h
cvs rdiff -u -r1.1.1.4 -r1.1.1.4.8.1 \
src/external/gpl3/gcc/dist/gcc/config/i386/i386-protos.h \
src/external/gpl3/gcc/dist/gcc/config/i386/predicates.md
cvs rdiff -u -r1.12.8.2 -r1.12.8.3 \
src/external/gpl3/gcc/dist/gcc/config/i386/i386.c
cvs rdiff -u -r1.5.8.1 -r1.5.8.2 \
src/external/gpl3/gcc/dist/gcc/config/i386/i386.h
cvs rdiff -u -r1.1.1.8.8.1 -r1.1.1.8.8.2 \
src/external/gpl3/gcc/dist/gcc/config/i386/i386.md
cvs rdiff -u -r1.1.1.3.8.1 -r1.1.1.3.8.2 \
src/external/gpl3/gcc/dist/gcc/config/i386/i386.opt
cvs rdiff -u -r1.1.1.7.8.1 -r1.1.1.7.8.2 \
src/external/gpl3/gcc/dist/gcc/doc/extend.texi
cvs rdiff -u -r1.11.8.1 -r1.11.8.2 \
src/external/gpl3/gcc/dist/gcc/doc/invoke.texi
cvs rdiff -u -r1.7 -r1.7.4.1 src/tools/gcc/gcc-version.mk

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

Modified files:

Index: src/external/gpl3/gcc/dist/gcc/config/i386/constraints.md
diff -u src/external/gpl3/gcc/dist/gcc/config/i386/constraints.md:1.1.1.5 src/external/gpl3/gcc/dist/gcc/config/i386/constraints.md:1.1.1.5.8.1
--- src/external/gpl3/gcc/dist/gcc/config/i386/constraints.md:1.1.1.5	Tue Jun  7 05:58:17 2016
+++ src/external/gpl3/gcc/dist/gcc/config/i386/constraints.md	Sun Apr  1 09:00:43 2018
@@ -157,12 +157,14 @@
 
 (define_constraint "Bs"
   "@internal Sibcall memory operand."
-  (and (not (match_test "TARGET_X32"))
+  (and (not (match_test "ix86_indirect_branch_register"))
+   (not (match_test "TARGET_X32"))
(match_operand 0 "sibcall_memory_operand")))
 
 (define_constraint "Bw"
   "@internal Call memory operand."
-  (and (not (match_test "TARGET_X32"))
+  (and (not (match_test "ix86_indirect_branch_register"))
+   (not (match_test "TARGET_X32"))
(match_operand 0 "memory_operand")))
 
 (define_constraint "Bz"

Index: src/external/gpl3/gcc/dist/gcc/config/i386/i386-opts.h
diff -u src/external/gpl3/gcc/dist/gcc/config/i386/i386-opts.h:1.1.1.2 src/external/gpl3/gcc/dist/gcc/config/i386/i386-opts.h:1.1.1.2.8.1
--- src/external/gpl3/gcc/dist/gcc/config/i386/i386-opts.h:1.1.1.2	Sun Jan 24 06:06:24 2016
+++ src/external/gpl3/gcc/dist/gcc/config/i386/i386-opts.h	Sun Apr  1 09:00:43 2018
@@ -99,4 +99,17 @@ enum stack_protector_guard {
   SSP_GLOBAL/* global canary */
 };
 
+/* This is used to mitigate variant #2 of the speculative execution
+   vulnerabilities on x86 processors identified by CVE-2017-5715, aka
+   Spectre.  They convert indirect branches and function returns to
+   call and return thunks to avoid speculative execution via indirect
+   call, jmp and ret.  */
+enum indirect_branch {
+  indirect_branch_unset = 0,
+  indirect_branch_keep,
+  indirect_branch_thunk,
+  

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

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 08:51:47 UTC 2018

Modified Files:
src/sys/arch/x86/include [netbsd-8]: cpu.h
src/sys/arch/x86/x86 [netbsd-8]: identcpu.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #681):
sys/arch/x86/include/cpu.h: revision 1.90
sys/arch/x86/x86/identcpu.c: revision 1.71
Retrieve cpuid.7:%edx.


To generate a diff of this commit:
cvs rdiff -u -r1.71.2.4 -r1.71.2.5 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.55.2.2 -r1.55.2.3 src/sys/arch/x86/x86/identcpu.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/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.71.2.4 src/sys/arch/x86/include/cpu.h:1.71.2.5
--- src/sys/arch/x86/include/cpu.h:1.71.2.4	Thu Mar 22 16:59:04 2018
+++ src/sys/arch/x86/include/cpu.h	Sun Apr  1 08:51:47 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.71.2.4 2018/03/22 16:59:04 martin Exp $	*/
+/*	$NetBSD: cpu.h,v 1.71.2.5 2018/04/01 08:51:47 martin Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -177,7 +177,7 @@ struct cpu_info {
 	uint32_t	ci_max_ext_cpuid; /* cpuid.8000:%eax */
 	volatile uint32_t	ci_lapic_counter;
 
-	uint32_t	ci_feat_val[7]; /* X86 CPUID feature bits */
+	uint32_t	ci_feat_val[8]; /* X86 CPUID feature bits */
 			/* [0] basic features cpuid.1:%edx
 			 * [1] basic features cpuid.1:%ecx (CPUID2_xxx bits)
 			 * [2] extended features cpuid:8001:%edx
@@ -185,6 +185,7 @@ struct cpu_info {
 			 * [4] VIA padlock features
 			 * [5] structured extended features cpuid.7:%ebx
 			 * [6] structured extended features cpuid.7:%ecx
+			 * [7] structured extended features cpuid.7:%edx
 			 */
 	
 	const struct cpu_functions *ci_func;  /* start/stop functions */

Index: src/sys/arch/x86/x86/identcpu.c
diff -u src/sys/arch/x86/x86/identcpu.c:1.55.2.2 src/sys/arch/x86/x86/identcpu.c:1.55.2.3
--- src/sys/arch/x86/x86/identcpu.c:1.55.2.2	Fri Mar 16 13:05:32 2018
+++ src/sys/arch/x86/x86/identcpu.c	Sun Apr  1 08:51:47 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: identcpu.c,v 1.55.2.2 2018/03/16 13:05:32 martin Exp $	*/
+/*	$NetBSD: identcpu.c,v 1.55.2.3 2018/04/01 08:51:47 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.55.2.2 2018/03/16 13:05:32 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.55.2.3 2018/04/01 08:51:47 martin Exp $");
 
 #include "opt_xen.h"
 
@@ -889,6 +889,7 @@ cpu_probe(struct cpu_info *ci)
 		x86_cpuid(7, descs);
 		ci->ci_feat_val[5] = descs[1]; /* %ebx */
 		ci->ci_feat_val[6] = descs[2]; /* %ecx */
+		ci->ci_feat_val[7] = descs[3]; /* %edx */
 	}
 
 	cpu_probe_intel(ci);



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

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 08:48:39 UTC 2018

Modified Files:
src/sys/netipsec [netbsd-8]: xform_ah.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #680):

sys/netipsec/xform_ah.c: revision 1.87
sys/netipsec/xform_ah.c: revision 1.77

Reinforce and clarify.

Reinforce this area, make sure the length field fits the option. Normally
it always does because the options were already sanitized earlier.


To generate a diff of this commit:
cvs rdiff -u -r1.54.2.5 -r1.54.2.6 src/sys/netipsec/xform_ah.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.54.2.5 src/sys/netipsec/xform_ah.c:1.54.2.6
--- src/sys/netipsec/xform_ah.c:1.54.2.5	Mon Feb 26 18:42:49 2018
+++ src/sys/netipsec/xform_ah.c	Sun Apr  1 08:48:39 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_ah.c,v 1.54.2.5 2018/02/26 18:42:49 martin Exp $	*/
+/*	$NetBSD: xform_ah.c,v 1.54.2.6 2018/04/01 08:48:39 martin 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.54.2.5 2018/02/26 18:42:49 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.54.2.6 2018/04/01 08:48:39 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -491,54 +491,48 @@ ah_massage_headers(struct mbuf **m0, int
 
 		nxt = ip6.ip6_nxt & 0xff; /* Next header type. */
 
-		for (off = 0; off < skip - sizeof(struct ip6_hdr);)
+		for (off = 0; off < skip - sizeof(struct ip6_hdr);) {
+			int noff;
+
 			switch (nxt) {
 			case IPPROTO_HOPOPTS:
 			case IPPROTO_DSTOPTS:
-ip6e = (struct ip6_ext *) (ptr + off);
+ip6e = (struct ip6_ext *)(ptr + off);
+noff = off + ((ip6e->ip6e_len + 1) << 3);
+
+/* Sanity check. */
+if (noff > skip - sizeof(struct ip6_hdr)) {
+	goto error6;
+}
 
 /*
- * Process the mutable/immutable
- * options -- borrows heavily from the
- * KAME code.
+ * Zero out mutable options.
  */
 for (count = off + sizeof(struct ip6_ext);
- count < off + ((ip6e->ip6e_len + 1) << 3);) {
+ count < noff;) {
 	if (ptr[count] == IP6OPT_PAD1) {
 		count++;
-		continue; /* Skip padding. */
+		continue;
 	}
 
-	/* Sanity check. */
-	if (count > off +
-	((ip6e->ip6e_len + 1) << 3)) {
-		m_freem(m);
-
-		/* Free, if we allocated. */
-		if (alloc)
-			free(ptr, M_XDATA);
-		return EINVAL;
+	if (count + 1 >= noff) {
+		goto error6;
 	}
-
 	ad = ptr[count + 1] + 2;
 
-	/* If mutable option, zeroize. */
-	if (ptr[count] & IP6OPT_MUTABLE)
-		memcpy(ptr + count, ipseczeroes,
-		ad);
+	if (count + ad > noff) {
+		goto error6;
+	}
+
+	if (ptr[count] & IP6OPT_MUTABLE) {
+		memset(ptr + count, 0, ad);
+	}
 
 	count += ad;
+}
 
-	/* Sanity check. */
-	if (count >
-	skip - sizeof(struct ip6_hdr)) {
-		m_freem(m);
-
-		/* Free, if we allocated. */
-		if (alloc)
-			free(ptr, M_XDATA);
-		return EINVAL;
-	}
+if (count != noff) {
+	goto error6;
 }
 
 /* Advance. */
@@ -551,7 +545,7 @@ ah_massage_headers(struct mbuf **m0, int
  * Always include routing headers in
  * computation.
  */
-ip6e = (struct ip6_ext *) (ptr + off);
+ip6e = (struct ip6_ext *)(ptr + off);
 rh = (struct ip6_rthdr *)(ptr + off);
 /*
  * must adjust content to make it look like
@@ -592,11 +586,13 @@ ah_massage_headers(struct mbuf **m0, int
 			default:
 DPRINTF(("%s: unexpected IPv6 header type %d\n",
 __func__, off));
+error6:
 if (alloc)
 	free(ptr, M_XDATA);
 m_freem(m);
 return EINVAL;
 			}
+		}
 
 		/* Copyback and free, if we allocated. */
 		if (alloc) {



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

2018-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  1 08:45:43 UTC 2018

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

Log Message:
Pull up following revision(s) (requested by kamil in ticket #679):

sys/kern/kern_proc.c: revision 1.211

Make sysctl_doeproc() more predictable

Swap the order of looking into zombie and all process lists, start now
with the zombie one. This prevents a race observed previously that the
same process could be detected on both lists during a single polling call.

While there:
 - Short-circuit break for KERN_PROC_PID, once a pid has been detected.
 - Removal of redundant "if (kbuf)" and "if (marker)" checks.
 - Update of comments regarding potential optimization, explaining why we
   don't want to it as of now. Performance gain from lookup call vs
   iteration over a list is neglible on a regular system.
 - Return ESRCH when no results have been found. This allows more easily
   to implement a retry or abandon algorithm.

This corrects races observed in the existing ATF ptrace(2) tests, related
to await_zombie(). This function was expecting to check whether a process
has been transformed into a zombie, however it was causing occasional
crashes as it was overflowing the return buffer, returning the same pid
twice: once from allproc list and the second time from zombieproc one.

Fix suggested by 
Short-circuit break suggested by 

Discussed on tech-kern.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.206.6.1 -r1.206.6.2 src/sys/kern/kern_proc.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_proc.c
diff -u src/sys/kern/kern_proc.c:1.206.6.1 src/sys/kern/kern_proc.c:1.206.6.2
--- src/sys/kern/kern_proc.c:1.206.6.1	Mon Jan  1 18:58:32 2018
+++ src/sys/kern/kern_proc.c	Sun Apr  1 08:45:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_proc.c,v 1.206.6.1 2018/01/01 18:58:32 snj Exp $	*/
+/*	$NetBSD: kern_proc.c,v 1.206.6.2 2018/04/01 08:45:43 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.206.6.1 2018/01/01 18:58:32 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.206.6.2 2018/04/01 08:45:43 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kstack.h"
@@ -1675,12 +1675,16 @@ sysctl_doeproc(SYSCTLFN_ARGS)
 	marker->p_flag = PK_MARKER;
 
 	mutex_enter(proc_lock);
-	mmmbrains = false;
-	for (p = LIST_FIRST();; p = next) {
+	/*
+	 * Start with zombies to prevent reporting processes twice, in case they
+	 * are dying and being moved from the list of alive processes to zombies.
+	 */
+	mmmbrains = true;
+	for (p = LIST_FIRST();; p = next) {
 		if (p == NULL) {
-			if (!mmmbrains) {
-p = LIST_FIRST();
-mmmbrains = true;
+			if (mmmbrains) {
+p = LIST_FIRST();
+mmmbrains = false;
 			}
 			if (p == NULL)
 break;
@@ -1705,17 +1709,17 @@ sysctl_doeproc(SYSCTLFN_ARGS)
 		}
 
 		/*
-		 * TODO - make more efficient (see notes below).
-		 * do by session.
+		 * Hande all the operations in one switch on the cost of
+		 * algorithm complexity is on purpose. The win splitting this
+		 * function into several similar copies makes maintenance burden
+		 * burden, code grow and boost is neglible in practical systems.
 		 */
 		switch (op) {
 		case KERN_PROC_PID:
-			/* could do this with just a lookup */
 			match = (p->p_pid == (pid_t)arg);
 			break;
 
 		case KERN_PROC_PGRP:
-			/* could do this by traversing pgrp */
 			match = (p->p_pgrp->pg_id == (pid_t)arg);
 			break;
 
@@ -1821,10 +1825,20 @@ sysctl_doeproc(SYSCTLFN_ARGS)
 			rw_exit(>p_reflock);
 			next = LIST_NEXT(p, p_list);
 		}
+
+		/*
+		 * Short-circuit break quickly!
+		 */
+		if (op == KERN_PROC_PID)
+	break;
 	}
 	mutex_exit(proc_lock);
 
 	if (where != NULL) {
+		if (needed == 0) {
+			error = ESRCH;
+			goto out;
+		}
 		*oldlenp = dp - where;
 		if (needed > *oldlenp) {
 			error = ENOMEM;
@@ -1834,10 +1848,8 @@ sysctl_doeproc(SYSCTLFN_ARGS)
 		needed += KERN_PROCSLOP;
 		*oldlenp = needed;
 	}
-	if (kbuf)
-		kmem_free(kbuf, sizeof(*kbuf));
-	if (marker)
-		kmem_free(marker, sizeof(*marker));
+	kmem_free(kbuf, sizeof(*kbuf));
+	kmem_free(marker, sizeof(*marker));
 	sysctl_relock();
 	return 0;
  bah:
@@ -1848,10 +1860,8 @@ sysctl_doeproc(SYSCTLFN_ARGS)
  cleanup:
 	mutex_exit(proc_lock);
  out:
-	if (kbuf)
-		kmem_free(kbuf, sizeof(*kbuf));
-	if (marker)
-		kmem_free(marker, sizeof(*marker));
+	kmem_free(kbuf, sizeof(*kbuf));
+	kmem_free(marker, sizeof(*marker));
 	sysctl_relock();
 	return error;
 }