CVS commit: src/sys/net

2018-04-26 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Fri Apr 27 00:06:40 UTC 2018

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

Log Message:
Fix "how" argument of MGET(). Pointed out by maxv@n.o, thanks.

MGET() does not have M_ZERO flag, so add memset when it is required.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/net/if_ipsec.c

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



CVS commit: src/sys/net

2018-04-26 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Fri Apr 27 00:06:40 UTC 2018

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

Log Message:
Fix "how" argument of MGET(). Pointed out by maxv@n.o, thanks.

MGET() does not have M_ZERO flag, so add memset when it is required.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/net/if_ipsec.c

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

Modified files:

Index: src/sys/net/if_ipsec.c
diff -u src/sys/net/if_ipsec.c:1.11 src/sys/net/if_ipsec.c:1.12
--- src/sys/net/if_ipsec.c:1.11	Fri Apr  6 10:38:53 2018
+++ src/sys/net/if_ipsec.c	Fri Apr 27 00:06:40 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ipsec.c,v 1.11 2018/04/06 10:38:53 knakahara Exp $  */
+/*	$NetBSD: if_ipsec.c,v 1.12 2018/04/27 00:06:40 knakahara Exp $  */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ipsec.c,v 1.11 2018/04/06 10:38:53 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ipsec.c,v 1.12 2018/04/27 00:06:40 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1339,10 +1339,11 @@ if_ipsec_add_mbuf_optalign(struct mbuf *
 {
 	struct mbuf *m;
 
-	MGET(m, M_WAITOK | M_ZERO, MT_DATA);
-	if (align)
+	MGET(m, M_WAIT, MT_DATA);
+	if (align) {
 		m->m_len = PFKEY_ALIGN8(len);
-	else
+		memset(mtod(m, void *), 0, m->m_len);
+	} else
 		m->m_len = len;
 	m_copyback(m, 0, len, data);
 	m_cat(m0, m);
@@ -1378,8 +1379,9 @@ if_ipsec_add_pad(struct mbuf *m0, size_t
 	if (len == 0)
 		return;
 
-	MGET(m, M_WAITOK | M_ZERO, MT_DATA);
+	MGET(m, M_WAIT, MT_DATA);
 	m->m_len = len;
+	memset(mtod(m, void *), 0, m->m_len);
 	m_cat(m0, m);
 }
 
@@ -1556,7 +1558,7 @@ if_ipsec_add_sp0(struct sockaddr *src, i
 	memset(, 0, sizeof(xpl));
 	memset(, 0, sizeof(xisr));
 
-	MGETHDR(m, M_WAITOK, MT_DATA);
+	MGETHDR(m, M_WAIT, MT_DATA);
 
 	size = if_ipsec_set_sadb_src(, src, proto);
 	ext_msg_len += PFKEY_UNIT64(size);
@@ -1683,7 +1685,7 @@ if_ipsec_del_sp0(struct secpolicy *sp)
 	memset(, 0, sizeof(msg));
 	memset(, 0, sizeof(xpl));
 
-	MGETHDR(m, M_WAITOK, MT_DATA);
+	MGETHDR(m, M_WAIT, MT_DATA);
 
 	size = if_ipsec_set_sadb_x_policy(, NULL, 0, 0, sp->id, 0, NULL, NULL);
 	ext_msg_len += PFKEY_UNIT64(size);



CVS commit: src/sys/nfs

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 20:10:44 UTC 2018

Modified Files:
src/sys/nfs: nfs_subs.c

Log Message:
Hum. This should be M_READONLY, not M_ROMAP.

M_ROMAP tells us whether the mbuf storage is mapped on a read-only page.
But an mbuf can still be read-only in the sense that the storage is
shared with other mbufs.


To generate a diff of this commit:
cvs rdiff -u -r1.230 -r1.231 src/sys/nfs/nfs_subs.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/nfs/nfs_subs.c
diff -u src/sys/nfs/nfs_subs.c:1.230 src/sys/nfs/nfs_subs.c:1.231
--- src/sys/nfs/nfs_subs.c:1.230	Sun Jan 21 20:36:49 2018
+++ src/sys/nfs/nfs_subs.c	Thu Apr 26 20:10:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_subs.c,v 1.230 2018/01/21 20:36:49 christos Exp $	*/
+/*	$NetBSD: nfs_subs.c,v 1.231 2018/04/26 20:10:44 maxv Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.230 2018/01/21 20:36:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.231 2018/04/26 20:10:44 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -1602,7 +1602,7 @@ nfs_zeropad(struct mbuf *mp, int len, in
 		char *cp;
 		int i;
 
-		if (M_ROMAP(m) || M_TRAILINGSPACE(m) < nul) {
+		if (M_READONLY(m) || M_TRAILINGSPACE(m) < nul) {
 			struct mbuf *n;
 
 			KDASSERT(MLEN >= nul);



CVS commit: src/sys/nfs

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 20:10:44 UTC 2018

Modified Files:
src/sys/nfs: nfs_subs.c

Log Message:
Hum. This should be M_READONLY, not M_ROMAP.

M_ROMAP tells us whether the mbuf storage is mapped on a read-only page.
But an mbuf can still be read-only in the sense that the storage is
shared with other mbufs.


To generate a diff of this commit:
cvs rdiff -u -r1.230 -r1.231 src/sys/nfs/nfs_subs.c

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



CVS commit: src/sys/net

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 19:56:55 UTC 2018

Modified Files:
src/sys/net: if_arcsubr.c if_ethersubr.c if_fddisubr.c
if_ieee1394subr.c if_tokensubr.c raw_usrreq.c

Log Message:
m_copy -> m_copym


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/net/if_arcsubr.c
cvs rdiff -u -r1.263 -r1.264 src/sys/net/if_ethersubr.c
cvs rdiff -u -r1.105 -r1.106 src/sys/net/if_fddisubr.c
cvs rdiff -u -r1.59 -r1.60 src/sys/net/if_ieee1394subr.c \
src/sys/net/raw_usrreq.c
cvs rdiff -u -r1.81 -r1.82 src/sys/net/if_tokensubr.c

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



CVS commit: src/sys/net

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 19:56:55 UTC 2018

Modified Files:
src/sys/net: if_arcsubr.c if_ethersubr.c if_fddisubr.c
if_ieee1394subr.c if_tokensubr.c raw_usrreq.c

Log Message:
m_copy -> m_copym


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/net/if_arcsubr.c
cvs rdiff -u -r1.263 -r1.264 src/sys/net/if_ethersubr.c
cvs rdiff -u -r1.105 -r1.106 src/sys/net/if_fddisubr.c
cvs rdiff -u -r1.59 -r1.60 src/sys/net/if_ieee1394subr.c \
src/sys/net/raw_usrreq.c
cvs rdiff -u -r1.81 -r1.82 src/sys/net/if_tokensubr.c

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

Modified files:

Index: src/sys/net/if_arcsubr.c
diff -u src/sys/net/if_arcsubr.c:1.78 src/sys/net/if_arcsubr.c:1.79
--- src/sys/net/if_arcsubr.c:1.78	Mon Oct 23 09:22:24 2017
+++ src/sys/net/if_arcsubr.c	Thu Apr 26 19:56:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arcsubr.c,v 1.78 2017/10/23 09:22:24 msaitoh Exp $	*/
+/*	$NetBSD: if_arcsubr.c,v 1.79 2018/04/26 19:56:55 maxv Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Ignatios Souvatzis
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.78 2017/10/23 09:22:24 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.79 2018/04/26 19:56:55 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -155,7 +155,7 @@ arc_output(struct ifnet *ifp, struct mbu
 		/* If broadcasting on a simplex interface, loopback a copy */
 		if ((m->m_flags & (M_BCAST|M_MCAST)) &&
 		(ifp->if_flags & IFF_SIMPLEX))
-			mcopy = m_copy(m, 0, (int)M_COPYALL);
+			mcopy = m_copym(m, 0, (int)M_COPYALL, M_DONTWAIT);
 		if (ifp->if_flags & IFF_LINK0) {
 			atype = ARCTYPE_IP;
 			newencoding = 1;

Index: src/sys/net/if_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.263 src/sys/net/if_ethersubr.c:1.264
--- src/sys/net/if_ethersubr.c:1.263	Mon Apr  9 16:14:11 2018
+++ src/sys/net/if_ethersubr.c	Thu Apr 26 19:56:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.263 2018/04/09 16:14:11 maxv Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.264 2018/04/26 19:56:55 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.263 2018/04/09 16:14:11 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.264 2018/04/26 19:56:55 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -247,7 +247,7 @@ ether_output(struct ifnet * const ifp0, 
 		}
 		/* If broadcasting on a simplex interface, loopback a copy */
 		if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX))
-			mcopy = m_copy(m, 0, M_COPYALL);
+			mcopy = m_copym(m, 0, M_COPYALL, M_DONTWAIT);
 		etype = htons(ETHERTYPE_IP);
 		break;
 

Index: src/sys/net/if_fddisubr.c
diff -u src/sys/net/if_fddisubr.c:1.105 src/sys/net/if_fddisubr.c:1.106
--- src/sys/net/if_fddisubr.c:1.105	Tue Feb 14 03:05:06 2017
+++ src/sys/net/if_fddisubr.c	Thu Apr 26 19:56:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_fddisubr.c,v 1.105 2017/02/14 03:05:06 ozaki-r Exp $	*/
+/*	$NetBSD: if_fddisubr.c,v 1.106 2018/04/26 19:56:55 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -96,7 +96,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.105 2017/02/14 03:05:06 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.106 2018/04/26 19:56:55 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_gateway.h"
@@ -243,7 +243,7 @@ fddi_output(struct ifnet *ifp0, struct m
 			return error == EWOULDBLOCK ? 0 : error;
 		/* If broadcasting on a simplex interface, loopback a copy */
 		if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX))
-			mcopy = m_copy(m, 0, (int)M_COPYALL);
+			mcopy = m_copym(m, 0, (int)M_COPYALL, M_DONTWAIT);
 		etype = htons(ETHERTYPE_IP);
 		break;
 	}

