CVS commit: src/libexec/httpd

2018-11-24 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Nov 25 07:37:20 UTC 2018

Modified Files:
src/libexec/httpd: bozohttpd.c main.c

Log Message:
fix -X option parsing.  noted by Rajeev V. Pillai.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/libexec/httpd/bozohttpd.c
cvs rdiff -u -r1.21 -r1.22 src/libexec/httpd/main.c

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

Modified files:

Index: src/libexec/httpd/bozohttpd.c
diff -u src/libexec/httpd/bozohttpd.c:1.98 src/libexec/httpd/bozohttpd.c:1.99
--- src/libexec/httpd/bozohttpd.c:1.98	Sat Nov 24 18:38:59 2018
+++ src/libexec/httpd/bozohttpd.c	Sun Nov 25 07:37:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bozohttpd.c,v 1.98 2018/11/24 18:38:59 mrg Exp $	*/
+/*	$NetBSD: bozohttpd.c,v 1.99 2018/11/25 07:37:20 mrg Exp $	*/
 
 /*	$eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $	*/
 
@@ -109,7 +109,7 @@
 #define INDEX_HTML		"index.html"
 #endif
 #ifndef SERVER_SOFTWARE
-#define SERVER_SOFTWARE		"bozohttpd/20181124"
+#define SERVER_SOFTWARE		"bozohttpd/20181125"
 #endif
 #ifndef PUBLIC_HTML
 #define PUBLIC_HTML		"public_html"

Index: src/libexec/httpd/main.c
diff -u src/libexec/httpd/main.c:1.21 src/libexec/httpd/main.c:1.22
--- src/libexec/httpd/main.c:1.21	Sat Nov 24 02:30:56 2018
+++ src/libexec/httpd/main.c	Sun Nov 25 07:37:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.21 2018/11/24 02:30:56 mrg Exp $	*/
+/*	$NetBSD: main.c,v 1.22 2018/11/25 07:37:20 mrg Exp $	*/
 
 /*	$eterna: main.c,v 1.6 2011/11/18 09:21:15 mrg Exp $	*/
 /* from: eterna: bozohttpd.c,v 1.159 2009/05/23 02:14:30 mrg Exp 	*/
@@ -336,10 +336,6 @@ main(int argc, char **argv)
 			bozo_set_pref(, , "enable users", "true");
 			break;
 
-			bozo_set_pref(, , "directory indexing",
-  "true");
-			break;
-
 		case 'V':
 			bozo_set_pref(, , "unknown slash", "true");
 			break;
@@ -352,6 +348,10 @@ main(int argc, char **argv)
 			if (!have_dirindex)
 goto no_dirindex_support;
 
+			bozo_set_pref(, , "directory indexing",
+  "true");
+			break;
+
 		case 'x':
 			bozo_set_pref(, , "index.html", optarg);
 			break;



CVS commit: [netbsd-8] src/doc

2018-11-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Nov 24 23:51:05 UTC 2018

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

Log Message:
Tickets #1103 and #1104


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.60 -r1.1.2.61 src/doc/CHANGES-8.1

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

Modified files:

Index: src/doc/CHANGES-8.1
diff -u src/doc/CHANGES-8.1:1.1.2.60 src/doc/CHANGES-8.1:1.1.2.61
--- src/doc/CHANGES-8.1:1.1.2.60	Wed Nov 21 12:06:14 2018
+++ src/doc/CHANGES-8.1	Sat Nov 24 23:51:05 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.1,v 1.1.2.60 2018/11/21 12:06:14 martin Exp $
+# $NetBSD: CHANGES-8.1,v 1.1.2.61 2018/11/24 23:51:05 martin Exp $
 
 A complete list of changes from the NetBSD 8.0 release to the NetBSD 8.1
 release:
@@ -1748,3 +1748,50 @@ sys/kern/kern_event.c1.104
 	Fix kernel info leak.
 	[maxv, ticket #1102]
 
+usr.sbin/mtree/create.c1.76
+
+	Avoid null de-reference.
+	[sevan, ticket #1103]
+
+libexec/httpd/testsuite/data/.bzremap   up to 1.1
+libexec/httpd/testsuite/t12.out up to 1.1
+libexec/httpd/testsuite/t12.in  up to 1.1
+libexec/httpd/testsuite/t13.out up to 1.1
+libexec/httpd/testsuite/t13.in  up to 1.1
+libexec/httpd/testsuite/t14.out up to 1.1
+libexec/httpd/testsuite/t14.in  up to 1.1
+libexec/httpd/testsuite/t15.out up to 1.1
+libexec/httpd/testsuite/t15.in  up to 1.1
+libexec/httpd/CHANGES   up to 1.28
+libexec/httpd/auth-bozo.c   up to 1.22
+libexec/httpd/bozohttpd.8   up to 1.74
+libexec/httpd/bozohttpd.c   up to 1.96
+libexec/httpd/bozohttpd.h   up to 1.56
+libexec/httpd/cgi-bozo.cup to 1.44
+libexec/httpd/content-bozo.cup to 1.16
+libexec/httpd/daemon-bozo.c up to 1.19
+libexec/httpd/dir-index-bozo.c  up to 1.28
+libexec/httpd/main.cup to 1.21
+libexec/httpd/ssl-bozo.cup to 1.25
+libexec/httpd/tilde-luzah-bozo.cup to 1.16
+libexec/httpd/lua/bozo.lua  up to 1.3
+libexec/httpd/lua/glue.cup to 1.5
+libexec/httpd/lua/optparse.lua  up to 1.2
+libexec/httpd/testsuite/Makefileup to 1.11
+libexec/httpd/testsuite/html_cmpup to 1.6
+libexec/httpd/testsuite/t3.out  up to 1.4
+libexec/httpd/testsuite/t5.out  up to 1.4
+libexec/httpd/testsuite/t6.out  up to 1.4
+libexec/httpd/testsuite/test-bigfileup to 1.5
+libexec/httpd/testsuite/test-simple up to 1.5
+
+	Sync with HEAD as of 2018-11-24. Includes various changes:
+	Cosmetic changes to Lua binding in bozohttpd.
+	Fix -C scripts execution and document restrictions.
+	Add support for remapping requested paths via a .bzredirect file.
+	Handle redirections for any protocol, not just http:.
+	Fix a denial of service attack against header contents, which
+	is now bounded at 16KiB.
+	Fix access checks for special files.
+	[mrg, #1104]
+



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

2018-11-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Nov 24 23:50:36 UTC 2018

Modified Files:
src/usr.sbin/mtree [netbsd-8]: create.c

Log Message:
Pull up following revision(s) (requested by sevan in ticket #1103):

usr.sbin/mtree/create.c: revision 1.76

Adjust test, we only want to return the structure member if the result
is not NULL.

Heads up by Sascha Wildner @ DragonFly BSD.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.73.16.1 src/usr.sbin/mtree/create.c

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/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.73 src/usr.sbin/mtree/create.c:1.73.16.1
--- src/usr.sbin/mtree/create.c:1.73	Thu Apr 24 17:22:41 2014
+++ src/usr.sbin/mtree/create.c	Sat Nov 24 23:50:36 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.73 2014/04/24 17:22:41 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.73.16.1 2018/11/24 23:50:36 martin Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)create.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: create.c,v 1.73 2014/04/24 17:22:41 christos Exp $");
+__RCSID("$NetBSD: create.c,v 1.73.16.1 2018/11/24 23:50:36 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -117,7 +117,7 @@ cwalk(FILE *fp)
 	host[sizeof(host) - 1] = '\0';
 	if ((user = getlogin()) == NULL) {
 		struct passwd *pw;
-		user = (pw = getpwuid(getuid())) == NULL ? pw->pw_name :
+		user = (pw = getpwuid(getuid())) != NULL ? pw->pw_name :
 		"";
 	}
 



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

2018-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Nov 24 22:49:35 UTC 2018

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

Log Message:
Provide a LWP_PC for Taylor


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/aarch64/include/cpu.h

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

Modified files:

Index: src/sys/arch/aarch64/include/cpu.h
diff -u src/sys/arch/aarch64/include/cpu.h:1.11 src/sys/arch/aarch64/include/cpu.h:1.12
--- src/sys/arch/aarch64/include/cpu.h:1.11	Tue Nov 20 01:59:51 2018
+++ src/sys/arch/aarch64/include/cpu.h	Sat Nov 24 22:49:35 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.11 2018/11/20 01:59:51 mrg Exp $ */
+/* $NetBSD: cpu.h,v 1.12 2018/11/24 22:49:35 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -55,6 +55,11 @@ struct clockframe {
 #define CLKF_PC(cf)		((cf)->cf_tf.tf_pc)
 #define CLKF_INTR(cf)		((void)(cf), curcpu()->ci_intr_depth > 1)
 
+/*
+ * LWP_PC: Find out the program counter for the given lwp.
+ */
+#define LWP_PC(l)		((l)->l_md.md_utf->tf_pc)
+
 #include 
 #include 
 #include 



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

2018-11-24 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat Nov 24 22:18:58 UTC 2018

Modified Files:
src/sys/arch/arm/fdt: gicv3_fdt.c

Log Message:
attach GICv3 ITS where applicable


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/gicv3_fdt.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/fdt/gicv3_fdt.c
diff -u src/sys/arch/arm/fdt/gicv3_fdt.c:1.5 src/sys/arch/arm/fdt/gicv3_fdt.c:1.6
--- src/sys/arch/arm/fdt/gicv3_fdt.c:1.5	Mon Nov 19 13:54:15 2018
+++ src/sys/arch/arm/fdt/gicv3_fdt.c	Sat Nov 24 22:18:57 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_fdt.c,v 1.5 2018/11/19 13:54:15 jakllsch Exp $ */
+/* $NetBSD: gicv3_fdt.c,v 1.6 2018/11/24 22:18:57 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2015-2018 Jared McNeill 
@@ -26,10 +26,12 @@
  * SUCH DAMAGE.
  */
 
+#include "pci.h"
+
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.5 2018/11/19 13:54:15 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.6 2018/11/24 22:18:57 jakllsch Exp $");
 
 #include 
 #include 
@@ -44,6 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,
 #include 
 
 #include 
+#include 
 #include 
 
 #define	GICV3_MAXIRQ	1020
@@ -58,6 +61,9 @@ static int	gicv3_fdt_match(device_t, cfd
 static void	gicv3_fdt_attach(device_t, device_t, void *);
 
 static int	gicv3_fdt_map_registers(struct gicv3_fdt_softc *);
+#if NPCI > 0
+static void	gicv3_fdt_attach_its(struct gicv3_fdt_softc *, bus_space_tag_t, int);
+#endif
 
 static int	gicv3_fdt_intr(void *);
 
@@ -152,6 +158,16 @@ gicv3_fdt_attach(device_t parent, device
 		return;
 	}
 
+#if NPCI > 0
+	for (int child = OF_child(phandle); child; child = OF_peer(child)) {
+		if (!fdtbus_status_okay(child))
+			continue;
+		const char * const its_compat[] = { "arm,gic-v3-its", NULL };
+		if (of_match_compatible(child, its_compat))
+			gicv3_fdt_attach_its(sc, faa->faa_bst, child);
+	}
+#endif
+
 	arm_fdt_irq_set_handler(gicv3_irq_handler);
 }
 
@@ -222,6 +238,31 @@ gicv3_fdt_map_registers(struct gicv3_fdt
 	return 0;
 }
 
+#if NPCI > 0
+static void
+gicv3_fdt_attach_its(struct gicv3_fdt_softc *sc, bus_space_tag_t bst, int phandle)
+{
+	bus_space_handle_t bsh;
+	bus_addr_t addr;
+	bus_size_t size;
+
+	if (fdtbus_get_reg(phandle, 0, , ) != 0) {
+		aprint_error_dev(sc->sc_gic.sc_dev, "couldn't get ITS address\n");
+		return;
+	}
+
+	if (bus_space_map(bst, addr, size, 0, ) != 0) {
+		aprint_error_dev(sc->sc_gic.sc_dev, "couldn't map ITS\n");
+		return;
+	}
+
+	gicv3_its_init(>sc_gic, bsh, addr, 0);
+
+	aprint_verbose_dev(sc->sc_gic.sc_dev, "ITS @ %#" PRIxBUSADDR "\n",
+	addr);
+}
+#endif
+
 static void *
 gicv3_fdt_establish(device_t dev, u_int *specifier, int ipl, int flags,
 int (*func)(void *), void *arg)



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

2018-11-24 Thread Robert Swindells
Module Name:src
Committed By:   rjs
Date:   Sat Nov 24 22:17:12 UTC 2018

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
Allow building when plcom isn't used.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/acpi/acpi_platform.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/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.6 src/sys/arch/arm/acpi/acpi_platform.c:1.7
--- src/sys/arch/arm/acpi/acpi_platform.c:1.6	Tue Oct 30 16:41:51 2018
+++ src/sys/arch/arm/acpi/acpi_platform.c	Sat Nov 24 22:17:12 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.6 2018/10/30 16:41:51 skrll Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.7 2018/11/24 22:17:12 rjs Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #include "opt_efi.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.6 2018/10/30 16:41:51 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.7 2018/11/24 22:17:12 rjs Exp $");
 
 #include 
 #include 
@@ -88,7 +88,9 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_platfor
 extern struct bus_space arm_generic_bs_tag;
 extern struct bus_space arm_generic_a4x_bs_tag;
 
+#if NPLCOM > 0
 static struct plcom_instance plcom_console;
+#endif
 
 static const struct pmap_devmap *
 acpi_platform_devmap(void)



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

2018-11-24 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat Nov 24 22:08:54 UTC 2018

Modified Files:
src/sys/arch/arm/cortex: gicv3_its.h

Log Message:
include dev/pci/pcivar.h, we use pci_attach_args directly


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/cortex/gicv3_its.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/arm/cortex/gicv3_its.h
diff -u src/sys/arch/arm/cortex/gicv3_its.h:1.2 src/sys/arch/arm/cortex/gicv3_its.h:1.3
--- src/sys/arch/arm/cortex/gicv3_its.h:1.2	Sat Nov 10 11:46:31 2018
+++ src/sys/arch/arm/cortex/gicv3_its.h	Sat Nov 24 22:08:53 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_its.h,v 1.2 2018/11/10 11:46:31 jmcneill Exp $ */
+/* $NetBSD: gicv3_its.h,v 1.3 2018/11/24 22:08:53 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,6 +32,8 @@
 #ifndef _ARM_CORTEX_GICV3_ITS_H
 #define _ARM_CORTEX_GICV3_ITS_H
 
+#include 
+
 #include 
 #include 
 #include 



CVS commit: src/share/man/man4

2018-11-24 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Nov 24 20:31:29 UTC 2018

Modified Files:
src/share/man/man4: mfii.4

Log Message:
Sort SEE ALSO. Fix date. Whitespace fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/man/man4/mfii.4

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/man4/mfii.4
diff -u src/share/man/man4/mfii.4:1.1 src/share/man/man4/mfii.4:1.2
--- src/share/man/man4/mfii.4:1.1	Sat Nov 24 18:37:50 2018
+++ src/share/man/man4/mfii.4	Sat Nov 24 20:31:29 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mfii.4,v 1.1 2018/11/24 18:37:50 bouyer Exp $
+.\"	$NetBSD: mfii.4,v 1.2 2018/11/24 20:31:29 wiz Exp $
 .\"	$OpenBSD: mfii.4,v 1.7 2018/03/27 07:01:42 jsg Exp $
 .\"
 .\" Copyright (c) 2012 David Gwynne 
@@ -15,7 +15,7 @@
 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd March 27 2018
+.Dd March 27, 2018
 .Dt MFII 4
 .Os
 .Sh NAME
@@ -58,7 +58,7 @@ they appear as SCSI controllers.
 All RAID configuration is done through the controllers' BIOSes.
 .Pp
 .Nm
-supports monitoring of the logical disks in the controller through the  
+supports monitoring of the logical disks in the controller through the
 .Xr bioctl 8
 and
 .Xr envstat 8
@@ -66,17 +66,17 @@ commands.
 .Sh EVENTS
 The
 .Nm
-driver is able to send events to  
+driver is able to send events to
 .Xr powerd 8
 if a logical drive in the controller is not online.
 The
 .Em state-changed
 event will be sent to the
-.Pa /etc/powerd/scripts/sensor_drive  
-script when such condition happens.   
+.Pa /etc/powerd/scripts/sensor_drive
+script when such condition happens.
 .Sh SEE ALSO
-.Xr intro 4 ,
 .Xr bio 4 ,
+.Xr intro 4 ,
 .Xr pci 4 ,
 .Xr scsi 4 ,
 .Xr sd 4 ,
@@ -87,7 +87,8 @@ script when such condition happens.   
 The
 .Nm
 driver first appeared in
-.Ox 5.3 and
+.Ox 5.3
+and
 .Nx 8.0 .
 .Sh AUTHORS
 .An -nosplit



CVS commit: src/sys/kern

2018-11-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov 24 19:22:17 UTC 2018

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

Log Message:
- instead of zeroing struct proc on each allocation, provide a pool cache
  constructor.
- instead of sprinkling memsets, zalloc the whole buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.220 -r1.221 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.220 src/sys/kern/kern_proc.c:1.221
--- src/sys/kern/kern_proc.c:1.220	Sat Nov 24 11:18:36 2018
+++ src/sys/kern/kern_proc.c	Sat Nov 24 14:22:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_proc.c,v 1.220 2018/11/24 16:18:36 maxv Exp $	*/
+/*	$NetBSD: kern_proc.c,v 1.221 2018/11/24 19:22:17 christos 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.220 2018/11/24 16:18:36 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.221 2018/11/24 19:22:17 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kstack.h"
@@ -317,6 +317,13 @@ proc_listener_cb(kauth_cred_t cred, kaut
 	return result;
 }
 
+static int
+proc_ctor(void *arg __unused, void *obj, int flags __unused)
+{
+	memset(obj, 0, sizeof(struct proc));
+	return 0;
+}
+
 /*
  * Initialize global process hashing structures.
  */
@@ -356,7 +363,7 @@ procinit(void)
 	KASSERT(proc_specificdata_domain != NULL);
 
 	proc_cache = pool_cache_init(sizeof(struct proc), 0, 0, 0,
-	"procpl", NULL, IPL_NONE, NULL, NULL, NULL);
+	"procpl", NULL, IPL_NONE, proc_ctor, NULL, NULL);
 
 	proc_listener = kauth_listen_scope(KAUTH_SCOPE_PROCESS,
 	proc_listener_cb, NULL);
@@ -747,7 +754,6 @@ proc_alloc(void)
 	struct proc *p;
 
 	p = pool_cache_get(proc_cache, PR_WAITOK);
-	memset(p, 0, sizeof(*p));
 	p->p_stat = SIDL;			/* protect against others */
 	proc_initspecific(p);
 	kdtrace_proc_ctor(NULL, p);
@@ -1672,7 +1678,7 @@ sysctl_doeproc(SYSCTLFN_ARGS)
 
 	sysctl_unlock();
 
-	kbuf = kmem_alloc(sizeof(*kbuf), KM_SLEEP);
+	kbuf = kmem_zalloc(sizeof(*kbuf), KM_SLEEP);
 	marker = kmem_alloc(sizeof(*marker), KM_SLEEP);
 	marker->p_flag = PK_MARKER;
 
@@ -2170,8 +2176,6 @@ fill_proc(const struct proc *psrc, struc
 {
 	const bool allowaddr = get_expose_address(curproc);
 
-	memset(p, 0, sizeof(*p));
-
 	COND_SET_VALUE(p->p_list, psrc->p_list, allowaddr);
 	COND_SET_VALUE(p->p_auxlock, psrc->p_auxlock, allowaddr);
 	COND_SET_VALUE(p->p_lock, psrc->p_lock, allowaddr);
@@ -2271,8 +2275,6 @@ fill_eproc(struct proc *p, struct eproc 
 	KASSERT(mutex_owned(proc_lock));
 	KASSERT(mutex_owned(p->p_lock));
 
-	memset(ep, 0, sizeof(*ep));
-
 	const bool allowaddr = get_expose_address(curproc);
 
 	COND_SET_VALUE(ep->e_paddr, p, allowaddr);
@@ -2339,7 +2341,6 @@ fill_kproc2(struct proc *p, struct kinfo
 
 	sigemptyset();
 	sigemptyset();
-	memset(ki, 0, sizeof(*ki));
 
 	COND_SET_VALUE(ki->p_paddr, PTRTOUINT64(p), allowaddr);
 	COND_SET_VALUE(ki->p_fd, PTRTOUINT64(p->p_fd), allowaddr);



CVS commit: src/doc

2018-11-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 24 18:48:08 UTC 2018

Modified Files:
src/doc: CHANGES

Log Message:
aarch64: Add support for ARM Server Base System Architecture (SBSA).
The SBSA is a hardware system architecture for servers based on
64-bit ARM processors. The Server Base Boot Requirements (SBBR)
specification defines a UEFI + ACPI interface for OS bootstrap,
which is supported by a combination of a new UEFI bootloader
(bootaa64.efi) and the addition of ACPI support in the
GENERIC64 kernel config.


To generate a diff of this commit:
cvs rdiff -u -r1.2457 -r1.2458 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.2457 src/doc/CHANGES:1.2458
--- src/doc/CHANGES:1.2457	Thu Nov  8 08:32:57 2018
+++ src/doc/CHANGES	Sat Nov 24 18:48:08 2018
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2457 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2458 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -245,3 +245,10 @@ Changes from NetBSD 8.0 to NetBSD 9.0:
 	kernel: Add NVMM, the NetBSD virtualization driver, with initial
 		support for x86. [maxv 20181107]
 	aarch64: Add support for kASan. [maxv 20181108]
+	aarch64: Add support for ARM Server Base System Architecture (SBSA).
+		The SBSA is a hardware system architecture for servers based on
+		64-bit ARM processors. The Server Base Boot Requirements (SBBR)
+		specification defines a UEFI + ACPI interface for OS bootstrap,
+		which is supported by a combination of a new UEFI bootloader
+		(bootaa64.efi) and the addition of ACPI support in the
+		GENERIC64 kernel config. [jmcneill 20181124]



CVS commit: src/libexec/httpd

2018-11-24 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Nov 24 18:38:59 UTC 2018

Modified Files:
src/libexec/httpd: bozohttpd.c

Log Message:
avoid c99ism.


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/libexec/httpd/bozohttpd.c

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

Modified files:

Index: src/libexec/httpd/bozohttpd.c
diff -u src/libexec/httpd/bozohttpd.c:1.97 src/libexec/httpd/bozohttpd.c:1.98
--- src/libexec/httpd/bozohttpd.c:1.97	Sat Nov 24 13:08:10 2018
+++ src/libexec/httpd/bozohttpd.c	Sat Nov 24 18:38:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bozohttpd.c,v 1.97 2018/11/24 13:08:10 christos Exp $	*/
+/*	$NetBSD: bozohttpd.c,v 1.98 2018/11/24 18:38:59 mrg Exp $	*/
 
 /*	$eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $	*/
 
@@ -1924,8 +1924,9 @@ int
 bozo_check_special_files(bozo_httpreq_t *request, const char *name)
 {
 	bozohttpd_t *httpd = request->hr_httpd;
+	size_t i;
 
-	for (size_t i = 0; specials[i].file; i++)
+	for (i = 0; specials[i].file; i++)
 		if (strcmp(name, specials[i].file) == 0)
 			return bozo_http_error(httpd, 403, request,
 	   specials[i].name);



CVS commit: src

2018-11-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Nov 24 18:37:50 UTC 2018

Modified Files:
src/distrib/sets/lists/man: mi
src/share/man/man4: Makefile
Added Files:
src/share/man/man4: mfii.4

Log Message:
add a man page for the new mpii, mostly from OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.1627 -r1.1628 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.672 -r1.673 src/share/man/man4/Makefile
cvs rdiff -u -r0 -r1.1 src/share/man/man4/mfii.4

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

Modified files:

Index: src/distrib/sets/lists/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1627 src/distrib/sets/lists/man/mi:1.1628
--- src/distrib/sets/lists/man/mi:1.1627	Sun Sep 30 15:56:47 2018
+++ src/distrib/sets/lists/man/mi	Sat Nov 24 18:37:50 2018
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1627 2018/09/30 15:56:47 jmcneill Exp $
+# $NetBSD: mi,v 1.1628 2018/11/24 18:37:50 bouyer Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -1433,6 +1433,7 @@
 ./usr/share/man/cat4/md.0			man-sys-catman		.cat
 ./usr/share/man/cat4/mfb.0			man-sys-catman		.cat
 ./usr/share/man/cat4/mfi.0			man-sys-catman		.cat
+./usr/share/man/cat4/mfii.0			man-sys-catman		.cat
 ./usr/share/man/cat4/mgadrm.0			man-sys-catman		.cat
 ./usr/share/man/cat4/mhzc.0			man-sys-catman		.cat
 ./usr/share/man/cat4/micphy.0			man-sys-catman		.cat
@@ -4546,6 +4547,7 @@
 ./usr/share/man/html4/md.html			man-sys-htmlman		html
 ./usr/share/man/html4/mfb.html			man-sys-htmlman		html
 ./usr/share/man/html4/mfi.html			man-sys-htmlman		html
+./usr/share/man/html4/mfii.html			man-sys-htmlman		html
 ./usr/share/man/html4/mgadrm.html		man-sys-htmlman		html
 ./usr/share/man/html4/mhzc.html			man-sys-htmlman		html
 ./usr/share/man/html4/micphy.html		man-sys-htmlman		html
@@ -7509,6 +7511,7 @@
 ./usr/share/man/man4/md.4			man-sys-man		.man
 ./usr/share/man/man4/mfb.4			man-sys-man		.man
 ./usr/share/man/man4/mfi.4			man-sys-man		.man
+./usr/share/man/man4/mfii.4			man-sys-man		.man
 ./usr/share/man/man4/mgadrm.4			man-sys-man		.man
 ./usr/share/man/man4/mhzc.4			man-sys-man		.man
 ./usr/share/man/man4/micphy.4			man-sys-man		.man

Index: src/share/man/man4/Makefile
diff -u src/share/man/man4/Makefile:1.672 src/share/man/man4/Makefile:1.673
--- src/share/man/man4/Makefile:1.672	Sun Sep 23 09:21:00 2018
+++ src/share/man/man4/Makefile	Sat Nov 24 18:37:50 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.672 2018/09/23 09:21:00 maxv Exp $
+#	$NetBSD: Makefile,v 1.673 2018/11/24 18:37:50 bouyer Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/18/93
 
 MAN=	aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
@@ -39,7 +39,7 @@ MAN=	aac.4 ac97.4 acardide.4 aceride.4 a
 	kloader.4 kse.4 ksyms.4 kttcp.4 \
 	l2tp.4 lc.4 ld.4 lii.4 lo.4 lua.4 lxtphy.4 \
 	mainbus.4 makphy.4 malo.4 mbe.4 mca.4 mcclock.4 md.4 mfb.4 \
-	mfi.4 mhzc.4 \
+	mfi.4 mfii.4 mhzc.4 \
 	micphy.4 midi.4 mii.4 mk48txx.4 mlx.4 mly.4 mpls.4 mpii.4 mpt.4 \
 	mpu.4 mtd.4 mtio.4 msm6242b.4 multicast.4 mvsata.4 \
 	nadb.4 ne.4 neo.4 netintro.4 nfe.4 nfsmb.4 njata.4 njs.4 \

Added files:

Index: src/share/man/man4/mfii.4
diff -u /dev/null src/share/man/man4/mfii.4:1.1
--- /dev/null	Sat Nov 24 18:37:50 2018
+++ src/share/man/man4/mfii.4	Sat Nov 24 18:37:50 2018
@@ -0,0 +1,97 @@
+.\"	$NetBSD: mfii.4,v 1.1 2018/11/24 18:37:50 bouyer Exp $
+.\"	$OpenBSD: mfii.4,v 1.7 2018/03/27 07:01:42 jsg Exp $
+.\"
+.\" Copyright (c) 2012 David Gwynne 
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.Dd March 27 2018
+.Dt MFII 4
+.Os
+.Sh NAME
+.Nm mfii
+.Nd LSI Logic MegaRAID SAS Fusion RAID controller
+.Sh SYNOPSIS
+.Cd "mfii* at pci?"
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for the MegaRAID SAS Fusion family of RAID controllers
+using the following chipsets:
+.Pp
+.Bl -dash -offset indent -compact
+.It
+SAS2208
+.It
+SAS3008
+.It
+SAS3108
+.It
+SAS3404
+.It
+SAS3408
+.It
+SAS3416
+.It
+SAS3504
+.It
+SAS3508
+.It
+SAS3516
+.El
+.Pp
+These controllers support RAID 0, RAID 1, RAID 5, RAID 6, RAID 10, RAID 50 and
+RAID 60 using either SAS or SATA II drives.
+.Pp
+Although the controllers are actual RAID controllers,
+they appear as SCSI controllers.
+All RAID configuration is done through the 

CVS commit: src/sys/dev/pci

2018-11-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Nov 24 18:37:16 UTC 2018

Modified Files:
src/sys/dev/pci: mfii.c

Log Message:
Add my name in copyright list


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/mfii.c

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

Modified files:

Index: src/sys/dev/pci/mfii.c
diff -u src/sys/dev/pci/mfii.c:1.1 src/sys/dev/pci/mfii.c:1.2
--- src/sys/dev/pci/mfii.c:1.1	Sat Nov 24 18:23:29 2018
+++ src/sys/dev/pci/mfii.c	Sat Nov 24 18:37:16 2018
@@ -1,7 +1,8 @@
-/* $NetBSD: mfii.c,v 1.1 2018/11/24 18:23:29 bouyer Exp $ */
+/* $NetBSD: mfii.c,v 1.2 2018/11/24 18:37:16 bouyer Exp $ */
 /* $OpenBSD: mfii.c,v 1.58 2018/08/14 05:22:21 jmatthew Exp $ */
 
 /*
+ * Copyright (c) 2018 Manuel Bouyer 
  * Copyright (c) 2012 David Gwynne 
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -18,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.1 2018/11/24 18:23:29 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.2 2018/11/24 18:37:16 bouyer Exp $");
 
 #include "bio.h"
 



CVS commit: src/sys

2018-11-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Nov 24 18:23:29 UTC 2018

Modified Files:
src/sys/arch/amd64/conf: ALL GENERIC XEN3_DOM0
src/sys/arch/i386/conf: ALL GENERIC XEN3PAE_DOM0
src/sys/dev/pci: files.pci
Added Files:
src/sys/dev/pci: mfii.c

Log Message:
Add mpii(4), a driver for LSI Megaraid Fusion controllers.
Ported from OpenBSD. This driver is MP-safe.
Note that the earlier fusion controllers (Megaraid 2208, codenamed Thunderbold)
are also supported by mfi(4). mpii will take precedence if both drivers
are enabled.
Tested on a
mfii0 at pci6 dev 0 function 0: "PERC H740P Adapter ", firmware 50.3.0-1512, 819
2MB cache
mfii0: interrupting at ioapic2 pin 2
scsibus0 at mfii0: 64 targets, 8 luns per target
scsibus0: waiting 2 seconds for devices to settle...
sd0 at scsibus0 target 0 lun 0:  disk fixed
sd0: fabricating a geometry
sd0: 99 GB, 102399 cyl, 64 head, 32 sec, 512 bytes/sect x 209714688 sectors
sd0: tagged queueing
sd1 at scsibus0 target 1 lun 0:  disk fixed
sd1: fabricating a geometry
sd1: 22254 GB, 22788608 cyl, 64 head, 32 sec, 512 bytes/sect x 46671069696 
sectors
sd1: fabricating a geometry

It supports bioctl(8) ioctls, as well as sensors for the BBU and logical
drives.

Sponsored by LIP6.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/arch/amd64/conf/ALL
cvs rdiff -u -r1.507 -r1.508 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.158 -r1.159 src/sys/arch/amd64/conf/XEN3_DOM0
cvs rdiff -u -r1.457 -r1.458 src/sys/arch/i386/conf/ALL
cvs rdiff -u -r1.1193 -r1.1194 src/sys/arch/i386/conf/GENERIC
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/conf/XEN3PAE_DOM0
cvs rdiff -u -r1.409 -r1.410 src/sys/dev/pci/files.pci
cvs rdiff -u -r0 -r1.1 src/sys/dev/pci/mfii.c

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

Modified files:

Index: src/sys/arch/amd64/conf/ALL
diff -u src/sys/arch/amd64/conf/ALL:1.107 src/sys/arch/amd64/conf/ALL:1.108
--- src/sys/arch/amd64/conf/ALL:1.107	Sun Sep 23 09:21:01 2018
+++ src/sys/arch/amd64/conf/ALL	Sat Nov 24 18:23:29 2018
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.107 2018/09/23 09:21:01 maxv Exp $
+# $NetBSD: ALL,v 1.108 2018/11/24 18:23:29 bouyer Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"ALL-$Revision: 1.107 $"
+#ident		"ALL-$Revision: 1.108 $"
 
 maxusers	64		# estimated number of users
 
@@ -752,6 +752,7 @@ dpt*	at pci? dev ? function ?	# DPT Smar
 iha*	at pci? dev ? function ?	# Initio INIC-940/950 SCSI
 isp*	at pci? dev ? function ?	# Qlogic ISP [12]0x0 SCSI/FibreChannel
 mfi*	at pci? dev ? function ?	# LSI MegaRAID SAS
+mfii*	at pci? dev ? function ?	# LSI MegaRAID SAS (Fusion and newer)
 mly*	at pci? dev ? function ?	# Mylex AcceleRAID and eXtremeRAID
 mpt*	at pci? dev ? function ?	# LSILogic 9x9 and 53c1030 (Fusion-MPT)
 mpii*	at pci? dev ? function ?	# LSI Logic Fusion-MPT II

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.507 src/sys/arch/amd64/conf/GENERIC:1.508
--- src/sys/arch/amd64/conf/GENERIC:1.507	Sat Nov 17 20:29:49 2018
+++ src/sys/arch/amd64/conf/GENERIC	Sat Nov 24 18:23:29 2018
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.507 2018/11/17 20:29:49 uwe Exp $
+# $NetBSD: GENERIC,v 1.508 2018/11/24 18:23:29 bouyer Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.507 $"
+#ident		"GENERIC-$Revision: 1.508 $"
 
 maxusers	64		# estimated number of users
 
@@ -613,6 +613,7 @@ dpt*	at pci? dev ? function ?	# DPT Smar
 iha*	at pci? dev ? function ?	# Initio INIC-940/950 SCSI
 isp*	at pci? dev ? function ?	# Qlogic ISP [12]0x0 SCSI/FibreChannel
 mfi*	at pci? dev ? function ?	# LSI MegaRAID SAS
+mfii*	at pci? dev ? function ?	# LSI MegaRAID SAS (Fusion and newer)
 mly*	at pci? dev ? function ?	# Mylex AcceleRAID and eXtremeRAID
 mpt*	at pci? dev ? function ?	# LSILogic 9x9 and 53c1030 (Fusion-MPT)
 mpii*	at pci? dev ? function ?	# LSI Logic Fusion-MPT II

Index: src/sys/arch/amd64/conf/XEN3_DOM0
diff -u src/sys/arch/amd64/conf/XEN3_DOM0:1.158 src/sys/arch/amd64/conf/XEN3_DOM0:1.159
--- src/sys/arch/amd64/conf/XEN3_DOM0:1.158	Tue Oct 23 19:58:52 2018
+++ src/sys/arch/amd64/conf/XEN3_DOM0	Sat Nov 24 18:23:29 2018
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOM0,v 1.158 2018/10/23 19:58:52 jdolecek Exp $
+# $NetBSD: XEN3_DOM0,v 1.159 2018/11/24 18:23:29 bouyer Exp $
 
 include 	"arch/amd64/conf/std.xen"
 
@@ -10,7 +10,7 @@ options 	INCLUDE_CONFIG_FILE	# embed con
 #options 	UVMHIST_PRINT
 #options 	SYSCALL_DEBUG
 
-#ident		"XEN3_DOM0-$Revision: 1.158 $"
+#ident		"XEN3_DOM0-$Revision: 1.159 $"
 
 maxusers	32		# estimated number of users
 
@@ -519,6 +519,7 @@ dpt*	at 

CVS commit: src/sys/dev/scsipi

2018-11-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Nov 24 18:15:23 UTC 2018

Modified Files:
src/sys/dev/scsipi: scsipi_base.c

Log Message:
Add more KASSERTS about locking.


To generate a diff of this commit:
cvs rdiff -u -r1.179 -r1.180 src/sys/dev/scsipi/scsipi_base.c

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

Modified files:

Index: src/sys/dev/scsipi/scsipi_base.c
diff -u src/sys/dev/scsipi/scsipi_base.c:1.179 src/sys/dev/scsipi/scsipi_base.c:1.180
--- src/sys/dev/scsipi/scsipi_base.c:1.179	Mon Sep  3 16:29:33 2018
+++ src/sys/dev/scsipi/scsipi_base.c	Sat Nov 24 18:15:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: scsipi_base.c,v 1.179 2018/09/03 16:29:33 riastradh Exp $	*/
+/*	$NetBSD: scsipi_base.c,v 1.180 2018/11/24 18:15:23 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.179 2018/09/03 16:29:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.180 2018/11/24 18:15:23 bouyer Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_scsi.h"
@@ -348,6 +348,8 @@ scsipi_get_tag(struct scsipi_xfer *xs)
 	int bit, tag;
 	u_int word;
 
+	KASSERT(mutex_owned(chan_mtx(periph->periph_channel)));
+
 	bit = 0;	/* XXX gcc */
 	for (word = 0; word < PERIPH_NTAGWORDS; word++) {
 		bit = ffs(periph->periph_freetags[word]);
@@ -389,6 +391,8 @@ scsipi_put_tag(struct scsipi_xfer *xs)
 	struct scsipi_periph *periph = xs->xs_periph;
 	int word, bit;
 
+	KASSERT(mutex_owned(chan_mtx(periph->periph_channel)));
+
 	word = xs->xs_tag_id >> 5;
 	bit = xs->xs_tag_id & 0x1f;
 
@@ -466,6 +470,7 @@ scsipi_get_xs(struct scsipi_periph *peri
 		(periph->periph_flags & PERIPH_RECOVERING) != 0)
 			goto wait_for_opening;
 		periph->periph_active++;
+		KASSERT(mutex_owned(chan_mtx(periph->periph_channel)));
 		break;
 
  wait_for_opening:
@@ -511,6 +516,7 @@ scsipi_get_xs(struct scsipi_periph *peri
 		if ((flags & XS_CTL_NOSLEEP) == 0)
 			mutex_enter(chan_mtx(periph->periph_channel));
 		TAILQ_INSERT_TAIL(>periph_xferq, xs, device_q);
+		KASSERT(mutex_owned(chan_mtx(periph->periph_channel)));
 		if ((flags & XS_CTL_NOSLEEP) == 0)
 			mutex_exit(chan_mtx(periph->periph_channel));
 	}
@@ -534,6 +540,7 @@ scsipi_put_xs(struct scsipi_xfer *xs)
 	int flags = xs->xs_control;
 
 	SC_DEBUG(periph, SCSIPI_DB3, ("scsipi_free_xs\n"));
+	KASSERT(mutex_owned(chan_mtx(periph->periph_channel)));
 
 	TAILQ_REMOVE(>periph_xferq, xs, device_q);
 	callout_destroy(>xs_callout);
@@ -1790,6 +1797,7 @@ scsipi_enqueue(struct scsipi_xfer *xs)
 	 * If the xfer is to be polled, and there are already jobs on
 	 * the queue, we can't proceed.
 	 */
+	KASSERT(mutex_owned(chan_mtx(chan)));
 	if ((xs->xs_control & XS_CTL_POLL) != 0 &&
 	TAILQ_FIRST(>chan_queue) != NULL) {
 		xs->error = XS_DRIVER_STUFFUP;



CVS commit: src/sys/dev/pci

2018-11-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Nov 24 18:14:44 UTC 2018

Modified Files:
src/sys/dev/pci: if_bge.c

Log Message:
5717 and newer handle TSO in a sighly different way. From FreeBSD.
While there, use different lowat/hiwat values if MTU is larger than ETHERMTU,
from FreeBSD.
Tested at LIP6 on a
bge0 at pci4 dev 0 function 0: Broadcom BCM5720 Gigabit Ethernet
bge0: APE firmware NCSI 1.4.22.0
bge0: interrupting at msi1 vec 0
bge0: HW config 002b1194, 6014, 0002aa38,  000c
bge0: ASIC BCM5720 A0 (0x572), Ethernet address d0:94:66:8b:9c:18
bge0: setting short Tx thresholds
brgphy0 at bge0 phy 1: BCM5720C 1000BASE-T media interface, rev. 0
with all ipv4 checksums and TSO4 enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.315 -r1.316 src/sys/dev/pci/if_bge.c

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

Modified files:

Index: src/sys/dev/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.315 src/sys/dev/pci/if_bge.c:1.316
--- src/sys/dev/pci/if_bge.c:1.315	Mon Sep  3 16:29:32 2018
+++ src/sys/dev/pci/if_bge.c	Sat Nov 24 18:14:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.315 2018/09/03 16:29:32 riastradh Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.316 2018/11/24 18:14:43 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.315 2018/09/03 16:29:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.316 2018/11/24 18:14:43 bouyer Exp $");
 
 #include 
 #include 
@@ -2555,8 +2555,13 @@ bge_blockinit(struct bge_softc *sc)
 	 */
 	if (BGE_IS_5717_PLUS(sc)) {
 		CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_READDMA_LOWAT, 0x0);
-		CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_MACRX_LOWAT, 0x2a);
-		CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_HIWAT, 0xa0);
+		if (ifp->if_mtu > ETHERMTU) {
+			CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_MACRX_LOWAT, 0x7e);
+			CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_HIWAT, 0xea);
+		} else {
+			CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_MACRX_LOWAT, 0x2a);
+			CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_HIWAT, 0xa0);
+		}
 	} else if (BGE_IS_5705_PLUS(sc)) {
 		CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_READDMA_LOWAT, 0x0);
 
@@ -3060,8 +3065,11 @@ bge_blockinit(struct bge_softc *sc)
 		if (ifp->if_mtu <= ETHERMTU)
 			val |= BGE_RDMAMODE_JMB_2K_MMRR;
 	}
-	if (sc->bge_flags & BGEF_TSO)
+	if (sc->bge_flags & BGEF_TSO) {
 		val |= BGE_RDMAMODE_TSO4_ENABLE;
+		if (BGE_IS_5717_PLUS(sc))
+			val |= BGE_RDMAMODE_TSO6_ENABLE;
+	}
 
 	if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5720) {
 		val |= CSR_READ_4(sc, BGE_RDMA_MODE) &
@@ -3641,6 +3649,10 @@ bge_attach(device_t parent, device_t sel
 		if ((PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_BROADCOM_BCM5754) &&
 		(PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_BROADCOM_BCM5754M))
 			sc->bge_flags |= BGEF_TSO;
+		/* TSO on BCM5719 A0 does not work. */
+		if ((BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5719) &&
+		(sc->bge_chipid == BGE_CHIPID_BCM5719_A0))
+			sc->bge_flags &= ~BGEF_TSO;
 	}
 
 	capmask = 0x; /* XXX BMSR_DEFCAPMASK */
@@ -5221,7 +5233,7 @@ doit:
 		if (__predict_false(m0->m_len <
 (hlen + sizeof(struct tcphdr {
 
-			aprint_debug_dev(sc->bge_dev,
+			aprint_error_dev(sc->bge_dev,
 			"TSO: hard case m0->m_len == %d < ip/tcp hlen %zd,"
 			"not handled yet\n",
 			 m0->m_len, hlen+ sizeof(struct tcphdr));
@@ -5298,7 +5310,13 @@ doit:
 		 */
 		tcp_seg_flags = 0;
 		if (iptcp_opt_words) {
-			if (BGE_IS_5705_PLUS(sc)) {
+			if (BGE_IS_5717_PLUS(sc)) {
+tcp_seg_flags =
+	(iptcp_opt_words & 0x3) << 14;
+txbd_tso_flags |=
+((iptcp_opt_words & 0xF8) << 7) |
+((iptcp_opt_words & 0x4) << 2);
+			} else if (BGE_IS_5705_PLUS(sc)) {
 tcp_seg_flags =
 	iptcp_opt_words << 11;
 			} else {



CVS commit: src/sys/dev/pci

2018-11-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Nov 24 18:11:22 UTC 2018

Modified Files:
src/sys/dev/pci: mpii.c
Added Files:
src/sys/dev/pci: mpiireg.h

Log Message:
Move registers definitions to a separate file, needed for the upcomning mpii
driver. No functionnal change.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/mpii.c
cvs rdiff -u -r0 -r1.1 src/sys/dev/pci/mpiireg.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/mpii.c
diff -u src/sys/dev/pci/mpii.c:1.12 src/sys/dev/pci/mpii.c:1.13
--- src/sys/dev/pci/mpii.c:1.12	Sun Oct 14 17:37:40 2018
+++ src/sys/dev/pci/mpii.c	Sat Nov 24 18:11:22 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: mpii.c,v 1.12 2018/10/14 17:37:40 jdolecek Exp $ */
+/* $NetBSD: mpii.c,v 1.13 2018/11/24 18:11:22 bouyer Exp $ */
 /*	OpenBSD: mpii.c,v 1.51 2012/04/11 13:29:14 naddy Exp 	*/
 /*
  * Copyright (c) 2010 Mike Belopuhov 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.12 2018/10/14 17:37:40 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.13 2018/11/24 18:11:22 bouyer Exp $");
 
 #include "bio.h"
 
@@ -44,1665 +44,13 @@ __KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.1
 #include 
 #include 
 
+#include 
+
+#if NBIO > 0
 #include 
 #include 
 #include 
-
-#define MPII_DOORBELL			(0x00)
-/* doorbell read bits */
-#define MPII_DOORBELL_STATE		(0xf<<28) /* ioc state */
-#define  MPII_DOORBELL_STATE_RESET	(0x0<<28)
-#define  MPII_DOORBELL_STATE_READY	(0x1<<28)
-#define  MPII_DOORBELL_STATE_OPER	(0x2<<28)
-#define  MPII_DOORBELL_STATE_FAULT	(0x4<<28)
-#define  MPII_DOORBELL_INUSE		(0x1<<27) /* doorbell used */
-#define MPII_DOORBELL_WHOINIT		(0x7<<24) /* last to reset ioc */
-#define  MPII_DOORBELL_WHOINIT_NOONE	(0x0<<24) /* not initialized */
-#define  MPII_DOORBELL_WHOINIT_SYSBIOS	(0x1<<24) /* system bios */
-#define  MPII_DOORBELL_WHOINIT_ROMBIOS	(0x2<<24) /* rom bios */
-#define  MPII_DOORBELL_WHOINIT_PCIPEER	(0x3<<24) /* pci peer */
-#define  MPII_DOORBELL_WHOINIT_DRIVER	(0x4<<24) /* host driver */
-#define  MPII_DOORBELL_WHOINIT_MANUFACT	(0x5<<24) /* manufacturing */
-#define MPII_DOORBELL_FAULT		(0x<<0) /* fault code */
-/* doorbell write bits */
-#define MPII_DOORBELL_FUNCTION_SHIFT	(24)
-#define MPII_DOORBELL_FUNCTION_MASK	(0xff << MPII_DOORBELL_FUNCTION_SHIFT)
-#define MPII_DOORBELL_FUNCTION(x)	\
-(((x) << MPII_DOORBELL_FUNCTION_SHIFT) & MPII_DOORBELL_FUNCTION_MASK)
-#define MPII_DOORBELL_DWORDS_SHIFT	16
-#define MPII_DOORBELL_DWORDS_MASK	(0xff << MPII_DOORBELL_DWORDS_SHIFT)
-#define MPII_DOORBELL_DWORDS(x)		\
-(((x) << MPII_DOORBELL_DWORDS_SHIFT) & MPII_DOORBELL_DWORDS_MASK)
-#define MPII_DOORBELL_DATA_MASK		(0x)
-
-#define MPII_WRITESEQ			(0x04)
-#define  MPII_WRITESEQ_KEY_VALUE_MASK	(0x000f) /* key value */
-#define  MPII_WRITESEQ_FLUSH		(0x00)
-#define  MPII_WRITESEQ_1		(0x0f)
-#define  MPII_WRITESEQ_2		(0x04)
-#define  MPII_WRITESEQ_3		(0x0b)
-#define  MPII_WRITESEQ_4		(0x02)
-#define  MPII_WRITESEQ_5		(0x07)
-#define  MPII_WRITESEQ_6		(0x0d)
-
-#define MPII_HOSTDIAG			(0x08)
-#define  MPII_HOSTDIAG_BDS_MASK		(0x1800) /* boot device select */
-#define   MPII_HOSTDIAG_BDS_DEFAULT 	(0<<11)	/* default address map, flash */
-#define   MPII_HOSTDIAG_BDS_HCDW	(1<<11)	/* host code and data window */
-#define  MPII_HOSTDIAG_CLEARFBS		(1<<10) /* clear flash bad sig */
-#define  MPII_HOSTDIAG_FORCE_HCB_ONBOOT (1<<9)	/* force host controlled boot */
-#define  MPII_HOSTDIAG_HCB_MODE		(1<<8)	/* host controlled boot mode */
-#define  MPII_HOSTDIAG_DWRE		(1<<7) 	/* diag reg write enabled */
-#define  MPII_HOSTDIAG_FBS		(1<<6) 	/* flash bad sig */
-#define  MPII_HOSTDIAG_RESET_HIST	(1<<5) 	/* reset history */
-#define  MPII_HOSTDIAG_DIAGWR_EN	(1<<4) 	/* diagnostic write enabled */
-#define  MPII_HOSTDIAG_RESET_ADAPTER	(1<<2) 	/* reset adapter */
-#define  MPII_HOSTDIAG_HOLD_IOC_RESET	(1<<1) 	/* hold ioc in reset */
-#define  MPII_HOSTDIAG_DIAGMEM_EN	(1<<0) 	/* diag mem enable */
-
-#define MPII_DIAGRWDATA			(0x10)
-
-#define MPII_DIAGRWADDRLOW		(0x14)
-
-#define MPII_DIAGRWADDRHIGH		(0x18)
-
-#define MPII_INTR_STATUS		(0x30)
-#define  MPII_INTR_STATUS_SYS2IOCDB	(1<<31) /* ioc written to by host */
-#define  MPII_INTR_STATUS_RESET		(1<<30) /* physical ioc reset */
-#define  MPII_INTR_STATUS_REPLY		(1<<3)	/* reply message interrupt */
-#define  MPII_INTR_STATUS_IOC2SYSDB	(1<<0) 	/* ioc write to doorbell */
-
-#define MPII_INTR_MASK			(0x34)
-#define  MPII_INTR_MASK_RESET		(1<<30) /* ioc reset intr mask */
-#define  MPII_INTR_MASK_REPLY		(1<<3) 	/* reply message intr mask */
-#define  MPII_INTR_MASK_DOORBELL	(1<<0) 	/* doorbell interrupt mask */
-
-#define MPII_DCR_DATA			(0x38)
-
-#define MPII_DCR_ADDRESS		(0x3c)
-
-#define MPII_REPLY_FREE_HOST_INDEX	(0x48)
-
-#define MPII_REPLY_POST_HOST_INDEX	(0x6c)
-
-#define MPII_HCB_SIZE			(0x74)
-
-#define MPII_HCB_ADDRESS_LOW		(0x78)

CVS commit: src/sys/dev/ic

2018-11-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Nov 24 18:10:29 UTC 2018

Modified Files:
src/sys/dev/ic: mfi.c mfireg.h

Log Message:
Add some definitions from OpenBSD, needed by the upcoming mfii driver.
No functionnal change.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/dev/ic/mfi.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ic/mfireg.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/ic/mfi.c
diff -u src/sys/dev/ic/mfi.c:1.59 src/sys/dev/ic/mfi.c:1.60
--- src/sys/dev/ic/mfi.c:1.59	Mon Sep  3 16:29:31 2018
+++ src/sys/dev/ic/mfi.c	Sat Nov 24 18:10:29 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: mfi.c,v 1.59 2018/09/03 16:29:31 riastradh Exp $ */
+/* $NetBSD: mfi.c,v 1.60 2018/11/24 18:10:29 bouyer Exp $ */
 /* $OpenBSD: mfi.c,v 1.66 2006/11/28 23:59:45 dlg Exp $ */
 
 /*
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.59 2018/09/03 16:29:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.60 2018/11/24 18:10:29 bouyer Exp $");
 
 #include "bio.h"
 
@@ -1879,7 +1879,7 @@ mfi_mgmt(struct mfi_ccb *ccb, struct scs
 	DNPRINTF(MFI_D_MISC, "%s: mfi_mgmt %#x\n", DEVNAME(ccb->ccb_sc), opc);
 
 	dcmd = >ccb_frame->mfr_dcmd;
-	memset(dcmd->mdf_mbox, 0, MFI_MBOX_SIZE);
+	memset(dcmd->mdf_mbox.b, 0, MFI_MBOX_SIZE);
 	dcmd->mdf_header.mfh_cmd = MFI_CMD_DCMD;
 	dcmd->mdf_header.mfh_timeout = 0;
 
@@ -1893,7 +1893,7 @@ mfi_mgmt(struct mfi_ccb *ccb, struct scs
 
 	/* handle special opcodes */
 	if (mbox)
-		memcpy(dcmd->mdf_mbox, mbox, MFI_MBOX_SIZE);
+		memcpy(dcmd->mdf_mbox.b, mbox, MFI_MBOX_SIZE);
 
 	if (dir != MFI_DATA_NONE) {
 		dcmd->mdf_header.mfh_data_len = len;
@@ -2017,7 +2017,7 @@ mfi_ioctl_inq(struct mfi_softc *sc, stru
 
 	/* get figures */
 	cfg = malloc(sizeof *cfg, M_DEVBUF, M_WAITOK);
-	if (mfi_mgmt_internal(sc, MD_DCMD_CONF_GET, MFI_DATA_IN,
+	if (mfi_mgmt_internal(sc, MR_DCMD_CONF_GET, MFI_DATA_IN,
 	sizeof *cfg, cfg, NULL, false))
 		goto freeme;
 
@@ -2141,7 +2141,7 @@ mfi_ioctl_disk(struct mfi_softc *sc, str
 
 	/* send single element command to retrieve size for full structure */
 	cfg = malloc(sizeof *cfg, M_DEVBUF, M_WAITOK);
-	if (mfi_mgmt_internal(sc, MD_DCMD_CONF_GET, MFI_DATA_IN,
+	if (mfi_mgmt_internal(sc, MR_DCMD_CONF_GET, MFI_DATA_IN,
 	sizeof *cfg, cfg, NULL, false))
 		goto freeme;
 
@@ -2150,7 +2150,7 @@ mfi_ioctl_disk(struct mfi_softc *sc, str
 
 	/* memory for read config */
 	cfg = malloc(size, M_DEVBUF, M_WAITOK|M_ZERO);
-	if (mfi_mgmt_internal(sc, MD_DCMD_CONF_GET, MFI_DATA_IN,
+	if (mfi_mgmt_internal(sc, MR_DCMD_CONF_GET, MFI_DATA_IN,
 	size, cfg, NULL, false))
 		goto freeme;
 
@@ -2400,7 +2400,7 @@ mfi_ioctl_setstate(struct mfi_softc *sc,
 	}
 
 
-	if (mfi_mgmt_internal(sc, MD_DCMD_PD_SET_STATE, MFI_DATA_NONE,
+	if (mfi_mgmt_internal(sc, MR_DCMD_PD_SET_STATE, MFI_DATA_NONE,
 	0, NULL, mbox, false))
 		goto done;
 
@@ -2433,7 +2433,7 @@ mfi_bio_hs(struct mfi_softc *sc, int vol
 
 	/* send single element command to retrieve size for full structure */
 	cfg = malloc(sizeof *cfg, M_DEVBUF, M_WAITOK);
-	if (mfi_mgmt_internal(sc, MD_DCMD_CONF_GET, MFI_DATA_IN,
+	if (mfi_mgmt_internal(sc, MR_DCMD_CONF_GET, MFI_DATA_IN,
 	sizeof *cfg, cfg, NULL, false))
 		goto freeme;
 
@@ -2442,7 +2442,7 @@ mfi_bio_hs(struct mfi_softc *sc, int vol
 
 	/* memory for read config */
 	cfg = malloc(size, M_DEVBUF, M_WAITOK|M_ZERO);
-	if (mfi_mgmt_internal(sc, MD_DCMD_CONF_GET, MFI_DATA_IN,
+	if (mfi_mgmt_internal(sc, MR_DCMD_CONF_GET, MFI_DATA_IN,
 	size, cfg, NULL, false))
 		goto freeme;
 

Index: src/sys/dev/ic/mfireg.h
diff -u src/sys/dev/ic/mfireg.h:1.8 src/sys/dev/ic/mfireg.h:1.9
--- src/sys/dev/ic/mfireg.h:1.8	Wed Sep 19 21:24:29 2012
+++ src/sys/dev/ic/mfireg.h	Sat Nov 24 18:10:29 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: mfireg.h,v 1.8 2012/09/19 21:24:29 bouyer Exp $ */
+/* $NetBSD: mfireg.h,v 1.9 2018/11/24 18:10:29 bouyer Exp $ */
 /* $OpenBSD: mfireg.h,v 1.24 2006/06/19 19:05:45 marco Exp $ */
 /*
  * Copyright (c) 2006 Marco Peereboom 
@@ -182,12 +182,12 @@
  ((MEGASAS_THUNDERBOLT_NEW_MSG_SIZE - \
(sizeof(struct mfi_mpi2_request_raid_scsi_io) - sizeof(mpi2_sge_io_union))\
   ) / sizeof(mpi2_sge_io_union))
- 
-/* 
+
+/*
  * (Command frame size allocaed in SRB ext - Raid SCSI IO message size)
- * / size of SGL ; 
+ * / size of SGL ;
  * (1280 - 256) / 16 = 64
- */   
+ */
 #define MEGASAS_THUNDERBOLT_MAX_SGE_IN_CHAINMSG \
   ((MR_COMMAND_SIZE - MEGASAS_THUNDERBOLT_NEW_MSG_SIZE) / \
sizeof(mpi2_sge_io_union))
@@ -234,8 +234,8 @@
 #define MR_DCMD_PD_GET_LIST		0x0201
 #define MR_DCMD_PD_LIST_QUERY		0x02010100
 #define MR_DCMD_PD_GET_INFO		0x0202
-#define MD_DCMD_PD_SET_STATE		0x02030100
-#define MD_DCMD_PD_REBUILD		0x02040100
+#define MR_DCMD_PD_SET_STATE		0x02030100
+#define MR_DCMD_PD_REBUILD		0x02040100
 #define MR_DCMD_PD_BLINK		0x02070100
 #define MR_DCMD_PD_UNBLINK		0x02070200
 #define 

CVS commit: src/sys/dev

2018-11-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Nov 24 18:09:14 UTC 2018

Modified Files:
src/sys/dev: dksubr.c

Log Message:
rnd_add_uint32() doens't support concurent calls for the same rnd_source,
call it with dksc->sc_iolock held.


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/dev/dksubr.c

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

Modified files:

Index: src/sys/dev/dksubr.c
diff -u src/sys/dev/dksubr.c:1.103 src/sys/dev/dksubr.c:1.104
--- src/sys/dev/dksubr.c:1.103	Mon Sep  3 16:29:30 2018
+++ src/sys/dev/dksubr.c	Sat Nov 24 18:09:13 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: dksubr.c,v 1.103 2018/09/03 16:29:30 riastradh Exp $ */
+/* $NetBSD: dksubr.c,v 1.104 2018/11/24 18:09:13 bouyer Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.103 2018/09/03 16:29:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.104 2018/11/24 18:09:13 bouyer Exp $");
 
 #include 
 #include 
@@ -460,11 +460,11 @@ dk_done1(struct dk_softc *dksc, struct b
 	if (lock)
 		mutex_enter(>sc_iolock);
 	disk_unbusy(dk, bp->b_bcount - bp->b_resid, (bp->b_flags & B_READ));
-	if (lock)
-		mutex_exit(>sc_iolock);
 
 	if ((dksc->sc_flags & DKF_NO_RND) == 0)
 		rnd_add_uint32(>sc_rnd_source, bp->b_rawblkno);
+	if (lock)
+		mutex_exit(>sc_iolock);
 
 	biodone(bp);
 }



CVS commit: src/doc

2018-11-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Nov 24 17:54:19 UTC 2018

Modified Files:
src/doc: TODO.kaslr

Log Message:
Mark as done the two entries I added just minutes ago, they are now fixed.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/doc/TODO.kaslr

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

Modified files:

Index: src/doc/TODO.kaslr
diff -u src/doc/TODO.kaslr:1.8 src/doc/TODO.kaslr:1.9
--- src/doc/TODO.kaslr:1.8	Sat Nov 24 17:31:10 2018
+++ src/doc/TODO.kaslr	Sat Nov 24 17:54:18 2018
@@ -26,8 +26,8 @@
[DONE] - kern.lwp
[DONE] - sysctl_inpcblist
[DONE] - sysctl_unpcblist
-   - sysctl_doevcnt
-   - sysctl_dobuf
+   [DONE] - sysctl_doevcnt
+   [DONE] - sysctl_dobuf
 
 -- Be careful with dmesg.
 



CVS commit: src/sys/kern

2018-11-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Nov 24 17:52:39 UTC 2018

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

Log Message:
Fix kernel pointer leaks in sysctl_dobuf. While here constify argument.

Also memset the buffer, to prevent leaks (even if there doesn't seem to
be currently).


To generate a diff of this commit:
cvs rdiff -u -r1.277 -r1.278 src/sys/kern/vfs_bio.c

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

Modified files:

Index: src/sys/kern/vfs_bio.c
diff -u src/sys/kern/vfs_bio.c:1.277 src/sys/kern/vfs_bio.c:1.278
--- src/sys/kern/vfs_bio.c:1.277	Wed Aug 29 09:05:17 2018
+++ src/sys/kern/vfs_bio.c	Sat Nov 24 17:52:39 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_bio.c,v 1.277 2018/08/29 09:05:17 hannken Exp $	*/
+/*	$NetBSD: vfs_bio.c,v 1.278 2018/11/24 17:52:39 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.277 2018/08/29 09:05:17 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.278 2018/11/24 17:52:39 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bufcache.h"
@@ -1746,8 +1746,11 @@ buf_syncwait(void)
 }
 
 static void
-sysctl_fillbuf(buf_t *i, struct buf_sysctl *o)
+sysctl_fillbuf(const buf_t *i, struct buf_sysctl *o)
 {
+	const bool allowaddr = get_expose_address(curproc);
+
+	memset(o, 0, sizeof(*o));
 
 	o->b_flags = i->b_flags | i->b_cflags | i->b_oflags;
 	o->b_error = i->b_error;
@@ -1756,13 +1759,13 @@ sysctl_fillbuf(buf_t *i, struct buf_sysc
 	o->b_bufsize = i->b_bufsize;
 	o->b_bcount = i->b_bcount;
 	o->b_resid = i->b_resid;
-	o->b_addr = PTRTOUINT64(i->b_data);
+	COND_SET_VALUE(o->b_addr, PTRTOUINT64(i->b_data), allowaddr);
 	o->b_blkno = i->b_blkno;
 	o->b_rawblkno = i->b_rawblkno;
-	o->b_iodone = PTRTOUINT64(i->b_iodone);
-	o->b_proc = PTRTOUINT64(i->b_proc);
-	o->b_vp = PTRTOUINT64(i->b_vp);
-	o->b_saveaddr = PTRTOUINT64(i->b_saveaddr);
+	COND_SET_VALUE(o->b_iodone, PTRTOUINT64(i->b_iodone), allowaddr);
+	COND_SET_VALUE(o->b_proc, PTRTOUINT64(i->b_proc), allowaddr);
+	COND_SET_VALUE(o->b_vp, PTRTOUINT64(i->b_vp), allowaddr);
+	COND_SET_VALUE(o->b_saveaddr, PTRTOUINT64(i->b_saveaddr), allowaddr);
 	o->b_lblkno = i->b_lblkno;
 }
 



CVS commit: [netbsd-7] src/doc

2018-11-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Nov 24 17:25:39 UTC 2018

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

Log Message:
Tickets #1654 and #1655


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.14 -r1.1.2.15 src/doc/CHANGES-7.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.3
diff -u src/doc/CHANGES-7.3:1.1.2.14 src/doc/CHANGES-7.3:1.1.2.15
--- src/doc/CHANGES-7.3:1.1.2.14	Wed Nov 21 12:12:44 2018
+++ src/doc/CHANGES-7.3	Sat Nov 24 17:25:39 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.3,v 1.1.2.14 2018/11/21 12:12:44 martin Exp $
+# $NetBSD: CHANGES-7.3,v 1.1.2.15 2018/11/24 17:25:39 martin Exp $
 
 A complete list of changes from the NetBSD 7.2 release to the NetBSD 7.3
 release:
@@ -230,3 +230,53 @@ sys/kern/kern_event.c1.104
 	Fix kernel info leak.
 	[maxv, ticket #1653]
 
+usr.sbin/mtree/create.c1.76
+
+	Avoid null de-reference.
+	[sevan, ticket #1654]
+
+libexec/httpd/testsuite/data/.bzremap   up to 1.1
+libexec/httpd/testsuite/t12.out up to 1.1
+libexec/httpd/testsuite/t12.in  up to 1.1
+libexec/httpd/testsuite/t13.out up to 1.1
+libexec/httpd/testsuite/t13.in  up to 1.1
+libexec/httpd/testsuite/t14.out up to 1.1
+libexec/httpd/testsuite/t14.in  up to 1.1
+libexec/httpd/testsuite/t15.out up to 1.1
+libexec/httpd/testsuite/t15.in  up to 1.1
+libexec/httpd/CHANGES   up to 1.28
+libexec/httpd/Makefile  up to 1.27
+libexec/httpd/auth-bozo.c   up to 1.22
+libexec/httpd/bozohttpd.8   up to 1.74
+libexec/httpd/bozohttpd.c   up to 1.96
+libexec/httpd/bozohttpd.h   up to 1.56
+libexec/httpd/cgi-bozo.cup to 1.44
+libexec/httpd/content-bozo.cup to 1.16
+libexec/httpd/daemon-bozo.c up to 1.19
+libexec/httpd/dir-index-bozo.c  up to 1.28
+libexec/httpd/lua-bozo.cup to 1.15
+libexec/httpd/main.cup to 1.21
+libexec/httpd/ssl-bozo.cup to 1.25
+libexec/httpd/tilde-luzah-bozo.cup to 1.16
+libexec/httpd/libbozohttpd/Makefile up to 1.3
+libexec/httpd/lua/bozo.lua  up to 1.3
+libexec/httpd/lua/glue.cup to 1.5
+libexec/httpd/lua/optparse.lua  up to 1.2
+libexec/httpd/testsuite/Makefileup to 1.11
+libexec/httpd/testsuite/html_cmpup to 1.6
+libexec/httpd/testsuite/t3.out  up to 1.4
+libexec/httpd/testsuite/t5.out  up to 1.4
+libexec/httpd/testsuite/t6.out  up to 1.4
+libexec/httpd/testsuite/test-bigfileup to 1.5
+libexec/httpd/testsuite/test-simple up to 1.5
+
+	Sync with HEAD as of 2018-11-24. Includes various changes:
+	Cosmetic changes to Lua binding in bozohttpd.
+	Fix -C scripts execution and document restrictions.
+	Add support for remapping requested paths via a .bzredirect file.
+	Handle redirections for any protocol, not just http:.
+	Fix a denial of service attack against header contents, which
+	is now bounded at 16KiB.
+	Fix access checks for special files.
+	[mrg, ticket #1655]
+



CVS commit: src/doc

2018-11-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Nov 24 17:31:10 UTC 2018

Modified Files:
src/doc: TODO.kaslr

Log Message:
Mark four issues as fixed, add two more. Netstat was actually
sysctl_unpcblist, so remove it as duplicate.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/doc/TODO.kaslr

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

Modified files:

Index: src/doc/TODO.kaslr
diff -u src/doc/TODO.kaslr:1.7 src/doc/TODO.kaslr:1.8
--- src/doc/TODO.kaslr:1.7	Sat Oct 13 05:53:50 2018
+++ src/doc/TODO.kaslr	Sat Nov 24 17:31:10 2018
@@ -19,14 +19,15 @@
 
 -- Several entry points leak kernel addresses:
[DONE] - "modstat -k"
-   - "netstat -nat"
[DONE] - kern.proc
[DONE] - kern.proc2
-   - kern.file
+   [DONE] - kern.file
[DONE] - kern.file2
-   - kern.lwp
-   - sysctl_inpcblist
-   - sysctl_unpcblist
+   [DONE] - kern.lwp
+   [DONE] - sysctl_inpcblist
+   [DONE] - sysctl_unpcblist
+   - sysctl_doevcnt
+   - sysctl_dobuf
 
 -- Be careful with dmesg.
 



CVS commit: src/sys/kern

2018-11-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Nov 24 17:40:37 UTC 2018

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

Log Message:
Fix kernel pointer leaks in sysctl_doevcnt.

While here also fix info leak; there is a big padding so use zalloc.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/kern/subr_evcnt.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_evcnt.c
diff -u src/sys/kern/subr_evcnt.c:1.12 src/sys/kern/subr_evcnt.c:1.13
--- src/sys/kern/subr_evcnt.c:1.12	Tue Feb 25 18:30:11 2014
+++ src/sys/kern/subr_evcnt.c	Sat Nov 24 17:40:37 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_evcnt.c,v 1.12 2014/02/25 18:30:11 pooka Exp $ */
+/* $NetBSD: subr_evcnt.c,v 1.13 2018/11/24 17:40:37 maxv Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_evcnt.c,v 1.12 2014/02/25 18:30:11 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_evcnt.c,v 1.13 2018/11/24 17:40:37 maxv Exp $");
 
 #include 
 #include 
@@ -204,13 +204,16 @@ static size_t
 sysctl_fillevcnt(const struct evcnt *ev, struct xevcnt_sysctl *xevs,
 	size_t *copylenp)
 {
+	const bool allowaddr = get_expose_address(curproc);
 	const size_t copylen = offsetof(struct evcnt_sysctl, ev_strings)
 	+ ev->ev_grouplen + 1 + ev->ev_namelen + 1;
 	const size_t len = roundup2(copylen, sizeof(uint64_t));
+
 	if (xevs != NULL) {
 		xevs->evs.ev_count = ev->ev_count;
-		xevs->evs.ev_addr = PTRTOUINT64(ev);
-		xevs->evs.ev_parent = PTRTOUINT64(ev->ev_parent);
+		COND_SET_VALUE(xevs->evs.ev_addr, PTRTOUINT64(ev), allowaddr);
+		COND_SET_VALUE(xevs->evs.ev_parent, PTRTOUINT64(ev->ev_parent),
+		allowaddr);
 		xevs->evs.ev_type = ev->ev_type;
 		xevs->evs.ev_grouplen = ev->ev_grouplen;
 		xevs->evs.ev_namelen = ev->ev_namelen;
@@ -257,7 +260,7 @@ sysctl_doevcnt(SYSCTLFN_ARGS)
 	sysctl_unlock();
 
 	if (oldp != NULL && xevs0 == NULL)
-		xevs0 = kmem_alloc(sizeof(*xevs0), KM_SLEEP);
+		xevs0 = kmem_zalloc(sizeof(*xevs0), KM_SLEEP);
 
 	retries = 100;
  retry:



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

2018-11-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Nov 24 17:25:01 UTC 2018

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

Log Message:
Ticket #1655


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.20 -r1.1.2.21 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.20 src/doc/CHANGES-7.1.3:1.1.2.21
--- src/doc/CHANGES-7.1.3:1.1.2.20	Wed Nov 21 12:13:46 2018
+++ src/doc/CHANGES-7.1.3	Sat Nov 24 17:25:01 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.1.3,v 1.1.2.20 2018/11/21 12:13:46 martin Exp $
+# $NetBSD: CHANGES-7.1.3,v 1.1.2.21 2018/11/24 17:25:01 martin Exp $
 
 A complete list of changes from the NetBSD 7.1.2 release to the NetBSD 7.1.3
 release:
@@ -232,3 +232,48 @@ sys/kern/kern_event.c1.104
 	Fix kernel info leak.
 	[maxv, ticket #1653]
 
+libexec/httpd/testsuite/data/.bzremap   up to 1.1
+libexec/httpd/testsuite/t12.out up to 1.1
+libexec/httpd/testsuite/t12.in  up to 1.1
+libexec/httpd/testsuite/t13.out up to 1.1
+libexec/httpd/testsuite/t13.in  up to 1.1
+libexec/httpd/testsuite/t14.out up to 1.1
+libexec/httpd/testsuite/t14.in  up to 1.1
+libexec/httpd/testsuite/t15.out up to 1.1
+libexec/httpd/testsuite/t15.in  up to 1.1
+libexec/httpd/CHANGES   up to 1.28
+libexec/httpd/Makefile  up to 1.27
+libexec/httpd/auth-bozo.c   up to 1.22
+libexec/httpd/bozohttpd.8   up to 1.74
+libexec/httpd/bozohttpd.c   up to 1.96
+libexec/httpd/bozohttpd.h   up to 1.56
+libexec/httpd/cgi-bozo.cup to 1.44
+libexec/httpd/content-bozo.cup to 1.16
+libexec/httpd/daemon-bozo.c up to 1.19
+libexec/httpd/dir-index-bozo.c  up to 1.28
+libexec/httpd/lua-bozo.cup to 1.15
+libexec/httpd/main.cup to 1.21
+libexec/httpd/ssl-bozo.cup to 1.25
+libexec/httpd/tilde-luzah-bozo.cup to 1.16
+libexec/httpd/libbozohttpd/Makefile up to 1.3
+libexec/httpd/lua/bozo.lua  up to 1.3
+libexec/httpd/lua/glue.cup to 1.5
+libexec/httpd/lua/optparse.lua  up to 1.2
+libexec/httpd/testsuite/Makefileup to 1.11
+libexec/httpd/testsuite/html_cmpup to 1.6
+libexec/httpd/testsuite/t3.out  up to 1.4
+libexec/httpd/testsuite/t5.out  up to 1.4
+libexec/httpd/testsuite/t6.out  up to 1.4
+libexec/httpd/testsuite/test-bigfileup to 1.5
+libexec/httpd/testsuite/test-simple up to 1.5
+
+	Sync with HEAD as of 2018-11-24. Includes various changes:
+	Cosmetic changes to Lua binding in bozohttpd.
+	Fix -C scripts execution and document restrictions.
+	Add support for remapping requested paths via a .bzredirect file.
+	Handle redirections for any protocol, not just http:.
+	Fix a denial of service attack against header contents, which
+	is now bounded at 16KiB.
+	Fix access checks for special files.
+	[mrg, ticket #1655]
+



CVS commit: [netbsd-7-0] src/libexec/httpd

2018-11-24 Thread Martin Husemann
literal
+#! /bin/sh
+
+if [ -r "$SCRIPT_FILENAME" -a -x "$SCRIPT_FILENAME" ]; then
+	exec /usr/pkg/bin/perl "$SCRIPT_FILENAME"
+fi
+
+exit 1
+.Ed
 .Sh SEE ALSO
 .Xr inetd.conf 5 ,
 .Xr inetd 8
@@ -531,7 +599,7 @@ The focus has always been simplicity and
 and regular code audits.
 This manual documents
 .Nm
-version 20170201.
+version 20181123.
 .Sh AUTHORS
 .An -nosplit
 .Nm
@@ -590,7 +658,8 @@ provided initial IPv6 support
 .It
 .An Martin Husemann
 .Aq Mt mar...@netbsd.org
-provided .bzabsredirect support, and fixed various redirection issues
+provided .bzabsredirect and .bzredir support, and fixed various
+redirection issues
 .It
 .An Arto Huusko
 .Aq Mt arto.huu...@pp2.inet.fi
@@ -606,11 +675,11 @@ provided cgi-bin enhancements
 .It
 .An Nicolas Jombart
 .Aq Mt e...@ipv42.net
-provided fixes for HTTP basic authorisation support
+provided fixes for HTTP basic authorization support
 .It
 .An Antti Kantee
 .Aq Mt po...@netbsd.org
-provided fixes for HTTP basic authorisation support
+provided fixes for HTTP basic authorization support
 .It
 .An Thomas Klausner
 .Aq Mt w...@netbsd.org
@@ -644,7 +713,7 @@ option (pidfile support) and provided so
 .An Luke Mewburn
 .Aq Mt lu...@netbsd.org
 provided many various fixes, including cgi-bin fixes and enhancements,
-HTTP basic authorisation support and much code clean up
+HTTP basic authorization support and much code clean up
 .It
 .An Rajeev V. Pillai
 .Aq Mt rajeev_v_pil...@yahoo.com
@@ -686,7 +755,7 @@ provided a man page fix
 .It
 .An Holger Weiss
 .Aq Mt hol...@cis.fu-berlin.de
-provided http authorisation fixes
+provided http authorization fixes
 .It
 .Aq Mt x...@kittenz.org
 provided chroot and change-to-user support, and other various fixes

Index: src/libexec/httpd/bozohttpd.c
diff -u src/libexec/httpd/bozohttpd.c:1.56.2.4.2.3 src/libexec/httpd/bozohttpd.c:1.56.2.4.2.4
--- src/libexec/httpd/bozohttpd.c:1.56.2.4.2.3	Sun Feb 12 21:59:44 2017
+++ src/libexec/httpd/bozohttpd.c	Sat Nov 24 17:23:47 2018
@@ -1,9 +1,9 @@
-/*	$NetBSD: bozohttpd.c,v 1.56.2.4.2.3 2017/02/12 21:59:44 snj Exp $	*/
+/*	$NetBSD: bozohttpd.c,v 1.56.2.4.2.4 2018/11/24 17:23:47 martin Exp $	*/
 
 /*	$eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $	*/
 
 /*
- * Copyright (c) 1997-2017 Matthew R. Green
+ * Copyright (c) 1997-2018 Matthew R. Green
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -109,16 +109,7 @@
 #define INDEX_HTML		"index.html"
 #endif
 #ifndef SERVER_SOFTWARE
-#define SERVER_SOFTWARE		"bozohttpd/20170201"
-#endif
-#ifndef DIRECT_ACCESS_FILE
-#define DIRECT_ACCESS_FILE	".bzdirect"
-#endif
-#ifndef REDIRECT_FILE
-#define REDIRECT_FILE		".bzredirect"
-#endif
-#ifndef ABSREDIRECT_FILE
-#define ABSREDIRECT_FILE	".bzabsredirect"
+#define SERVER_SOFTWARE		"bozohttpd/20181124"
 #endif
 #ifndef PUBLIC_HTML
 #define PUBLIC_HTML		"public_html"
@@ -149,6 +140,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -156,8 +148,19 @@
 
 #include "bozohttpd.h"
 
-#ifndef MAX_WAIT_TIME
-#define	MAX_WAIT_TIME	60	/* hang around for 60 seconds max */
+#ifndef INITIAL_TIMEOUT
+#define	INITIAL_TIMEOUT		"30"	/* wait for 30 seconds initially */
+#endif
+#ifndef HEADER_WAIT_TIME
+#define	HEADER_WAIT_TIME	"10"	/* need more headers every 10 seconds */
+#endif
+#ifndef TOTAL_MAX_REQ_TIME
+#define	TOTAL_MAX_REQ_TIME	"600"	/* must have total request in 600 */
+#endif	/* seconds */
+
+/* if monotonic time is not available try real time. */
+#ifndef CLOCK_MONOTONIC
+#define CLOCK_MONOTONIC CLOCK_REALTIME
 #endif
 
 /* variables and functions */
@@ -165,7 +168,22 @@
 #define LOG_FTP LOG_DAEMON
 #endif
 
-volatile sig_atomic_t	alarmhit;
+/*
+ * List of special file that we should never serve.
+ */
+struct {
+	const char *file;
+	const char *name;
+} specials[] = {
+	{ DIRECT_ACCESS_FILE, "rejected direct access request" },
+	{ REDIRECT_FILE,  "rejected redirect request" },
+	{ ABSREDIRECT_FILE,   "rejected absredirect request" },
+	{ REMAP_FILE, "rejected remap request" },
+	{ AUTH_FILE,  "rejected authfile request" },
+	{ NULL,   NULL },
+};
+
+volatile sig_atomic_t	timeout_hit;
 
 /*
  * check there's enough space in the prefs and names arrays.
@@ -368,7 +386,34 @@ bozo_clean_request(bozo_httpreq_t *reque
 static void
 alarmer(int sig)
 {
-	alarmhit = 1;
+	timeout_hit = 1;
+}
+
+
+/*
+ * set a timeout for "initial", "header", or "request".
+ */
+int
+bozo_set_timeout(bozohttpd_t *httpd, bozoprefs_t *prefs,
+		 const char *target, const char *val)
+{
+	const char *cur, *timeouts[] = {
+		"initial timeout",
+		"header timeout",
+		"request timeout",
+		NULL,
+	};
+	/* adjust minlen if more timeouts appear with conflicting n

CVS commit: src/sys/kern

2018-11-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Nov 24 17:26:27 UTC 2018

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

Log Message:
Fix kernel pointer leaks in the kern.lwp sysctl.


To generate a diff of this commit:
cvs rdiff -u -r1.218 -r1.219 src/sys/kern/init_sysctl.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/init_sysctl.c
diff -u src/sys/kern/init_sysctl.c:1.218 src/sys/kern/init_sysctl.c:1.219
--- src/sys/kern/init_sysctl.c:1.218	Fri Oct  5 22:12:38 2018
+++ src/sys/kern/init_sysctl.c	Sat Nov 24 17:26:27 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: init_sysctl.c,v 1.218 2018/10/05 22:12:38 christos Exp $ */
+/*	$NetBSD: init_sysctl.c,v 1.219 2018/11/24 17:26:27 maxv Exp $ */
 
 /*-
  * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.218 2018/10/05 22:12:38 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.219 2018/11/24 17:26:27 maxv Exp $");
 
 #include "opt_sysv.h"
 #include "opt_compat_netbsd.h"
@@ -1600,6 +1600,7 @@ sysctl_consdev(SYSCTLFN_ARGS)
 static void
 fill_lwp(struct lwp *l, struct kinfo_lwp *kl)
 {
+	const bool allowaddr = get_expose_address(curproc);
 	struct proc *p = l->l_proc;
 	struct timeval tv;
 
@@ -1609,8 +1610,8 @@ fill_lwp(struct lwp *l, struct kinfo_lwp
 
 	kl->l_forw = 0;
 	kl->l_back = 0;
-	kl->l_laddr = PTRTOUINT64(l);
-	kl->l_addr = PTRTOUINT64(l->l_addr);
+	COND_SET_VALUE(kl->l_laddr, PTRTOUINT64(l), allowaddr);
+	COND_SET_VALUE(kl->l_addr, PTRTOUINT64(l->l_addr), allowaddr);
 	kl->l_stat = l->l_stat;
 	kl->l_lid = l->l_lid;
 	kl->l_flag = L_INMEM;
@@ -1627,7 +1628,7 @@ fill_lwp(struct lwp *l, struct kinfo_lwp
 	kl->l_usrpri = l->l_priority;
 	if (l->l_wchan)
 		strncpy(kl->l_wmesg, l->l_wmesg, sizeof(kl->l_wmesg));
-	kl->l_wchan = PTRTOUINT64(l->l_wchan);
+	COND_SET_VALUE(kl->l_wchan, PTRTOUINT64(l->l_wchan), allowaddr);
 	kl->l_cpuid = cpu_index(l->l_cpu);
 	bintime2timeval(>l_rtime, );
 	kl->l_rtime_sec = tv.tv_sec;



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

2018-11-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Nov 24 17:24:32 UTC 2018

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

Log Message:
Ticket #1655


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.113 -r1.1.2.114 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.113 src/doc/CHANGES-7.0.3:1.1.2.114
--- src/doc/CHANGES-7.0.3:1.1.2.113	Wed Nov 21 12:15:40 2018
+++ src/doc/CHANGES-7.0.3	Sat Nov 24 17:24:31 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.0.3,v 1.1.2.113 2018/11/21 12:15:40 martin Exp $
+# $NetBSD: CHANGES-7.0.3,v 1.1.2.114 2018/11/24 17:24:31 martin Exp $
 
 A complete list of changes from the NetBSD 7.0.2 release to the NetBSD 7.0.3
 release:
@@ -5540,3 +5540,48 @@ sys/kern/kern_event.c1.104
 	Fix kernel info leak.
 	[maxv, ticket #1653]
 
+libexec/httpd/testsuite/data/.bzremap   up to 1.1
+libexec/httpd/testsuite/t12.out up to 1.1
+libexec/httpd/testsuite/t12.in  up to 1.1
+libexec/httpd/testsuite/t13.out up to 1.1
+libexec/httpd/testsuite/t13.in  up to 1.1
+libexec/httpd/testsuite/t14.out up to 1.1
+libexec/httpd/testsuite/t14.in  up to 1.1
+libexec/httpd/testsuite/t15.out up to 1.1
+libexec/httpd/testsuite/t15.in  up to 1.1
+libexec/httpd/CHANGES   up to 1.28
+libexec/httpd/Makefile  up to 1.27
+libexec/httpd/auth-bozo.c   up to 1.22
+libexec/httpd/bozohttpd.8   up to 1.74
+libexec/httpd/bozohttpd.c   up to 1.96
+libexec/httpd/bozohttpd.h   up to 1.56
+libexec/httpd/cgi-bozo.cup to 1.44
+libexec/httpd/content-bozo.cup to 1.16
+libexec/httpd/daemon-bozo.c up to 1.19
+libexec/httpd/dir-index-bozo.c  up to 1.28
+libexec/httpd/lua-bozo.cup to 1.15
+libexec/httpd/main.cup to 1.21
+libexec/httpd/ssl-bozo.cup to 1.25
+libexec/httpd/tilde-luzah-bozo.cup to 1.16
+libexec/httpd/libbozohttpd/Makefile up to 1.3
+libexec/httpd/lua/bozo.lua  up to 1.3
+libexec/httpd/lua/glue.cup to 1.5
+libexec/httpd/lua/optparse.lua  up to 1.2
+libexec/httpd/testsuite/Makefileup to 1.11
+libexec/httpd/testsuite/html_cmpup to 1.6
+libexec/httpd/testsuite/t3.out  up to 1.4
+libexec/httpd/testsuite/t5.out  up to 1.4
+libexec/httpd/testsuite/t6.out  up to 1.4
+libexec/httpd/testsuite/test-bigfileup to 1.5
+libexec/httpd/testsuite/test-simple up to 1.5
+
+	Sync with HEAD as of 2018-11-24. Includes various changes:
+	Cosmetic changes to Lua binding in bozohttpd.
+	Fix -C scripts execution and document restrictions.
+	Add support for remapping requested paths via a .bzredirect file.
+	Handle redirections for any protocol, not just http:.
+	Fix a denial of service attack against header contents, which
+	is now bounded at 16KiB.
+	Fix access checks for special files.
+	[mrg, ticket #1655]
+



CVS commit: [netbsd-7-1] src/libexec/httpd

2018-11-24 Thread Martin Husemann
;$SCRIPT_FILENAME" -a -x "$SCRIPT_FILENAME" ]; then
+	exec /usr/pkg/bin/perl "$SCRIPT_FILENAME"
+fi
+
+exit 1
+.Ed
 .Sh SEE ALSO
 .Xr inetd.conf 5 ,
 .Xr inetd 8
@@ -531,7 +599,7 @@ The focus has always been simplicity and
 and regular code audits.
 This manual documents
 .Nm
-version 20170201.
+version 20181123.
 .Sh AUTHORS
 .An -nosplit
 .Nm
@@ -590,7 +658,8 @@ provided initial IPv6 support
 .It
 .An Martin Husemann
 .Aq Mt mar...@netbsd.org
-provided .bzabsredirect support, and fixed various redirection issues
+provided .bzabsredirect and .bzredir support, and fixed various
+redirection issues
 .It
 .An Arto Huusko
 .Aq Mt arto.huu...@pp2.inet.fi
@@ -606,11 +675,11 @@ provided cgi-bin enhancements
 .It
 .An Nicolas Jombart
 .Aq Mt e...@ipv42.net
-provided fixes for HTTP basic authorisation support
+provided fixes for HTTP basic authorization support
 .It
 .An Antti Kantee
 .Aq Mt po...@netbsd.org
-provided fixes for HTTP basic authorisation support
+provided fixes for HTTP basic authorization support
 .It
 .An Thomas Klausner
 .Aq Mt w...@netbsd.org
@@ -644,7 +713,7 @@ option (pidfile support) and provided so
 .An Luke Mewburn
 .Aq Mt lu...@netbsd.org
 provided many various fixes, including cgi-bin fixes and enhancements,
-HTTP basic authorisation support and much code clean up
+HTTP basic authorization support and much code clean up
 .It
 .An Rajeev V. Pillai
 .Aq Mt rajeev_v_pil...@yahoo.com
@@ -686,7 +755,7 @@ provided a man page fix
 .It
 .An Holger Weiss
 .Aq Mt hol...@cis.fu-berlin.de
-provided http authorisation fixes
+provided http authorization fixes
 .It
 .Aq Mt x...@kittenz.org
 provided chroot and change-to-user support, and other various fixes

Index: src/libexec/httpd/bozohttpd.c
diff -u src/libexec/httpd/bozohttpd.c:1.56.2.8 src/libexec/httpd/bozohttpd.c:1.56.2.8.2.1
--- src/libexec/httpd/bozohttpd.c:1.56.2.8	Sun Feb 12 22:07:17 2017
+++ src/libexec/httpd/bozohttpd.c	Sat Nov 24 17:23:20 2018
@@ -1,9 +1,9 @@
-/*	$NetBSD: bozohttpd.c,v 1.56.2.8 2017/02/12 22:07:17 snj Exp $	*/
+/*	$NetBSD: bozohttpd.c,v 1.56.2.8.2.1 2018/11/24 17:23:20 martin Exp $	*/
 
 /*	$eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $	*/
 
 /*
- * Copyright (c) 1997-2017 Matthew R. Green
+ * Copyright (c) 1997-2018 Matthew R. Green
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -109,16 +109,7 @@
 #define INDEX_HTML		"index.html"
 #endif
 #ifndef SERVER_SOFTWARE
-#define SERVER_SOFTWARE		"bozohttpd/20170201"
-#endif
-#ifndef DIRECT_ACCESS_FILE
-#define DIRECT_ACCESS_FILE	".bzdirect"
-#endif
-#ifndef REDIRECT_FILE
-#define REDIRECT_FILE		".bzredirect"
-#endif
-#ifndef ABSREDIRECT_FILE
-#define ABSREDIRECT_FILE	".bzabsredirect"
+#define SERVER_SOFTWARE		"bozohttpd/20181124"
 #endif
 #ifndef PUBLIC_HTML
 #define PUBLIC_HTML		"public_html"
@@ -149,6 +140,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -156,8 +148,19 @@
 
 #include "bozohttpd.h"
 
-#ifndef MAX_WAIT_TIME
-#define	MAX_WAIT_TIME	60	/* hang around for 60 seconds max */
+#ifndef INITIAL_TIMEOUT
+#define	INITIAL_TIMEOUT		"30"	/* wait for 30 seconds initially */
+#endif
+#ifndef HEADER_WAIT_TIME
+#define	HEADER_WAIT_TIME	"10"	/* need more headers every 10 seconds */
+#endif
+#ifndef TOTAL_MAX_REQ_TIME
+#define	TOTAL_MAX_REQ_TIME	"600"	/* must have total request in 600 */
+#endif	/* seconds */
+
+/* if monotonic time is not available try real time. */
+#ifndef CLOCK_MONOTONIC
+#define CLOCK_MONOTONIC CLOCK_REALTIME
 #endif
 
 /* variables and functions */
@@ -165,7 +168,22 @@
 #define LOG_FTP LOG_DAEMON
 #endif
 
-volatile sig_atomic_t	alarmhit;
+/*
+ * List of special file that we should never serve.
+ */
+struct {
+	const char *file;
+	const char *name;
+} specials[] = {
+	{ DIRECT_ACCESS_FILE, "rejected direct access request" },
+	{ REDIRECT_FILE,  "rejected redirect request" },
+	{ ABSREDIRECT_FILE,   "rejected absredirect request" },
+	{ REMAP_FILE, "rejected remap request" },
+	{ AUTH_FILE,  "rejected authfile request" },
+	{ NULL,   NULL },
+};
+
+volatile sig_atomic_t	timeout_hit;
 
 /*
  * check there's enough space in the prefs and names arrays.
@@ -368,7 +386,34 @@ bozo_clean_request(bozo_httpreq_t *reque
 static void
 alarmer(int sig)
 {
-	alarmhit = 1;
+	timeout_hit = 1;
+}
+
+
+/*
+ * set a timeout for "initial", "header", or "request".
+ */
+int
+bozo_set_timeout(bozohttpd_t *httpd, bozoprefs_t *prefs,
+		 const char *target, const char *val)
+{
+	const char *cur, *timeouts[] = {
+		"initial timeout",
+		"header timeout",
+		"request timeout",
+		NULL,
+	};
+	/* adjust minlen if more timeouts appear with conflicting names */
+	const size_t minlen = 1;
+	size_t len = strlen(target);
+

CVS commit: [netbsd-7] src/libexec/httpd

2018-11-24 Thread Martin Husemann
 .Sh SEE ALSO
 .Xr inetd.conf 5 ,
 .Xr inetd 8
@@ -531,7 +599,7 @@ The focus has always been simplicity and
 and regular code audits.
 This manual documents
 .Nm
-version 20170201.
+version 20181123.
 .Sh AUTHORS
 .An -nosplit
 .Nm
@@ -590,7 +658,8 @@ provided initial IPv6 support
 .It
 .An Martin Husemann
 .Aq Mt mar...@netbsd.org
-provided .bzabsredirect support, and fixed various redirection issues
+provided .bzabsredirect and .bzredir support, and fixed various
+redirection issues
 .It
 .An Arto Huusko
 .Aq Mt arto.huu...@pp2.inet.fi
@@ -606,11 +675,11 @@ provided cgi-bin enhancements
 .It
 .An Nicolas Jombart
 .Aq Mt e...@ipv42.net
-provided fixes for HTTP basic authorisation support
+provided fixes for HTTP basic authorization support
 .It
 .An Antti Kantee
 .Aq Mt po...@netbsd.org
-provided fixes for HTTP basic authorisation support
+provided fixes for HTTP basic authorization support
 .It
 .An Thomas Klausner
 .Aq Mt w...@netbsd.org
@@ -644,7 +713,7 @@ option (pidfile support) and provided so
 .An Luke Mewburn
 .Aq Mt lu...@netbsd.org
 provided many various fixes, including cgi-bin fixes and enhancements,
-HTTP basic authorisation support and much code clean up
+HTTP basic authorization support and much code clean up
 .It
 .An Rajeev V. Pillai
 .Aq Mt rajeev_v_pil...@yahoo.com
@@ -686,7 +755,7 @@ provided a man page fix
 .It
 .An Holger Weiss
 .Aq Mt hol...@cis.fu-berlin.de
-provided http authorisation fixes
+provided http authorization fixes
 .It
 .Aq Mt x...@kittenz.org
 provided chroot and change-to-user support, and other various fixes

Index: src/libexec/httpd/bozohttpd.c
diff -u src/libexec/httpd/bozohttpd.c:1.56.2.9 src/libexec/httpd/bozohttpd.c:1.56.2.10
--- src/libexec/httpd/bozohttpd.c:1.56.2.9	Mon Feb 19 19:43:14 2018
+++ src/libexec/httpd/bozohttpd.c	Sat Nov 24 17:22:57 2018
@@ -1,9 +1,9 @@
-/*	$NetBSD: bozohttpd.c,v 1.56.2.9 2018/02/19 19:43:14 snj Exp $	*/
+/*	$NetBSD: bozohttpd.c,v 1.56.2.10 2018/11/24 17:22:57 martin Exp $	*/
 
 /*	$eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $	*/
 
 /*
- * Copyright (c) 1997-2017 Matthew R. Green
+ * Copyright (c) 1997-2018 Matthew R. Green
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -109,16 +109,7 @@
 #define INDEX_HTML		"index.html"
 #endif
 #ifndef SERVER_SOFTWARE
-#define SERVER_SOFTWARE		"bozohttpd/20170201"
-#endif
-#ifndef DIRECT_ACCESS_FILE
-#define DIRECT_ACCESS_FILE	".bzdirect"
-#endif
-#ifndef REDIRECT_FILE
-#define REDIRECT_FILE		".bzredirect"
-#endif
-#ifndef ABSREDIRECT_FILE
-#define ABSREDIRECT_FILE	".bzabsredirect"
+#define SERVER_SOFTWARE		"bozohttpd/20181124"
 #endif
 #ifndef PUBLIC_HTML
 #define PUBLIC_HTML		"public_html"
@@ -149,6 +140,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -156,8 +148,19 @@
 
 #include "bozohttpd.h"
 
-#ifndef MAX_WAIT_TIME
-#define	MAX_WAIT_TIME	60	/* hang around for 60 seconds max */
+#ifndef INITIAL_TIMEOUT
+#define	INITIAL_TIMEOUT		"30"	/* wait for 30 seconds initially */
+#endif
+#ifndef HEADER_WAIT_TIME
+#define	HEADER_WAIT_TIME	"10"	/* need more headers every 10 seconds */
+#endif
+#ifndef TOTAL_MAX_REQ_TIME
+#define	TOTAL_MAX_REQ_TIME	"600"	/* must have total request in 600 */
+#endif	/* seconds */
+
+/* if monotonic time is not available try real time. */
+#ifndef CLOCK_MONOTONIC
+#define CLOCK_MONOTONIC CLOCK_REALTIME
 #endif
 
 /* variables and functions */
@@ -165,7 +168,22 @@
 #define LOG_FTP LOG_DAEMON
 #endif
 
-volatile sig_atomic_t	alarmhit;
+/*
+ * List of special file that we should never serve.
+ */
+struct {
+	const char *file;
+	const char *name;
+} specials[] = {
+	{ DIRECT_ACCESS_FILE, "rejected direct access request" },
+	{ REDIRECT_FILE,  "rejected redirect request" },
+	{ ABSREDIRECT_FILE,   "rejected absredirect request" },
+	{ REMAP_FILE, "rejected remap request" },
+	{ AUTH_FILE,  "rejected authfile request" },
+	{ NULL,   NULL },
+};
+
+volatile sig_atomic_t	timeout_hit;
 
 /*
  * check there's enough space in the prefs and names arrays.
@@ -368,7 +386,34 @@ bozo_clean_request(bozo_httpreq_t *reque
 static void
 alarmer(int sig)
 {
-	alarmhit = 1;
+	timeout_hit = 1;
+}
+
+
+/*
+ * set a timeout for "initial", "header", or "request".
+ */
+int
+bozo_set_timeout(bozohttpd_t *httpd, bozoprefs_t *prefs,
+		 const char *target, const char *val)
+{
+	const char *cur, *timeouts[] = {
+		"initial timeout",
+		"header timeout",
+		"request timeout",
+		NULL,
+	};
+	/* adjust minlen if more timeouts appear with conflicting names */
+	const size_t minlen = 1;
+	size_t len = strlen(target);
+
+	for (cur = timeouts[0]; len >= minlen && *cur; cur++) {
+		if (strncmp(target, cur, len) == 0) {
+			bozo_set_pref(httpd, 

CVS commit: src/sys/kern

2018-11-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Nov 24 17:16:44 UTC 2018

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

Log Message:
Fix kernel pointer leaks in sysctl_unpcblist.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/kern/uipc_domain.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_domain.c
diff -u src/sys/kern/uipc_domain.c:1.104 src/sys/kern/uipc_domain.c:1.105
--- src/sys/kern/uipc_domain.c:1.104	Mon Sep  3 16:29:35 2018
+++ src/sys/kern/uipc_domain.c	Sat Nov 24 17:16:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_domain.c,v 1.104 2018/09/03 16:29:35 riastradh Exp $	*/
+/*	$NetBSD: uipc_domain.c,v 1.105 2018/11/24 17:16:44 maxv Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.104 2018/09/03 16:29:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.105 2018/11/24 17:16:44 maxv Exp $");
 
 #include 
 #include 
@@ -472,6 +472,7 @@ sockaddr_format(const struct sockaddr *s
 static void
 sysctl_dounpcb(struct kinfo_pcb *pcb, const struct socket *so)
 {
+	const bool allowaddr = get_expose_address(curproc);
 	struct unpcb *unp = sotounpcb(so);
 	struct sockaddr_un *un = unp->unp_addr;
 
@@ -482,9 +483,9 @@ sysctl_dounpcb(struct kinfo_pcb *pcb, co
 	pcb->ki_protocol = so->so_proto->pr_protocol;
 	pcb->ki_pflags = unp->unp_flags;
 
-	pcb->ki_pcbaddr = PTRTOUINT64(unp);
+	COND_SET_VALUE(pcb->ki_pcbaddr, PTRTOUINT64(unp), allowaddr);
 	/* pcb->ki_ppcbaddr = unp has no ppcb... */
-	pcb->ki_sockaddr = PTRTOUINT64(so);
+	COND_SET_VALUE(pcb->ki_sockaddr, PTRTOUINT64(so), allowaddr);
 
 	pcb->ki_sostate = so->so_state;
 	/* pcb->ki_prstate = unp has no state... */
@@ -523,10 +524,11 @@ sysctl_dounpcb(struct kinfo_pcb *pcb, co
 	}
 
 	pcb->ki_inode = unp->unp_ino;
-	pcb->ki_vnode = PTRTOUINT64(unp->unp_vnode);
-	pcb->ki_conn = PTRTOUINT64(unp->unp_conn);
-	pcb->ki_refs = PTRTOUINT64(unp->unp_refs);
-	pcb->ki_nextref = PTRTOUINT64(unp->unp_nextref);
+	COND_SET_VALUE(pcb->ki_vnode, PTRTOUINT64(unp->unp_vnode), allowaddr);
+	COND_SET_VALUE(pcb->ki_conn, PTRTOUINT64(unp->unp_conn), allowaddr);
+	COND_SET_VALUE(pcb->ki_refs, PTRTOUINT64(unp->unp_refs), allowaddr);
+	COND_SET_VALUE(pcb->ki_nextref, PTRTOUINT64(unp->unp_nextref),
+	allowaddr);
 }
 
 static int



CVS commit: [netbsd-8] src/libexec/httpd

2018-11-24 Thread Martin Husemann
686,7 +755,7 @@ provided a man page fix
 .It
 .An Holger Weiss
 .Aq Mt hol...@cis.fu-berlin.de
-provided http authorisation fixes
+provided http authorization fixes
 .It
 .Aq Mt x...@kittenz.org
 provided chroot and change-to-user support, and other various fixes

Index: src/libexec/httpd/bozohttpd.c
diff -u src/libexec/httpd/bozohttpd.c:1.86.4.1 src/libexec/httpd/bozohttpd.c:1.86.4.2
--- src/libexec/httpd/bozohttpd.c:1.86.4.1	Sun Feb  4 12:49:25 2018
+++ src/libexec/httpd/bozohttpd.c	Sat Nov 24 17:13:51 2018
@@ -1,9 +1,9 @@
-/*	$NetBSD: bozohttpd.c,v 1.86.4.1 2018/02/04 12:49:25 martin Exp $	*/
+/*	$NetBSD: bozohttpd.c,v 1.86.4.2 2018/11/24 17:13:51 martin Exp $	*/
 
 /*	$eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $	*/
 
 /*
- * Copyright (c) 1997-2017 Matthew R. Green
+ * Copyright (c) 1997-2018 Matthew R. Green
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -109,16 +109,7 @@
 #define INDEX_HTML		"index.html"
 #endif
 #ifndef SERVER_SOFTWARE
-#define SERVER_SOFTWARE		"bozohttpd/20170201"
-#endif
-#ifndef DIRECT_ACCESS_FILE
-#define DIRECT_ACCESS_FILE	".bzdirect"
-#endif
-#ifndef REDIRECT_FILE
-#define REDIRECT_FILE		".bzredirect"
-#endif
-#ifndef ABSREDIRECT_FILE
-#define ABSREDIRECT_FILE	".bzabsredirect"
+#define SERVER_SOFTWARE		"bozohttpd/20181124"
 #endif
 #ifndef PUBLIC_HTML
 #define PUBLIC_HTML		"public_html"
@@ -149,6 +140,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -156,8 +148,19 @@
 
 #include "bozohttpd.h"
 
-#ifndef MAX_WAIT_TIME
-#define	MAX_WAIT_TIME	60	/* hang around for 60 seconds max */
+#ifndef INITIAL_TIMEOUT
+#define	INITIAL_TIMEOUT		"30"	/* wait for 30 seconds initially */
+#endif
+#ifndef HEADER_WAIT_TIME
+#define	HEADER_WAIT_TIME	"10"	/* need more headers every 10 seconds */
+#endif
+#ifndef TOTAL_MAX_REQ_TIME
+#define	TOTAL_MAX_REQ_TIME	"600"	/* must have total request in 600 */
+#endif	/* seconds */
+
+/* if monotonic time is not available try real time. */
+#ifndef CLOCK_MONOTONIC
+#define CLOCK_MONOTONIC CLOCK_REALTIME
 #endif
 
 /* variables and functions */
@@ -165,7 +168,22 @@
 #define LOG_FTP LOG_DAEMON
 #endif
 
-volatile sig_atomic_t	alarmhit;
+/*
+ * List of special file that we should never serve.
+ */
+struct {
+	const char *file;
+	const char *name;
+} specials[] = {
+	{ DIRECT_ACCESS_FILE, "rejected direct access request" },
+	{ REDIRECT_FILE,  "rejected redirect request" },
+	{ ABSREDIRECT_FILE,   "rejected absredirect request" },
+	{ REMAP_FILE, "rejected remap request" },
+	{ AUTH_FILE,  "rejected authfile request" },
+	{ NULL,   NULL },
+};
+
+volatile sig_atomic_t	timeout_hit;
 
 /*
  * check there's enough space in the prefs and names arrays.
@@ -368,7 +386,34 @@ bozo_clean_request(bozo_httpreq_t *reque
 static void
 alarmer(int sig)
 {
-	alarmhit = 1;
+	timeout_hit = 1;
+}
+
+
+/*
+ * set a timeout for "initial", "header", or "request".
+ */
+int
+bozo_set_timeout(bozohttpd_t *httpd, bozoprefs_t *prefs,
+		 const char *target, const char *val)
+{
+	const char *cur, *timeouts[] = {
+		"initial timeout",
+		"header timeout",
+		"request timeout",
+		NULL,
+	};
+	/* adjust minlen if more timeouts appear with conflicting names */
+	const size_t minlen = 1;
+	size_t len = strlen(target);
+
+	for (cur = timeouts[0]; len >= minlen && *cur; cur++) {
+		if (strncmp(target, cur, len) == 0) {
+			bozo_set_pref(httpd, prefs, cur, val);
+			return 0;
+		}
+	}
+	return 1;
 }
 
 /*
@@ -536,6 +581,18 @@ process_method(bozo_httpreq_t *request, 
 	return bozo_http_error(httpd, 404, request, "unknown method");
 }
 
+/* check header byte count */
+static int
+bozo_got_header_length(bozo_httpreq_t *request, size_t len)
+{
+	request->hr_header_bytes += len;
+	if (request->hr_header_bytes < BOZO_HEADERS_MAX_SIZE)
+		return 0;
+
+	return bozo_http_error(request->hr_httpd, 413, request,
+		"too many headers");
+}
+
 /*
  * This function reads a http request from stdin, returning a pointer to a
  * bozo_httpreq_t structure, describing the request.
@@ -553,6 +610,7 @@ bozo_read_request(bozohttpd_t *httpd)
 	int	line = 0;
 	socklen_t slen;
 	bozo_httpreq_t *request;
+	struct timespec ots, ts;
 
 	/*
 	 * if we're in daemon mode, bozo_daemon_fork() will return here twice
@@ -635,21 +693,44 @@ bozo_read_request(bozohttpd_t *httpd)
 	sa.sa_flags = 0;
 	sigaction(SIGALRM, , NULL);
 
-	alarm(MAX_WAIT_TIME);
+	if (clock_gettime(CLOCK_MONOTONIC, ) != 0) {
+		bozo_http_error(httpd, 500, NULL, "clock_gettime failed");
+		goto cleanup;
+	}
+
+	alarm(httpd->initial_timeout);
 	while ((str = bozodgetln(httpd, STDIN_FILENO, , bozo_read)) != NULL) {
 		alarm(0);
-		if (alarmhit) {
-		

CVS commit: src/sys/netinet

2018-11-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Nov 24 17:05:54 UTC 2018

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

Log Message:
KNF, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.220 -r1.221 src/sys/netinet/tcp_usrreq.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_usrreq.c
diff -u src/sys/netinet/tcp_usrreq.c:1.220 src/sys/netinet/tcp_usrreq.c:1.221
--- src/sys/netinet/tcp_usrreq.c:1.220	Sat Nov 24 16:58:40 2018
+++ src/sys/netinet/tcp_usrreq.c	Sat Nov 24 17:05:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_usrreq.c,v 1.220 2018/11/24 16:58:40 maxv Exp $	*/
+/*	$NetBSD: tcp_usrreq.c,v 1.221 2018/11/24 17:05:54 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -99,7 +99,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.220 2018/11/24 16:58:40 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.221 2018/11/24 17:05:54 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -152,8 +152,8 @@ __KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c
 #include 
 #include 
 
-static int  
-tcp_debug_capture(struct tcpcb *tp, int req)  
+static int
+tcp_debug_capture(struct tcpcb *tp, int req)
 {
 #ifdef TCP_DEBUG
 	return tp->t_state;
@@ -163,7 +163,7 @@ tcp_debug_capture(struct tcpcb *tp, int 
 
 static inline void
 tcp_debug_trace(struct socket *so, struct tcpcb *tp, int ostate, int req)
-{
+{
 #ifdef TCP_DEBUG
 	if (tp && (so->so_options & SO_DEBUG))
 		tcp_trace(TA_USER, ostate, tp, NULL, req);
@@ -216,7 +216,7 @@ change_keepalive(struct socket *so, stru
 	if (tp->t_state == TCPS_SYN_RECEIVED ||
 	tp->t_state == TCPS_SYN_SENT) {
 		TCP_TIMER_ARM(tp, TCPT_KEEP, tp->t_keepinit);
-	} else if (so->so_options & SO_KEEPALIVE && 
+	} else if (so->so_options & SO_KEEPALIVE &&
 	tp->t_state <= TCPS_CLOSE_WAIT) {
 		TCP_TIMER_ARM(tp, TCPT_KEEP, tp->t_keepintvl);
 	} else {
@@ -330,7 +330,7 @@ tcp_ctloutput(int op, struct socket *so,
 #endif
 	{
 		splx(s);
-		return (ECONNRESET);
+		return ECONNRESET;
 	}
 	if (level != IPPROTO_TCP) {
 		switch (family) {
@@ -344,7 +344,7 @@ tcp_ctloutput(int op, struct socket *so,
 #endif
 		}
 		splx(s);
-		return (error);
+		return error;
 	}
 	if (inp)
 		tp = intotcpcb(inp);
@@ -487,7 +487,7 @@ setval:			error = sockopt_set(sopt, 
 		break;
 	}
 	splx(s);
-	return (error);
+	return error;
 }
 
 #ifndef TCP_SENDSPACE
@@ -1255,7 +1255,7 @@ tcp_disconnect1(struct tcpcb *tp)
 		if (tp)
 			(void) tcp_output(tp);
 	}
-	return (tp);
+	return tp;
 }
 
 /*
@@ -1322,7 +1322,7 @@ tcp_usrclosed(struct tcpcb *tp)
 			tp = 0;
 		}
 	}
-	return (tp);
+	return tp;
 }
 
 /*
@@ -1340,17 +1340,17 @@ sysctl_net_inet_tcp_mssdflt(SYSCTLFN_ARG
 	node.sysctl_data = 
 	error = sysctl_lookup(SYSCTLFN_CALL());
 	if (error || newp == NULL)
-		return (error);
+		return error;
 
 	if (mssdflt < 32)
-		return (EINVAL);
+		return EINVAL;
 	tcp_mssdflt = mssdflt;
 
 	mutex_enter(softnet_lock);
 	tcp_tcpcb_template();
 	mutex_exit(softnet_lock);
 
-	return (0);
+	return 0;
 }
 
 /*
@@ -1401,7 +1401,7 @@ sysctl_net_inet_ip_ports(SYSCTLFN_ARGS)
 	struct sysctlnode node;
 
 	if (namelen != 0)
-		return (EINVAL);
+		return EINVAL;
 
 	switch (name[-3]) {
 	case PF_INET:
@@ -1423,7 +1423,7 @@ sysctl_net_inet_ip_ports(SYSCTLFN_ARGS)
 		break;
 #endif /* INET6 */
 	default:
-		return (EINVAL);
+		return EINVAL;
 	}
 
 	/*
@@ -1435,13 +1435,13 @@ sysctl_net_inet_ip_ports(SYSCTLFN_ARGS)
 	node.sysctl_data = 
 	error = sysctl_lookup(SYSCTLFN_CALL());
 	if (error || newp == NULL)
-		return (error);
+		return error;
 
 	/*
 	 * simple port range check
 	 */
 	if (tmp < 0 || tmp > 65535)
-		return (EINVAL);
+		return EINVAL;
 
 	/*
 	 * per-node range checks
@@ -1450,20 +1450,20 @@ sysctl_net_inet_ip_ports(SYSCTLFN_ARGS)
 	case IPCTL_ANONPORTMIN:
 	case IPV6CTL_ANONPORTMIN:
 		if (tmp >= apmax)
-			return (EINVAL);
+			return EINVAL;
 #ifndef IPNOPRIVPORTS
 		if (tmp < IPPORT_RESERVED)
-return (EINVAL);
+return EINVAL;
 #endif /* IPNOPRIVPORTS */
 		break;
 
 	case IPCTL_ANONPORTMAX:
 	case IPV6CTL_ANONPORTMAX:
 if (apmin >= tmp)
-			return (EINVAL);
+			return EINVAL;
 #ifndef IPNOPRIVPORTS
 		if (tmp < IPPORT_RESERVED)
-return (EINVAL);
+return EINVAL;
 #endif /* IPNOPRIVPORTS */
 		break;
 
@@ -1473,7 +1473,7 @@ sysctl_net_inet_ip_ports(SYSCTLFN_ARGS)
 		if (tmp >= lpmax ||
 		tmp > IPPORT_RESERVEDMAX ||
 		tmp < IPPORT_RESERVEDMIN)
-			return (EINVAL);
+			return EINVAL;
 		break;
 
 	case IPCTL_LOWPORTMAX:
@@ -1481,17 +1481,17 @@ sysctl_net_inet_ip_ports(SYSCTLFN_ARGS)
 		if (lpmin >= tmp ||
 		tmp > IPPORT_RESERVEDMAX ||
 		tmp < IPPORT_RESERVEDMIN)
-			return (EINVAL);
+			return EINVAL;
 		break;
 #endif /* IPNOPRIVPORTS */
 
 	default:
-		return (EINVAL);
+		

CVS commit: [netbsd-7] src/usr.sbin/mtree

2018-11-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Nov 24 16:59:11 UTC 2018

Modified Files:
src/usr.sbin/mtree [netbsd-7]: create.c

Log Message:
Pull up following revision(s) (requested by sevan in ticket #1654):

usr.sbin/mtree/create.c: revision 1.76

Adjust test, we only want to return the structure member if the result
is not NULL.

Heads up by Sascha Wildner @ DragonFly BSD.
Adjust test, we only want to return the structure member if the result
is not NULL.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.73.2.1 src/usr.sbin/mtree/create.c

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/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.73 src/usr.sbin/mtree/create.c:1.73.2.1
--- src/usr.sbin/mtree/create.c:1.73	Thu Apr 24 17:22:41 2014
+++ src/usr.sbin/mtree/create.c	Sat Nov 24 16:59:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.73 2014/04/24 17:22:41 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.73.2.1 2018/11/24 16:59:11 martin Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)create.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: create.c,v 1.73 2014/04/24 17:22:41 christos Exp $");
+__RCSID("$NetBSD: create.c,v 1.73.2.1 2018/11/24 16:59:11 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -117,7 +117,7 @@ cwalk(FILE *fp)
 	host[sizeof(host) - 1] = '\0';
 	if ((user = getlogin()) == NULL) {
 		struct passwd *pw;
-		user = (pw = getpwuid(getuid())) == NULL ? pw->pw_name :
+		user = (pw = getpwuid(getuid())) != NULL ? pw->pw_name :
 		"";
 	}
 



CVS commit: src/sys/netinet

2018-11-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Nov 24 16:58:40 UTC 2018

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

Log Message:
Fix kernel pointer leaks in sysctl_inpcblist.


To generate a diff of this commit:
cvs rdiff -u -r1.219 -r1.220 src/sys/netinet/tcp_usrreq.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_usrreq.c
diff -u src/sys/netinet/tcp_usrreq.c:1.219 src/sys/netinet/tcp_usrreq.c:1.220
--- src/sys/netinet/tcp_usrreq.c:1.219	Thu May  3 07:13:48 2018
+++ src/sys/netinet/tcp_usrreq.c	Sat Nov 24 16:58:40 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_usrreq.c,v 1.219 2018/05/03 07:13:48 maxv Exp $	*/
+/*	$NetBSD: tcp_usrreq.c,v 1.220 2018/11/24 16:58:40 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -99,7 +99,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.219 2018/05/03 07:13:48 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.220 2018/11/24 16:58:40 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1713,6 +1713,7 @@ sysctl_net_inet_tcp_ident(SYSCTLFN_ARGS)
 int
 sysctl_inpcblist(SYSCTLFN_ARGS)
 {
+	const bool allowaddr = get_expose_address(curproc);
 	struct sockaddr_in *in;
 	const struct inpcb *inp;
 #ifdef INET6
@@ -1798,9 +1799,12 @@ sysctl_inpcblist(SYSCTLFN_ARGS)
 pcb.ki_tflags = tp->t_flags;
 			}
 
-			pcb.ki_pcbaddr = PTRTOUINT64(inp);
-			pcb.ki_ppcbaddr = PTRTOUINT64(inp->inp_ppcb);
-			pcb.ki_sockaddr = PTRTOUINT64(inp->inp_socket);
+			COND_SET_VALUE(pcb.ki_pcbaddr,
+			PTRTOUINT64(inp), allowaddr);
+			COND_SET_VALUE(pcb.ki_ppcbaddr,
+			PTRTOUINT64(inp->inp_ppcb), allowaddr);
+			COND_SET_VALUE(pcb.ki_sockaddr,
+			PTRTOUINT64(inp->inp_socket), allowaddr);
 
 			pcb.ki_rcvq = inp->inp_socket->so_rcv.sb_cc;
 			pcb.ki_sndq = inp->inp_socket->so_snd.sb_cc;
@@ -1835,9 +1839,12 @@ sysctl_inpcblist(SYSCTLFN_ARGS)
 pcb.ki_tflags = tp->t_flags;
 			}
 
-			pcb.ki_pcbaddr = PTRTOUINT64(in6p);
-			pcb.ki_ppcbaddr = PTRTOUINT64(in6p->in6p_ppcb);
-			pcb.ki_sockaddr = PTRTOUINT64(in6p->in6p_socket);
+			COND_SET_VALUE(pcb.ki_pcbaddr,
+			PTRTOUINT64(in6p), allowaddr);
+			COND_SET_VALUE(pcb.ki_ppcbaddr,
+			PTRTOUINT64(in6p->in6p_ppcb), allowaddr);
+			COND_SET_VALUE(pcb.ki_sockaddr,
+			PTRTOUINT64(in6p->in6p_socket), allowaddr);
 
 			pcb.ki_rcvq = in6p->in6p_socket->so_rcv.sb_cc;
 			pcb.ki_sndq = in6p->in6p_socket->so_snd.sb_cc;



CVS commit: src/sys/kern

2018-11-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Nov 24 16:41:48 UTC 2018

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

Log Message:
Fix kernel pointer leaks in the kern.file sysctl, same as kern.file2.


To generate a diff of this commit:
cvs rdiff -u -r1.240 -r1.241 src/sys/kern/kern_descrip.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_descrip.c
diff -u src/sys/kern/kern_descrip.c:1.240 src/sys/kern/kern_descrip.c:1.241
--- src/sys/kern/kern_descrip.c:1.240	Sat Nov 24 16:25:20 2018
+++ src/sys/kern/kern_descrip.c	Sat Nov 24 16:41:48 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_descrip.c,v 1.240 2018/11/24 16:25:20 maxv Exp $	*/
+/*	$NetBSD: kern_descrip.c,v 1.241 2018/11/24 16:41:48 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.240 2018/11/24 16:25:20 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.241 2018/11/24 16:41:48 maxv Exp $");
 
 #include 
 #include 
@@ -118,6 +118,7 @@ static int	filedescopen(dev_t, int, int,
 
 static int sysctl_kern_file(SYSCTLFN_PROTO);
 static int sysctl_kern_file2(SYSCTLFN_PROTO);
+static void fill_file(struct file *, const struct file *);
 static void fill_file2(struct kinfo_file *, const file_t *, const fdfile_t *,
 		  int, pid_t);
 
@@ -1990,6 +1991,8 @@ sysctl_file_marker_reset(void)
 static int
 sysctl_kern_file(SYSCTLFN_ARGS)
 {
+	const bool allowaddr = get_expose_address(curproc);
+	struct filelist flist;
 	int error;
 	size_t buflen;
 	struct file *fp, fbuf;
@@ -2016,13 +2019,18 @@ sysctl_kern_file(SYSCTLFN_ARGS)
 		return 0;
 	}
 	sysctl_unlock();
-	error = sysctl_copyout(l, , where, sizeof(filehead));
+	if (allowaddr) {
+		memcpy(, , sizeof(flist));
+	} else {
+		memset(, 0, sizeof(flist));
+	}
+	error = sysctl_copyout(l, , where, sizeof(flist));
 	if (error) {
 		sysctl_relock();
 		return error;
 	}
-	buflen -= sizeof(filehead);
-	where += sizeof(filehead);
+	buflen -= sizeof(flist);
+	where += sizeof(flist);
 
 	/*
 	 * followed by an array of file structures
@@ -2090,7 +2098,7 @@ sysctl_kern_file(SYSCTLFN_ARGS)
 break;
 			}
 
-			memcpy(, fp, sizeof(fbuf));
+			fill_file(, fp);
 			mutex_exit(>f_lock);
 			error = sysctl_copyout(l, , where, sizeof(fbuf));
 			if (error) {
@@ -2286,6 +2294,29 @@ sysctl_kern_file2(SYSCTLFN_ARGS)
 }
 
 static void
+fill_file(struct file *fp, const struct file *fpsrc)
+{
+	const bool allowaddr = get_expose_address(curproc);
+
+	memset(fp, 0, sizeof(*fp));
+
+	fp->f_offset = fpsrc->f_offset;
+	COND_SET_VALUE(fp->f_cred, fpsrc->f_cred, allowaddr);
+	COND_SET_VALUE(fp->f_ops, fpsrc->f_ops, allowaddr);
+	COND_SET_VALUE(fp->f_undata, fpsrc->f_undata, allowaddr);
+	COND_SET_VALUE(fp->f_list, fpsrc->f_list, allowaddr);
+	COND_SET_VALUE(fp->f_lock, fpsrc->f_lock, allowaddr);
+	fp->f_flag = fpsrc->f_flag;
+	fp->f_marker = fpsrc->f_marker;
+	fp->f_type = fpsrc->f_type;
+	fp->f_advice = fpsrc->f_advice;
+	fp->f_count = fpsrc->f_count;
+	fp->f_msgcount = fpsrc->f_msgcount;
+	fp->f_unpcount = fpsrc->f_unpcount;
+	COND_SET_VALUE(fp->f_unplist, fpsrc->f_unplist, allowaddr);
+}
+
+static void
 fill_file2(struct kinfo_file *kp, const file_t *fp, const fdfile_t *ff,
 	  int i, pid_t pid)
 {



CVS commit: src/sys/kern

2018-11-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Nov 24 16:25:20 UTC 2018

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

Log Message:
Rename fill_file -> fill_file2, since that's the KERN_FILE2 sysctl.


To generate a diff of this commit:
cvs rdiff -u -r1.239 -r1.240 src/sys/kern/kern_descrip.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_descrip.c
diff -u src/sys/kern/kern_descrip.c:1.239 src/sys/kern/kern_descrip.c:1.240
--- src/sys/kern/kern_descrip.c:1.239	Fri Nov  2 12:27:47 2018
+++ src/sys/kern/kern_descrip.c	Sat Nov 24 16:25:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_descrip.c,v 1.239 2018/11/02 12:27:47 maxv Exp $	*/
+/*	$NetBSD: kern_descrip.c,v 1.240 2018/11/24 16:25:20 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.239 2018/11/02 12:27:47 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.240 2018/11/24 16:25:20 maxv Exp $");
 
 #include 
 #include 
@@ -118,7 +118,7 @@ static int	filedescopen(dev_t, int, int,
 
 static int sysctl_kern_file(SYSCTLFN_PROTO);
 static int sysctl_kern_file2(SYSCTLFN_PROTO);
-static void fill_file(struct kinfo_file *, const file_t *, const fdfile_t *,
+static void fill_file2(struct kinfo_file *, const file_t *, const fdfile_t *,
 		  int, pid_t);
 
 const struct cdevsw filedesc_cdevsw = {
@@ -2235,7 +2235,7 @@ sysctl_kern_file2(SYSCTLFN_ARGS)
 }
 if (len >= elem_size && elem_count > 0) {
 	mutex_enter(>f_lock);
-	fill_file(, fp, ff, i, p->p_pid);
+	fill_file2(, fp, ff, i, p->p_pid);
 	mutex_exit(>f_lock);
 	mutex_exit(>fd_lock);
 	error = sysctl_copyout(l,
@@ -2286,7 +2286,7 @@ sysctl_kern_file2(SYSCTLFN_ARGS)
 }
 
 static void
-fill_file(struct kinfo_file *kp, const file_t *fp, const fdfile_t *ff,
+fill_file2(struct kinfo_file *kp, const file_t *fp, const fdfile_t *ff,
 	  int i, pid_t pid)
 {
 	const bool allowaddr = get_expose_address(curproc);



CVS commit: src/sys/kern

2018-11-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Nov 24 16:18:36 UTC 2018

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

Log Message:
Fix kernel info leak, we do a blunt copy of struct proc, but it has
padding. So zero out the structure on each allocation. And copy field by
field while here, because many fields should be hidden by COND_SET_VALUE.


To generate a diff of this commit:
cvs rdiff -u -r1.219 -r1.220 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.219 src/sys/kern/kern_proc.c:1.220
--- src/sys/kern/kern_proc.c:1.219	Mon Nov 12 06:55:03 2018
+++ src/sys/kern/kern_proc.c	Sat Nov 24 16:18:36 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_proc.c,v 1.219 2018/11/12 06:55:03 maxv Exp $	*/
+/*	$NetBSD: kern_proc.c,v 1.220 2018/11/24 16:18:36 maxv 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.219 2018/11/12 06:55:03 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.220 2018/11/24 16:18:36 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kstack.h"
@@ -241,6 +241,7 @@ static pool_cache_t proc_cache;
 
 static kauth_listener_t proc_listener;
 
+static void fill_proc(const struct proc *, struct proc *);
 static int fill_pathname(struct lwp *, pid_t, void *, size_t *);
 
 static int
@@ -746,6 +747,7 @@ proc_alloc(void)
 	struct proc *p;
 
 	p = pool_cache_get(proc_cache, PR_WAITOK);
+	memset(p, 0, sizeof(*p));
 	p->p_stat = SIDL;			/* protect against others */
 	proc_initspecific(p);
 	kdtrace_proc_ctor(NULL, p);
@@ -1791,7 +1793,7 @@ sysctl_doeproc(SYSCTLFN_ARGS)
 		if (buflen >= elem_size &&
 		(type == KERN_PROC || elem_count > 0)) {
 			if (type == KERN_PROC) {
-kbuf->kproc.kp_proc = *p;
+fill_proc(p, >kproc.kp_proc);
 fill_eproc(p, >kproc.kp_eproc, zombie);
 			} else {
 fill_kproc2(p, >kproc2, zombie);
@@ -2161,6 +2163,103 @@ done:
 }
 
 /*
+ * Fill in a proc structure for the specified process.
+ */
+static void
+fill_proc(const struct proc *psrc, struct proc *p)
+{
+	const bool allowaddr = get_expose_address(curproc);
+
+	memset(p, 0, sizeof(*p));
+
+	COND_SET_VALUE(p->p_list, psrc->p_list, allowaddr);
+	COND_SET_VALUE(p->p_auxlock, psrc->p_auxlock, allowaddr);
+	COND_SET_VALUE(p->p_lock, psrc->p_lock, allowaddr);
+	COND_SET_VALUE(p->p_stmutex, psrc->p_stmutex, allowaddr);
+	COND_SET_VALUE(p->p_reflock, psrc->p_reflock, allowaddr);
+	COND_SET_VALUE(p->p_waitcv, psrc->p_waitcv, allowaddr);
+	COND_SET_VALUE(p->p_lwpcv, psrc->p_lwpcv, allowaddr);
+	COND_SET_VALUE(p->p_cred, psrc->p_cred, allowaddr);
+	COND_SET_VALUE(p->p_fd, psrc->p_fd, allowaddr);
+	COND_SET_VALUE(p->p_cwdi, psrc->p_cwdi, allowaddr);
+	COND_SET_VALUE(p->p_stats, psrc->p_stats, allowaddr);
+	COND_SET_VALUE(p->p_limit, psrc->p_limit, allowaddr);
+	COND_SET_VALUE(p->p_vmspace, psrc->p_vmspace, allowaddr);
+	COND_SET_VALUE(p->p_sigacts, psrc->p_sigacts, allowaddr);
+	COND_SET_VALUE(p->p_aio, psrc->p_aio, allowaddr);
+	p->p_mqueue_cnt = psrc->p_mqueue_cnt;
+	COND_SET_VALUE(p->p_specdataref, psrc->p_specdataref, allowaddr);
+	p->p_exitsig = psrc->p_exitsig;
+	p->p_flag = psrc->p_flag;
+	p->p_sflag = psrc->p_sflag;
+	p->p_slflag = psrc->p_slflag;
+	p->p_lflag = psrc->p_lflag;
+	p->p_stflag = psrc->p_stflag;
+	p->p_stat = psrc->p_stat;
+	p->p_trace_enabled = psrc->p_trace_enabled;
+	p->p_pid = psrc->p_pid;
+	COND_SET_VALUE(p->p_pglist, psrc->p_pglist, allowaddr);
+	COND_SET_VALUE(p->p_pptr, psrc->p_pptr, allowaddr);
+	COND_SET_VALUE(p->p_sibling, psrc->p_sibling, allowaddr);
+	COND_SET_VALUE(p->p_children, psrc->p_children, allowaddr);
+	COND_SET_VALUE(p->p_lwps, psrc->p_lwps, allowaddr);
+	COND_SET_VALUE(p->p_raslist, psrc->p_raslist, allowaddr);
+	p->p_nlwps = psrc->p_nlwps;
+	p->p_nzlwps = psrc->p_nzlwps;
+	p->p_nrlwps = psrc->p_nrlwps;
+	p->p_nlwpwait = psrc->p_nlwpwait;
+	p->p_ndlwps = psrc->p_ndlwps;
+	p->p_nlwpid = psrc->p_nlwpid;
+	p->p_nstopchild = psrc->p_nstopchild;
+	p->p_waited = psrc->p_waited;
+	COND_SET_VALUE(p->p_zomblwp, psrc->p_zomblwp, allowaddr);
+	COND_SET_VALUE(p->p_vforklwp, psrc->p_vforklwp, allowaddr);
+	COND_SET_VALUE(p->p_sched_info, psrc->p_sched_info, allowaddr);
+	p->p_estcpu = psrc->p_estcpu;
+	p->p_estcpu_inherited = psrc->p_estcpu_inherited;
+	p->p_forktime = psrc->p_forktime;
+	p->p_pctcpu = psrc->p_pctcpu;
+	COND_SET_VALUE(p->p_opptr, psrc->p_opptr, allowaddr);
+	COND_SET_VALUE(p->p_timers, psrc->p_timers, allowaddr);
+	p->p_rtime = psrc->p_rtime;
+	p->p_uticks = psrc->p_uticks;
+	p->p_sticks = psrc->p_sticks;
+	p->p_iticks = psrc->p_iticks;
+	p->p_xutime = psrc->p_xutime;
+	p->p_xstime = psrc->p_xstime;
+	p->p_traceflag = psrc->p_traceflag;
+	COND_SET_VALUE(p->p_tracep, psrc->p_tracep, allowaddr);
+	COND_SET_VALUE(p->p_textvp, psrc->p_textvp, allowaddr);
+	

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

2018-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Nov 24 15:44:13 UTC 2018

Modified Files:
src/sys/arch/arm/include: cputypes.h

Log Message:
Add some ThunderX CPU Ids


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/include/cputypes.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/arm/include/cputypes.h
diff -u src/sys/arch/arm/include/cputypes.h:1.3 src/sys/arch/arm/include/cputypes.h:1.4
--- src/sys/arch/arm/include/cputypes.h:1.3	Wed Oct  3 05:43:37 2018
+++ src/sys/arch/arm/include/cputypes.h	Sat Nov 24 15:44:13 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cputypes.h,v 1.3 2018/10/03 05:43:37 skrll Exp $	*/
+/*	$NetBSD: cputypes.h,v 1.4 2018/11/24 15:44:13 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Ben Harris
@@ -178,9 +178,13 @@
 #define CPU_ID_CORTEX_A75_P(n)	((n & 0xff0ff0f0) == 0x410fd0a0)
 
 #define CPU_ID_THUNDERXRX	0x43000a10
+#define CPU_ID_THUNDERXP1d0	0x43000a10
+#define CPU_ID_THUNDERXP1d1	0x43000a11
+#define CPU_ID_THUNDERXP2d1	0x431f0a11
 #define CPU_ID_THUNDERX81XXRX	0x43000a20
 #define CPU_ID_THUNDERX83XXRX	0x43000a30
 #define CPU_ID_THUNDERX2RX	0x43000af0
+
 #define CPU_ID_SA110		0x4401a100
 #define CPU_ID_SA1100		0x4401a110
 #define CPU_ID_TI925T		0x54029250



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

2018-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Nov 24 15:40:57 UTC 2018

Modified Files:
src/sys/arch/arm/cortex: gic_reg.h gicv3_its.c

Log Message:
Handle ThunderX errata


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/cortex/gic_reg.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/cortex/gicv3_its.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/cortex/gic_reg.h
diff -u src/sys/arch/arm/cortex/gic_reg.h:1.9 src/sys/arch/arm/cortex/gic_reg.h:1.10
--- src/sys/arch/arm/cortex/gic_reg.h:1.9	Tue Nov 13 22:25:28 2018
+++ src/sys/arch/arm/cortex/gic_reg.h	Sat Nov 24 15:40:57 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: gic_reg.h,v 1.9 2018/11/13 22:25:28 jmcneill Exp $	*/
+/*	$NetBSD: gic_reg.h,v 1.10 2018/11/24 15:40:57 skrll Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -335,6 +335,11 @@
 #define	GITS_CTLR_ImDe			__BIT(1)
 #define	GITS_CTLR_Enabled		__BIT(0)
 
+#define	GITS_IIDR_ProductID		__BITS(31,24)
+#define	GITS_IIDR_Variant		__BITS(19,16)
+#define	GITS_IIDR_Revision		__BITS(15,12)
+#define	GITS_IIDR_Implementor		__BITS(11,0)
+
 #define	GITS_TYPER_VMOVP		__BIT(37)
 #define	GITS_TYPER_CIL			__BIT(36)
 #define	GITS_TYPER_CIDbits		__BITS(35,32)

Index: src/sys/arch/arm/cortex/gicv3_its.c
diff -u src/sys/arch/arm/cortex/gicv3_its.c:1.7 src/sys/arch/arm/cortex/gicv3_its.c:1.8
--- src/sys/arch/arm/cortex/gicv3_its.c:1.7	Fri Nov 23 16:01:27 2018
+++ src/sys/arch/arm/cortex/gicv3_its.c	Sat Nov 24 15:40:57 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_its.c,v 1.7 2018/11/23 16:01:27 jmcneill Exp $ */
+/* $NetBSD: gicv3_its.c,v 1.8 2018/11/24 15:40:57 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #define _INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gicv3_its.c,v 1.7 2018/11/23 16:01:27 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_its.c,v 1.8 2018/11/24 15:40:57 skrll Exp $");
 
 #include 
 #include 
@@ -56,6 +56,13 @@ __KERNEL_RCSID(0, "$NetBSD: gicv3_its.c,
 
 #define	GITS_ITT_ALIGN		0x100
 
+/*
+ * IIDR values used for errata
+ */
+#define GITS_IIDR_PID_CAVIUM_THUNDERX	0xa1
+#define GITS_IIDR_IMP_CAVIUM		0x34c
+
+
 static inline uint32_t
 gits_read_4(struct gicv3_its *its, bus_size_t reg)
 {
@@ -594,7 +601,26 @@ gicv3_its_table_init(struct gicv3_softc 
 	int tab;
 
 	const uint64_t typer = gits_read_8(its, GITS_TYPER);
-	const u_int devbits = __SHIFTOUT(typer, GITS_TYPER_Devbits) + 1;
+
+	/* devbits and innercache defaults */
+	u_int devbits = __SHIFTOUT(typer, GITS_TYPER_Devbits) + 1;
+	u_int innercache = GITS_Cache_NORMAL_NC;
+
+	uint32_t iidr = gits_read_4(its, GITS_IIDR);
+	const uint32_t ctx =
+	   __SHIFTIN(GITS_IIDR_IMP_CAVIUM, GITS_IIDR_Implementor) |
+	   __SHIFTIN(GITS_IIDR_PID_CAVIUM_THUNDERX, GITS_IIDR_ProductID) |
+	   __SHIFTIN(0, GITS_IIDR_Variant);
+	const uint32_t mask =
+	GITS_IIDR_Implementor |
+	GITS_IIDR_ProductID |
+	GITS_IIDR_Variant;
+
+	if ((iidr & mask) == ctx) {
+		devbits = 20;		/* 8Mb */
+		innercache = GITS_Cache_DEVICE_nGnRnE;
+		aprint_normal_dev(sc->sc_dev, "Cavium ThunderX errata detected\n");
+	}
 
 	for (tab = 0; tab < 8; tab++) {
 		baser = gits_read_8(its, GITS_BASERn(tab));
@@ -646,11 +672,11 @@ gicv3_its_table_init(struct gicv3_softc 
 		baser &= ~GITS_BASER_Physical_Address;
 		baser |= its->its_tab[tab].segs[0].ds_addr;
 		baser &= ~GITS_BASER_InnerCache;
-		baser |= __SHIFTIN(GITS_Cache_NORMAL_NC, GITS_BASER_InnerCache);
+		baser |= __SHIFTIN(innercache, GITS_BASER_InnerCache);
 		baser &= ~GITS_BASER_Shareability;
 		baser |= __SHIFTIN(GITS_Shareability_NS, GITS_BASER_Shareability);
 		baser |= GITS_BASER_Valid;
-		
+
 		gits_write_8(its, GITS_BASERn(tab), baser);
 	}
 }



CVS commit: src/sys/dev/pci

2018-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Nov 24 15:35:45 UTC 2018

Modified Files:
src/sys/dev/pci: ahcisata_pci.c

Log Message:
Handle Cavium AHCI/RAID controller BAR weirdness.

Support 64bit BARs as well.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/pci/ahcisata_pci.c

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

Modified files:

Index: src/sys/dev/pci/ahcisata_pci.c
diff -u src/sys/dev/pci/ahcisata_pci.c:1.45 src/sys/dev/pci/ahcisata_pci.c:1.46
--- src/sys/dev/pci/ahcisata_pci.c:1.45	Tue Nov 20 15:16:43 2018
+++ src/sys/dev/pci/ahcisata_pci.c	Sat Nov 24 15:35:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_pci.c,v 1.45 2018/11/20 15:16:43 prlw1 Exp $	*/
+/*	$NetBSD: ahcisata_pci.c,v 1.46 2018/11/24 15:35:45 skrll Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.45 2018/11/20 15:16:43 prlw1 Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.46 2018/11/24 15:35:45 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ahcisata_pci.h"
@@ -220,6 +220,8 @@ CFATTACH_DECL3_NEW(ahcisata_pci, sizeof(
 ahci_pci_match, ahci_pci_attach, ahci_pci_detach, NULL,
 NULL, ahci_pci_childdetached, DVF_DETACH_SHUTDOWN);
 
+#define	AHCI_PCI_ABAR_CAVIUM	0x10
+
 static int
 ahci_pci_has_quirk(pci_vendor_id_t vendor, pci_product_id_t product)
 {
@@ -233,6 +235,20 @@ ahci_pci_has_quirk(pci_vendor_id_t vendo
 }
 
 static int
+ahci_pci_abar(struct pci_attach_args *pa)
+{
+	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_CAVIUM) {
+		if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CAVIUM_THUNDERX_AHCI ||
+		PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CAVIUM_THUNDERX_RAID) {
+			return AHCI_PCI_ABAR_CAVIUM;
+		}
+	}
+
+	return AHCI_PCI_ABAR;
+}
+
+
+static int
 ahci_pci_match(device_t parent, cfdata_t match, void *aux)
 {
 	struct pci_attach_args *pa = aux;
@@ -253,9 +269,9 @@ ahci_pci_match(device_t parent, cfdata_t
 	(force == false))
 		return 0;
 
-	if (pci_mapreg_map(pa, AHCI_PCI_ABAR,
-	PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0,
-	, , NULL, ) != 0)
+	int bar = ahci_pci_abar(pa);
+	pcireg_t memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, bar);
+	if (pci_mapreg_map(pa, bar, memtype, 0, , , NULL, ) != 0)
 		return 0;
 
 	if ((PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_MASS_STORAGE_SATA &&
@@ -281,9 +297,10 @@ ahci_pci_attach(device_t parent, device_
 
 	sc->sc_atac.atac_dev = self;
 
-	if (pci_mapreg_map(pa, AHCI_PCI_ABAR,
-	PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0,
-	>sc_ahcit, >sc_ahcih, NULL, >sc_ahcis) != 0) {
+	int bar = ahci_pci_abar(pa);
+	pcireg_t memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, bar);
+	if (pci_mapreg_map(pa, bar, memtype, 0, >sc_ahcit, >sc_ahcih,
+	NULL, >sc_ahcis) != 0) {
 		aprint_error_dev(self, "can't map ahci registers\n");
 		return;
 	}



CVS commit: src/sys/dev/pci

2018-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Nov 24 14:50:04 UTC 2018

Modified Files:
src/sys/dev/pci: xhci_pci.c

Log Message:
Fixup the retry loop wrt with XHCI_DISABLE_MSI{,X}


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/pci/xhci_pci.c

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

Modified files:

Index: src/sys/dev/pci/xhci_pci.c
diff -u src/sys/dev/pci/xhci_pci.c:1.16 src/sys/dev/pci/xhci_pci.c:1.17
--- src/sys/dev/pci/xhci_pci.c:1.16	Thu Nov 15 22:15:43 2018
+++ src/sys/dev/pci/xhci_pci.c	Sat Nov 24 14:50:04 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci_pci.c,v 1.16 2018/11/15 22:15:43 jdolecek Exp $	*/
+/*	$NetBSD: xhci_pci.c,v 1.17 2018/11/24 14:50:04 skrll Exp $	*/
 /*	OpenBSD: xhci_pci.c,v 1.4 2014/07/12 17:38:51 yuo Exp	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.16 2018/11/15 22:15:43 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.17 2018/11/24 14:50:04 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_xhci_pci.h"
@@ -203,17 +203,23 @@ alloc_retry:
 		pci_intr_release(pc, psc->sc_pihp, 1);
 		psc->sc_ih = NULL;
 		switch (intr_type) {
+#ifndef XHCI_DISABLE_MSIX
 		case PCI_INTR_TYPE_MSIX:
 			/* The next try is for MSI: Disable MSIX */
 			counts[PCI_INTR_TYPE_MSIX] = 0;
+#ifndef XHCI_DISABLE_MSI
 			counts[PCI_INTR_TYPE_MSI] = 1;
+#endif
 			counts[PCI_INTR_TYPE_INTX] = 1;
 			goto alloc_retry;
+#endif
+#ifndef XHCI_DISABLE_MSI
 		case PCI_INTR_TYPE_MSI:
 			/* The next try is for INTx: Disable MSI */
 			counts[PCI_INTR_TYPE_MSI] = 0;
 			counts[PCI_INTR_TYPE_INTX] = 1;
 			goto alloc_retry;
+#endif
 		case PCI_INTR_TYPE_INTX:
 		default:
 			aprint_error_dev(self, "couldn't establish interrupt");



CVS commit: src/sys/dev/pci

2018-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Nov 24 14:43:55 UTC 2018

Modified Files:
src/sys/dev/pci: pcidevs.h pcidevs_data.h

Log Message:
Regen


To generate a diff of this commit:
cvs rdiff -u -r1.1342 -r1.1343 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1341 -r1.1342 src/sys/dev/pci/pcidevs_data.h

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

diffs are larger than 1MB and have been omitted


CVS commit: src/sys/dev/pci

2018-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Nov 24 14:41:56 UTC 2018

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Add Rockchip vendor ID and a device. Requested by jak@

>From OpenBSD


To generate a diff of this commit:
cvs rdiff -u -r1.1353 -r1.1354 src/sys/dev/pci/pcidevs

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/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1353 src/sys/dev/pci/pcidevs:1.1354
--- src/sys/dev/pci/pcidevs:1.1353	Sat Nov 24 14:37:48 2018
+++ src/sys/dev/pci/pcidevs	Sat Nov 24 14:41:56 2018
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1353 2018/11/24 14:37:48 skrll Exp $
+$NetBSD: pcidevs,v 1.1354 2018/11/24 14:41:56 skrll Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -649,6 +649,7 @@ vendor QINHENG2		0x1c00	Nanjing QinHeng 
 vendor SYMPHONY2	0x1c1c	Symphony Labs (2nd PCI Vendor ID)
 vendor HGST		0x1c58	HGST, Inc.
 vendor BEIJING_MEMBLAZE	0x1c5f	Beijing Memblaze Technology Co. Ltd.
+vendor ROCKCHIP		0x1d87	Rockchip
 vendor TEKRAM2		0x1de1	Tekram Technology (2nd PCI Vendor ID)
 vendor SUNIX2		0x1fd4	SUNIX Co
 vendor HINT		0x3388	HiNT
@@ -6758,6 +6759,9 @@ product RISCOM N2	0x5568	N2
 /* RNS products */
 product RNS FDDI	0x2200	2200 FDDI
 
+/* Rockchip products */
+product ROCKCHIP RK3399_RC	0x0100	RK3399 Root Complex
+ 
 /* S2io products */
 product S2IO XFRAME	0x5831	Xframe 10 Gigabit Ethernet Adapter
 product S2IO XFRAME2	0x5832	Xframe2 10 Gigabit Ethernet Adapter



CVS commit: src/sys/dev/pci

2018-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Nov 24 14:37:48 UTC 2018

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Add a whole bunch of Cavium ThunderX devices


To generate a diff of this commit:
cvs rdiff -u -r1.1352 -r1.1353 src/sys/dev/pci/pcidevs

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/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1352 src/sys/dev/pci/pcidevs:1.1353
--- src/sys/dev/pci/pcidevs:1.1352	Mon Nov 12 04:37:26 2018
+++ src/sys/dev/pci/pcidevs	Sat Nov 24 14:37:48 2018
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1352 2018/11/12 04:37:26 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1353 2018/11/24 14:37:48 skrll Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -1935,7 +1935,58 @@ product BUSLOGIC FLASHPOINT	0x8130	Flash
 product C4T GPPCI		0x6773	GPPCI
 
 /* Cavium products */
-product CAVIUM NITROX		0x0001	Nitrox XL
+product CAVIUM NITROX			0x0001	Nitrox XL
+product CAVIUM THUNDERX_MRML		0xa001	Master RML Bridge to RSL devices
+product CAVIUM THUNDERX_PCIB		0xa002	PCI Bridge
+product CAVIUM THUNDERX_RESET		0xa00e	Reset Controller
+product CAVIUM THUNDERX_RNG		0xa018	Random Number Generator
+product CAVIUM THUNDERX_XHCI		0xa01b	xHCI USB Controller
+product CAVIUM THUNDERX_AHCI		0xa01c	AHCI SATA Controller
+product CAVIUM THUNDERX_RAID		0xa01d	RAID Coprocessor
+product CAVIUM THUNDERX_NIC		0xa01e	Network Interface Controller
+product CAVIUM THUNDERX_TNS		0xa01f	Traffic Network Switch
+product CAVIUM THUNDERX_LMC		0xa022	DRAM Controller
+product CAVIUM THUNDERX_BGX		0xa026	Common Ethernet Interface
+product CAVIUM THUNDERX_L2C_TAD		0xa02e	Level 2 cache tag and data
+product CAVIUM THUNDERX_L2C_CBC		0xa02f	L2C-CBC
+product CAVIUM THUNDERX_L2C_MCI		0xa030	L2C-MCI
+
+product CAVIUM THUNDERX_SMMU		0xa008	SMMU
+product CAVIUM THUNDERX_GIC		0xa009	Generic Interrupt Controller
+product CAVIUM THUNDERX_GPIO		0xa00a	GPIO Controller
+product CAVIUM THUNDERX_MPI_SPI		0xa00b	MPI / SPI Controller
+product CAVIUM THUNDERX_MIO_PTP		0xa00c	MIO-PTP Controller
+product CAVIUM THUNDERX_MIX		0xa00d	MIX Network Controller
+product CAVIUM THUNDERX_UART		0xa00f	UART Controller
+product CAVIUM THUNDERX_EMMC_SD		0xa010	eMMC/SD Controller
+product CAVIUM THUNDERX_MIO_BOOT	0xa011	MIO-BOOT Controller
+product CAVIUM THUNDERX_TWSI_I2C	0xa012	TWSI / I2C Controller
+product CAVIUM THUNDERX_CCPI		0xa013	CCPI (Multi-node connect)
+product CAVIUM THUNDERX_VRM		0xa014	Voltage Regulator Module
+product CAVIUM THUNDERX_PSLI		0xa015	PCIe Switch Logic Interface
+product CAVIUM THUNDERX_KM		0xa016	Key Memory
+product CAVIUM THUNDERX_GST		0xa017	GTI (Global System Timers)
+product CAVIUM THUNDERX_DFA		0xa019	DFA
+product CAVIUM THUNDERX_ZIP		0xa01a	Zip Coprocessor
+product CAVIUM THUNDERX_PEM		0xa020	PEM (PCI Express Interface)
+product CAVIUM THUNDERX_L2C		0xa021	L2C (Level-2 Cache Controller)
+product CAVIUM THUNDERX_OCLA		0xa023	OCLA (On-Chip Logic Analyzer)
+product CAVIUM THUNDERX_OSM		0xa024	OSM
+product CAVIUM THUNDERX_GSER		0xa025	GSER (General Serializer/Deserializer)
+product CAVIUM THUNDERX_IOBN		0xa027	IOBN
+product CAVIUM THUNDERX_NCSCI		0xa029	NCSI (Network Controller Sideband Interface)
+product CAVIUM THUNDERX_SGPIO		0xa02a	SGPIO (Serial GPIO controller for SATA disk lights)
+product CAVIUM THUNDERX_SMI_MDIO	0xa02b	SMI / MDIO Controller
+product CAVIUM THUNDERX_DAP		0xa02c	DAP (Debug Access Port)
+product CAVIUM THUNDERX_PCIERC		0xa02d	PCIERC (PCIe Root Complex)
+product CAVIUM THUNDERX_MIOS_FUS	0xa031	MIO-FUS (Fuse Access Controller)
+product CAVIUM THUNDERX_FUSE		0xa032	FUSF (Fuse Controller)
+product CAVIUM THUNDERX_RNGVF		0xa033	Random Number Generator virtual function
+product CAVIUM THUNDERX_NICVF		0xa034	Network Interface Controller virtual function
+product CAVIUM THUNDERX_PB		0xa035	Parallel Bus
+product CAVIUM THUNDERX_RAIDVF		0xa036	RAD (RAID acceleration engine) virtual function
+product CAVIUM THUNDERX_ZIPVF		0xa037	ZIP virtual function
+product CAVIUM THUNDERX_CA		0xa040	CPT Cryptographic Accelerator
 
 /* Chelsio products */
 product CHELSIO PE9000		0x0020	PE9000 10GbE



CVS commit: src/usr.bin/xlint/lint1

2018-11-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov 24 13:10:21 UTC 2018

Modified Files:
src/usr.bin/xlint/lint1: cgram.y scan.l

Log Message:
add warn_unused_result.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.84 -r1.85 src/usr.bin/xlint/lint1/scan.l

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/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.98 src/usr.bin/xlint/lint1/cgram.y:1.99
--- src/usr.bin/xlint/lint1/cgram.y:1.98	Mon Sep  3 11:16:33 2018
+++ src/usr.bin/xlint/lint1/cgram.y	Sat Nov 24 08:10:20 2018
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.98 2018/09/03 15:16:33 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.99 2018/11/24 13:10:20 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.98 2018/09/03 15:16:33 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.99 2018/11/24 13:10:20 christos Exp $");
 #endif
 
 #include 
@@ -234,6 +234,7 @@ anonymize(sym_t *s)
 %token 		T_AT_UNUSED
 %token 		T_AT_USED
 %token 		T_AT_VISIBILITY
+%token 		T_AT_WARN_UNUSED_RESULT
 %token 		T_AT_WEAK
 
 %left	T_COMMA
@@ -561,6 +562,7 @@ type_attribute_spec:
 	| T_AT_UNUSED {
 		addused();
 	}
+	| T_AT_WARN_UNUSED_RESULT
 	| T_AT_WEAK
 	| T_AT_VISIBILITY T_LPARN constant T_RPARN
 	| T_QUAL {

Index: src/usr.bin/xlint/lint1/scan.l
diff -u src/usr.bin/xlint/lint1/scan.l:1.84 src/usr.bin/xlint/lint1/scan.l:1.85
--- src/usr.bin/xlint/lint1/scan.l:1.84	Sun Oct  7 10:20:01 2018
+++ src/usr.bin/xlint/lint1/scan.l	Sat Nov 24 08:10:20 2018
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.84 2018/10/07 14:20:01 christos Exp $ */
+/* $NetBSD: scan.l,v 1.85 2018/11/24 13:10:20 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: scan.l,v 1.84 2018/10/07 14:20:01 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.85 2018/11/24 13:10:20 christos Exp $");
 #endif
 
 #include 
@@ -291,6 +291,7 @@ static	struct	kwtab {
 	{ "visibility", T_AT_VISIBILITY,0,	0,	0,	  0,0,1,1,5 },
 	{ "void",	T_TYPE,		0,	VOID,	0,	  0,0,0,0,1 },
 	{ "volatile",	T_QUAL,		0,	0,	VOLATILE, 1,0,0,0,7 },
+	{ "warn_unused_result", T_AT_WARN_UNUSED_RESULT, 0, 0, 0, 0,0,1,1,5 },
 	{ "weak",	T_AT_WEAK,	0,	0,	0,	  0,0,1,1,5 },
 	{ "while",	T_WHILE,	0,	0,	0,	  0,0,0,0,1 },
 	{ NULL,		0,		0,	0,	0,	  0,0,0,0,0 }



CVS commit: src/libexec/httpd

2018-11-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov 24 13:08:11 UTC 2018

Modified Files:
src/libexec/httpd: bozohttpd.c

Log Message:
- add FALLTHROUGH comment
- one return is usually enough.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/libexec/httpd/bozohttpd.c

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

Modified files:

Index: src/libexec/httpd/bozohttpd.c
diff -u src/libexec/httpd/bozohttpd.c:1.96 src/libexec/httpd/bozohttpd.c:1.97
--- src/libexec/httpd/bozohttpd.c:1.96	Fri Nov 23 21:35:13 2018
+++ src/libexec/httpd/bozohttpd.c	Sat Nov 24 08:08:10 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bozohttpd.c,v 1.96 2018/11/24 02:35:13 mrg Exp $	*/
+/*	$NetBSD: bozohttpd.c,v 1.97 2018/11/24 13:08:10 christos Exp $	*/
 
 /*	$eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $	*/
 
@@ -1018,6 +1018,7 @@ bozo_escape_rfc3986(bozohttpd_t *httpd, 
 		case '"':
 			if (absolute)
 goto leave_it;
+			/*FALLTHROUGH*/
 		case '\n':
 		case '\r':
 		case ' ':
@@ -1026,8 +1027,8 @@ bozo_escape_rfc3986(bozohttpd_t *httpd, 
 			d += 3;
 			len += 3;
 			break;
-		leave_it:
 		default:
+		leave_it:
 			*d++ = *s++;
 			len++;
 			break;
@@ -1477,7 +1478,6 @@ check_bzredirect(bozo_httpreq_t *request
 			 REDIRECT_FILE) >= sizeof(redir)) {
 		return bozo_http_error(httpd, 404, request,
 		"redirectfile path too long");
-		return -1;
 	}
 	if (lstat(redir, ) == 0) {
 		if (!S_ISLNK(sb.st_mode))



CVS commit: src/libexec/httpd

2018-11-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov 24 13:03:15 UTC 2018

Modified Files:
src/libexec/httpd: cgi-bozo.c

Log Message:
appease lint


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/libexec/httpd/cgi-bozo.c

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

Modified files:

Index: src/libexec/httpd/cgi-bozo.c
diff -u src/libexec/httpd/cgi-bozo.c:1.44 src/libexec/httpd/cgi-bozo.c:1.45
--- src/libexec/httpd/cgi-bozo.c:1.44	Fri Nov 23 03:11:20 2018
+++ src/libexec/httpd/cgi-bozo.c	Sat Nov 24 08:03:15 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgi-bozo.c,v 1.44 2018/11/23 08:11:20 mrg Exp $	*/
+/*	$NetBSD: cgi-bozo.c,v 1.45 2018/11/24 13:03:15 christos Exp $	*/
 
 /*	$eterna: cgi-bozo.c,v 1.40 2011/11/18 09:21:15 mrg Exp $	*/
 
@@ -234,14 +234,14 @@ parse_search_string(bozo_httpreq_t *requ
 	 */
 	*args_len = 1;
 	/* count '+' in str */
-	for (s = str; (s = strchr(s, '+')); (*args_len)++)
+	for (s = str; (s = strchr(s, '+')) != NULL; (*args_len)++)
 		s++;
 	
 	args = bozomalloc(httpd, sizeof(*args) * (*args_len + 1));
  
 	args[0] = str;
 	args[*args_len] = NULL;
-	for (s = str, i = 0; (s = strchr(s, '+'));) {
+	for (s = str, i = 0; (s = strchr(s, '+')) != NULL;) {
 		*s = '\0';
 		s++;
 		args[i++] = s;



CVS commit: src/libexec/httpd

2018-11-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov 24 13:02:46 UTC 2018

Modified Files:
src/libexec/httpd: bozohttpd.h

Log Message:
one semicolon is usually enough.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/libexec/httpd/bozohttpd.h

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

Modified files:

Index: src/libexec/httpd/bozohttpd.h
diff -u src/libexec/httpd/bozohttpd.h:1.56 src/libexec/httpd/bozohttpd.h:1.57
--- src/libexec/httpd/bozohttpd.h:1.56	Thu Nov 22 03:54:08 2018
+++ src/libexec/httpd/bozohttpd.h	Sat Nov 24 08:02:46 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bozohttpd.h,v 1.56 2018/11/22 08:54:08 mrg Exp $	*/
+/*	$NetBSD: bozohttpd.h,v 1.57 2018/11/24 13:02:46 christos Exp $	*/
 
 /*	$eterna: bozohttpd.h,v 1.39 2011/11/18 09:21:15 mrg Exp $	*/
 
@@ -407,7 +407,7 @@ void	bozo_add_content_map_cgi(bozohttpd_
 #endif
 
 /* I/O */
-int bozo_printf(bozohttpd_t *, const char *, ...) BOZO_PRINTFLIKE(2, 3);;
+int bozo_printf(bozohttpd_t *, const char *, ...) BOZO_PRINTFLIKE(2, 3);
 ssize_t bozo_read(bozohttpd_t *, int, void *, size_t);
 ssize_t bozo_write(bozohttpd_t *, int, const void *, size_t);
 int bozo_flush(bozohttpd_t *, FILE *);



CVS commit: src/lib/libedit

2018-11-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov 24 12:17:35 UTC 2018

Modified Files:
src/lib/libedit: terminal.c

Log Message:
PR/53682: Jordan Lewis: use newlines instead of padded spaces when restoring
multi-line histories.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/lib/libedit/terminal.c

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

Modified files:

Index: src/lib/libedit/terminal.c
diff -u src/lib/libedit/terminal.c:1.33 src/lib/libedit/terminal.c:1.34
--- src/lib/libedit/terminal.c:1.33	Tue Jun 27 19:23:09 2017
+++ src/lib/libedit/terminal.c	Sat Nov 24 07:17:35 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: terminal.c,v 1.33 2017/06/27 23:23:09 christos Exp $	*/
+/*	$NetBSD: terminal.c,v 1.34 2018/11/24 12:17:35 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)term.c	8.2 (Berkeley) 4/30/95";
 #else
-__RCSID("$NetBSD: terminal.c,v 1.33 2017/06/27 23:23:09 christos Exp $");
+__RCSID("$NetBSD: terminal.c,v 1.34 2018/11/24 12:17:35 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -509,36 +509,14 @@ terminal_move_to_line(EditLine *el, int 
 		return;
 	}
 	if ((del = where - el->el_cursor.v) > 0) {
-		while (del > 0) {
-			if (EL_HAS_AUTO_MARGINS &&
-			el->el_display[el->el_cursor.v][0] != '\0') {
-size_t h = (size_t)
-(el->el_terminal.t_size.h - 1);
-for (; h > 0 &&
- el->el_display[el->el_cursor.v][h] ==
- MB_FILL_CHAR;
- h--)
-continue;
-/* move without newline */
-terminal_move_to_char(el, (int)h);
-terminal_overwrite(el, >el_display
-[el->el_cursor.v][el->el_cursor.h],
-(size_t)(el->el_terminal.t_size.h -
-el->el_cursor.h));
-/* updates Cursor */
-del--;
-			} else {
-if ((del > 1) && GoodStr(T_DO)) {
-	terminal_tputs(el, tgoto(Str(T_DO), del,
-	del), del);
-	del = 0;
-} else {
-	for (; del > 0; del--)
-		terminal__putc(el, '\n');
-	/* because the \n will become \r\n */
-	el->el_cursor.h = 0;
-}
-			}
+		if ((del > 1) && GoodStr(T_DO)) {
+			terminal_tputs(el, tgoto(Str(T_DO), del, del), del);
+			del = 0;
+		} else {
+			for (; del > 0; del--)
+terminal__putc(el, '\n');
+			/* because the \n will become \r\n */
+			el->el_cursor.h = 0;
 		}
 	} else {		/* del < 0 */
 		if (GoodStr(T_UP) && (-del > 1 || !GoodStr(T_up)))



CVS commit: src/external/gpl2/lvm2/dist/libdm/ioctl

2018-11-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Nov 24 11:27:37 UTC 2018

Modified Files:
src/external/gpl2/lvm2/dist/libdm/ioctl: libdm-nbsd-iface.c

Log Message:
Support device nodes that have no entry in /dev, identify them by major:minor
numbers like the original Linux code.

While here, fix a memory leak.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
src/external/gpl2/lvm2/dist/libdm/ioctl/libdm-nbsd-iface.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/gpl2/lvm2/dist/libdm/ioctl/libdm-nbsd-iface.c
diff -u src/external/gpl2/lvm2/dist/libdm/ioctl/libdm-nbsd-iface.c:1.11 src/external/gpl2/lvm2/dist/libdm/ioctl/libdm-nbsd-iface.c:1.12
--- src/external/gpl2/lvm2/dist/libdm/ioctl/libdm-nbsd-iface.c:1.11	Tue Feb  8 03:26:12 2011
+++ src/external/gpl2/lvm2/dist/libdm/ioctl/libdm-nbsd-iface.c	Sat Nov 24 11:27:37 2018
@@ -1,4 +1,4 @@
-/*  $NetBSD: libdm-nbsd-iface.c,v 1.11 2011/02/08 03:26:12 haad Exp $*/
+/*  $NetBSD: libdm-nbsd-iface.c,v 1.12 2018/11/24 11:27:37 mlelstv Exp $*/
 
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
@@ -25,7 +25,9 @@
 #include 
 
 #include 
+#include 
 #include 
+#include 
 #include 
 
 #include 
@@ -367,40 +369,31 @@ static int _unmarshal_status(struct dm_t
 }
 
 static char *
-get_dev_name(char *d_name, uint32_t d_major, uint32_t d_minor)
+get_dev_name(dev_t dev)
 {
+	static char * const dirs[2] = { _PATH_DEV, NULL };
 	static char d_buf[MAXPATHLEN];
-	struct dirent *dire;
-	struct stat st;
-	DIR *dev_dir;
-
-	int err;
+	FTS *ftsp;
+	FTSENT *fe;
 	char *name;
 
-	dev_dir = opendir("/dev");
-
-	while ((dire = readdir(dev_dir)) != NULL) {
+	if ((ftsp = fts_open(dirs, FTS_NOCHDIR | FTS_PHYSICAL, NULL)) == NULL)
+		return NULL;
 
-		if (strstr(dire->d_name, d_name) == NULL)
+	name = NULL;
+	while ((fe = fts_read(ftsp)) != NULL) {
+		if (fe->fts_info != FTS_DEFAULT)
 			continue;
-
-		snprintf(d_buf, MAXPATHLEN, "/dev/%s", dire->d_name);
-
-		if ((err = stat(d_buf, )) < 0)
-			printf("stat failed with %d", err);
-
-		if (st.st_mode & S_IFBLK){
-			if ((major(st.st_rdev) == d_major) && (minor(st.st_rdev) == d_minor)) {
-strncpy(d_buf, dire->d_name, strlen(dire->d_name) + 1);
+		if (S_ISBLK(fe->fts_statp->st_mode)) {
+			if (fe->fts_statp->st_rdev == dev) {
+strlcpy(d_buf, fe->fts_path, sizeof(d_buf));
 name = d_buf;
 break;
 			}
 		}
-
-		memset(d_buf, '0', sizeof(d_buf));
 	}
 
-	(void)closedir(dev_dir);
+	fts_close(ftsp);
 
 	return name;
 }
@@ -417,13 +410,15 @@ int dm_format_dev(char *buf, int bufsize
 		  uint32_t dev_minor)
 {
 	int r;
-	uint32_t major, dm_major;
+	uint32_t dm_major;
+	int major;
 	char *name;
 	mode_t mode;
 	dev_t dev;
 	size_t val_len,i;
 	struct kinfo_drivers *kd;
 
+	major = -1;
 	mode = 0;
 
 	nbsd_get_dm_major(_major, DM_BLOCK_MAJOR);
@@ -432,7 +427,7 @@ int dm_format_dev(char *buf, int bufsize
 		return 0;
 
 	if (sysctlbyname("kern.drivers",NULL,_len,NULL,0) < 0) {
-		printf("sysctlbyname failed");
+		printf("sysctlbyname failed\n");
 		return 0;
 	}
 
@@ -442,7 +437,8 @@ int dm_format_dev(char *buf, int bufsize
 	}
 
 	if (sysctlbyname("kern.drivers", kd, _len, NULL, 0) < 0) {
-		printf("sysctlbyname failed kd");
+		free(kd);
+		printf("sysctlbyname failed kd\n");
 		return 0;
 	}
 
@@ -453,18 +449,22 @@ int dm_format_dev(char *buf, int bufsize
 		}
 	}
 
-	dev = MKDEV(major,dev_minor);
-
-	mode |= S_IFBLK;
-
-	if ((name = devname(dev,mode)) == NULL)
-		name = get_dev_name(kd[i].d_name, major, dev_minor);
-
-	r = snprintf(buf, (size_t) bufsize, "/dev/%s",name);
+	if (major != -1) {
+		dev = MKDEV(major,dev_minor);
+		mode |= S_IFBLK;
+		if ((name = devname(dev,mode)) == NULL)
+			name = get_dev_name(dev);
+	} else
+		name = NULL;
 
 	free(kd);
 
-	if (r < 0 || r > bufsize - 1 || name == NULL)
+	if (name == NULL)
+		r = snprintf(buf, (size_t) bufsize, "%d:%d", dev_major, dev_minor);
+	else
+		r = snprintf(buf, (size_t) bufsize, _PATH_DEV "%s", name);
+
+	if (r < 0 || r > bufsize - 1)
 		return 0;
 
 	return 1;



CVS commit: src/lib/libcurses

2018-11-24 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Nov 24 11:04:39 UTC 2018

Modified Files:
src/lib/libcurses: curses_cchar.3

Log Message:
Grammar improvements.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libcurses/curses_cchar.3

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

Modified files:

Index: src/lib/libcurses/curses_cchar.3
diff -u src/lib/libcurses/curses_cchar.3:1.1 src/lib/libcurses/curses_cchar.3:1.2
--- src/lib/libcurses/curses_cchar.3:1.1	Mon Nov 19 01:08:22 2018
+++ src/lib/libcurses/curses_cchar.3	Sat Nov 24 11:04:39 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: curses_cchar.3,v 1.1 2018/11/19 01:08:22 uwe Exp $
+.\"	$NetBSD: curses_cchar.3,v 1.2 2018/11/24 11:04:39 wiz Exp $
 .\"
 .\" Copyright (c) 2018 Valery Ushakov
 .\" All rights reserved.
@@ -55,12 +55,12 @@
 .Fa "const void *opts"
 .Fc
 .Sh DESCRIPTION
-Curses uses opaque type
+Curses uses the opaque type
 .Vt cchar_t
 to represent a string of wide characters up to an
 implementation-dependent length along with a color pair and zero or
 more attributes.
-A null 
+A null
 .Vt cchar_t
 object is an object that references an empty wide-character string.
 Arrays of
@@ -71,19 +71,19 @@ object.
 .Pp
 Objects of type
 .Vt cchar_t
-can be manipulated using
+can be manipulated using the
 .Nm getcchar
 and
 .Nm setcchar
 functions.
-Both these functions take as their last paramter the
+Both these functions take as their last parameter the
 .Fa opts
 argument which is reserved for future extensions.
 Currently, the application must provide a null pointer as
 .Fa opts .
 .\"
 .Pp
-When
+When the
 .Nm getcchar
 function is called with non-null
 .Fa wch
@@ -96,7 +96,7 @@ is copied to the
 .Fa wch
 array.
 The attributes are stored in
-.Fa attrs ,
+.Fa attrs
 and the color pair is stored in
 .Fa color_pair .
 In this case it returns