Index: src/sys/net/if_ieee1394subr.c
diff -u src/sys/net/if_ieee1394subr.c:1.59 src/sys/net/if_ieee1394subr.c:1.60
--- src/sys/net/if_ieee1394subr.c:1.59	Tue Feb 14 03:05:06 2017
+++ src/sys/net/if_ieee1394subr.c	Thu Apr 26 19:56:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ieee1394subr.c,v 1.59 2017/02/14 03:05:06 ozaki-r Exp $	*/
+/*	$NetBSD: if_ieee1394subr.c,v 1.60 2018/04/26 19:56:55 maxv Exp $	*/
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.59 2017/02/14 03:05:06 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.60 2018/04/26 19:56:55 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -143,7 +143,7 @@ ieee1394_output(struct ifnet *ifp, struc
 			return error == EWOULDBLOCK ? 0 : error;
 		/* if broadcasting on a simplex interface, loopback a copy */
 		if ((m0->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX))
-			mcopy = m_copy(m0, 0, M_COPYALL);
+			mcopy = m_copym(m0, 0, M_COPYALL, M_DONTWAIT);
 		etype = htons(ETHERTYPE_IP);
 		break;
 	case AF_ARP:
@@ 

CVS commit: src/sys

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 19:50:09 UTC 2018

Modified Files:
src/sys/kern: uipc_socket.c
src/sys/netinet6: icmp6.c ip6_forward.c ip6_mroute.c ip6_output.c
raw_ip6.c
src/sys/netipsec: keysock.c

Log Message:
Stop using m_copy(), use m_copym() directly. m_copy is useless,
undocumented and confusing.


To generate a diff of this commit:
cvs rdiff -u -r1.262 -r1.263 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.231 -r1.232 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.93 -r1.94 src/sys/netinet6/ip6_forward.c
cvs rdiff -u -r1.124 -r1.125 src/sys/netinet6/ip6_mroute.c
cvs rdiff -u -r1.205 -r1.206 src/sys/netinet6/ip6_output.c
cvs rdiff -u -r1.168 -r1.169 src/sys/netinet6/raw_ip6.c
cvs rdiff -u -r1.64 -r1.65 src/sys/netipsec/keysock.c

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



CVS commit: src/sys

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 19:50:09 UTC 2018

Modified Files:
src/sys/kern: uipc_socket.c
src/sys/netinet6: icmp6.c ip6_forward.c ip6_mroute.c ip6_output.c
raw_ip6.c
src/sys/netipsec: keysock.c

Log Message:
Stop using m_copy(), use m_copym() directly. m_copy is useless,
undocumented and confusing.


To generate a diff of this commit:
cvs rdiff -u -r1.262 -r1.263 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.231 -r1.232 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.93 -r1.94 src/sys/netinet6/ip6_forward.c
cvs rdiff -u -r1.124 -r1.125 src/sys/netinet6/ip6_mroute.c
cvs rdiff -u -r1.205 -r1.206 src/sys/netinet6/ip6_output.c
cvs rdiff -u -r1.168 -r1.169 src/sys/netinet6/raw_ip6.c
cvs rdiff -u -r1.64 -r1.65 src/sys/netipsec/keysock.c

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

Modified files:

Index: src/sys/kern/uipc_socket.c
diff -u src/sys/kern/uipc_socket.c:1.262 src/sys/kern/uipc_socket.c:1.263
--- src/sys/kern/uipc_socket.c:1.262	Thu Apr 26 19:22:17 2018
+++ src/sys/kern/uipc_socket.c	Thu Apr 26 19:50:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_socket.c,v 1.262 2018/04/26 19:22:17 maxv Exp $	*/
+/*	$NetBSD: uipc_socket.c,v 1.263 2018/04/26 19:50:09 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.262 2018/04/26 19:22:17 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.263 2018/04/26 19:50:09 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1316,7 +1316,7 @@ soreceive(struct socket *so, struct mbuf
 		orig_resid = 0;
 		if (flags & MSG_PEEK) {
 			if (paddr)
-*paddr = m_copy(m, 0, m->m_len);
+*paddr = m_copym(m, 0, m->m_len, M_DONTWAIT);
 			m = m->m_next;
 		} else {
 			sbfree(>so_rcv, m);
@@ -1341,7 +1341,7 @@ soreceive(struct socket *so, struct mbuf
 			orig_resid = 0;
 			if (flags & MSG_PEEK) {
 if (paddr)
-	*paddr = m_copy(m, 0, m->m_len);
+	*paddr = m_copym(m, 0, m->m_len, M_DONTWAIT);
 m = m->m_next;
 			} else {
 sbfree(>so_rcv, m);
@@ -1370,7 +1370,7 @@ soreceive(struct socket *so, struct mbuf
 		do {
 			if (flags & MSG_PEEK) {
 if (controlp != NULL) {
-	*controlp = m_copy(m, 0, m->m_len);
+	*controlp = m_copym(m, 0, m->m_len, M_DONTWAIT);
 	controlp = &(*controlp)->m_next;
 }
 m = m->m_next;

Index: src/sys/netinet6/icmp6.c
diff -u src/sys/netinet6/icmp6.c:1.231 src/sys/netinet6/icmp6.c:1.232
--- src/sys/netinet6/icmp6.c:1.231	Thu Apr 26 07:28:21 2018
+++ src/sys/netinet6/icmp6.c	Thu Apr 26 19:50:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: icmp6.c,v 1.231 2018/04/26 07:28:21 maxv Exp $	*/
+/*	$NetBSD: icmp6.c,v 1.232 2018/04/26 19:50:09 maxv Exp $	*/
 /*	$KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.231 2018/04/26 07:28:21 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.232 2018/04/26 19:50:09 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1967,7 +1967,7 @@ icmp6_rip6_input(struct mbuf **mp, int o
 			/* do not inject data into pcb */
 		}
 #endif
-		else if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
+		else if ((n = m_copym(m, 0, (int)M_COPYALL, M_DONTWAIT)) != NULL) {
 			if (last->in6p_flags & IN6P_CONTROLOPTS)
 ip6_savecontrol(last, , ip6, n);
 			/* strip intermediate headers */

Index: src/sys/netinet6/ip6_forward.c
diff -u src/sys/netinet6/ip6_forward.c:1.93 src/sys/netinet6/ip6_forward.c:1.94
--- src/sys/netinet6/ip6_forward.c:1.93	Wed Apr 18 07:17:49 2018
+++ src/sys/netinet6/ip6_forward.c	Thu Apr 26 19:50:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_forward.c,v 1.93 2018/04/18 07:17:49 maxv Exp $	*/
+/*	$NetBSD: ip6_forward.c,v 1.94 2018/04/26 19:50:09 maxv 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.93 2018/04/18 07:17:49 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.94 2018/04/26 19:50:09 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_gateway.h"
@@ -177,7 +177,8 @@ ip6_forward(struct mbuf *m, int srcrt)
 	 * It is important to save it before IPsec processing as IPsec
 	 * processing may modify the mbuf.
 	 */
-	mcopy = m_copy(m, 0, imin(m->m_pkthdr.len, ICMPV6_PLD_MAXLEN));
+	mcopy = m_copym(m, 0, imin(m->m_pkthdr.len, ICMPV6_PLD_MAXLEN),
+	M_DONTWAIT);
 
 #ifdef IPSEC
 	if (ipsec_used) {

Index: src/sys/netinet6/ip6_mroute.c
diff -u src/sys/netinet6/ip6_mroute.c:1.124 src/sys/netinet6/ip6_mroute.c:1.125
--- src/sys/netinet6/ip6_mroute.c:1.124	Thu Apr 26 07:28:21 2018
+++ src/sys/netinet6/ip6_mroute.c	Thu Apr 26 19:50:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_mroute.c,v 1.124 2018/04/26 07:28:21 maxv Exp $	*/
+/*	$NetBSD: ip6_mroute.c,v 1.125 2018/04/26 19:50:09 maxv Exp $	*/
 /*	

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

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 19:33:02 UTC 2018

Modified Files:
src/sys/arch/arm/gemini: gemini_gmac.c

Log Message:
Fix inverted arguments in m_gethdr().


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/gemini/gemini_gmac.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/gemini/gemini_gmac.c
diff -u src/sys/arch/arm/gemini/gemini_gmac.c:1.13 src/sys/arch/arm/gemini/gemini_gmac.c:1.14
--- src/sys/arch/arm/gemini/gemini_gmac.c:1.13	Thu Jun  1 02:45:05 2017
+++ src/sys/arch/arm/gemini/gemini_gmac.c	Thu Apr 26 19:33:02 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: gemini_gmac.c,v 1.13 2017/06/01 02:45:05 chs Exp $ */
+/* $NetBSD: gemini_gmac.c,v 1.14 2018/04/26 19:33:02 maxv Exp $ */
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -49,7 +49,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: gemini_gmac.c,v 1.13 2017/06/01 02:45:05 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gemini_gmac.c,v 1.14 2018/04/26 19:33:02 maxv Exp $");
 
 #define	SWFREEQ_DESCS	256	/* one page worth */
 #define	HWFREEQ_DESCS	256	/* one page worth */
@@ -695,7 +695,7 @@ gmac_rxproduce(gmac_hwqueue_t *hwq, size
 
 		KASSERT(map->dm_mapsize == 0);
 
-		m = m_gethdr(MT_DATA, M_DONTWAIT);
+		m = m_gethdr(M_DONTWAIT, MT_DATA);
 		if (m == NULL) {
 			gmac_mapcache_put(hqm->hqm_mc, map);
 			break;



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

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 19:33:02 UTC 2018

Modified Files:
src/sys/arch/arm/gemini: gemini_gmac.c

Log Message:
Fix inverted arguments in m_gethdr().


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/gemini/gemini_gmac.c

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



CVS commit: src/sys/fs/nfs/common

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 19:27:04 UTC 2018

Modified Files:
src/sys/fs/nfs/common: nfs_commonsubs.c

Log Message:
Fix inverted arguments in MGET().


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/fs/nfs/common/nfs_commonsubs.c

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

Modified files:

Index: src/sys/fs/nfs/common/nfs_commonsubs.c
diff -u src/sys/fs/nfs/common/nfs_commonsubs.c:1.2 src/sys/fs/nfs/common/nfs_commonsubs.c:1.3
--- src/sys/fs/nfs/common/nfs_commonsubs.c:1.2	Tue Dec 13 22:31:51 2016
+++ src/sys/fs/nfs/common/nfs_commonsubs.c	Thu Apr 26 19:27:04 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_commonsubs.c,v 1.2 2016/12/13 22:31:51 pgoyette Exp $	*/
+/*	$NetBSD: nfs_commonsubs.c,v 1.3 2018/04/26 19:27:04 maxv Exp $	*/
 /*-
  * Copyright (c) 1989, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -34,7 +34,7 @@
 
 #include 
 /* __FBSDID("FreeBSD: head/sys/fs/nfs/nfs_commonsubs.c 308708 2016-11-16 01:11:49Z cperciva "); */
-__RCSID("$NetBSD: nfs_commonsubs.c,v 1.2 2016/12/13 22:31:51 pgoyette Exp $");
+__RCSID("$NetBSD: nfs_commonsubs.c,v 1.3 2018/04/26 19:27:04 maxv Exp $");
 
 /*
  * These functions support the macros and help fiddle mbuf chains for
@@ -309,7 +309,7 @@ nfsm_dissct(struct nfsrv_descript *nd, i
 	} else if (siz > ncl_mbuf_mhlen) {
 		panic("nfs S too big");
 	} else {
-		MGET(mp2, MT_DATA, how);
+		MGET(mp2, how, MT_DATA);
 		if (mp2 == NULL)
 			return (NULL);
 		mbuf_setnext(mp2, mbuf_next(nd->nd_md));



CVS commit: src/sys/fs/nfs/common

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 19:27:04 UTC 2018

Modified Files:
src/sys/fs/nfs/common: nfs_commonsubs.c

Log Message:
Fix inverted arguments in MGET().


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/fs/nfs/common/nfs_commonsubs.c

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



CVS commit: src/sys

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 19:22:17 UTC 2018

Modified Files:
src/sys/kern: uipc_socket.c
src/sys/netinet: ip_input.c
src/sys/netinet6: ip6_input.c
src/sys/sys: socketvar.h

Log Message:
Remove unused mbuf argument from sbsavetimestamp.


To generate a diff of this commit:
cvs rdiff -u -r1.261 -r1.262 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.380 -r1.381 src/sys/netinet/ip_input.c
cvs rdiff -u -r1.199 -r1.200 src/sys/netinet6/ip6_input.c
cvs rdiff -u -r1.152 -r1.153 src/sys/sys/socketvar.h

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



CVS commit: src/sys

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 19:22:17 UTC 2018

Modified Files:
src/sys/kern: uipc_socket.c
src/sys/netinet: ip_input.c
src/sys/netinet6: ip6_input.c
src/sys/sys: socketvar.h

Log Message:
Remove unused mbuf argument from sbsavetimestamp.


To generate a diff of this commit:
cvs rdiff -u -r1.261 -r1.262 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.380 -r1.381 src/sys/netinet/ip_input.c
cvs rdiff -u -r1.199 -r1.200 src/sys/netinet6/ip6_input.c
cvs rdiff -u -r1.152 -r1.153 src/sys/sys/socketvar.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/uipc_socket.c
diff -u src/sys/kern/uipc_socket.c:1.261 src/sys/kern/uipc_socket.c:1.262
--- src/sys/kern/uipc_socket.c:1.261	Mon Mar 19 16:32:30 2018
+++ src/sys/kern/uipc_socket.c	Thu Apr 26 19:22:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_socket.c,v 1.261 2018/03/19 16:32:30 roy Exp $	*/
+/*	$NetBSD: uipc_socket.c,v 1.262 2018/04/26 19:22:17 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.261 2018/03/19 16:32:30 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.262 2018/04/26 19:22:17 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -2431,7 +2431,7 @@ sopoll(struct socket *so, int events)
 }
 
 struct mbuf **
-sbsavetimestamp(int opt, struct mbuf *m, struct mbuf **mp)
+sbsavetimestamp(int opt, struct mbuf **mp)
 {
 	struct timeval tv;
 	microtime();

Index: src/sys/netinet/ip_input.c
diff -u src/sys/netinet/ip_input.c:1.380 src/sys/netinet/ip_input.c:1.381
--- src/sys/netinet/ip_input.c:1.380	Sun Apr 15 07:35:49 2018
+++ src/sys/netinet/ip_input.c	Thu Apr 26 19:22:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_input.c,v 1.380 2018/04/15 07:35:49 maxv Exp $	*/
+/*	$NetBSD: ip_input.c,v 1.381 2018/04/26 19:22:17 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.380 2018/04/15 07:35:49 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.381 2018/04/26 19:22:17 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1497,7 +1497,7 @@ ip_savecontrol(struct inpcb *inp, struct
 	int inpflags = inp->inp_flags;
 
 	if (SOOPT_TIMESTAMP(so->so_options))
-		mp = sbsavetimestamp(so->so_options, m, mp);
+		mp = sbsavetimestamp(so->so_options, mp);
 
 	if (inpflags & INP_RECVDSTADDR) {
 		*mp = sbcreatecontrol(>ip_dst,

Index: src/sys/netinet6/ip6_input.c
diff -u src/sys/netinet6/ip6_input.c:1.199 src/sys/netinet6/ip6_input.c:1.200
--- src/sys/netinet6/ip6_input.c:1.199	Thu Apr 26 07:01:38 2018
+++ src/sys/netinet6/ip6_input.c	Thu Apr 26 19:22:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_input.c,v 1.199 2018/04/26 07:01:38 maxv Exp $	*/
+/*	$NetBSD: ip6_input.c,v 1.200 2018/04/26 19:22:17 maxv Exp $	*/
 /*	$KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.199 2018/04/26 07:01:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.200 2018/04/26 19:22:17 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_gateway.h"
@@ -1074,7 +1074,7 @@ ip6_savecontrol(struct in6pcb *in6p, str
 #endif
 
 	if (SOOPT_TIMESTAMP(so->so_options))
-		mp = sbsavetimestamp(so->so_options, m, mp);
+		mp = sbsavetimestamp(so->so_options, mp);
 
 	/* some OSes call this logic with IPv4 packet, for SO_TIMESTAMP */
 	if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION)

Index: src/sys/sys/socketvar.h
diff -u src/sys/sys/socketvar.h:1.152 src/sys/sys/socketvar.h:1.153
--- src/sys/sys/socketvar.h:1.152	Thu Apr 19 21:19:07 2018
+++ src/sys/sys/socketvar.h	Thu Apr 26 19:22:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: socketvar.h,v 1.152 2018/04/19 21:19:07 christos Exp $	*/
+/*	$NetBSD: socketvar.h,v 1.153 2018/04/26 19:22:17 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -283,7 +283,7 @@ struct mbuf *
 struct mbuf *
 	sbcreatecontrol1(void **, int, int, int, int);
 struct mbuf **
-	sbsavetimestamp(int, struct mbuf *, struct mbuf **);
+	sbsavetimestamp(int, struct mbuf **);
 void	sbdrop(struct sockbuf *, int);
 void	sbdroprecord(struct sockbuf *);
 void	sbflush(struct sockbuf *);



CVS commit: src/sys

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 19:13:34 UTC 2018

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

Log Message:
Change MCLGET, so that it calls m_clget instead of doing the work in a
macro. Macros are inefficient when they contain too many instructions and
are used too often, because of cache coherency (and also register use).

This change saves 32KB of kernel .text.


To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.197 src/sys/kern/uipc_mbuf.c
cvs rdiff -u -r1.189 -r1.190 src/sys/sys/mbuf.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/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.196 src/sys/kern/uipc_mbuf.c:1.197
--- src/sys/kern/uipc_mbuf.c:1.196	Thu Apr 26 08:31:36 2018
+++ src/sys/kern/uipc_mbuf.c	Thu Apr 26 19:13:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.196 2018/04/26 08:31:36 maxv Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.197 2018/04/26 19:13:34 maxv Exp $	*/
 
 /*
  * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.196 2018/04/26 08:31:36 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.197 2018/04/26 19:13:34 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -653,7 +653,7 @@ void
 m_clget(struct mbuf *m, int nowait)
 {
 
-	MCLGET(m, nowait);
+	_MCLGET(m, mcl_cache, MCLBYTES, nowait);
 }
 
 #ifdef MBUFTRACE

Index: src/sys/sys/mbuf.h
diff -u src/sys/sys/mbuf.h:1.189 src/sys/sys/mbuf.h:1.190
--- src/sys/sys/mbuf.h:1.189	Tue Apr 24 08:10:32 2018
+++ src/sys/sys/mbuf.h	Thu Apr 26 19:13:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbuf.h,v 1.189 2018/04/24 08:10:32 maxv Exp $	*/
+/*	$NetBSD: mbuf.h,v 1.190 2018/04/26 19:13:34 maxv Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
@@ -531,7 +531,7 @@ do {	\
 /*
  * The standard mbuf cluster pool.
  */
-#define	MCLGET(m, how)	_MCLGET((m), mcl_cache, MCLBYTES, (how))
+#define	MCLGET(m, how)	m_clget((m), (how))
 
 #define	MEXTMALLOC(m, size, how)	\
 do {	\



CVS commit: src/sys

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 19:13:34 UTC 2018

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

Log Message:
Change MCLGET, so that it calls m_clget instead of doing the work in a
macro. Macros are inefficient when they contain too many instructions and
are used too often, because of cache coherency (and also register use).

This change saves 32KB of kernel .text.


To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.197 src/sys/kern/uipc_mbuf.c
cvs rdiff -u -r1.189 -r1.190 src/sys/sys/mbuf.h

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



CVS commit: src/share/man/man9

2018-04-26 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Apr 26 18:56:18 UTC 2018

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

Log Message:
Add SVS. It may not be disabled at securelevel 1 and above.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/share/man/man9/secmodel_securelevel.9

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

Modified files:

Index: src/share/man/man9/secmodel_securelevel.9
diff -u src/share/man/man9/secmodel_securelevel.9:1.15 src/share/man/man9/secmodel_securelevel.9:1.16
--- src/share/man/man9/secmodel_securelevel.9:1.15	Tue Mar 18 18:20:40 2014
+++ src/share/man/man9/secmodel_securelevel.9	Thu Apr 26 18:56:18 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: secmodel_securelevel.9,v 1.15 2014/03/18 18:20:40 riastradh Exp $
+.\" $NetBSD: secmodel_securelevel.9,v 1.16 2018/04/26 18:56:18 alnsn Exp $
 .\"
 .\" Copyright (c) 2006 Elad Efrat 
 .\" Copyright (c) 2000 Hugh Graham
@@ -26,7 +26,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd November 22, 2012
+.Dd April 26, 2018
 .Dt SECMODEL_SECURELEVEL 9
 .Os
 .Sh NAME
@@ -136,6 +136,8 @@ Access to unmanaged memory is denied.
 Only GPIO pins that have been set at
 .Em securelevel
 0 can be accessed.
+.It
+SVS (Separate Virtual Space) may not be disabled on platforms that support it.
 .El
 .It \ 2 Em Highly secure mode
 .Bl -bullet



CVS commit: src/share/man/man9

2018-04-26 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Apr 26 18:56:18 UTC 2018

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

Log Message:
Add SVS. It may not be disabled at securelevel 1 and above.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/share/man/man9/secmodel_securelevel.9

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



CVS commit: src/sys

2018-04-26 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Apr 26 18:54:09 UTC 2018

Modified Files:
src/sys/arch/x86/x86: svs.c
src/sys/secmodel/securelevel: secmodel_securelevel.c
src/sys/secmodel/suser: secmodel_suser.c
src/sys/sys: kauth.h

Log Message:
Add KAUTH_MACHDEP_SVS_DISABLE and add support to secmodel_securelevel(9).

Disabling SVS is denied at securelevel 1 and above.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x86/x86/svs.c
cvs rdiff -u -r1.30 -r1.31 \
src/sys/secmodel/securelevel/secmodel_securelevel.c
cvs rdiff -u -r1.43 -r1.44 src/sys/secmodel/suser/secmodel_suser.c
cvs rdiff -u -r1.75 -r1.76 src/sys/sys/kauth.h

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

Modified files:

Index: src/sys/arch/x86/x86/svs.c
diff -u src/sys/arch/x86/x86/svs.c:1.17 src/sys/arch/x86/x86/svs.c:1.18
--- src/sys/arch/x86/x86/svs.c:1.17	Fri Mar 30 19:58:05 2018
+++ src/sys/arch/x86/x86/svs.c	Thu Apr 26 18:54:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: svs.c,v 1.17 2018/03/30 19:58:05 maxv Exp $	*/
+/*	$NetBSD: svs.c,v 1.18 2018/04/26 18:54:09 alnsn Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.17 2018/03/30 19:58:05 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.18 2018/04/26 18:54:09 alnsn Exp $");
 
 #include "opt_svs.h"
 
@@ -38,6 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.17
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -737,11 +738,13 @@ sysctl_machdep_svs_enabled(SYSCTLFN_ARGS
 			error = 0;
 		else
 			error = EOPNOTSUPP;
-	} else {
-		if (svs_enabled)
+	} else if (svs_enabled) {
+		error = kauth_authorize_machdep(kauth_cred_get(),
+		KAUTH_MACHDEP_SVS_DISABLE, NULL, NULL, NULL, NULL);
+		if (!error)
 			error = svs_disable();
-		else
-			error = 0;
+	} else {
+		error = 0;
 	}
 
 	return error;

Index: src/sys/secmodel/securelevel/secmodel_securelevel.c
diff -u src/sys/secmodel/securelevel/secmodel_securelevel.c:1.30 src/sys/secmodel/securelevel/secmodel_securelevel.c:1.31
--- src/sys/secmodel/securelevel/secmodel_securelevel.c:1.30	Tue Feb 25 18:30:13 2014
+++ src/sys/secmodel/securelevel/secmodel_securelevel.c	Thu Apr 26 18:54:09 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_securelevel.c,v 1.30 2014/02/25 18:30:13 pooka Exp $ */
+/* $NetBSD: secmodel_securelevel.c,v 1.31 2018/04/26 18:54:09 alnsn Exp $ */
 /*-
  * Copyright (c) 2006 Elad Efrat 
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_securelevel.c,v 1.30 2014/02/25 18:30:13 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_securelevel.c,v 1.31 2018/04/26 18:54:09 alnsn Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_insecure.h"
@@ -494,6 +494,11 @@ secmodel_securelevel_machdep_cb(kauth_cr
 			result = KAUTH_RESULT_DENY;
 		break;
 
+	case KAUTH_MACHDEP_SVS_DISABLE:
+		if (securelevel > 0)
+			result = KAUTH_RESULT_DENY;
+		break;
+
 	case KAUTH_MACHDEP_CPU_UCODE_APPLY:
 		if (securelevel > 1)
 			result = KAUTH_RESULT_DENY;

Index: src/sys/secmodel/suser/secmodel_suser.c
diff -u src/sys/secmodel/suser/secmodel_suser.c:1.43 src/sys/secmodel/suser/secmodel_suser.c:1.44
--- src/sys/secmodel/suser/secmodel_suser.c:1.43	Wed Jun 14 17:48:41 2017
+++ src/sys/secmodel/suser/secmodel_suser.c	Thu Apr 26 18:54:09 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_suser.c,v 1.43 2017/06/14 17:48:41 maxv Exp $ */
+/* $NetBSD: secmodel_suser.c,v 1.44 2018/04/26 18:54:09 alnsn Exp $ */
 /*-
  * Copyright (c) 2006 Elad Efrat 
  * All rights reserved.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.43 2017/06/14 17:48:41 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.44 2018/04/26 18:54:09 alnsn Exp $");
 
 #include 
 #include 
@@ -854,6 +854,7 @@ secmodel_suser_machdep_cb(kauth_cred_t c
 	case KAUTH_MACHDEP_UNMANAGEDMEM:
 	case KAUTH_MACHDEP_PXG:
 	case KAUTH_MACHDEP_X86PMC:
+	case KAUTH_MACHDEP_SVS_DISABLE:
 		if (isroot)
 			result = KAUTH_RESULT_ALLOW;
 		break;

Index: src/sys/sys/kauth.h
diff -u src/sys/sys/kauth.h:1.75 src/sys/sys/kauth.h:1.76
--- src/sys/sys/kauth.h:1.75	Mon Aug 28 00:46:07 2017
+++ src/sys/sys/kauth.h	Thu Apr 26 18:54:09 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: kauth.h,v 1.75 2017/08/28 00:46:07 kamil Exp $ */
+/* $NetBSD: kauth.h,v 1.76 2018/04/26 18:54:09 alnsn Exp $ */
 
 /*-
  * Copyright (c) 2005, 2006 Elad Efrat   
@@ -320,7 +320,8 @@ enum {
 	KAUTH_MACHDEP_NVRAM,
 	KAUTH_MACHDEP_UNMANAGEDMEM,
 	KAUTH_MACHDEP_PXG,
-	KAUTH_MACHDEP_X86PMC
+	KAUTH_MACHDEP_X86PMC,
+	KAUTH_MACHDEP_SVS_DISABLE
 };
 
 /*



CVS commit: src/sys

2018-04-26 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Apr 26 18:54:09 UTC 2018

Modified Files:
src/sys/arch/x86/x86: svs.c
src/sys/secmodel/securelevel: secmodel_securelevel.c
src/sys/secmodel/suser: secmodel_suser.c
src/sys/sys: kauth.h

Log Message:
Add KAUTH_MACHDEP_SVS_DISABLE and add support to secmodel_securelevel(9).

Disabling SVS is denied at securelevel 1 and above.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x86/x86/svs.c
cvs rdiff -u -r1.30 -r1.31 \
src/sys/secmodel/securelevel/secmodel_securelevel.c
cvs rdiff -u -r1.43 -r1.44 src/sys/secmodel/suser/secmodel_suser.c
cvs rdiff -u -r1.75 -r1.76 src/sys/sys/kauth.h

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



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

2018-04-26 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 26 18:33:02 UTC 2018

Modified Files:
src/sys/arch/macppc/include: param.h

Log Message:
bump message buffer size


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/macppc/include/param.h

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

Modified files:

Index: src/sys/arch/macppc/include/param.h
diff -u src/sys/arch/macppc/include/param.h:1.20 src/sys/arch/macppc/include/param.h:1.21
--- src/sys/arch/macppc/include/param.h:1.20	Sun Sep 23 22:31:38 2012
+++ src/sys/arch/macppc/include/param.h	Thu Apr 26 18:33:02 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.20 2012/09/23 22:31:38 mrg Exp $	*/
+/*	$NetBSD: param.h,v 1.21 2018/04/26 18:33:02 macallan Exp $	*/
 
 /*-
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -43,7 +43,7 @@
  * 4KB isn't enough for a full boot message for a macppc system anymore
  */
 #ifndef MSGBUFSIZE
-#define	MSGBUFSIZE		(3*NBPG)
+#define	MSGBUFSIZE		(8*NBPG)
 #endif
 
 #endif /* _KERNEL && !_MODULE */



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

2018-04-26 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 26 18:33:02 UTC 2018

Modified Files:
src/sys/arch/macppc/include: param.h

Log Message:
bump message buffer size


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/macppc/include/param.h

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



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

2018-04-26 Thread Sean Cole
Module Name:src
Committed By:   scole
Date:   Thu Apr 26 18:06:25 UTC 2018

Modified Files:
src/sys/arch/ia64/include: mcontext.h

Log Message:
Update some of the _UC_MACHINE* macros even though gregs[] aren't tied to 
anything yet


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/ia64/include/mcontext.h

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



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

2018-04-26 Thread Sean Cole
Module Name:src
Committed By:   scole
Date:   Thu Apr 26 18:06:25 UTC 2018

Modified Files:
src/sys/arch/ia64/include: mcontext.h

Log Message:
Update some of the _UC_MACHINE* macros even though gregs[] aren't tied to 
anything yet


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/ia64/include/mcontext.h

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

Modified files:

Index: src/sys/arch/ia64/include/mcontext.h
diff -u src/sys/arch/ia64/include/mcontext.h:1.7 src/sys/arch/ia64/include/mcontext.h:1.8
--- src/sys/arch/ia64/include/mcontext.h:1.7	Tue Feb 27 09:51:28 2018
+++ src/sys/arch/ia64/include/mcontext.h	Thu Apr 26 18:06:25 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcontext.h,v 1.7 2018/02/27 09:51:28 kamil Exp $	*/
+/*	$NetBSD: mcontext.h,v 1.8 2018/04/26 18:06:25 scole Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -111,11 +111,11 @@ typedef struct __mcontext {
 	__fpregset_t		__fpregs;
 } mcontext_t;
 
-#define _UC_MACHINE_SP(uc)	((uc)->uc_mcontext.mc_special.sp)
+#define _UC_MACHINE_SP(uc)	((uc)->uc_mcontext.mc_special.sp)  /* gregs[12] */
 #define _UC_MACHINE_FP(uc)	((uc)->uc_mcontext.__gregs[79])
-/* XXX or assembly "mov Rn = ip" or ...? */
 #define	_UC_MACHINE_PC(uc)	((uc)->uc_mcontext.mc_special.iip)
-#define	_UC_MACHINE_INTRV(uc)	0 /* XXX */
+#define	_UC_MACHINE_INTRV(uc)	((uc)->uc_mcontext.__gregs[8])
+#define _UC_MACHINE_SET_PC(uc)  _UC_MACHINE_PC(uc) = (pc)  /* XXX */
 
 static __inline void *
 __lwp_getprivate_fast(void)



CVS commit: src/share/man/man9

2018-04-26 Thread Sean Cole
Module Name:src
Committed By:   scole
Date:   Thu Apr 26 14:59:11 UTC 2018

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

Log Message:
Rename "cpu_switch" to "cpu_switchto"


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/share/man/man9/cpu_lwp_fork.9

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

Modified files:

Index: src/share/man/man9/cpu_lwp_fork.9
diff -u src/share/man/man9/cpu_lwp_fork.9:1.6 src/share/man/man9/cpu_lwp_fork.9:1.7
--- src/share/man/man9/cpu_lwp_fork.9:1.6	Fri Mar 10 15:30:45 2017
+++ src/share/man/man9/cpu_lwp_fork.9	Thu Apr 26 14:59:11 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: cpu_lwp_fork.9,v 1.6 2017/03/10 15:30:45 wiz Exp $
+.\" $NetBSD: cpu_lwp_fork.9,v 1.7 2018/04/26 14:59:11 scole Exp $
 .\"
 .\" Copyright (c) 2002, 2005, 2006 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 March 10, 2017
+.Dd April 26, 2018
 .Dt CPU_LWP_FORK 9
 .Os
 .Sh NAME
@@ -58,7 +58,7 @@ rigs the child's kernel stack so that it
 .Fn lwp_trampoline .
 .Fn lwp_trampoline
 does not have a normal calling sequence and is entered by
-.Fn cpu_switch .
+.Fn cpu_switchto .
 If an alternate user-level stack is requested (with non-zero values
 in both the
 .Fa stack
@@ -67,7 +67,7 @@ and
 arguments), the user stack pointer is set up accordingly.
 .Pp
 After being entered by
-.Fn cpu_switch
+.Fn cpu_switchto
 and while running in user context (within the kernel)
 .Fn lwp_trampoline
 will invoke the function



CVS commit: src/share/man/man9

2018-04-26 Thread Sean Cole
Module Name:src
Committed By:   scole
Date:   Thu Apr 26 14:59:11 UTC 2018

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

Log Message:
Rename "cpu_switch" to "cpu_switchto"


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/share/man/man9/cpu_lwp_fork.9

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



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

2018-04-26 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Apr 26 09:37:22 UTC 2018

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

Log Message:
Import rev 1.5 from HEAD


To generate a diff of this commit:
cvs rdiff -u -r1.3.56.6 -r1.3.56.7 src/sys/compat/common/uipc_syscalls_50.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/uipc_syscalls_50.c
diff -u src/sys/compat/common/uipc_syscalls_50.c:1.3.56.6 src/sys/compat/common/uipc_syscalls_50.c:1.3.56.7
--- src/sys/compat/common/uipc_syscalls_50.c:1.3.56.6	Mon Apr 16 03:41:34 2018
+++ src/sys/compat/common/uipc_syscalls_50.c	Thu Apr 26 09:37:22 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_syscalls_50.c,v 1.3.56.6 2018/04/16 03:41:34 pgoyette Exp $	*/
+/*	$NetBSD: uipc_syscalls_50.c,v 1.3.56.7 2018/04/26 09:37:22 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_50.c,v 1.3.56.6 2018/04/16 03:41:34 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_50.c,v 1.3.56.7 2018/04/26 09:37:22 pgoyette Exp $");
 
 #include 
 #include 
@@ -66,10 +66,19 @@ compat_ifdatareq(struct lwp *l, u_long c
 	struct ifnet *ifp;
 	int error;
 
-	ifp = ifunit(ifdr->ifdr_name);
-	if (ifp == NULL)
-		return ENXIO;
+	/* Validate arguments. */
+	switch (cmd) {
+	case SIOCGIFDATA:
+	case SIOCZIFDATA:
+		ifp = ifunit(ifdr->ifdr_name);
+		if (ifp == NULL)
+			return ENXIO;
+		break;
+	default:
+		return ENOSYS;
+	}
 
+	/* Do work. */
 	switch (cmd) {
 	case SIOCGIFDATA:
 		ifdatan2o(>ifdr_data, >if_data);
@@ -94,6 +103,7 @@ compat_ifdatareq(struct lwp *l, u_long c
 		return 0;
 
 	default:
+		/* Impossible due to above validation, but makes gcc happy. */
 		return ENOSYS;
 	}
 }



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

2018-04-26 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Apr 26 09:37:22 UTC 2018

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

Log Message:
Import rev 1.5 from HEAD


To generate a diff of this commit:
cvs rdiff -u -r1.3.56.6 -r1.3.56.7 src/sys/compat/common/uipc_syscalls_50.c

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



CVS commit: src/sys/kern

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 08:31:36 UTC 2018

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

Log Message:
Rename

m_copyback0 -> m_copyback_internal
M_COPYBACK0_* -> CB_*

That's a lot less misleading. While here, fix a bunch of panic messages.


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

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

Modified files:

Index: src/sys/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.195 src/sys/kern/uipc_mbuf.c:1.196
--- src/sys/kern/uipc_mbuf.c:1.195	Thu Apr 26 08:13:30 2018
+++ src/sys/kern/uipc_mbuf.c	Thu Apr 26 08:31:36 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.195 2018/04/26 08:13:30 maxv Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.196 2018/04/26 08:31:36 maxv Exp $	*/
 
 /*
  * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.195 2018/04/26 08:13:30 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.196 2018/04/26 08:31:36 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -104,13 +104,14 @@ static struct sysctllog *mbuf_sysctllog;
 
 static struct mbuf *m_copy_internal(struct mbuf *, int, int, int, bool);
 static struct mbuf *m_split_internal(struct mbuf *, int, int, bool);
-static int m_copyback0(struct mbuf **, int, int, const void *, int, int);
+static int m_copyback_internal(struct mbuf **, int, int, const void *,
+int, int);
 
-/* flags for m_copyback0 */
-#define	M_COPYBACK0_COPYBACK	0x0001	/* copyback from cp */
-#define	M_COPYBACK0_PRESERVE	0x0002	/* preserve original data */
-#define	M_COPYBACK0_COW		0x0004	/* do copy-on-write */
-#define	M_COPYBACK0_EXTEND	0x0008	/* extend chain */
+/* Flags for m_copyback_internal. */
+#define	CB_COPYBACK	0x0001	/* copyback from cp */
+#define	CB_PRESERVE	0x0002	/* preserve original data */
+#define	CB_COW		0x0004	/* do copy-on-write */
+#define	CB_EXTEND	0x0008	/* extend chain */
 
 static const char mclpool_warnmsg[] =
 "WARNING: mclpool limit reached; increase kern.mbuf.nmbclusters";
@@ -745,12 +746,12 @@ m_copy_internal(struct mbuf *m, int off0
 	int copyhdr = 0;
 
 	if (off < 0 || (len != M_COPYALL && len < 0))
-		panic("m_copym: off %d, len %d", off, len);
+		panic("%s: off %d, len %d", __func__, off, len);
 	if (off == 0 && m->m_flags & M_PKTHDR)
 		copyhdr = 1;
 	while (off > 0) {
 		if (m == NULL)
-			panic("m_copym: m == 0, off %d", off);
+			panic("%s: m == 0, off %d", __func__, off);
 		if (off < m->m_len)
 			break;
 		off -= m->m_len;
@@ -762,8 +763,8 @@ m_copy_internal(struct mbuf *m, int off0
 	while (len == M_COPYALL || len > 0) {
 		if (m == NULL) {
 			if (len != M_COPYALL)
-panic("m_copym: m == 0, len %d [!COPYALL]",
-len);
+panic("%s: m == NULL, len %d [!COPYALL]",
+__func__, len);
 			break;
 		}
 
@@ -810,7 +811,7 @@ m_copy_internal(struct mbuf *m, int off0
 		off += n->m_len;
 #ifdef DIAGNOSTIC
 		if (off > m->m_len)
-			panic("m_copym0 overrun %d %d", off, m->m_len);
+			panic("%s overrun %d %d", __func__, off, m->m_len);
 #endif
 		if (off == m->m_len) {
 			m = m->m_next;
@@ -1316,8 +1317,8 @@ m_copyback(struct mbuf *m0, int off, int
 #if defined(DEBUG)
 	error =
 #endif
-	m_copyback0(, off, len, cp,
-	M_COPYBACK0_COPYBACK|M_COPYBACK0_EXTEND, M_DONTWAIT);
+	m_copyback_internal(, off, len, cp, CB_COPYBACK|CB_EXTEND,
+	M_DONTWAIT);
 
 #if defined(DEBUG)
 	if (error != 0 || (m0 != NULL && origm != m0))
@@ -1334,8 +1335,8 @@ m_copyback_cow(struct mbuf *m0, int off,
 	KASSERT(len != M_COPYALL);
 	KDASSERT(off + len <= m_length(m0));
 
-	error = m_copyback0(, off, len, cp,
-	M_COPYBACK0_COPYBACK|M_COPYBACK0_COW, how);
+	error = m_copyback_internal(, off, len, cp, CB_COPYBACK|CB_COW,
+	how);
 	if (error) {
 		/*
 		 * no way to recover from partial success.
@@ -1347,9 +1348,6 @@ m_copyback_cow(struct mbuf *m0, int off,
 	return m0;
 }
 
-/*
- * m_makewritable: ensure the specified range writable.
- */
 int
 m_makewritable(struct mbuf **mp, int off, int len, int how)
 {
@@ -1358,9 +1356,8 @@ m_makewritable(struct mbuf **mp, int off
 	int origlen = m_length(*mp);
 #endif
 
-	error = m_copyback0(mp, off, len, NULL,
-	M_COPYBACK0_PRESERVE|M_COPYBACK0_COW, how);
-
+	error = m_copyback_internal(mp, off, len, NULL, CB_PRESERVE|CB_COW,
+	how);
 	if (error)
 		return error;
 
@@ -1430,9 +1427,9 @@ m_defrag(struct mbuf *mold, int flags)
 	return m0;
 }
 
-int
-m_copyback0(struct mbuf **mp0, int off, int len, const void *vp, int flags,
-int how)
+static int
+m_copyback_internal(struct mbuf **mp0, int off, int len, const void *vp,
+int flags, int how)
 {
 	int mlen;
 	struct mbuf *m, *n;
@@ -1442,18 +1439,18 @@ m_copyback0(struct mbuf **mp0, int off, 
 
 	KASSERT(mp0 != NULL);
 	KASSERT(*mp0 != NULL);
-	KASSERT((flags & M_COPYBACK0_PRESERVE) == 0 || cp == NULL);
-	

CVS commit: src/sys/kern

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 08:31:36 UTC 2018

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

Log Message:
Rename

m_copyback0 -> m_copyback_internal
M_COPYBACK0_* -> CB_*

That's a lot less misleading. While here, fix a bunch of panic messages.


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

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



CVS commit: src

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 08:13:30 UTC 2018

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

Log Message:
Stop adding '0's in parameter and function names, that's just misleading.
Some remain, they need more investigation.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/share/man/man9/mbuf.9
cvs rdiff -u -r1.194 -r1.195 src/sys/kern/uipc_mbuf.c

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



CVS commit: src

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 08:13:30 UTC 2018

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

Log Message:
Stop adding '0's in parameter and function names, that's just misleading.
Some remain, they need more investigation.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/share/man/man9/mbuf.9
cvs rdiff -u -r1.194 -r1.195 src/sys/kern/uipc_mbuf.c

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

Modified files:

Index: src/share/man/man9/mbuf.9
diff -u src/share/man/man9/mbuf.9:1.58 src/share/man/man9/mbuf.9:1.59
--- src/share/man/man9/mbuf.9:1.58	Thu Apr 26 07:48:21 2018
+++ src/share/man/man9/mbuf.9	Thu Apr 26 08:13:30 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mbuf.9,v 1.58 2018/04/26 07:48:21 maxv Exp $
+.\"	$NetBSD: mbuf.9,v 1.59 2018/04/26 08:13:30 maxv Exp $
 .\"
 .\" Copyright (c) 1997 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -75,7 +75,7 @@
 .Ft struct mbuf *
 .Fn m_devget "char *buf" "int totlen" "int off0" "struct ifnet *ifp" "void (*copy)(const void *, void *, size_t)"
 .Ft struct mbuf *
-.Fn m_copym "struct mbuf *m" "int off0" "int len" "int wait"
+.Fn m_copym "struct mbuf *m" "int off" "int len" "int wait"
 .Ft struct mbuf *
 .Fn m_copypacket "struct mbuf *m" "int how"
 .Ft void
@@ -89,7 +89,7 @@
 .Ft void
 .Fn m_cat "struct mbuf *m" "struct mbuf *n"
 .Ft struct mbuf *
-.Fn m_dup "struct mbuf *m" "int off0" "int len" "int wait"
+.Fn m_dup "struct mbuf *m" "int off" "int len" "int wait"
 .Ft struct mbuf *
 .Fn m_pulldown "struct mbuf *m" "int off" "int len" "int *offp"
 .Ft struct mbuf *
@@ -97,7 +97,7 @@
 .Ft struct mbuf *
 .Fn m_copyup "struct mbuf *m" "int len" "int dstoff"
 .Ft struct mbuf *
-.Fn m_split "struct mbuf *m0" "int len0" "int wait"
+.Fn m_split "struct mbuf *m0" "int len" "int wait"
 .Ft void
 .Fn m_adj "struct mbuf *mp" "int req_len"
 .Ft int
@@ -267,9 +267,9 @@ is non-zero, the packet is supposed to b
 .Fa off
 bytes plus the type and length fields will be skipped before copying.
 Returns the top of the mbuf chain it created.
-.It Fn m_copym "struct mbuf *m" "int off0" "int len" "int wait"
+.It Fn m_copym "struct mbuf *m" "int off" "int len" "int wait"
 Creates a copy of an mbuf chain starting
-.Fa off0
+.Fa off
 bytes from the beginning, continuing for
 .Fa len
 bytes.
@@ -385,11 +385,11 @@ to
 Both chains must be of the same type; packet headers will
 .Em not
 be updated if present.
-.It Fn m_dup "struct mbuf *m" "int off0" "int len" "int wait"
+.It Fn m_dup "struct mbuf *m" "int off" "int len" "int wait"
 Similarly to
 .Fn m_copym ,
 the function creates a copy of an mbuf chain starting
-.Fa off0
+.Fa off
 bytes from the beginning, continuing for
 .Fa len
 bytes.
@@ -475,7 +475,7 @@ the function does not allocate mbuf clus
 .Fa len + dstoff
 must be less than
 .Dv MHLEN .
-.It Fn m_split "struct mbuf *m0" "int len0" "int wait"
+.It Fn m_split "struct mbuf *m0" "int len" "int wait"
 Partitions an mbuf chain in two pieces, returning the tail,
 which is all but the first
 .Fa len0

Index: src/sys/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.194 src/sys/kern/uipc_mbuf.c:1.195
--- src/sys/kern/uipc_mbuf.c:1.194	Thu Apr 26 07:46:24 2018
+++ src/sys/kern/uipc_mbuf.c	Thu Apr 26 08:13:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.194 2018/04/26 07:46:24 maxv Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.195 2018/04/26 08:13:30 maxv Exp $	*/
 
 /*
  * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.194 2018/04/26 07:46:24 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.195 2018/04/26 08:13:30 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -102,8 +102,8 @@ static void	sysctl_kern_mbuf_setup(void)
 
 static struct sysctllog *mbuf_sysctllog;
 
-static struct mbuf *m_copym0(struct mbuf *, int, int, int, bool);
-static struct mbuf *m_split0(struct mbuf *, int, int, bool);
+static struct mbuf *m_copy_internal(struct mbuf *, int, int, int, bool);
+static struct mbuf *m_split_internal(struct mbuf *, int, int, bool);
 static int m_copyback0(struct mbuf **, int, int, const void *, int, int);
 
 /* flags for m_copyback0 */
@@ -717,17 +717,17 @@ m_prepend(struct mbuf *m, int len, int h
  * The wait parameter is a choice of M_WAIT/M_DONTWAIT from caller.
  */
 struct mbuf *
-m_copym(struct mbuf *m, int off0, int len, int wait)
+m_copym(struct mbuf *m, int off, int len, int wait)
 {
-
-	return m_copym0(m, off0, len, wait, false); /* shallow copy on M_EXT */
+	/* Shallow copy on M_EXT. */
+	return m_copy_internal(m, off, len, wait, false);
 }
 
 struct mbuf *
-m_dup(struct mbuf *m, int off0, int len, int wait)
+m_dup(struct mbuf *m, int off, int len, int wait)
 {
-
-	return m_copym0(m, off0, len, wait, true); /* deep copy */
+	/* Deep copy. */
+	return m_copy_internal(m, off, len, wait, true);
 }
 
 static 

CVS commit: src/sys/compat/common

2018-04-26 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Apr 26 08:11:18 UTC 2018

Modified Files:
src/sys/compat/common: uipc_syscalls_50.c

Log Message:
Test for valid interface for ioctls that demand it.

Thanks to Robert Swindells for the patch.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/compat/common/uipc_syscalls_50.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/uipc_syscalls_50.c
diff -u src/sys/compat/common/uipc_syscalls_50.c:1.4 src/sys/compat/common/uipc_syscalls_50.c:1.5
--- src/sys/compat/common/uipc_syscalls_50.c:1.4	Thu Apr 12 18:50:13 2018
+++ src/sys/compat/common/uipc_syscalls_50.c	Thu Apr 26 08:11:18 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_syscalls_50.c,v 1.4 2018/04/12 18:50:13 christos Exp $	*/
+/*	$NetBSD: uipc_syscalls_50.c,v 1.5 2018/04/26 08:11:18 roy Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_50.c,v 1.4 2018/04/12 18:50:13 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_50.c,v 1.5 2018/04/26 08:11:18 roy Exp $");
 
 #include 
 #include 
@@ -63,10 +63,19 @@ compat_ifdatareq(struct lwp *l, u_long c
 	struct ifnet *ifp;
 	int error;
 
-	ifp = ifunit(ifdr->ifdr_name);
-	if (ifp == NULL)
-		return ENXIO;
+	/* Validate arguments. */
+	switch (cmd) {
+	case SIOCGIFDATA:
+	case SIOCZIFDATA:
+		ifp = ifunit(ifdr->ifdr_name);
+		if (ifp == NULL)
+			return ENXIO;
+		break;
+	default:
+		return ENOSYS;
+	}
 
+	/* Do work. */
 	switch (cmd) {
 	case SIOCGIFDATA:
 		ifdatan2o(>ifdr_data, >if_data);
@@ -91,6 +100,7 @@ compat_ifdatareq(struct lwp *l, u_long c
 		return 0;
 
 	default:
+		/* Impossible due to above validation, but makes gcc happy. */
 		return ENOSYS;
 	}
 }



CVS commit: src/sys/compat/common

2018-04-26 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Apr 26 08:11:18 UTC 2018

Modified Files:
src/sys/compat/common: uipc_syscalls_50.c

Log Message:
Test for valid interface for ioctls that demand it.

Thanks to Robert Swindells for the patch.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/compat/common/uipc_syscalls_50.c

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



CVS commit: src/share/man/man9

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 07:48:21 UTC 2018

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

Log Message:
Remove m_prepend from the man page, it's a helper, and is not supposed to
be part of the API.


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

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

Modified files:

Index: src/share/man/man9/mbuf.9
diff -u src/share/man/man9/mbuf.9:1.57 src/share/man/man9/mbuf.9:1.58
--- src/share/man/man9/mbuf.9:1.57	Tue Apr 10 16:12:29 2018
+++ src/share/man/man9/mbuf.9	Thu Apr 26 07:48:21 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mbuf.9,v 1.57 2018/04/10 16:12:29 maxv Exp $
+.\"	$NetBSD: mbuf.9,v 1.58 2018/04/26 07:48:21 maxv Exp $
 .\"
 .\" Copyright (c) 1997 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd April 10, 2018
+.Dd April 26, 2018
 .Dt MBUF 9
 .Os
 .Sh NAME
@@ -43,7 +43,6 @@
 .Nm m_cat ,
 .Nm m_dup ,
 .Nm m_makewritable ,
-.Nm m_prepend ,
 .Nm m_pulldown ,
 .Nm m_pullup ,
 .Nm m_copyup ,
@@ -92,8 +91,6 @@
 .Ft struct mbuf *
 .Fn m_dup "struct mbuf *m" "int off0" "int len" "int wait"
 .Ft struct mbuf *
-.Fn m_prepend "struct mbuf *m" "int len" "int how"
-.Ft struct mbuf *
 .Fn m_pulldown "struct mbuf *m" "int off" "int len" "int *offp"
 .Ft struct mbuf *
 .Fn m_pullup "struct mbuf *n" "int len"
@@ -404,23 +401,6 @@ flag,
 .Fn m_dup
 will deep-copy the whole data content into new mbuf chain
 and avoids shared external storage.
-.It Fn m_prepend "struct mbuf *m" "int len" "int how"
-Lesser-used path for
-.Fn M_PREPEND :
-allocates new mbuf
-.Fa m
-of size
-.Fa len
-to prepend to the chain, copying junk along.
-The
-.Fa how
-parameter is a choice of
-.Dv M_WAIT / M_DONTWAIT
-from caller.
-It is illegal for the
-.Fa len
-parameter to be greater than
-.Dv MHLEN .
 .It Fn m_pulldown "struct mbuf *m" "int off" "int len" "int *offp"
 Rearranges an mbuf chain so that
 .Fa len
@@ -709,6 +689,10 @@ and allocation fails, the original mbuf 
 .Fa m
 is set to
 .Dv NULL .
+It is illegal for the
+.Fa plen
+parameter to be greater than
+.Dv MHLEN .
 Implemented as a macro.
 .It Fn MCHTYPE "struct mbuf *m" "int type"
 Change mbuf



CVS commit: src/share/man/man9

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 07:48:21 UTC 2018

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

Log Message:
Remove m_prepend from the man page, it's a helper, and is not supposed to
be part of the API.


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

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



CVS commit: src/sys/kern

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 07:46:24 UTC 2018

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

Log Message:
Change comment, to clearly say that m_prepend should not be used directly.


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

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

Modified files:

Index: src/sys/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.193 src/sys/kern/uipc_mbuf.c:1.194
--- src/sys/kern/uipc_mbuf.c:1.193	Fri Apr 20 06:01:59 2018
+++ src/sys/kern/uipc_mbuf.c	Thu Apr 26 07:46:24 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.193 2018/04/20 06:01:59 maxv Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.194 2018/04/26 07:46:24 maxv Exp $	*/
 
 /*
  * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.193 2018/04/20 06:01:59 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.194 2018/04/26 07:46:24 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -673,9 +673,7 @@ m_claimm(struct mbuf *m, struct mowner *
  */
 
 /*
- * Lesser-used path for M_PREPEND:
- * allocate new mbuf to prepend to chain,
- * copy junk along.
+ * Utility function for M_PREPEND. Do *NOT* use it directly.
  */
 struct mbuf *
 m_prepend(struct mbuf *m, int len, int how)



CVS commit: src/sys/kern

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 07:46:24 UTC 2018

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

Log Message:
Change comment, to clearly say that m_prepend should not be used directly.


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

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



CVS commit: src/sys

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 07:28:21 UTC 2018

Modified Files:
src/sys/netinet: ip_icmp.c
src/sys/netinet6: icmp6.c ip6_mroute.c

Log Message:
Use M_UNWRITABLE, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.168 -r1.169 src/sys/netinet/ip_icmp.c
cvs rdiff -u -r1.230 -r1.231 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.123 -r1.124 src/sys/netinet6/ip6_mroute.c

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



CVS commit: src/sys

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 07:28:21 UTC 2018

Modified Files:
src/sys/netinet: ip_icmp.c
src/sys/netinet6: icmp6.c ip6_mroute.c

Log Message:
Use M_UNWRITABLE, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.168 -r1.169 src/sys/netinet/ip_icmp.c
cvs rdiff -u -r1.230 -r1.231 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.123 -r1.124 src/sys/netinet6/ip6_mroute.c

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

Modified files:

Index: src/sys/netinet/ip_icmp.c
diff -u src/sys/netinet/ip_icmp.c:1.168 src/sys/netinet/ip_icmp.c:1.169
--- src/sys/netinet/ip_icmp.c:1.168	Thu Feb  8 09:32:02 2018
+++ src/sys/netinet/ip_icmp.c	Thu Apr 26 07:28:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_icmp.c,v 1.168 2018/02/08 09:32:02 maxv Exp $	*/
+/*	$NetBSD: ip_icmp.c,v 1.169 2018/04/26 07:28:21 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.168 2018/02/08 09:32:02 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.169 2018/04/26 07:28:21 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -448,7 +448,7 @@ _icmp_input(struct mbuf *m, int hlen, in
 		goto freeit;
 	}
 	i = hlen + min(icmplen, ICMP_ADVLENMIN);
-	if ((m->m_len < i || M_READONLY(m)) && (m = m_pullup(m, i)) == NULL) {
+	if (M_UNWRITABLE(m, i) && (m = m_pullup(m, i)) == NULL) {
 		ICMP_STATINC(ICMP_STAT_TOOSHORT);
 		return;
 	}

Index: src/sys/netinet6/icmp6.c
diff -u src/sys/netinet6/icmp6.c:1.230 src/sys/netinet6/icmp6.c:1.231
--- src/sys/netinet6/icmp6.c:1.230	Sat Apr 14 17:55:47 2018
+++ src/sys/netinet6/icmp6.c	Thu Apr 26 07:28:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: icmp6.c,v 1.230 2018/04/14 17:55:47 maxv Exp $	*/
+/*	$NetBSD: icmp6.c,v 1.231 2018/04/26 07:28:21 maxv Exp $	*/
 /*	$KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.230 2018/04/14 17:55:47 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.231 2018/04/26 07:28:21 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -642,8 +642,7 @@ _icmp6_input(struct mbuf *m, int off, in
 			/* Give up local */
 			n = m;
 			m = NULL;
-		} else if (M_READONLY(n) ||
-		n->m_len < off + sizeof(struct icmp6_hdr)) {
+		} else if (M_UNWRITABLE(n, off + sizeof(struct icmp6_hdr))) {
 			struct mbuf *n0 = n;
 
 			/*

Index: src/sys/netinet6/ip6_mroute.c
diff -u src/sys/netinet6/ip6_mroute.c:1.123 src/sys/netinet6/ip6_mroute.c:1.124
--- src/sys/netinet6/ip6_mroute.c:1.123	Wed Mar 21 14:23:54 2018
+++ src/sys/netinet6/ip6_mroute.c	Thu Apr 26 07:28:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_mroute.c,v 1.123 2018/03/21 14:23:54 roy Exp $	*/
+/*	$NetBSD: ip6_mroute.c,v 1.124 2018/04/26 07:28:21 maxv Exp $	*/
 /*	$KAME: ip6_mroute.c,v 1.49 2001/07/25 09:21:18 jinmei Exp $	*/
 
 /*
@@ -117,7 +117,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.123 2018/03/21 14:23:54 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.124 2018/04/26 07:28:21 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1131,8 +1131,7 @@ ip6_mforward(struct ip6_hdr *ip6, struct
 		 * Pullup packet header if needed before storing it,
 		 * as other references may modify it in the meantime.
 		 */
-		if (mb0 &&
-		(M_READONLY(mb0) || mb0->m_len < sizeof(struct ip6_hdr)))
+		if (mb0 && M_UNWRITABLE(mb0, sizeof(struct ip6_hdr)))
 			mb0 = m_pullup(mb0, sizeof(struct ip6_hdr));
 		if (mb0 == NULL) {
 			free(rte, M_MRTABLE);
@@ -1416,9 +1415,7 @@ ip6_mdq(struct mbuf *m, struct ifnet *if
 struct omrt6msg *oim;
 
 mm = m_copy(m, 0, sizeof(struct ip6_hdr));
-if (mm &&
-(M_READONLY(mm) ||
- mm->m_len < sizeof(struct ip6_hdr)))
+if (mm && M_UNWRITABLE(mm, sizeof(struct ip6_hdr)))
 	mm = m_pullup(mm, sizeof(struct ip6_hdr));
 if (mm == NULL)
 	return ENOBUFS;
@@ -1552,8 +1549,7 @@ phyint_send(struct ip6_hdr *ip6, struct 
 	 * so that ip6_output() only scribbles on the copy.
 	 */
 	mb_copy = m_copy(m, 0, M_COPYALL);
-	if (mb_copy &&
-	(M_READONLY(mb_copy) || mb_copy->m_len < sizeof(struct ip6_hdr)))
+	if (mb_copy && M_UNWRITABLE(mb_copy, sizeof(struct ip6_hdr)))
 		mb_copy = m_pullup(mb_copy, sizeof(struct ip6_hdr));
 	if (mb_copy == NULL) {
 		splx(s);



CVS commit: src/sys/netinet6

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 07:01:38 UTC 2018

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

Log Message:
Move the address checks into one function, ip6_badaddr(). In this function,
reinstate the "IPv4-compatible IPv6 addresses" check; these addresses are
deprecated by RFC4291 (2006).


To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.199 src/sys/netinet6/ip6_input.c

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



CVS commit: src/sys/netinet6

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 07:01:38 UTC 2018

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

Log Message:
Move the address checks into one function, ip6_badaddr(). In this function,
reinstate the "IPv4-compatible IPv6 addresses" check; these addresses are
deprecated by RFC4291 (2006).


To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.199 src/sys/netinet6/ip6_input.c

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

Modified files:

Index: src/sys/netinet6/ip6_input.c
diff -u src/sys/netinet6/ip6_input.c:1.198 src/sys/netinet6/ip6_input.c:1.199
--- src/sys/netinet6/ip6_input.c:1.198	Sun Apr 15 08:31:18 2018
+++ src/sys/netinet6/ip6_input.c	Thu Apr 26 07:01:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_input.c,v 1.198 2018/04/15 08:31:18 maxv Exp $	*/
+/*	$NetBSD: ip6_input.c,v 1.199 2018/04/26 07:01:38 maxv Exp $	*/
 /*	$KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.198 2018/04/15 08:31:18 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.199 2018/04/26 07:01:38 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_gateway.h"
@@ -138,6 +138,7 @@ percpu_t *ip6_forward_rt_percpu __cachel
 
 static void ip6_init2(void);
 static void ip6intr(void *);
+static bool ip6_badaddr(struct ip6_hdr *);
 static struct m_tag *ip6_setdstifaddr(struct mbuf *, const struct in6_ifaddr *);
 
 static int ip6_process_hopopts(struct mbuf *, u_int8_t *, int, u_int32_t *,
@@ -320,55 +321,13 @@ ip6_input(struct mbuf *m, struct ifnet *
 		goto bad;
 	}
 
-	/*
-	 * Check against address spoofing/corruption.
-	 */
-	if (IN6_IS_ADDR_MULTICAST(>ip6_src) ||
-	IN6_IS_ADDR_UNSPECIFIED(>ip6_dst)) {
-		/*
-		 * XXX: "badscope" is not very suitable for a multicast source.
-		 */
+	if (ip6_badaddr(ip6)) {
 		IP6_STATINC(IP6_STAT_BADSCOPE);
 		in6_ifstat_inc(rcvif, ifs6_in_addrerr);
 		goto bad;
 	}
 
 	/*
-	 * The following check is not documented in specs.  A malicious
-	 * party may be able to use IPv4 mapped addr to confuse tcp/udp stack
-	 * and bypass security checks (act as if it was from 127.0.0.1 by using
-	 * IPv6 src :::127.0.0.1).  Be cautious.
-	 *
-	 * This check chokes if we are in an SIIT cloud.  As none of BSDs
-	 * support IPv4-less kernel compilation, we cannot support SIIT
-	 * environment at all.  So, it makes more sense for us to reject any
-	 * malicious packets for non-SIIT environment, than try to do a
-	 * partial support for SIIT environment.
-	 */
-	if (IN6_IS_ADDR_V4MAPPED(>ip6_src) ||
-	IN6_IS_ADDR_V4MAPPED(>ip6_dst)) {
-		IP6_STATINC(IP6_STAT_BADSCOPE);
-		in6_ifstat_inc(rcvif, ifs6_in_addrerr);
-		goto bad;
-	}
-
-#if 0
-	/*
-	 * Reject packets with IPv4 compatible addresses (auto tunnel).
-	 *
-	 * The code forbids auto tunnel relay case in RFC1933 (the check is
-	 * stronger than RFC1933).  We may want to re-enable it if mech-xx
-	 * is revised to forbid relaying case.
-	 */
-	if (IN6_IS_ADDR_V4COMPAT(>ip6_src) ||
-	IN6_IS_ADDR_V4COMPAT(>ip6_dst)) {
-		IP6_STATINC(IP6_STAT_BADSCOPE);
-		in6_ifstat_inc(rcvif, ifs6_in_addrerr);
-		goto bad;
-	}
-#endif
-
-	/*
 	 * Assume that we can create a fast-forward IP flow entry
 	 * based on this packet.
 	 */
@@ -804,6 +763,43 @@ bad:
 	return;
 }
 
+static bool
+ip6_badaddr(struct ip6_hdr *ip6)
+{
+	/* Check against address spoofing/corruption. */
+	if (IN6_IS_ADDR_MULTICAST(>ip6_src) ||
+	IN6_IS_ADDR_UNSPECIFIED(>ip6_dst)) {
+		return true;
+	}
+
+	/*
+	 * The following check is not documented in specs.  A malicious
+	 * party may be able to use IPv4 mapped addr to confuse tcp/udp stack
+	 * and bypass security checks (act as if it was from 127.0.0.1 by using
+	 * IPv6 src :::127.0.0.1).  Be cautious.
+	 *
+	 * This check chokes if we are in an SIIT cloud.  As none of BSDs
+	 * support IPv4-less kernel compilation, we cannot support SIIT
+	 * environment at all.  So, it makes more sense for us to reject any
+	 * malicious packets for non-SIIT environment, than try to do a
+	 * partial support for SIIT environment.
+	 */
+	if (IN6_IS_ADDR_V4MAPPED(>ip6_src) ||
+	IN6_IS_ADDR_V4MAPPED(>ip6_dst)) {
+		return true;
+	}
+
+	/*
+	 * Reject packets with IPv4-compatible IPv6 addresses (RFC4291).
+	 */
+	if (IN6_IS_ADDR_V4COMPAT(>ip6_src) ||
+	IN6_IS_ADDR_V4COMPAT(>ip6_dst)) {
+		return true;
+	}
+
+	return false;
+}
+
 /*
  * set/grab in6_ifaddr correspond to IPv6 destination address.
  */



CVS commit: src/tests/net/net

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 06:23:33 UTC 2018

Modified Files:
src/tests/net/net: t_ping6_opts.sh

Log Message:
Remove ping6_opts_hops, "-g" does not exist anymore (RH0 removed).


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/net/net/t_ping6_opts.sh

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



CVS commit: src/tests/net/net

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 06:23:33 UTC 2018

Modified Files:
src/tests/net/net: t_ping6_opts.sh

Log Message:
Remove ping6_opts_hops, "-g" does not exist anymore (RH0 removed).


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/net/net/t_ping6_opts.sh

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

Modified files:

Index: src/tests/net/net/t_ping6_opts.sh
diff -u src/tests/net/net/t_ping6_opts.sh:1.8 src/tests/net/net/t_ping6_opts.sh:1.9
--- src/tests/net/net/t_ping6_opts.sh:1.8	Fri Nov 25 08:51:17 2016
+++ src/tests/net/net/t_ping6_opts.sh	Thu Apr 26 06:23:33 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: t_ping6_opts.sh,v 1.8 2016/11/25 08:51:17 ozaki-r Exp $
+#	$NetBSD: t_ping6_opts.sh,v 1.9 2018/04/26 06:23:33 maxv Exp $
 #
 # Copyright (c) 2016 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -292,89 +292,10 @@ ping6_opts_gateway_cleanup()
 	cleanup
 }
 
-atf_test_case ping6_opts_hops cleanup
-ping6_opts_hops_head()
-{
-
-	atf_set "descr" "tests of ping6 hops (Type 0 Routing Header)"
-	atf_set "require.progs" "rump_server"
-}
-
-ping6_opts_hops_body()
-{
-	local my_macaddr=
-	local gw_shmif0_macaddr=
-	local gw_shmif2_macaddr=
-
-	setup6
-	setup_forwarding6
-
-	my_macaddr=$(get_macaddr ${SOCKSRC} shmif0)
-	gw_shmif0_macaddr=$(get_macaddr ${SOCKFWD} shmif0)
-
-	export RUMP_SERVER=$SOCKSRC
-	atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST
-	check_echo_request_pkt_with_macaddr \
-	$my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST
-
-	rump_server_add_iface $SOCKFWD shmif2 $BUS_SRCGW
-	export RUMP_SERVER=$SOCKFWD
-	atf_check -s exit:0 rump.ifconfig shmif2 inet6 $IP6SRCGW2
-	atf_check -s exit:0 rump.ifconfig -w 10
-	gw_shmif2_macaddr=$(get_macaddr ${SOCKFWD} shmif2)
-
-	export RUMP_SERVER=$SOCKSRC
-	atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST
-	check_echo_request_pkt_with_macaddr \
-	$my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST
-
-	# ping6 hops
-
-	# ping6 fails expectedly because the kernel doesn't support
-	# to receive packets with type 0 routing headers, but we can
-	# check whether a sent packet is correct.
-	atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
-	$IP6SRCGW $IP6DST
-	check_echo_request_pkt_with_macaddr_and_rthdr0 \
-	$my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6SRCGW $IP6DST
-
-	atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
-	$IP6SRCGW2 $IP6DST
-	check_echo_request_pkt_with_macaddr_and_rthdr0 \
-	$my_macaddr $gw_shmif2_macaddr $IP6SRC $IP6SRCGW2 $IP6DST
-
-	# ping6 -g  hops
-	atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
-	-g $IP6SRCGW $IP6SRCGW $IP6DST
-	check_echo_request_pkt_with_macaddr_and_rthdr0 \
-	$my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6SRCGW $IP6DST
-
-	atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
-	-g $IP6SRCGW2 $IP6SRCGW2 $IP6DST
-	check_echo_request_pkt_with_macaddr_and_rthdr0 \
-	$my_macaddr $gw_shmif2_macaddr $IP6SRC $IP6SRCGW2 $IP6DST
-
-	# ping6 -g  hops, but different nexthops (is it valid?)
-	atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
-	-g $IP6SRCGW $IP6SRCGW2 $IP6DST
-	check_echo_request_pkt_with_macaddr_and_rthdr0 \
-	$my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6SRCGW2 $IP6DST
-
-	rump_server_destroy_ifaces
-}
-
-ping6_opts_hops_cleanup()
-{
-
-	$DEBUG && dump
-	cleanup
-}
-
 atf_init_test_cases()
 {
 
 	atf_add_test_case ping6_opts_sourceaddr
 	atf_add_test_case ping6_opts_interface
 	atf_add_test_case ping6_opts_gateway
-	atf_add_test_case ping6_opts_hops
 }