CVS commit: src/common/lib/libc/gen

2024-05-04 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sat May  4 17:58:24 UTC 2024

Modified Files:
src/common/lib/libc/gen: radixtree.c

Log Message:
radixtree: allocate memory with KM_NOSLEEP to prevent pagedaemon hangs

Revert the part of rev 1.32 (reapplying "Do away with separate pool_cache
for some kernel objects") that changed the memory allocation for radixtree
nodes from PR_NOWAIT to KM_SLEEP as part of changing from a pool to kmem.
uvm_pageinsert_tree() calls into the radixtree code while holding
the object's vmobjlock, but that same lock is taken by the pagedaemon
in the process of reclaiming pages, and if the pagedaemon happens to
choose the same object to reclaim from that uvm_pageinsert_tree()
is being called on, then these two threads will deadlock.
The previous code already handled memory allocation failures
in uvm_pageinsert_tree() so we can simply change it back to nosleep.

Fixes a hang reported by simonb@, and the fix was also tested by him.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/common/lib/libc/gen/radixtree.c

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

Modified files:

Index: src/common/lib/libc/gen/radixtree.c
diff -u src/common/lib/libc/gen/radixtree.c:1.33 src/common/lib/libc/gen/radixtree.c:1.34
--- src/common/lib/libc/gen/radixtree.c:1.33	Sat Sep 23 19:17:38 2023
+++ src/common/lib/libc/gen/radixtree.c	Sat May  4 17:58:24 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: radixtree.c,v 1.33 2023/09/23 19:17:38 ad Exp $	*/
+/*	$NetBSD: radixtree.c,v 1.34 2024/05/04 17:58:24 chs Exp $	*/
 
 /*-
  * Copyright (c)2011,2012,2013 YAMAMOTO Takashi,
@@ -112,7 +112,7 @@
 #include 
 
 #if defined(_KERNEL) || defined(_STANDALONE)
-__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.33 2023/09/23 19:17:38 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.34 2024/05/04 17:58:24 chs Exp $");
 #include 
 #include 
 #include 
@@ -122,7 +122,7 @@ __KERNEL_RCSID(0, "$NetBSD: radixtree.c,
 #include 
 #endif /* defined(_STANDALONE) */
 #else /* defined(_KERNEL) || defined(_STANDALONE) */
-__RCSID("$NetBSD: radixtree.c,v 1.33 2023/09/23 19:17:38 ad Exp $");
+__RCSID("$NetBSD: radixtree.c,v 1.34 2024/05/04 17:58:24 chs Exp $");
 #include 
 #include 
 #include 
@@ -410,9 +410,10 @@ radix_tree_alloc_node(void)
 
 #if defined(_KERNEL)
 	/*
-	 * note that kmem_alloc can block.
+	 * We must not block waiting for memory because this function
+	 * can be called in contexts where waiting for memory is illegal.
 	 */
-	n = kmem_intr_alloc(sizeof(struct radix_tree_node), KM_SLEEP);
+	n = kmem_intr_alloc(sizeof(struct radix_tree_node), KM_NOSLEEP);
 #elif defined(_STANDALONE)
 	n = alloc(sizeof(*n));
 #else /* defined(_STANDALONE) */



CVS commit: src/common/lib/libc/gen

2024-05-04 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sat May  4 17:58:24 UTC 2024

Modified Files:
src/common/lib/libc/gen: radixtree.c

Log Message:
radixtree: allocate memory with KM_NOSLEEP to prevent pagedaemon hangs

Revert the part of rev 1.32 (reapplying "Do away with separate pool_cache
for some kernel objects") that changed the memory allocation for radixtree
nodes from PR_NOWAIT to KM_SLEEP as part of changing from a pool to kmem.
uvm_pageinsert_tree() calls into the radixtree code while holding
the object's vmobjlock, but that same lock is taken by the pagedaemon
in the process of reclaiming pages, and if the pagedaemon happens to
choose the same object to reclaim from that uvm_pageinsert_tree()
is being called on, then these two threads will deadlock.
The previous code already handled memory allocation failures
in uvm_pageinsert_tree() so we can simply change it back to nosleep.

Fixes a hang reported by simonb@, and the fix was also tested by him.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/common/lib/libc/gen/radixtree.c

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



CVS commit: src/sys/dev/pci

2024-01-08 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Jan  8 18:38:25 UTC 2024

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

Log Message:
ips: fix a couple more device_t/softc split bugs


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/ips.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/ips.c
diff -u src/sys/dev/pci/ips.c:1.6 src/sys/dev/pci/ips.c:1.7
--- src/sys/dev/pci/ips.c:1.6	Sat Feb 12 02:58:50 2022
+++ src/sys/dev/pci/ips.c	Mon Jan  8 18:38:25 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ips.c,v 1.6 2022/02/12 02:58:50 riastradh Exp $	*/
+/*	$NetBSD: ips.c,v 1.7 2024/01/08 18:38:25 chs Exp $	*/
 /*	$OpenBSD: ips.c,v 1.113 2016/08/14 04:08:03 dlg Exp $	*/
 
 /*-
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ips.c,v 1.6 2022/02/12 02:58:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ips.c,v 1.7 2024/01/08 18:38:25 chs Exp $");
 
 #include "bio.h"
 
@@ -458,7 +458,7 @@ struct ips_softc {
 };
 
 int	ips_match(device_t, cfdata_t, void *);
-void	ips_attach(struct device *, struct device *, void *);
+void	ips_attach(device_t, device_t, void *);
 
 void	ips_scsi_cmd(struct ips_ccb *);
 void	ips_scsi_pt_cmd(struct scsipi_xfer *);
@@ -617,9 +617,9 @@ ips_match(device_t parent, cfdata_t cfda
 }
 
 void
-ips_attach(struct device *parent, struct device *self, void *aux)
+ips_attach(device_t parent, device_t self, void *aux)
 {
-	struct ips_softc *sc = (struct ips_softc *)self;
+	struct ips_softc *sc = device_private(self);
 	struct pci_attach_args *pa = aux;
 	struct ips_ccb ccb0;
 	struct ips_adapterinfo *ai;
@@ -1042,7 +1042,7 @@ ips_scsi_ioctl(struct scsipi_channel *ch
 int
 ips_ioctl(device_t dev, u_long cmd, void *data)
 {
-	struct ips_softc *sc = (struct ips_softc *)dev;
+	struct ips_softc *sc = device_private(dev);
 
 	DPRINTF(IPS_D_INFO, ("%s: ips_ioctl: cmd %lu\n",
 	device_xname(sc->sc_dev), cmd));
@@ -1086,7 +1086,7 @@ ips_ioctl_vol(struct ips_softc *sc, stru
 	struct ips_rblstat *rblstat = >sc_info->rblstat;
 	struct ips_ld *ld;
 	int vid = bv->bv_volid;
-	struct device *dv;
+	device_t dv;
 	int error, rebuild = 0;
 	u_int32_t total = 0, done = 0;
 



CVS commit: src/sys/dev/pci

2024-01-08 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Jan  8 18:38:25 UTC 2024

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

Log Message:
ips: fix a couple more device_t/softc split bugs


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/ips.c

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



CVS commit: src/sys/dev/pci

2024-01-08 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Jan  8 18:37:24 UTC 2024

Modified Files:
src/sys/dev/pci: cmpci.c fms.c sv.c yds.c

Log Message:
mpu / opl: add an interface attribute to config_found() calls for these

specify an interface attribute when attaching mpu and opl devices.
the PCI devices that are the parents of these midi devices
(cmpci, eso, fms, sv, yds) have two interface attributes:
"audiobus", and also one named the same as the parent device,
eg. "cmpci" has an interface attribute named "cmpci".
we must specify the latter one to attach these children.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/dev/pci/cmpci.c
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/pci/fms.c
cvs rdiff -u -r1.61 -r1.62 src/sys/dev/pci/sv.c
cvs rdiff -u -r1.68 -r1.69 src/sys/dev/pci/yds.c

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



CVS commit: src/sys/dev/pci

2024-01-08 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Jan  8 18:37:24 UTC 2024

Modified Files:
src/sys/dev/pci: cmpci.c fms.c sv.c yds.c

Log Message:
mpu / opl: add an interface attribute to config_found() calls for these

specify an interface attribute when attaching mpu and opl devices.
the PCI devices that are the parents of these midi devices
(cmpci, eso, fms, sv, yds) have two interface attributes:
"audiobus", and also one named the same as the parent device,
eg. "cmpci" has an interface attribute named "cmpci".
we must specify the latter one to attach these children.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/dev/pci/cmpci.c
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/pci/fms.c
cvs rdiff -u -r1.61 -r1.62 src/sys/dev/pci/sv.c
cvs rdiff -u -r1.68 -r1.69 src/sys/dev/pci/yds.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/cmpci.c
diff -u src/sys/dev/pci/cmpci.c:1.60 src/sys/dev/pci/cmpci.c:1.61
--- src/sys/dev/pci/cmpci.c:1.60	Tue May 31 08:43:15 2022
+++ src/sys/dev/pci/cmpci.c	Mon Jan  8 18:37:24 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: cmpci.c,v 1.60 2022/05/31 08:43:15 andvar Exp $	*/
+/*	$NetBSD: cmpci.c,v 1.61 2024/01/08 18:37:24 chs Exp $	*/
 
 /*
  * Copyright (c) 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cmpci.c,v 1.60 2022/05/31 08:43:15 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cmpci.c,v 1.61 2024/01/08 18:37:24 chs Exp $");
 
 #if defined(AUDIO_DEBUG) || defined(DEBUG)
 #define DPRINTF(x) if (cmpcidebug) printf x
@@ -419,7 +419,7 @@ cmpci_attach(device_t parent, device_t s
 	aa.type = AUDIODEV_TYPE_OPL;
 	aa.hwif = NULL;
 	aa.hdl = NULL;
-	(void)config_found(sc->sc_dev, , audioprint, CFARGS_NONE);
+	(void)config_found(sc->sc_dev, , audioprint, CFARGS(.iattr = "cmpci"));
 
 	/* attach MPU-401 device */
 	aa.type = AUDIODEV_TYPE_MPU;
@@ -428,7 +428,7 @@ cmpci_attach(device_t parent, device_t s
 	if (bus_space_subregion(sc->sc_iot, sc->sc_ioh,
 	CMPCI_REG_MPU_BASE, CMPCI_REG_MPU_SIZE, >sc_mpu_ioh) == 0)
 		sc->sc_mpudev = config_found(sc->sc_dev, , audioprint,
-		CFARGS_NONE);
+		CFARGS(.iattr = "cmpci"));
 
 	/* get initial value (this is 0 and may be omitted but just in case) */
 	sc->sc_reg_misc = bus_space_read_4(sc->sc_iot, sc->sc_ioh,

Index: src/sys/dev/pci/fms.c
diff -u src/sys/dev/pci/fms.c:1.49 src/sys/dev/pci/fms.c:1.50
--- src/sys/dev/pci/fms.c:1.49	Sat Aug  7 16:19:14 2021
+++ src/sys/dev/pci/fms.c	Mon Jan  8 18:37:24 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: fms.c,v 1.49 2021/08/07 16:19:14 thorpej Exp $	*/
+/*	$NetBSD: fms.c,v 1.50 2024/01/08 18:37:24 chs Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fms.c,v 1.49 2021/08/07 16:19:14 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fms.c,v 1.50 2024/01/08 18:37:24 chs Exp $");
 
 #include "mpu.h"
 
@@ -325,12 +325,13 @@ fms_attach(device_t parent, device_t sel
 	aa.type = AUDIODEV_TYPE_OPL;
 	aa.hwif = NULL;
 	aa.hdl = NULL;
-	config_found(sc->sc_dev, , audioprint, CFARGS_NONE);
+	config_found(sc->sc_dev, , audioprint, CFARGS(.iattr = "fms"));
 
 	aa.type = AUDIODEV_TYPE_MPU;
 	aa.hwif = NULL;
 	aa.hdl = NULL;
-	sc->sc_mpu_dev = config_found(sc->sc_dev, , audioprint, CFARGS_NONE);
+	sc->sc_mpu_dev = config_found(sc->sc_dev, , audioprint,
+	CFARGS(.iattr = "fms"));
 }
 
 /*

Index: src/sys/dev/pci/sv.c
diff -u src/sys/dev/pci/sv.c:1.61 src/sys/dev/pci/sv.c:1.62
--- src/sys/dev/pci/sv.c:1.61	Sat Aug  7 16:19:14 2021
+++ src/sys/dev/pci/sv.c	Mon Jan  8 18:37:24 2024
@@ -1,4 +1,4 @@
-/*  $NetBSD: sv.c,v 1.61 2021/08/07 16:19:14 thorpej Exp $ */
+/*  $NetBSD: sv.c,v 1.62 2024/01/08 18:37:24 chs Exp $ */
 /*  $OpenBSD: sv.c,v 1.2 1998/07/13 01:50:15 csapuntz Exp $ */
 
 /*
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sv.c,v 1.61 2021/08/07 16:19:14 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sv.c,v 1.62 2024/01/08 18:37:24 chs Exp $");
 
 #include 
 #include 
@@ -449,7 +449,7 @@ sv_attach(device_t parent, device_t self
 	arg.type = AUDIODEV_TYPE_OPL;
 	arg.hwif = 0;
 	arg.hdl = 0;
-	(void)config_found(self, , audioprint, CFARGS_NONE);
+	(void)config_found(self, , audioprint, CFARGS(.iattr = "sv"));
 
 	sc->sc_pa = *pa;	/* for deferred setup */
 	config_defer(self, sv_defer);

Index: src/sys/dev/pci/yds.c
diff -u src/sys/dev/pci/yds.c:1.68 src/sys/dev/pci/yds.c:1.69
--- src/sys/dev/pci/yds.c:1.68	Sat Aug  7 16:19:14 2021
+++ src/sys/dev/pci/yds.c	Mon Jan  8 18:37:24 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: yds.c,v 1.68 2021/08/07 16:19:14 thorpej Exp $	*/
+/*	$NetBSD: yds.c,v 1.69 2024/01/08 18:37:24 chs Exp $	*/
 
 /*
  * Copyright (c) 2000, 2001 Kazuki Sakamoto and Minoura Makoto.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: yds.c,v 1.68 2021/08/07 16:19:14 thorpej Exp $");

CVS commit: src/sys/net

2023-12-29 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Fri Dec 29 23:01:02 UTC 2023

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

Log Message:
tun: add missing kpreempt_enable() if pktq_enqueue() fails


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/sys/net/if_tun.c

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



CVS commit: src/sys/net

2023-12-29 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Fri Dec 29 23:01:02 UTC 2023

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

Log Message:
tun: add missing kpreempt_enable() if pktq_enqueue() fails


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/sys/net/if_tun.c

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

Modified files:

Index: src/sys/net/if_tun.c
diff -u src/sys/net/if_tun.c:1.173 src/sys/net/if_tun.c:1.174
--- src/sys/net/if_tun.c:1.173	Mon Mar 28 12:33:22 2022
+++ src/sys/net/if_tun.c	Fri Dec 29 23:01:02 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_tun.c,v 1.173 2022/03/28 12:33:22 riastradh Exp $	*/
+/*	$NetBSD: if_tun.c,v 1.174 2023/12/29 23:01:02 chs Exp $	*/
 
 /*
  * Copyright (c) 1988, Julian Onions 
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.173 2022/03/28 12:33:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.174 2023/12/29 23:01:02 chs Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -982,6 +982,7 @@ tunwrite(dev_t dev, struct uio *uio, int
 	}
 	kpreempt_disable();
 	if (__predict_false(!pktq_enqueue(pktq, top, 0))) {
+		kpreempt_enable();
 		if_statinc(ifp, if_collisions);
 		mutex_exit(>tun_lock);
 		error = ENOBUFS;



CVS commit: src/sys/external/bsd/drm2/include/linux

2023-12-29 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Fri Dec 29 22:58:24 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/include/linux: smp.h

Log Message:
drm: put_cpu() should enable preemption, not disable it again


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/include/linux/smp.h

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



CVS commit: src/sys/external/bsd/drm2/include/linux

2023-12-29 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Fri Dec 29 22:58:24 UTC 2023

Modified Files:
src/sys/external/bsd/drm2/include/linux: smp.h

Log Message:
drm: put_cpu() should enable preemption, not disable it again


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/include/linux/smp.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/external/bsd/drm2/include/linux/smp.h
diff -u src/sys/external/bsd/drm2/include/linux/smp.h:1.4 src/sys/external/bsd/drm2/include/linux/smp.h:1.5
--- src/sys/external/bsd/drm2/include/linux/smp.h:1.4	Sun Dec 19 11:49:12 2021
+++ src/sys/external/bsd/drm2/include/linux/smp.h	Fri Dec 29 22:58:23 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: smp.h,v 1.4 2021/12/19 11:49:12 riastradh Exp $	*/
+/*	$NetBSD: smp.h,v 1.5 2023/12/29 22:58:23 chs Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@ static inline void
 put_cpu(void)
 {
 
-	kpreempt_disable();
+	kpreempt_enable();
 }
 
 static inline void



CVS commit: src

2023-11-03 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Fri Nov  3 09:07:57 UTC 2023

Modified Files:
src/external/cddl/osnet/dev/dtrace/amd64: dtrace_asm.S
src/external/cddl/osnet/dev/dtrace/i386: dtrace_asm.S
src/sys/arch/amd64/amd64: cpufunc.S
src/sys/arch/i386/i386: cpufunc.S

Log Message:
dtrace: add support for SMAP

Add support in dtrace for SMAP, so that actions like copyinstr() work.
It would be better if dtrace could use the SMAP_* hotpatch macros directly,
but the hotpatching code does not currently operate on kernel modules,
so we'll use some tiny functions in the base kernel for now.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S
cvs rdiff -u -r1.7 -r1.8 src/external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/i386/i386/cpufunc.S

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



CVS commit: src

2023-11-03 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Fri Nov  3 09:07:57 UTC 2023

Modified Files:
src/external/cddl/osnet/dev/dtrace/amd64: dtrace_asm.S
src/external/cddl/osnet/dev/dtrace/i386: dtrace_asm.S
src/sys/arch/amd64/amd64: cpufunc.S
src/sys/arch/i386/i386: cpufunc.S

Log Message:
dtrace: add support for SMAP

Add support in dtrace for SMAP, so that actions like copyinstr() work.
It would be better if dtrace could use the SMAP_* hotpatch macros directly,
but the hotpatching code does not currently operate on kernel modules,
so we'll use some tiny functions in the base kernel for now.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S
cvs rdiff -u -r1.7 -r1.8 src/external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/i386/i386/cpufunc.S

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

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S
diff -u src/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S:1.8 src/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S:1.9
--- src/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S:1.8	Mon May 28 21:05:03 2018
+++ src/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S	Fri Nov  3 09:07:56 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_asm.S,v 1.8 2018/05/28 21:05:03 chs Exp $	*/
+/*	$NetBSD: dtrace_asm.S,v 1.9 2023/11/03 09:07:56 chs Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -39,6 +39,11 @@
 
 #include "assym.h"
 
+#define DTRACE_SMAP_DISABLE			\
+	call	dtrace_smap_disable
+#define DTRACE_SMAP_ENABLE			\
+	call	dtrace_smap_enable
+
 #define INTR_POP\
 	MEXITCOUNT;\
 	movq	TF_RDI(%rsp),%rdi;		\
@@ -217,8 +222,10 @@ dtrace_copy(uintptr_t src, uintptr_t des
 
 	xchgq	%rdi, %rsi		/* make %rsi source, %rdi dest */
 	movq	%rdx, %rcx		/* load count */
+	DTRACE_SMAP_DISABLE
 	repz/* repeat for count ... */
 	smovb/*   move from %ds:rsi to %ed:rdi */
+	DTRACE_SMAP_ENABLE
 	leave
 	ret
 	END(dtrace_copy)
@@ -231,6 +238,7 @@ dtrace_copystr(uintptr_t uaddr, uintptr_
 	ENTRY(dtrace_copystr)
 	pushq	%rbp
 	movq	%rsp, %rbp
+	DTRACE_SMAP_DISABLE
 
 0:
 	movb	(%rdi), %al		/* load from source */
@@ -248,6 +256,7 @@ dtrace_copystr(uintptr_t uaddr, uintptr_
 	cmpq	$0, %rdx
 	jne	0b
 2:
+	DTRACE_SMAP_ENABLE
 	leave
 	ret
 
@@ -258,7 +267,9 @@ uintptr_t
 dtrace_fulword(void *addr)
 */
 	ENTRY(dtrace_fulword)
+	DTRACE_SMAP_DISABLE
 	movq	(%rdi), %rax
+	DTRACE_SMAP_ENABLE
 	ret
 	END(dtrace_fulword)
 
@@ -268,7 +279,9 @@ dtrace_fuword8_nocheck(void *addr)
 */
 	ENTRY(dtrace_fuword8_nocheck)
 	xorq	%rax, %rax
+	DTRACE_SMAP_DISABLE
 	movb	(%rdi), %al
+	DTRACE_SMAP_ENABLE
 	ret
 	END(dtrace_fuword8_nocheck)
 
@@ -278,7 +291,9 @@ dtrace_fuword16_nocheck(void *addr)
 */
 	ENTRY(dtrace_fuword16_nocheck)
 	xorq	%rax, %rax
+	DTRACE_SMAP_DISABLE
 	movw	(%rdi), %ax
+	DTRACE_SMAP_ENABLE
 	ret
 	END(dtrace_fuword16_nocheck)
 
@@ -288,7 +303,9 @@ dtrace_fuword32_nocheck(void *addr)
 */
 	ENTRY(dtrace_fuword32_nocheck)
 	xorq	%rax, %rax
+	DTRACE_SMAP_DISABLE
 	movl	(%rdi), %eax
+	DTRACE_SMAP_ENABLE
 	ret
 	END(dtrace_fuword32_nocheck)
 
@@ -297,7 +314,9 @@ uint64_t
 dtrace_fuword64_nocheck(void *addr)
 */
 	ENTRY(dtrace_fuword64_nocheck)
+	DTRACE_SMAP_DISABLE
 	movq	(%rdi), %rax
+	DTRACE_SMAP_ENABLE
 	ret
 	END(dtrace_fuword64_nocheck)
 

Index: src/external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S
diff -u src/external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S:1.7 src/external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S:1.8
--- src/external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S:1.7	Mon May 28 21:05:03 2018
+++ src/external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S	Fri Nov  3 09:07:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_asm.S,v 1.7 2018/05/28 21:05:03 chs Exp $	*/
+/*	$NetBSD: dtrace_asm.S,v 1.8 2023/11/03 09:07:57 chs Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -38,6 +38,11 @@
 #include 
 #include 
 
+#define DTRACE_SMAP_DISABLE			\
+	call	dtrace_smap_disable
+#define DTRACE_SMAP_ENABLE			\
+	call	dtrace_smap_enable
+
 #define INTR_POP		\
 	addl	$16, %esp;	\
 	popl	%edi;		\
@@ -225,8 +230,10 @@ void dtrace_copy(uintptr_t src, uintptr_
 	movl	8(%ebp), %esi		/* Load source address */
 	movl	12(%ebp), %edi		/* Load destination address */
 	movl	16(%ebp), %ecx		/* Load count */
+	DTRACE_SMAP_DISABLE
 	repz/* Repeat for count... */
 	smovb/*   move from %ds:si to %es:di */
+	DTRACE_SMAP_ENABLE
 
 	popl	%edi
 	popl	%esi
@@ -248,6 +255,7 @@ void dtrace_copystr(uintptr_t uaddr, uin
 	movl	8(%ebp), %ebx		/* Load source address */
 	movl	12(%ebp), %edx		/* Load destination address */
 	movl	16(%ebp), %ecx		/* Load count */
+	DTRACE_SMAP_DISABLE
 
 0:
 	movb	(%ebx), %al		/* Load from source */
@@ -261,6 +269,7 @@ void dtrace_copystr(uintptr_t uaddr, uin
 	jne	0b
 
 1:
+	DTRACE_SMAP_ENABLE
 	popl	%ebx
 	movl	%ebp, %esp

CVS commit: src/sys/uvm

2023-08-13 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Aug 13 23:06:07 UTC 2023

Modified Files:
src/sys/uvm: uvm_fault.c

Log Message:
uvm: prevent TLB invalidation races during COW resolution

When a thread takes a page fault which results in COW resolution,
other threads in the same process can be concurrently accessing that
same mapping on other CPUs.  When the faulting thread updates the pmap
entry at the end of COW processing, the resulting TLB invalidations to
other CPUs are not done atomically, so another thread can write to the
new writable page and then a third thread might still read from the
old read-only page, resulting in inconsistent views of the page by the
latter two threads.  Fix this by removing the pmap entry entirely for
the original page before we install the new pmap entry for the new
page, so that the new page can only be modified after the old page is
no longer accessible.

This fixes PR 56535 as well as the netbsd versions of problems
described in various bug trackers:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=225584
https://reviews.freebsd.org/D14347
https://github.com/golang/go/issues/34988


To generate a diff of this commit:
cvs rdiff -u -r1.233 -r1.234 src/sys/uvm/uvm_fault.c

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



CVS commit: src/sys/uvm

2023-08-13 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Aug 13 23:06:07 UTC 2023

Modified Files:
src/sys/uvm: uvm_fault.c

Log Message:
uvm: prevent TLB invalidation races during COW resolution

When a thread takes a page fault which results in COW resolution,
other threads in the same process can be concurrently accessing that
same mapping on other CPUs.  When the faulting thread updates the pmap
entry at the end of COW processing, the resulting TLB invalidations to
other CPUs are not done atomically, so another thread can write to the
new writable page and then a third thread might still read from the
old read-only page, resulting in inconsistent views of the page by the
latter two threads.  Fix this by removing the pmap entry entirely for
the original page before we install the new pmap entry for the new
page, so that the new page can only be modified after the old page is
no longer accessible.

This fixes PR 56535 as well as the netbsd versions of problems
described in various bug trackers:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=225584
https://reviews.freebsd.org/D14347
https://github.com/golang/go/issues/34988


To generate a diff of this commit:
cvs rdiff -u -r1.233 -r1.234 src/sys/uvm/uvm_fault.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/uvm/uvm_fault.c
diff -u src/sys/uvm/uvm_fault.c:1.233 src/sys/uvm/uvm_fault.c:1.234
--- src/sys/uvm/uvm_fault.c:1.233	Mon Jul 17 12:55:37 2023
+++ src/sys/uvm/uvm_fault.c	Sun Aug 13 23:06:07 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_fault.c,v 1.233 2023/07/17 12:55:37 riastradh Exp $	*/
+/*	$NetBSD: uvm_fault.c,v 1.234 2023/08/13 23:06:07 chs Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.233 2023/07/17 12:55:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.234 2023/08/13 23:06:07 chs Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -634,8 +634,17 @@ uvmfault_promote(struct uvm_faultinfo *u
 		goto done;
 	}
 
-	/* copy page [pg now dirty] */
+	/*
+	 * copy the page [pg now dirty]
+	 *
+	 * Remove the pmap entry now for the old page at this address
+	 * so that no thread can modify the new page while any thread
+	 * might still see the old page.
+	 */
 	if (opg) {
+		pmap_remove(vm_map_pmap(ufi->orig_map), ufi->orig_rvaddr,
+			 ufi->orig_rvaddr + PAGE_SIZE);
+		pmap_update(vm_map_pmap(ufi->orig_map));
 		uvm_pagecopy(opg, pg);
 	}
 	KASSERT(uvm_pagegetdirty(pg) == UVM_PAGE_STATUS_DIRTY);



CVS commit: src/tests/net/ipsec

2023-06-04 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Jun  4 22:18:47 UTC 2023

Modified Files:
src/tests/net/ipsec: t_ipsec_ah_keys.sh t_ipsec_esp_keys.sh
t_ipsec_transport.sh t_ipsec_tunnel.sh t_ipsec_tunnel_ipcomp.sh
t_ipsec_tunnel_odd.sh

Log Message:
The ATF design is O(N^2) in the number of TCs in one TP, which on some
slower platforms causes the net/ipsec tests to take as much as 30% of
the total time to run all of the ATF tests.  Reduce the number of TCs
in various net/ipsec TPs by iterating over *_ALGORITHMS_MINIMUM rather
than *_ALGORITHMS.  Various of the net/ipsec tests already use the
smaller lists, so change the rest of them to do so as well.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/net/ipsec/t_ipsec_ah_keys.sh \
src/tests/net/ipsec/t_ipsec_esp_keys.sh \
src/tests/net/ipsec/t_ipsec_tunnel_ipcomp.sh
cvs rdiff -u -r1.6 -r1.7 src/tests/net/ipsec/t_ipsec_transport.sh
cvs rdiff -u -r1.9 -r1.10 src/tests/net/ipsec/t_ipsec_tunnel.sh
cvs rdiff -u -r1.3 -r1.4 src/tests/net/ipsec/t_ipsec_tunnel_odd.sh

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

Modified files:

Index: src/tests/net/ipsec/t_ipsec_ah_keys.sh
diff -u src/tests/net/ipsec/t_ipsec_ah_keys.sh:1.2 src/tests/net/ipsec/t_ipsec_ah_keys.sh:1.3
--- src/tests/net/ipsec/t_ipsec_ah_keys.sh:1.2	Thu Aug  3 03:16:27 2017
+++ src/tests/net/ipsec/t_ipsec_ah_keys.sh	Sun Jun  4 22:18:47 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: t_ipsec_ah_keys.sh,v 1.2 2017/08/03 03:16:27 ozaki-r Exp $
+#	$NetBSD: t_ipsec_ah_keys.sh,v 1.3 2023/06/04 22:18:47 chs Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -152,7 +152,7 @@ add_test_invalid_keys()
 atf_init_test_cases()
 {
 
-	for aalgo in $AH_AUTHENTICATION_ALGORITHMS; do
+	for aalgo in $AH_AUTHENTICATION_ALGORITHMS_MINIMUM; do
 		add_test_valid_keys $aalgo
 		add_test_invalid_keys $aalgo
 	done
Index: src/tests/net/ipsec/t_ipsec_esp_keys.sh
diff -u src/tests/net/ipsec/t_ipsec_esp_keys.sh:1.2 src/tests/net/ipsec/t_ipsec_esp_keys.sh:1.3
--- src/tests/net/ipsec/t_ipsec_esp_keys.sh:1.2	Thu Aug  3 03:16:27 2017
+++ src/tests/net/ipsec/t_ipsec_esp_keys.sh	Sun Jun  4 22:18:47 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: t_ipsec_esp_keys.sh,v 1.2 2017/08/03 03:16:27 ozaki-r Exp $
+#	$NetBSD: t_ipsec_esp_keys.sh,v 1.3 2023/06/04 22:18:47 chs Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -152,7 +152,7 @@ add_test_invalid_keys()
 atf_init_test_cases()
 {
 
-	for ealgo in $ESP_ENCRYPTION_ALGORITHMS; do
+	for ealgo in $ESP_ENCRYPTION_ALGORITHMS_MINIMUM; do
 		add_test_valid_keys $ealgo
 		add_test_invalid_keys $ealgo
 	done
Index: src/tests/net/ipsec/t_ipsec_tunnel_ipcomp.sh
diff -u src/tests/net/ipsec/t_ipsec_tunnel_ipcomp.sh:1.2 src/tests/net/ipsec/t_ipsec_tunnel_ipcomp.sh:1.3
--- src/tests/net/ipsec/t_ipsec_tunnel_ipcomp.sh:1.2	Thu Aug  3 03:16:27 2017
+++ src/tests/net/ipsec/t_ipsec_tunnel_ipcomp.sh	Sun Jun  4 22:18:47 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: t_ipsec_tunnel_ipcomp.sh,v 1.2 2017/08/03 03:16:27 ozaki-r Exp $
+#	$NetBSD: t_ipsec_tunnel_ipcomp.sh,v 1.3 2023/06/04 22:18:47 chs Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -395,7 +395,7 @@ atf_init_test_cases()
 {
 	local calgo= algo=
 
-	for calgo in $IPCOMP_COMPRESSION_ALGORITHMS; do
+	for calgo in $IPCOMP_COMPRESSION_ALGORITHMS_MINIMUM; do
 		for algo in $ESP_ENCRYPTION_ALGORITHMS_MINIMUM; do
 			add_test_tunnel_mode ipv4 esp $algo $calgo
 			add_test_tunnel_mode ipv6 esp $algo $calgo

Index: src/tests/net/ipsec/t_ipsec_transport.sh
diff -u src/tests/net/ipsec/t_ipsec_transport.sh:1.6 src/tests/net/ipsec/t_ipsec_transport.sh:1.7
--- src/tests/net/ipsec/t_ipsec_transport.sh:1.6	Thu Aug  3 03:16:27 2017
+++ src/tests/net/ipsec/t_ipsec_transport.sh	Sun Jun  4 22:18:47 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: t_ipsec_transport.sh,v 1.6 2017/08/03 03:16:27 ozaki-r Exp $
+#	$NetBSD: t_ipsec_transport.sh,v 1.7 2023/06/04 22:18:47 chs Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -261,15 +261,15 @@ atf_init_test_cases()
 {
 	local algo=
 
-	for algo in $ESP_ENCRYPTION_ALGORITHMS; do
+	for algo in $ESP_ENCRYPTION_ALGORITHMS_MINIMUM; do
 		add_test_transport_mode ipv4 esp $algo
 		add_test_transport_mode ipv6 esp $algo
 	done
-	for algo in $AH_AUTHENTICATION_ALGORITHMS; do
+	for algo in $AH_AUTHENTICATION_ALGORITHMS_MINIMUM; do
 		add_test_transport_mode ipv4 ah $algo
 		add_test_transport_mode ipv6 ah $algo
 	done
-	for algo in $IPCOMP_COMPRESSION_ALGORITHMS; do
+	for algo in $IPCOMP_COMPRESSION_ALGORITHMS_MINIMUM; do
 		add_test_transport_mode ipv4 ipcomp $algo
 		add_test_transport_mode ipv6 ipcomp $algo
 	done

Index: src/tests/net/ipsec/t_ipsec_tunnel.sh
diff -u src/tests/net/ipsec/t_ipsec_tunnel.sh:1.9 src/tests/net/ipsec/t_ipsec_tunnel.sh:1.10
--- src/tests/net/ipsec/t_ipsec_tunnel.sh:1.9	Thu 

CVS commit: src/tests/net/ipsec

2023-06-04 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Jun  4 22:18:47 UTC 2023

Modified Files:
src/tests/net/ipsec: t_ipsec_ah_keys.sh t_ipsec_esp_keys.sh
t_ipsec_transport.sh t_ipsec_tunnel.sh t_ipsec_tunnel_ipcomp.sh
t_ipsec_tunnel_odd.sh

Log Message:
The ATF design is O(N^2) in the number of TCs in one TP, which on some
slower platforms causes the net/ipsec tests to take as much as 30% of
the total time to run all of the ATF tests.  Reduce the number of TCs
in various net/ipsec TPs by iterating over *_ALGORITHMS_MINIMUM rather
than *_ALGORITHMS.  Various of the net/ipsec tests already use the
smaller lists, so change the rest of them to do so as well.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/net/ipsec/t_ipsec_ah_keys.sh \
src/tests/net/ipsec/t_ipsec_esp_keys.sh \
src/tests/net/ipsec/t_ipsec_tunnel_ipcomp.sh
cvs rdiff -u -r1.6 -r1.7 src/tests/net/ipsec/t_ipsec_transport.sh
cvs rdiff -u -r1.9 -r1.10 src/tests/net/ipsec/t_ipsec_tunnel.sh
cvs rdiff -u -r1.3 -r1.4 src/tests/net/ipsec/t_ipsec_tunnel_odd.sh

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



CVS commit: src/sys/uvm

2023-05-14 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon May 15 01:42:42 UTC 2023

Modified Files:
src/sys/uvm: uvm_map.c

Log Message:
uvm: avoid a deadlock in uvm_map_clean()

The locking order between map locks and page "busy" locks
is that the page "busy" lock comes first, but uvm_map_clean()
breaks this rule by holding a map locked (as reader) while
waiting for page "busy" locks.

If another thread is in the page-fault path holding a page
"busy" lock while waiting for the map lock (as a reader)
and at the same time a third thread is blocked waiting for
the map lock as a writer (which blocks the page-fault thread),
then these three threads will all deadlock with each other.

Fix this by marking the map "busy" (to block any modifications)
and unlocking the map lock before possibly waiting for any
page "busy" locks.

Martin Pieuchot reported that the same problem existed in OpenBSD
he applied this fix there after several people tested it.

fixes PR 56952


To generate a diff of this commit:
cvs rdiff -u -r1.405 -r1.406 src/sys/uvm/uvm_map.c

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



CVS commit: src/sys/ufs/ffs

2023-05-11 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Thu May 11 23:11:25 UTC 2023

Modified Files:
src/sys/ufs/ffs: ffs_snapshot.c

Log Message:
ffs: apply the remaining ffs_snapshot.c part of this FreeBSD commit:

  commit 364ed814e7285c8216d8a201d3ab3674eb34ce29
  Author: Kirk McKusick 
  Date:   Thu Dec 9 21:24:00 2004 +

Fixes a bug that caused UFS2 filesystems bigger than 2TB to
prematurely report that they were full and/or to panic the kernel
with the message ``ffs_clusteralloc: allocated out of group''.

Submitted by:   Henry Whincup 
MFC after:  1 week

all the other changes in that commit were applied previously by others:
 - sborrill commmitted ffs_alloc.c rev 1.123 in 2009
 - simonb committed ffs_alloc.c rev 1.110 in 2008
 - the ffs_clusteralloc() part is not needed because we no longer have
   that function.

fixes PR 57307


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/sys/ufs/ffs/ffs_snapshot.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/ufs/ffs/ffs_snapshot.c
diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.154 src/sys/ufs/ffs/ffs_snapshot.c:1.155
--- src/sys/ufs/ffs/ffs_snapshot.c:1.154	Sat Apr 16 07:59:46 2022
+++ src/sys/ufs/ffs/ffs_snapshot.c	Thu May 11 23:11:25 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_snapshot.c,v 1.154 2022/04/16 07:59:46 hannken Exp $	*/
+/*	$NetBSD: ffs_snapshot.c,v 1.155 2023/05/11 23:11:25 chs Exp $	*/
 
 /*
  * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.154 2022/04/16 07:59:46 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.155 2023/05/11 23:11:25 chs Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -990,7 +990,7 @@ cgaccount1(int cg, struct vnode *vp, voi
 		fs->fs_bsize - fs->fs_cgsize);
 	numblks = howmany(fs->fs_size, fs->fs_frag);
 	len = howmany(fs->fs_fpg, fs->fs_frag);
-	base = cg * fs->fs_fpg / fs->fs_frag;
+	base = cgbase(fs, cg) / fs->fs_frag;
 	if (base + len >= numblks)
 		len = numblks - base - 1;
 	loc = 0;



CVS commit: src/sys/ufs/ffs

2023-05-11 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Thu May 11 23:11:25 UTC 2023

Modified Files:
src/sys/ufs/ffs: ffs_snapshot.c

Log Message:
ffs: apply the remaining ffs_snapshot.c part of this FreeBSD commit:

  commit 364ed814e7285c8216d8a201d3ab3674eb34ce29
  Author: Kirk McKusick 
  Date:   Thu Dec 9 21:24:00 2004 +

Fixes a bug that caused UFS2 filesystems bigger than 2TB to
prematurely report that they were full and/or to panic the kernel
with the message ``ffs_clusteralloc: allocated out of group''.

Submitted by:   Henry Whincup 
MFC after:  1 week

all the other changes in that commit were applied previously by others:
 - sborrill commmitted ffs_alloc.c rev 1.123 in 2009
 - simonb committed ffs_alloc.c rev 1.110 in 2008
 - the ffs_clusteralloc() part is not needed because we no longer have
   that function.

fixes PR 57307


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/sys/ufs/ffs/ffs_snapshot.c

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



CVS commit: src/libexec/ld.elf_so/arch/powerpc

2023-04-09 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Apr  9 17:24:48 UTC 2023

Modified Files:
src/libexec/ld.elf_so/arch/powerpc: Makefile.inc
Removed Files:
src/libexec/ld.elf_so/arch/powerpc: ld.so.script

Log Message:
ld.elf_so powerpc: remove bogus ldscript

This ldscript is not needed and actually makes things worse by putting
everything in one LOAD section, which then needs to have rwx permission.
Remove it so that we get two LOAD sections with better permissions.
Fixes PR 57323.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/libexec/ld.elf_so/arch/powerpc/Makefile.inc
cvs rdiff -u -r1.4 -r0 src/libexec/ld.elf_so/arch/powerpc/ld.so.script

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

Modified files:

Index: src/libexec/ld.elf_so/arch/powerpc/Makefile.inc
diff -u src/libexec/ld.elf_so/arch/powerpc/Makefile.inc:1.16 src/libexec/ld.elf_so/arch/powerpc/Makefile.inc:1.17
--- src/libexec/ld.elf_so/arch/powerpc/Makefile.inc:1.16	Tue Apr  3 21:10:27 2018
+++ src/libexec/ld.elf_so/arch/powerpc/Makefile.inc	Sun Apr  9 17:24:48 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.16 2018/04/03 21:10:27 joerg Exp $
+#	$NetBSD: Makefile.inc,v 1.17 2023/04/09 17:24:48 chs Exp $
 
 SRCS+=		ppc_reloc.c
 LDFLAGS+=	-Wl,-e,_rtld_start
@@ -12,5 +12,4 @@ CPPFLAGS+=	-DELFSIZE=64
 .else
 SRCS+=		rtld_start.S
 CPPFLAGS+=	-DELFSIZE=32
-LDFLAGS+=	-Wl,--script,${.CURDIR}/arch/powerpc/ld.so.script
 .endif



CVS commit: src/libexec/ld.elf_so/arch/powerpc

2023-04-09 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Apr  9 17:24:48 UTC 2023

Modified Files:
src/libexec/ld.elf_so/arch/powerpc: Makefile.inc
Removed Files:
src/libexec/ld.elf_so/arch/powerpc: ld.so.script

Log Message:
ld.elf_so powerpc: remove bogus ldscript

This ldscript is not needed and actually makes things worse by putting
everything in one LOAD section, which then needs to have rwx permission.
Remove it so that we get two LOAD sections with better permissions.
Fixes PR 57323.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/libexec/ld.elf_so/arch/powerpc/Makefile.inc
cvs rdiff -u -r1.4 -r0 src/libexec/ld.elf_so/arch/powerpc/ld.so.script

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



CVS commit: src/sbin/fsck_ffs

2023-03-27 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Mar 27 22:53:37 UTC 2023

Modified Files:
src/sbin/fsck_ffs: pass2.c

Log Message:
Apply this commit from FreeBSD:

  commit 6bae6625e0e06816c80ac4971dfccf0643abe3f0
  Author: Kirk McKusick 
  Date:   Wed Aug 17 14:19:59 2022 -0700

Improve handling of missing '.' and '..' in UFS directories.

The UFS filesystem expects to find '.' and '..' as the first two entries
in a directory. The kernel's UFS name cache can become quite confused
when these two entries are not present as the first two entries.

Prior to this change, when the fsck_ffs(8) utility detected that
'.' and/or '..' were missing, it would report them, but only offered
to replace them if the space at the beginning of the directory was
available. Otherwise it was left to the system administrator to
move the offending file(s) out of the way and then rerun fsck_ffs(8)
to create the '.' and '..' entries.

With this change, fsck_ffs(8) will always be able to create the '.'
and/or '..' entries. It moves any files in the way elsewhere in the
directory block. If there is no room in the directory block to which
to move them, they are placed in the lost+found directory.

Reported by:  Peter Holm
Sponsored by: The FreeBSD Foundation


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sbin/fsck_ffs/pass2.c

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

Modified files:

Index: src/sbin/fsck_ffs/pass2.c
diff -u src/sbin/fsck_ffs/pass2.c:1.51 src/sbin/fsck_ffs/pass2.c:1.52
--- src/sbin/fsck_ffs/pass2.c:1.51	Wed Feb  8 16:11:40 2017
+++ src/sbin/fsck_ffs/pass2.c	Mon Mar 27 22:53:37 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pass2.c,v 1.51 2017/02/08 16:11:40 rin Exp $	*/
+/*	$NetBSD: pass2.c,v 1.52 2023/03/27 22:53:37 chs Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)pass2.c	8.9 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: pass2.c,v 1.51 2017/02/08 16:11:40 rin Exp $");
+__RCSID("$NetBSD: pass2.c,v 1.52 2023/03/27 22:53:37 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -271,11 +271,9 @@ pass2(void)
 		info = inoinfo(inp->i_parent);
 		if (inp->i_dotdot == 0) {
 			inp->i_dotdot = inp->i_parent;
-			fileerror(inp->i_parent, inp->i_number, "MISSING '..'");
-			if (reply("FIX") == 0) {
-markclean = 0;
-continue;
-			}
+			if (debug)
+fileerror(inp->i_parent, inp->i_number,
+"DEFERRED MISSING '..' FIX");
 			(void)makeentry(inp->i_number, inp->i_parent, "..");
 			info->ino_linkcnt--;
 			continue;
@@ -331,7 +329,7 @@ pass2check(struct inodesc *idesc)
 	int n, entrysize, ret = 0;
 	union dinode *dp;
 	const char *errmsg;
-	struct direct proto;
+	struct direct proto, *newdirp;
 	char namebuf[MAXPATHLEN + 1];
 	char pathbuf[MAXPATHLEN + 1];
 
@@ -351,23 +349,22 @@ pass2check(struct inodesc *idesc)
 	if (dirp->d_ino != 0 && strcmp(dirp->d_name, ".") == 0) {
 		if (iswap32(dirp->d_ino) != idesc->id_number) {
 			direrror(idesc->id_number, "BAD INODE NUMBER FOR '.'");
-			dirp->d_ino = iswap32(idesc->id_number);
-			if (reply("FIX") == 1)
+			if (reply("FIX") == 1) {
+dirp->d_ino = iswap32(idesc->id_number);
 ret |= ALTERED;
-			else
+			} else
 markclean = 0;
 		}
 		if (newinofmt && dirp->d_type != DT_DIR) {
 			direrror(idesc->id_number, "BAD TYPE VALUE FOR '.'");
-			dirp->d_type = DT_DIR;
-			if (reply("FIX") == 1)
+			if (reply("FIX") == 1) {
+dirp->d_type = DT_DIR;
 ret |= ALTERED;
-			else
+			} else
 markclean = 0;
 		}
 		goto chk1;
 	}
-	direrror(idesc->id_number, "MISSING '.'");
 	proto.d_ino = iswap32(idesc->id_number);
 	if (newinofmt)
 		proto.d_type = DT_DIR;
@@ -387,33 +384,33 @@ pass2check(struct inodesc *idesc)
 			proto.d_namlen = tmp;
 		}
 	entrysize = UFS_DIRSIZ(0, , 0);
-	if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") != 0) {
-		pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n",
-			dirp->d_name);
-		markclean = 0;
-	} else if (iswap16(dirp->d_reclen) < entrysize) {
-		pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '.'\n");
-		markclean = 0;
-	} else if (iswap16(dirp->d_reclen) < 2 * entrysize) {
+	direrror(idesc->id_number, "MISSING '.'");
+	errmsg = "ADD '.' ENTRY";
+	if (iswap16(dirp->d_reclen) < entrysize + UFS_DIRSIZ(0, dirp, 0)) {
+		/* Not enough space to add '.', replace first entry with '.' */
+		if (dirp->d_ino != 0) {
+			pwarn("\nFIRST ENTRY IN DIRECTORY CONTAINS %s\n",
+			 dirp->d_name);
+			errmsg = "REPLACE WITH '.'";
+		}
+		if (reply(errmsg) == 0)
+			goto chk1;
 		proto.d_reclen = dirp->d_reclen;
 		memmove(dirp, , (size_t)entrysize);
-		if (reply("FIX") == 1)
-			ret |= ALTERED;
-		else
-			markclean = 0;
+		ret |= ALTERED;
 	} else {
-		n = iswap16(dirp->d_reclen) - entrysize;
+		/* Move over first entry and add '.' entry */
+		if (reply(errmsg) == 0)
+			goto chk1;
+		newdirp = (struct direct *)((char 

CVS commit: src/sbin/fsck_ffs

2023-03-27 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Mar 27 22:53:37 UTC 2023

Modified Files:
src/sbin/fsck_ffs: pass2.c

Log Message:
Apply this commit from FreeBSD:

  commit 6bae6625e0e06816c80ac4971dfccf0643abe3f0
  Author: Kirk McKusick 
  Date:   Wed Aug 17 14:19:59 2022 -0700

Improve handling of missing '.' and '..' in UFS directories.

The UFS filesystem expects to find '.' and '..' as the first two entries
in a directory. The kernel's UFS name cache can become quite confused
when these two entries are not present as the first two entries.

Prior to this change, when the fsck_ffs(8) utility detected that
'.' and/or '..' were missing, it would report them, but only offered
to replace them if the space at the beginning of the directory was
available. Otherwise it was left to the system administrator to
move the offending file(s) out of the way and then rerun fsck_ffs(8)
to create the '.' and '..' entries.

With this change, fsck_ffs(8) will always be able to create the '.'
and/or '..' entries. It moves any files in the way elsewhere in the
directory block. If there is no room in the directory block to which
to move them, they are placed in the lost+found directory.

Reported by:  Peter Holm
Sponsored by: The FreeBSD Foundation


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sbin/fsck_ffs/pass2.c

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



CVS commit: src/external/cddl/osnet/dist/lib/libdtrace/common

2023-02-07 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Feb  7 22:54:02 UTC 2023

Modified Files:
src/external/cddl/osnet/dist/lib/libdtrace/common: dt_subr.c

Log Message:
dtrace: remove unnecessary fflush()

Apply this commit from FreeBSD:

  commit f339a3ef6369b368f3a2455792a7a3a4c28f92c4
  Author: Chuck Silvers 
  Date:   Wed Feb 9 17:09:26 2022 -0800

  dtrace: remove unnecessary fflush()

  This call was added back in the early days of dtrace porting and
  no one knows why anymore.  The extra flushing causes lots of
  unnecessary CPU overhead when a script produces lots of output,
  as well as easily losing output because the command can't keep up.

  Sponsored by: Netflix
  Reviewed by:  imp, markj
  Differential Revision:https://reviews.freebsd.org/D34216


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 \
src/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c

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

Modified files:

Index: src/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c
diff -u src/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c:1.15 src/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c:1.16
--- src/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c:1.15	Mon Feb  6 22:22:12 2023
+++ src/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c	Tue Feb  7 22:54:02 2023
@@ -725,7 +725,6 @@ dt_printf(dtrace_hdl_t *dtp, FILE *fp, c
 
 	va_copy(ap2, ap);
 	n = vfprintf(fp, format, ap2);
-	fflush(fp);
 	va_end(ap2);
 	va_end(ap);
 



CVS commit: src/external/cddl/osnet/dist/lib/libdtrace/common

2023-02-07 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Feb  7 22:54:02 UTC 2023

Modified Files:
src/external/cddl/osnet/dist/lib/libdtrace/common: dt_subr.c

Log Message:
dtrace: remove unnecessary fflush()

Apply this commit from FreeBSD:

  commit f339a3ef6369b368f3a2455792a7a3a4c28f92c4
  Author: Chuck Silvers 
  Date:   Wed Feb 9 17:09:26 2022 -0800

  dtrace: remove unnecessary fflush()

  This call was added back in the early days of dtrace porting and
  no one knows why anymore.  The extra flushing causes lots of
  unnecessary CPU overhead when a script produces lots of output,
  as well as easily losing output because the command can't keep up.

  Sponsored by: Netflix
  Reviewed by:  imp, markj
  Differential Revision:https://reviews.freebsd.org/D34216


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 \
src/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c

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



CVS commit: src/external/cddl/osnet/dist/lib/libdtrace/common

2023-02-06 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Feb  6 22:22:12 UTC 2023

Modified Files:
src/external/cddl/osnet/dist/lib/libdtrace/common: dt_subr.c

Log Message:
dtrace: re-fix aggregations to report from all online CPUs

Reapply the fix to dt_status() from rev 1.10
("Don't return success when the target CPU is offline")
which was lost in rev 1.12 ("sync with FreeBSD").
The FreeBSD version that we have been using since then does run on NetBSD
but always reports that CPU 0 is online and all other CPUs are offline,
because the sysctl that it uses does not exist on NetBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 \
src/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c

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

Modified files:

Index: src/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c
diff -u src/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c:1.14 src/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c:1.15
--- src/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c:1.14	Sun Sep  6 21:49:32 2020
+++ src/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c	Mon Feb  6 22:22:12 2023
@@ -49,6 +49,11 @@
 #include 
 #include 
 #include 
+#ifdef __NetBSD__
+#include 
+#include 
+#include 
+#endif
 
 #include 
 
@@ -501,6 +506,27 @@ dt_ioctl(dtrace_hdl_t *dtp, u_long val, 
 	return (-1);
 }
 
+#ifdef __NetBSD__
+static bool
+cpu_online(processorid_t cpu)
+{
+	cpustate_t cs;
+	int fd, online = false;
+
+	if ((fd = open(_PATH_CPUCTL, O_RDONLY)) < 0)
+		return false;
+
+	cs.cs_id = cpu;
+	if (ioctl(fd, IOC_CPU_GETSTATE, ) == 0) {
+		if (cs.cs_online)
+			online = true;
+	}
+
+	close(fd);
+	return online;
+}
+#endif
+
 int
 dt_status(dtrace_hdl_t *dtp, processorid_t cpu)
 {
@@ -509,7 +535,8 @@ dt_status(dtrace_hdl_t *dtp, processorid
 	if (v == NULL) {
 #ifdef illumos
 		return (p_online(cpu, P_STATUS));
-#else
+#endif
+#ifdef __FreeBSD__
 		int maxid = 0;
 		size_t len = sizeof(maxid);
 		if (sysctlbyname("kern.smp.maxid", , , NULL, 0) != 0)
@@ -517,6 +544,9 @@ dt_status(dtrace_hdl_t *dtp, processorid
 		else
 			return (cpu <= maxid ? 1 : -1);
 #endif
+#ifdef __NetBSD__
+		return cpu_online(cpu) ? 1 : -1;
+#endif
 	}
 
 	return (v->dtv_status(dtp->dt_varg, cpu));



CVS commit: src/external/cddl/osnet/dist/lib/libdtrace/common

2023-02-06 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Feb  6 22:22:12 UTC 2023

Modified Files:
src/external/cddl/osnet/dist/lib/libdtrace/common: dt_subr.c

Log Message:
dtrace: re-fix aggregations to report from all online CPUs

Reapply the fix to dt_status() from rev 1.10
("Don't return success when the target CPU is offline")
which was lost in rev 1.12 ("sync with FreeBSD").
The FreeBSD version that we have been using since then does run on NetBSD
but always reports that CPU 0 is online and all other CPUs are offline,
because the sysctl that it uses does not exist on NetBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 \
src/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c

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



CVS commit: src/sbin/fsck_ffs

2023-01-07 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Jan  8 05:25:25 UTC 2023

Modified Files:
src/sbin/fsck_ffs: pass5.c setup.c

Log Message:
ufs: more signed/unsigned fixes

Fix the previous signed/unsigned fixes to build on 32-bit,
including applying this commit from FreeBSD:

  commit 2d34afcd04207cf3fa3d5b7f467a890eae75da41
  Author: Kirk McKusick 
  Date:   Sun Oct 25 21:04:07 2020 +

Use proper type (ino_t) for inode numbers to avoid improper sign extention
in the Pass 5 checks. The manifestation was fsck_ffs exiting with this 
error:

  ** Phase 5 - Check Cyl groups
  fsck_ffs: inoinfo: inumber 18446744071562087424 out of range

The error only manifests itself for filesystems bigger than about 100Tb.

Reported by:  Nikita Grechikhin 
MFC after:2 weeks
Sponsored by: Netflix


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sbin/fsck_ffs/pass5.c
cvs rdiff -u -r1.105 -r1.106 src/sbin/fsck_ffs/setup.c

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

Modified files:

Index: src/sbin/fsck_ffs/pass5.c
diff -u src/sbin/fsck_ffs/pass5.c:1.56 src/sbin/fsck_ffs/pass5.c:1.57
--- src/sbin/fsck_ffs/pass5.c:1.56	Sat Jan  7 19:41:29 2023
+++ src/sbin/fsck_ffs/pass5.c	Sun Jan  8 05:25:24 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pass5.c,v 1.56 2023/01/07 19:41:29 chs Exp $	*/
+/*	$NetBSD: pass5.c,v 1.57 2023/01/08 05:25:24 chs Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)pass5.c	8.9 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: pass5.c,v 1.56 2023/01/07 19:41:29 chs Exp $");
+__RCSID("$NetBSD: pass5.c,v 1.57 2023/01/08 05:25:24 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -60,12 +60,15 @@ void
 pass5(void)
 {
 	int blk, frags, basesize, sumsize, mapsize, cssize;
-	int inomapsize, blkmapsize;
+	uint32_t inomapsize, blkmapsize;
 	uint32_t c;
 	struct fs *fs = sblock;
 	daddr_t dbase, dmax;
 	daddr_t d;
-	long i, j, k;
+	uint32_t i;
+	int32_t j;
+	int k;
+	ino_t inum;
 	struct csum *cs;
 	struct csum_total cstotal;
 	struct inodesc idesc[4];
@@ -317,9 +320,9 @@ pass5(void)
 		if (!is_ufs2 && ((fs->fs_old_flags & FS_FLAGS_UPDATED) == 0) &&
 		fs->fs_old_postblformat == FS_42POSTBLFMT)
 			ocg->cg_magic = CG_MAGIC;
-		j = fs->fs_ipg * c;
-		for (i = 0; i < fs->fs_ipg; j++, i++) {
-			info = inoinfo(j);
+		inum = fs->fs_ipg * c;
+		for (i = 0; i < fs->fs_ipg; inum++, i++) {
+			info = inoinfo(inum);
 			switch (info->ino_state) {
 
 			case USTATE:
@@ -338,14 +341,14 @@ pass5(void)
 break;
 
 			default:
-if ((ino_t)j < UFS_ROOTINO)
+if (inum < UFS_ROOTINO)
 	break;
-errexit("BAD STATE %d FOR INODE I=%ld",
-info->ino_state, (long)j);
+errexit("BAD STATE %d FOR INODE I=%ju",
+info->ino_state, (uintmax_t)inum);
 			}
 		}
 		if (c == 0)
-			for (i = 0; i < (long)UFS_ROOTINO; i++) {
+			for (i = 0; i < UFS_ROOTINO; i++) {
 setbit(cg_inosused(newcg, 0), i);
 newcg->cg_cs.cs_nifree--;
 			}
@@ -450,7 +453,7 @@ pass5(void)
 		continue;
 	if (cg_inosused(cg, 0)[i] & (1 << k))
 		continue;
-	pwarn("ALLOCATED INODE %ld "
+	pwarn("ALLOCATED INODE %u "
 	"MARKED FREE\n",
 	c * fs->fs_ipg + i * 8 + k);
 }
@@ -464,7 +467,7 @@ pass5(void)
 		continue;
 	if (cg_inosused(cg, 0)[i] & (1 << k))
 		continue;
-	pwarn("ALLOCATED FRAG %ld "
+	pwarn("ALLOCATED FRAG %u "
 	"MARKED FREE\n",
 	c * fs->fs_fpg + i * 8 + k);
 }

Index: src/sbin/fsck_ffs/setup.c
diff -u src/sbin/fsck_ffs/setup.c:1.105 src/sbin/fsck_ffs/setup.c:1.106
--- src/sbin/fsck_ffs/setup.c:1.105	Sat Jan  7 19:41:29 2023
+++ src/sbin/fsck_ffs/setup.c	Sun Jan  8 05:25:24 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: setup.c,v 1.105 2023/01/07 19:41:29 chs Exp $	*/
+/*	$NetBSD: setup.c,v 1.106 2023/01/08 05:25:24 chs Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)setup.c	8.10 (Berkeley) 5/9/95";
 #else
-__RCSID("$NetBSD: setup.c,v 1.105 2023/01/07 19:41:29 chs Exp $");
+__RCSID("$NetBSD: setup.c,v 1.106 2023/01/08 05:25:24 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -85,7 +85,8 @@ int16_t sblkpostbl[256];
 int
 setup(const char *dev, const char *origdev)
 {
-	long cg, size, asked, i, j;
+	uint32_t cg;
+	long size, asked, i, j;
 	long bmapsize;
 	struct disk_geom geo;
 	struct dkwedge_info dkw;



CVS commit: src/sbin/fsck_ffs

2023-01-07 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Jan  8 05:25:25 UTC 2023

Modified Files:
src/sbin/fsck_ffs: pass5.c setup.c

Log Message:
ufs: more signed/unsigned fixes

Fix the previous signed/unsigned fixes to build on 32-bit,
including applying this commit from FreeBSD:

  commit 2d34afcd04207cf3fa3d5b7f467a890eae75da41
  Author: Kirk McKusick 
  Date:   Sun Oct 25 21:04:07 2020 +

Use proper type (ino_t) for inode numbers to avoid improper sign extention
in the Pass 5 checks. The manifestation was fsck_ffs exiting with this 
error:

  ** Phase 5 - Check Cyl groups
  fsck_ffs: inoinfo: inumber 18446744071562087424 out of range

The error only manifests itself for filesystems bigger than about 100Tb.

Reported by:  Nikita Grechikhin 
MFC after:2 weeks
Sponsored by: Netflix


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sbin/fsck_ffs/pass5.c
cvs rdiff -u -r1.105 -r1.106 src/sbin/fsck_ffs/setup.c

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



CVS commit: src

2023-01-07 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sat Jan  7 19:41:30 UTC 2023

Modified Files:
src/sbin/fsck_ffs: main.c pass1.c pass1b.c pass4.c pass5.c setup.c
src/sbin/fsdb: fsdb.c
src/sbin/newfs: mkfs.c
src/sbin/resize_ffs: resize_ffs.c
src/sbin/tunefs: tunefs.c
src/sys/ufs/ffs: ffs_alloc.c ffs_extern.h ffs_subr.c fs.h
src/usr.sbin/dumpfs: dumpfs.c
src/usr.sbin/makefs: Makefile ffs.c
src/usr.sbin/makefs/ffs: ffs_alloc.c ffs_extern.h mkfs.c
src/usr.sbin/quotacheck: quotacheck.c

Log Message:
ufs: fixed signed/unsigned bugs affecting large file systems

Apply these commits from FreeBSD:

  commit e870d1e6f97cc73308c11c40684b775bcfa906a2
  Author: Kirk McKusick 
  Date:   Wed Feb 10 20:10:35 2010 +

This fix corrects a problem in the file system that treats large
inode numbers as negative rather than unsigned. For a default
(16K block) file system, this bug began to show up at a file system
size above about 16Tb.

To fully handle this problem, newfs must be updated to ensure that
it will never create a filesystem with more than 2^32 inodes. That
patch will be forthcoming soon.

Reported by: Scott Burns, John Kilburg, Bruce Evans
Followup by: Jeff Roberson
PR:  133980
MFC after:   2 weeks

  commit 81479e688b0f643ffacd3f335b4b4bba460b769d
  Author: Kirk McKusick 
  Date:   Thu Feb 11 18:14:53 2010 +

One last pass to get all the unsigned comparisons correct.

In additional to the changes from FreeBSD, this commit includes quite a few
related changes to appease -Wsign-compare.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sbin/fsck_ffs/main.c
cvs rdiff -u -r1.62 -r1.63 src/sbin/fsck_ffs/pass1.c
cvs rdiff -u -r1.23 -r1.24 src/sbin/fsck_ffs/pass1b.c
cvs rdiff -u -r1.28 -r1.29 src/sbin/fsck_ffs/pass4.c
cvs rdiff -u -r1.55 -r1.56 src/sbin/fsck_ffs/pass5.c
cvs rdiff -u -r1.104 -r1.105 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.53 -r1.54 src/sbin/fsdb/fsdb.c
cvs rdiff -u -r1.132 -r1.133 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.57 -r1.58 src/sbin/resize_ffs/resize_ffs.c
cvs rdiff -u -r1.57 -r1.58 src/sbin/tunefs/tunefs.c
cvs rdiff -u -r1.171 -r1.172 src/sys/ufs/ffs/ffs_alloc.c
cvs rdiff -u -r1.87 -r1.88 src/sys/ufs/ffs/ffs_extern.h
cvs rdiff -u -r1.53 -r1.54 src/sys/ufs/ffs/ffs_subr.c
cvs rdiff -u -r1.70 -r1.71 src/sys/ufs/ffs/fs.h
cvs rdiff -u -r1.67 -r1.68 src/usr.sbin/dumpfs/dumpfs.c
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/makefs/Makefile
cvs rdiff -u -r1.73 -r1.74 src/usr.sbin/makefs/ffs.c
cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/makefs/ffs/ffs_alloc.c
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/makefs/ffs/ffs_extern.h
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/makefs/ffs/mkfs.c
cvs rdiff -u -r1.50 -r1.51 src/usr.sbin/quotacheck/quotacheck.c

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



CVS commit: src

2023-01-07 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sat Jan  7 19:41:30 UTC 2023

Modified Files:
src/sbin/fsck_ffs: main.c pass1.c pass1b.c pass4.c pass5.c setup.c
src/sbin/fsdb: fsdb.c
src/sbin/newfs: mkfs.c
src/sbin/resize_ffs: resize_ffs.c
src/sbin/tunefs: tunefs.c
src/sys/ufs/ffs: ffs_alloc.c ffs_extern.h ffs_subr.c fs.h
src/usr.sbin/dumpfs: dumpfs.c
src/usr.sbin/makefs: Makefile ffs.c
src/usr.sbin/makefs/ffs: ffs_alloc.c ffs_extern.h mkfs.c
src/usr.sbin/quotacheck: quotacheck.c

Log Message:
ufs: fixed signed/unsigned bugs affecting large file systems

Apply these commits from FreeBSD:

  commit e870d1e6f97cc73308c11c40684b775bcfa906a2
  Author: Kirk McKusick 
  Date:   Wed Feb 10 20:10:35 2010 +

This fix corrects a problem in the file system that treats large
inode numbers as negative rather than unsigned. For a default
(16K block) file system, this bug began to show up at a file system
size above about 16Tb.

To fully handle this problem, newfs must be updated to ensure that
it will never create a filesystem with more than 2^32 inodes. That
patch will be forthcoming soon.

Reported by: Scott Burns, John Kilburg, Bruce Evans
Followup by: Jeff Roberson
PR:  133980
MFC after:   2 weeks

  commit 81479e688b0f643ffacd3f335b4b4bba460b769d
  Author: Kirk McKusick 
  Date:   Thu Feb 11 18:14:53 2010 +

One last pass to get all the unsigned comparisons correct.

In additional to the changes from FreeBSD, this commit includes quite a few
related changes to appease -Wsign-compare.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sbin/fsck_ffs/main.c
cvs rdiff -u -r1.62 -r1.63 src/sbin/fsck_ffs/pass1.c
cvs rdiff -u -r1.23 -r1.24 src/sbin/fsck_ffs/pass1b.c
cvs rdiff -u -r1.28 -r1.29 src/sbin/fsck_ffs/pass4.c
cvs rdiff -u -r1.55 -r1.56 src/sbin/fsck_ffs/pass5.c
cvs rdiff -u -r1.104 -r1.105 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.53 -r1.54 src/sbin/fsdb/fsdb.c
cvs rdiff -u -r1.132 -r1.133 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.57 -r1.58 src/sbin/resize_ffs/resize_ffs.c
cvs rdiff -u -r1.57 -r1.58 src/sbin/tunefs/tunefs.c
cvs rdiff -u -r1.171 -r1.172 src/sys/ufs/ffs/ffs_alloc.c
cvs rdiff -u -r1.87 -r1.88 src/sys/ufs/ffs/ffs_extern.h
cvs rdiff -u -r1.53 -r1.54 src/sys/ufs/ffs/ffs_subr.c
cvs rdiff -u -r1.70 -r1.71 src/sys/ufs/ffs/fs.h
cvs rdiff -u -r1.67 -r1.68 src/usr.sbin/dumpfs/dumpfs.c
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/makefs/Makefile
cvs rdiff -u -r1.73 -r1.74 src/usr.sbin/makefs/ffs.c
cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/makefs/ffs/ffs_alloc.c
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/makefs/ffs/ffs_extern.h
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/makefs/ffs/mkfs.c
cvs rdiff -u -r1.50 -r1.51 src/usr.sbin/quotacheck/quotacheck.c

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

Modified files:

Index: src/sbin/fsck_ffs/main.c
diff -u src/sbin/fsck_ffs/main.c:1.90 src/sbin/fsck_ffs/main.c:1.91
--- src/sbin/fsck_ffs/main.c:1.90	Thu Nov 17 06:40:38 2022
+++ src/sbin/fsck_ffs/main.c	Sat Jan  7 19:41:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.90 2022/11/17 06:40:38 chs Exp $	*/
+/*	$NetBSD: main.c,v 1.91 2023/01/07 19:41:29 chs Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.6 (Berkeley) 5/14/95";
 #else
-__RCSID("$NetBSD: main.c,v 1.90 2022/11/17 06:40:38 chs Exp $");
+__RCSID("$NetBSD: main.c,v 1.91 2023/01/07 19:41:29 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -368,7 +368,7 @@ checkfilesys(const char *filesys, const 
 	daddr_t n_ffree, n_bfree;
 	struct dups *dp;
 	struct zlncnt *zlnp;
-	int cylno;
+	uint32_t cylno;
 #ifdef LITE2BORKEN
 	int flags;
 #endif

Index: src/sbin/fsck_ffs/pass1.c
diff -u src/sbin/fsck_ffs/pass1.c:1.62 src/sbin/fsck_ffs/pass1.c:1.63
--- src/sbin/fsck_ffs/pass1.c:1.62	Fri Nov 18 07:41:31 2022
+++ src/sbin/fsck_ffs/pass1.c	Sat Jan  7 19:41:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pass1.c,v 1.62 2022/11/18 07:41:31 martin Exp $	*/
+/*	$NetBSD: pass1.c,v 1.63 2023/01/07 19:41:29 chs Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)pass1.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: pass1.c,v 1.62 2022/11/18 07:41:31 martin Exp $");
+__RCSID("$NetBSD: pass1.c,v 1.63 2023/01/07 19:41:29 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -68,7 +68,7 @@ pass1(void)
 {
 	ino_t inumber, inosused, ninosused, ii;
 	size_t inospace;
-	int c;
+	uint32_t c;
 	daddr_t i, cgd;
 	struct inodesc idesc;
 	struct cg *cgp = cgrp;

Index: src/sbin/fsck_ffs/pass1b.c
diff -u src/sbin/fsck_ffs/pass1b.c:1.23 src/sbin/fsck_ffs/pass1b.c:1.24
--- src/sbin/fsck_ffs/pass1b.c:1.23	Tue Jan 22 09:39:12 2013
+++ src/sbin/fsck_ffs/pass1b.c	Sat Jan  7 19:41:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pass1b.c,v 1.23 2013/01/22 

CVS commit: src

2022-12-26 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Dec 26 22:22:22 UTC 2022

Modified Files:
src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common:
sanitizer_interceptors_ioctl_netbsd.inc
sanitizer_platform_limits_netbsd.cc
sanitizer_platform_limits_netbsd.h
src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common:
sanitizer_interceptors_ioctl_netbsd.inc
sanitizer_platform_limits_netbsd.cc
sanitizer_platform_limits_netbsd.h

Log Message:
remove the PPP HDLC ioctls from more copies of sanitizers.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \

src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc
cvs rdiff -u -r1.1.1.2 -r1.2 \

src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc
 \

src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h
cvs rdiff -u -r1.4 -r1.5 \

src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc
cvs rdiff -u -r1.7 -r1.8 \

src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cc
cvs rdiff -u -r1.5 -r1.6 \

src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_platform_limits_netbsd.h

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

Modified files:

Index: src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc
diff -u src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc:1.1.1.1 src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc:1.2
--- src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc:1.1.1.1	Fri Apr  9 22:33:11 2021
+++ src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc	Mon Dec 26 22:22:22 2022
@@ -1267,8 +1267,6 @@ static void ioctl_table_fill() {
   _(TIOCGFLAGS, WRITE, sizeof(int));
   _(TIOCSFLAGS, READ, sizeof(int));
   _(TIOCDCDTIMESTAMP, WRITE, struct_timeval_sz);
-  _(TIOCRCVFRAME, READ, sizeof(uptr));
-  _(TIOCXMTFRAME, READ, sizeof(uptr));
   _(TIOCPTMGET, WRITE, struct_ptmget_sz);
   _(TIOCGRANTPT, NONE, 0);
   _(TIOCPTSNAME, WRITE, struct_ptmget_sz);

Index: src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc
diff -u src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc:1.1.1.2 src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc:1.2
--- src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc:1.1.1.2	Fri Apr  9 22:33:11 2021
+++ src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc	Mon Dec 26 22:22:22 2022
@@ -2341,8 +2341,6 @@ unsigned IOCTL_TIOCDRAIN = TIOCDRAIN;
 unsigned IOCTL_TIOCGFLAGS = TIOCGFLAGS;
 unsigned IOCTL_TIOCSFLAGS = TIOCSFLAGS;
 unsigned IOCTL_TIOCDCDTIMESTAMP = TIOCDCDTIMESTAMP;
-unsigned IOCTL_TIOCRCVFRAME = TIOCRCVFRAME;
-unsigned IOCTL_TIOCXMTFRAME = TIOCXMTFRAME;
 unsigned IOCTL_TIOCPTMGET = TIOCPTMGET;
 unsigned IOCTL_TIOCGRANTPT = TIOCGRANTPT;
 unsigned IOCTL_TIOCPTSNAME = TIOCPTSNAME;
Index: src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h
diff -u src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h:1.1.1.2 src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h:1.2
--- src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h:1.1.1.2	Fri Apr  9 22:33:11 2021
+++ src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h	Mon Dec 26 22:22:22 2022
@@ -2194,8 +2194,6 @@ extern unsigned IOCTL_TIOCDRAIN;
 extern unsigned IOCTL_TIOCGFLAGS;
 extern unsigned IOCTL_TIOCSFLAGS;
 extern unsigned IOCTL_TIOCDCDTIMESTAMP;
-extern unsigned IOCTL_TIOCRCVFRAME;
-extern unsigned IOCTL_TIOCXMTFRAME;
 extern unsigned IOCTL_TIOCPTMGET;
 extern unsigned IOCTL_TIOCGRANTPT;
 extern unsigned IOCTL_TIOCPTSNAME;

Index: src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc
diff -u src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc:1.4 src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc:1.5
--- src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc:1.4	Fri Jan 31 14:01:36 2020
+++ src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc	Mon Dec 26 22:22:22 2022

CVS commit: src

2022-12-26 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Dec 26 22:22:22 UTC 2022

Modified Files:
src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common:
sanitizer_interceptors_ioctl_netbsd.inc
sanitizer_platform_limits_netbsd.cc
sanitizer_platform_limits_netbsd.h
src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common:
sanitizer_interceptors_ioctl_netbsd.inc
sanitizer_platform_limits_netbsd.cc
sanitizer_platform_limits_netbsd.h

Log Message:
remove the PPP HDLC ioctls from more copies of sanitizers.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \

src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc
cvs rdiff -u -r1.1.1.2 -r1.2 \

src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc
 \

src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h
cvs rdiff -u -r1.4 -r1.5 \

src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc
cvs rdiff -u -r1.7 -r1.8 \

src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cc
cvs rdiff -u -r1.5 -r1.6 \

src/sys/external/bsd/compiler_rt/dist/lib/sanitizer_common/sanitizer_platform_limits_netbsd.h

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



CVS commit: src

2022-12-21 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Dec 21 19:08:22 UTC 2022

Modified Files:
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common:
sanitizer_interceptors_ioctl_netbsd.inc
sanitizer_platform_limits_netbsd.cc
sanitizer_platform_limits_netbsd.h
src/sys/net: ppp_tty.c
src/sys/sys: ttycom.h

Log Message:
ppp: remove ioctls that never worked and crash the kernel

Remove vestigial bits of PPP HDLC support that never worked on netbsd.
The TIOCRCVFRAME ioctl was apparently intended to be called only from
within the kernel, but nothing prevents user code from calling this ioctl
and crashing the kernel.

Reported-by: syzbot+53e4620d0d17a4dd0...@syzkaller.appspotmail.com
Reported-by: syzbot+d3a8b784fed1e32e0...@syzkaller.appspotmail.com
Reported-by: syzbot+375bab63345a6a7a3...@syzkaller.appspotmail.com
Reported-by: syzbot+ba7ac85196274a20b...@syzkaller.appspotmail.com
Reported-by: syzbot+57ddb63a3d1d3299e...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \

src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc
cvs rdiff -u -r1.8 -r1.9 \

src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc
cvs rdiff -u -r1.7 -r1.8 \

src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h
cvs rdiff -u -r1.71 -r1.72 src/sys/net/ppp_tty.c
cvs rdiff -u -r1.21 -r1.22 src/sys/sys/ttycom.h

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



CVS commit: src

2022-12-21 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Dec 21 19:08:22 UTC 2022

Modified Files:
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common:
sanitizer_interceptors_ioctl_netbsd.inc
sanitizer_platform_limits_netbsd.cc
sanitizer_platform_limits_netbsd.h
src/sys/net: ppp_tty.c
src/sys/sys: ttycom.h

Log Message:
ppp: remove ioctls that never worked and crash the kernel

Remove vestigial bits of PPP HDLC support that never worked on netbsd.
The TIOCRCVFRAME ioctl was apparently intended to be called only from
within the kernel, but nothing prevents user code from calling this ioctl
and crashing the kernel.

Reported-by: syzbot+53e4620d0d17a4dd0...@syzkaller.appspotmail.com
Reported-by: syzbot+d3a8b784fed1e32e0...@syzkaller.appspotmail.com
Reported-by: syzbot+375bab63345a6a7a3...@syzkaller.appspotmail.com
Reported-by: syzbot+ba7ac85196274a20b...@syzkaller.appspotmail.com
Reported-by: syzbot+57ddb63a3d1d3299e...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \

src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc
cvs rdiff -u -r1.8 -r1.9 \

src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc
cvs rdiff -u -r1.7 -r1.8 \

src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h
cvs rdiff -u -r1.71 -r1.72 src/sys/net/ppp_tty.c
cvs rdiff -u -r1.21 -r1.22 src/sys/sys/ttycom.h

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

Modified files:

Index: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc
diff -u src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc:1.4 src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc:1.5
--- src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc:1.4	Sun Apr 11 23:54:27 2021
+++ src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc	Wed Dec 21 19:08:22 2022
@@ -1267,8 +1267,6 @@ static void ioctl_table_fill() {
   _(TIOCGFLAGS, WRITE, sizeof(int));
   _(TIOCSFLAGS, READ, sizeof(int));
   _(TIOCDCDTIMESTAMP, WRITE, struct_timeval_sz);
-  _(TIOCRCVFRAME, READ, sizeof(uptr));
-  _(TIOCXMTFRAME, READ, sizeof(uptr));
   _(TIOCPTMGET, WRITE, struct_ptmget_sz);
   _(TIOCGRANTPT, NONE, 0);
   _(TIOCPTSNAME, WRITE, struct_ptmget_sz);

Index: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc
diff -u src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc:1.8 src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc:1.9
--- src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc:1.8	Sun Apr 11 23:54:27 2021
+++ src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc	Wed Dec 21 19:08:22 2022
@@ -2341,8 +2341,6 @@ unsigned IOCTL_TIOCDRAIN = TIOCDRAIN;
 unsigned IOCTL_TIOCGFLAGS = TIOCGFLAGS;
 unsigned IOCTL_TIOCSFLAGS = TIOCSFLAGS;
 unsigned IOCTL_TIOCDCDTIMESTAMP = TIOCDCDTIMESTAMP;
-unsigned IOCTL_TIOCRCVFRAME = TIOCRCVFRAME;
-unsigned IOCTL_TIOCXMTFRAME = TIOCXMTFRAME;
 unsigned IOCTL_TIOCPTMGET = TIOCPTMGET;
 unsigned IOCTL_TIOCGRANTPT = TIOCGRANTPT;
 unsigned IOCTL_TIOCPTSNAME = TIOCPTSNAME;

Index: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h
diff -u src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h:1.7 src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h:1.8
--- src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h:1.7	Sat Nov 13 15:34:39 2021
+++ src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h	Wed Dec 21 19:08:22 2022
@@ -2194,8 +2194,6 @@ extern unsigned IOCTL_TIOCDRAIN;
 extern unsigned IOCTL_TIOCGFLAGS;
 extern unsigned IOCTL_TIOCSFLAGS;
 extern unsigned IOCTL_TIOCDCDTIMESTAMP;
-extern unsigned IOCTL_TIOCRCVFRAME;
-extern unsigned IOCTL_TIOCXMTFRAME;
 extern unsigned IOCTL_TIOCPTMGET;
 extern unsigned IOCTL_TIOCGRANTPT;
 extern unsigned IOCTL_TIOCPTSNAME;

Index: src/sys/net/ppp_tty.c
diff -u src/sys/net/ppp_tty.c:1.71 src/sys/net/ppp_tty.c:1.72
--- src/sys/net/ppp_tty.c:1.71	Wed Oct 26 23:42:56 2022
+++ src/sys/net/ppp_tty.c	Wed Dec 21 19:08:22 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ppp_tty.c,v 1.71 2022/10/26 23:42:56 riastradh Exp $	*/
+/*	$NetBSD: ppp_tty.c,v 1.72 2022/12/21 19:08:22 chs Exp $	*/
 /*	Id: ppp_tty.c,v 1.3 1996/07/01 01:04:11 paulus Exp 	*/
 
 /*
@@ -93,7 +93,7 @@
 /* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */
 
 #include 
-__KERNEL_RCSID(0, 

CVS commit: src/sbin/mount_nfs

2022-12-21 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Dec 21 19:00:52 UTC 2022

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

Log Message:
mount_nfs: add missing "A" to getopt string


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sbin/mount_nfs/mount_nfs.c

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

Modified files:

Index: src/sbin/mount_nfs/mount_nfs.c
diff -u src/sbin/mount_nfs/mount_nfs.c:1.74 src/sbin/mount_nfs/mount_nfs.c:1.75
--- src/sbin/mount_nfs/mount_nfs.c:1.74	Sat Oct  3 18:42:20 2020
+++ src/sbin/mount_nfs/mount_nfs.c	Wed Dec 21 19:00:52 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: mount_nfs.c,v 1.74 2020/10/03 18:42:20 christos Exp $	*/
+/*	$NetBSD: mount_nfs.c,v 1.75 2022/12/21 19:00:52 chs Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993, 1994
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 19
 #if 0
 static char sccsid[] = "@(#)mount_nfs.c	8.11 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: mount_nfs.c,v 1.74 2020/10/03 18:42:20 christos Exp $");
+__RCSID("$NetBSD: mount_nfs.c,v 1.75 2022/12/21 19:00:52 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -221,7 +221,7 @@ mount_nfs_parseargs(int argc, char *argv
 	memset(nfsargsp, 0, sizeof(*nfsargsp));
 	*nfsargsp = nfsdefargs;
 	while ((c = getopt(argc, argv,
-	"23a:bcCdD:g:I:iKL:lm:o:PpqR:r:sTt:w:x:UuX")) != -1)
+	"23Aa:bcCdD:g:I:iKL:lm:o:PpqR:r:sTt:w:x:UuX")) != -1)
 		switch (c) {
 		case '3':
 		case 'q':



CVS commit: src/sbin/mount_nfs

2022-12-21 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Dec 21 19:00:52 UTC 2022

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

Log Message:
mount_nfs: add missing "A" to getopt string


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sbin/mount_nfs/mount_nfs.c

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



CVS commit: src/sys/ufs/ffs

2022-12-21 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Dec 21 18:58:25 UTC 2022

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
ffs: fail mounts requesting ACLs for non-ea UFS2 file systems

For non-ea UFS2 file system, fail mounts that request ACLs rather than
letting the mount succeed only to reject all ACL operations later.

Also fix the messages about the on-disk fs flags conflicting with
the mount options for which type of ACLs to use, and about requesting
both types of ACLs.


To generate a diff of this commit:
cvs rdiff -u -r1.378 -r1.379 src/sys/ufs/ffs/ffs_vfsops.c

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

Modified files:

Index: src/sys/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.378 src/sys/ufs/ffs/ffs_vfsops.c:1.379
--- src/sys/ufs/ffs/ffs_vfsops.c:1.378	Thu Nov 17 06:40:40 2022
+++ src/sys/ufs/ffs/ffs_vfsops.c	Wed Dec 21 18:58:25 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.378 2022/11/17 06:40:40 chs Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.379 2022/12/21 18:58:25 chs Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.378 2022/11/17 06:40:40 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.379 2022/12/21 18:58:25 chs Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -395,28 +395,25 @@ ffs_mountroot(void)
 	return (0);
 }
 
-static void
+static int
 ffs_acls(struct mount *mp, int fs_flags)
 {
-	if ((fs_flags & FS_NFS4ACLS) != 0) {
-#ifdef UFS_ACL
-		if (mp->mnt_flag & MNT_POSIX1EACLS)
-			printf("WARNING: %s: ACLs flag on fs conflicts with "
-			"\"posix1eacls\" mount option; option ignored\n",
-			mp->mnt_stat.f_mntonname);
-		mp->mnt_flag &= ~MNT_POSIX1EACLS;
-		mp->mnt_flag |= MNT_NFS4ACLS;
+	struct ufsmount *ump;
 
-#else
-		printf("WARNING: %s: ACLs flag on fs but no ACLs support\n",
-		mp->mnt_stat.f_mntonname);
-#endif
+	ump = VFSTOUFS(mp);
+	if (ump->um_fstype == UFS2 && (ump->um_flags & UFS_EA) == 0 &&
+	((mp->mnt_flag & (MNT_POSIX1EACLS | MNT_NFS4ACLS)) != 0 ||
+	 (fs_flags & (FS_POSIX1EACLS | FS_NFS4ACLS)) != 0)) {
+		printf("%s: ACLs requested but not supported by this fs\n",
+		   mp->mnt_stat.f_mntonname);
+		return EINVAL;
 	}
+
 	if ((fs_flags & FS_POSIX1EACLS) != 0) {
 #ifdef UFS_ACL
 		if (mp->mnt_flag & MNT_NFS4ACLS)
-			printf("WARNING: %s: NFSv4 ACLs flag on fs conflicts "
-			"with \"acls\" mount option; option ignored\n",
+			printf("WARNING: %s: POSIX.1e ACLs flag on fs conflicts "
+			"with \"nfsv4acls\" mount option; option ignored\n",
 			mp->mnt_stat.f_mntonname);
 		mp->mnt_flag &= ~MNT_NFS4ACLS;
 		mp->mnt_flag |= MNT_POSIX1EACLS;
@@ -425,20 +422,34 @@ ffs_acls(struct mount *mp, int fs_flags)
 		"ACLs support\n", mp->mnt_stat.f_mntonname);
 #endif
 	}
+	if ((fs_flags & FS_NFS4ACLS) != 0) {
+#ifdef UFS_ACL
+		if (mp->mnt_flag & MNT_POSIX1EACLS)
+			printf("WARNING: %s: NFSv4 ACLs flag on fs conflicts "
+			"with \"posix1eacls\" mount option; option ignored\n",
+			mp->mnt_stat.f_mntonname);
+		mp->mnt_flag &= ~MNT_POSIX1EACLS;
+		mp->mnt_flag |= MNT_NFS4ACLS;
 
+#else
+		printf("WARNING: %s: NFSv4 ACLs flag on fs but no "
+		"ACLs support\n", mp->mnt_stat.f_mntonname);
+#endif
+	}
 	if ((mp->mnt_flag & (MNT_NFS4ACLS | MNT_POSIX1EACLS))
 	== (MNT_NFS4ACLS | MNT_POSIX1EACLS))
 	{
-		printf("WARNING: %s: posix1eacl conflicts "
-		"with \"acls\" mount option; option ignored\n",
+		printf("%s: \"posix1eacls\" and \"nfsv4acls\" options "
+		   "are mutually exclusive\n",
 		mp->mnt_stat.f_mntonname);
-		mp->mnt_flag &= ~MNT_POSIX1EACLS;
+		return EINVAL;
 	}
 
 	if (mp->mnt_flag & (MNT_NFS4ACLS | MNT_POSIX1EACLS))
 		mp->mnt_iflag &= ~(IMNT_SHRLOOKUP|IMNT_NCLOOKUP);
 	else
 		mp->mnt_iflag |= IMNT_SHRLOOKUP|IMNT_NCLOOKUP;
+	return 0;
 }
 
 /*
@@ -568,6 +579,11 @@ ffs_mount(struct mount *mp, const char *
 	mp->mnt_flag &= ~MNT_LOG;
 #endif /* !WAPBL */
 
+	error = set_statvfs_info(path, UIO_USERSPACE, args->fspec,
+	UIO_USERSPACE, mp->mnt_op->vfs_name, mp, l);
+	if (error)
+		goto fail;
+
 	if (!update) {
 		int xflags;
 
@@ -658,7 +674,9 @@ ffs_mount(struct mount *mp, const char *
 			fs->fs_fmod = 0;
 		}
 
-		ffs_acls(mp, fs->fs_flags);
+		error = ffs_acls(mp, fs->fs_flags);
+		if (error)
+			return error;
 		if (mp->mnt_flag & MNT_RELOAD) {
 			error = ffs_reload(mp, l->l_cred, l);
 			if (error) {
@@ -735,14 +753,9 @@ ffs_mount(struct mount *mp, const char *
 			return 0;
 	}
 
-	error = set_statvfs_info(path, UIO_USERSPACE, args->fspec,
-	UIO_USERSPACE, mp->mnt_op->vfs_name, mp, l);
-	if (error == 0)
-		(void)strncpy(fs->fs_fsmnt, mp->mnt_stat.f_mntonname,
-		sizeof(fs->fs_fsmnt));
-	else {
-	DPRINTF("set_statvfs_info returned %d", error);
-	}
+	(void)strncpy(fs->fs_fsmnt, mp->mnt_stat.f_mntonname,
+	sizeof(fs->fs_fsmnt));
+
 	fs->fs_flags 

CVS commit: src/sys/ufs/ffs

2022-12-21 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Dec 21 18:58:25 UTC 2022

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
ffs: fail mounts requesting ACLs for non-ea UFS2 file systems

For non-ea UFS2 file system, fail mounts that request ACLs rather than
letting the mount succeed only to reject all ACL operations later.

Also fix the messages about the on-disk fs flags conflicting with
the mount options for which type of ACLs to use, and about requesting
both types of ACLs.


To generate a diff of this commit:
cvs rdiff -u -r1.378 -r1.379 src/sys/ufs/ffs/ffs_vfsops.c

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



CVS commit: src/sys/uvm

2022-12-20 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Dec 21 02:28:06 UTC 2022

Modified Files:
src/sys/uvm: uvm_swap.c

Log Message:
swap: disallow user opens of swap block device

the swap/drum block device was never intended to allow user opens,
but when the internal VOP_OPEN() in uvm_swap_init() was added
back in rev 1.135, the d_open method was changed from always-fail
to always-succeed in order to allow the new initial internal open.
this had the side effect of incorrectly allowing user opens too.
fix this by replacing the swap_bdevsw d_open with one that succeeds
for the first call but fails for all subsequent calls.

Reported-by: syzbot+90a23d2f19e5a0a30...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.206 -r1.207 src/sys/uvm/uvm_swap.c

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



CVS commit: src/sys/uvm

2022-12-20 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Dec 21 02:28:06 UTC 2022

Modified Files:
src/sys/uvm: uvm_swap.c

Log Message:
swap: disallow user opens of swap block device

the swap/drum block device was never intended to allow user opens,
but when the internal VOP_OPEN() in uvm_swap_init() was added
back in rev 1.135, the d_open method was changed from always-fail
to always-succeed in order to allow the new initial internal open.
this had the side effect of incorrectly allowing user opens too.
fix this by replacing the swap_bdevsw d_open with one that succeeds
for the first call but fails for all subsequent calls.

Reported-by: syzbot+90a23d2f19e5a0a30...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.206 -r1.207 src/sys/uvm/uvm_swap.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/uvm/uvm_swap.c
diff -u src/sys/uvm/uvm_swap.c:1.206 src/sys/uvm/uvm_swap.c:1.207
--- src/sys/uvm/uvm_swap.c:1.206	Mon Aug 23 13:08:18 2021
+++ src/sys/uvm/uvm_swap.c	Wed Dec 21 02:28:06 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_swap.c,v 1.206 2021/08/23 13:08:18 hannken Exp $	*/
+/*	$NetBSD: uvm_swap.c,v 1.207 2022/12/21 02:28:06 chs Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1997, 2009 Matthew R. Green
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.206 2021/08/23 13:08:18 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.207 2022/12/21 02:28:06 chs Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_compat_netbsd.h"
@@ -1190,6 +1190,22 @@ again:
  */
 
 /*
+ * swopen: allow the initial open from uvm_swap_init() and reject all others.
+ */
+
+static int
+swopen(dev_t dev, int flag, int mode, struct lwp *l)
+{
+	static bool inited = false;
+
+	if (!inited) {
+		inited = true;
+		return 0;
+	}
+	return ENODEV;
+}
+
+/*
  * swstrategy: perform I/O on the drum
  *
  * => we must map the i/o request from the drum to the correct swapdev.
@@ -1308,8 +1324,8 @@ swwrite(dev_t dev, struct uio *uio, int 
 }
 
 const struct bdevsw swap_bdevsw = {
-	.d_open = nullopen,
-	.d_close = nullclose,
+	.d_open = swopen,
+	.d_close = noclose,
 	.d_strategy = swstrategy,
 	.d_ioctl = noioctl,
 	.d_dump = nodump,



CVS commit: src/sbin/tunefs

2022-12-19 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Dec 19 21:13:16 UTC 2022

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

Log Message:
tunefs: clarify that "-a" refers to NFSv4 ACLs


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sbin/tunefs/tunefs.c

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

Modified files:

Index: src/sbin/tunefs/tunefs.c
diff -u src/sbin/tunefs/tunefs.c:1.56 src/sbin/tunefs/tunefs.c:1.57
--- src/sbin/tunefs/tunefs.c:1.56	Thu Nov 17 06:40:39 2022
+++ src/sbin/tunefs/tunefs.c	Mon Dec 19 21:13:16 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tunefs.c,v 1.56 2022/11/17 06:40:39 chs Exp $	*/
+/*	$NetBSD: tunefs.c,v 1.57 2022/12/19 21:13:16 chs Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)tunefs.c	8.3 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: tunefs.c,v 1.56 2022/11/17 06:40:39 chs Exp $");
+__RCSID("$NetBSD: tunefs.c,v 1.57 2022/12/19 21:13:16 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -360,7 +360,7 @@ main(int argc, char *argv[])
 	 * be cleared by kernel or fsck.
 	 */
 	if (aflag) {
-		name = "ACLs";
+		name = "NFSv4 ACLs";
 		if (strcmp(avalue, "enable") == 0) {
 			if (is_ufs2 && !extattr) {
 warnx("%s not supported by this fs", name);



CVS commit: src/sbin/tunefs

2022-12-19 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Dec 19 21:13:16 UTC 2022

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

Log Message:
tunefs: clarify that "-a" refers to NFSv4 ACLs


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sbin/tunefs/tunefs.c

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



CVS commit: src/usr.sbin/dumpfs

2022-12-19 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Dec 19 18:51:42 UTC 2022

Modified Files:
src/usr.sbin/dumpfs: dumpfs.8 dumpfs.c

Log Message:
dumpfs: remove confusing output for UFS2

remove the mention of "fslevel 5" because no such thing exists.
the whole "fs level" concept really only applies to UFS1, so don't print
the line with the level number and details for UFS2 file systems at all.
try to clarify this in the manpage as well.
prompted by PR 57082.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/dumpfs/dumpfs.8
cvs rdiff -u -r1.66 -r1.67 src/usr.sbin/dumpfs/dumpfs.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/dumpfs/dumpfs.8
diff -u src/usr.sbin/dumpfs/dumpfs.8:1.20 src/usr.sbin/dumpfs/dumpfs.8:1.21
--- src/usr.sbin/dumpfs/dumpfs.8:1.20	Sat Feb 27 10:49:42 2010
+++ src/usr.sbin/dumpfs/dumpfs.8	Mon Dec 19 18:51:42 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: dumpfs.8,v 1.20 2010/02/27 10:49:42 wiz Exp $
+.\"	$NetBSD: dumpfs.8,v 1.21 2022/12/19 18:51:42 chs Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -80,7 +80,7 @@ defaults to
 .Nm
 is useful mostly for finding out certain file system
 information such as the file system block size, minimum
-free space percentage, and the file system level that
+free space percentage, and (for FFSv1) the file system level that
 can be upgraded with the
 .Fl c
 option of

Index: src/usr.sbin/dumpfs/dumpfs.c
diff -u src/usr.sbin/dumpfs/dumpfs.c:1.66 src/usr.sbin/dumpfs/dumpfs.c:1.67
--- src/usr.sbin/dumpfs/dumpfs.c:1.66	Thu Nov 17 06:40:40 2022
+++ src/usr.sbin/dumpfs/dumpfs.c	Mon Dec 19 18:51:42 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: dumpfs.c,v 1.66 2022/11/17 06:40:40 chs Exp $	*/
+/*	$NetBSD: dumpfs.c,v 1.67 2022/12/19 18:51:42 chs Exp $	*/
 
 /*
  * Copyright (c) 1983, 1992, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)dumpfs.c	8.5 (Berkeley) 4/29/95";
 #else
-__RCSID("$NetBSD: dumpfs.c,v 1.66 2022/11/17 06:40:40 chs Exp $");
+__RCSID("$NetBSD: dumpfs.c,v 1.67 2022/12/19 18:51:42 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -314,7 +314,7 @@ print_superblock(struct fs *fs, uint16_t
 	fs->fs_magic, ctime());
 
 	if (is_ufs2)
-		i = 5;
+		i = -1;
 	else {
 		i = 0;
 		if (fs->fs_old_postblformat != FS_42POSTBLFMT) {
@@ -338,10 +338,11 @@ print_superblock(struct fs *fs, uint16_t
 	fs->fs_id[0] || fs->fs_id[1])
 		printf("superblock location\t%jd\tid\t[ %x %x ]\n",
 		(intmax_t)fs->fs_sblockloc, fs->fs_id[0], fs->fs_id[1]);
-	printf("cylgrp\t%s\tinodes\t%s\tsblock\t%s\tfslevel %d\n",
-	i < 1 ? "static" : "dynamic",
-	i < 2 ? "4.2/4.3BSD" : i < 5 ? "4.4BSD" : "FFSv2",
-	i < 4 ? "FFSv1" : "FFSv2", i);
+	if (!is_ufs2)
+		printf("cylgrp\t%s\tinodes\t%s\tsblock\t%s\tfslevel %d\n",
+		i < 1 ? "static" : "dynamic",
+		i < 2 ? "4.2/4.3BSD" : i < 5 ? "4.4BSD" : "FFSv2",
+		i < 4 ? "FFSv1" : "FFSv2", i);
 	printf("nbfree\t%lld\tndir\t%lld\tnifree\t%lld\tnffree\t%lld\n",
 	(long long)fs->fs_cstotal.cs_nbfree,
 	(long long)fs->fs_cstotal.cs_ndir,



CVS commit: src/usr.sbin/dumpfs

2022-12-19 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Dec 19 18:51:42 UTC 2022

Modified Files:
src/usr.sbin/dumpfs: dumpfs.8 dumpfs.c

Log Message:
dumpfs: remove confusing output for UFS2

remove the mention of "fslevel 5" because no such thing exists.
the whole "fs level" concept really only applies to UFS1, so don't print
the line with the level number and details for UFS2 file systems at all.
try to clarify this in the manpage as well.
prompted by PR 57082.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/dumpfs/dumpfs.8
cvs rdiff -u -r1.66 -r1.67 src/usr.sbin/dumpfs/dumpfs.c

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



CVS commit: src/sbin/restore

2022-12-12 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Dec 12 16:53:30 UTC 2022

Modified Files:
src/sbin/restore: dirs.c tape.c

Log Message:
apply this commit from FreeBSD:

  commit 9dda00df7e8f9279a43d92758df6a7e10a9aed95
  Author: Chuck Silvers 
  Date:   Mon Dec 12 08:14:17 2022 -0800

  restore: fix restore of NFS4 ACLs

  Changing the mode bits on a file with an NFS4 ACL results in the
  NFS4 ACL being replaced by one matching the new mode bits being set,
  so when restoring a file with an NFS4 ACL, set the owner/group/mode first
  and then set the NFS4 ACL, so that setting the mode does not throw away
  the ACL that we just set.

  Reviewed by:mckusick
  Differential Revision:  https://reviews.freebsd.org/D37618


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sbin/restore/dirs.c
cvs rdiff -u -r1.73 -r1.74 src/sbin/restore/tape.c

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

Modified files:

Index: src/sbin/restore/dirs.c
diff -u src/sbin/restore/dirs.c:1.54 src/sbin/restore/dirs.c:1.55
--- src/sbin/restore/dirs.c:1.54	Sat Dec 10 18:49:44 2022
+++ src/sbin/restore/dirs.c	Mon Dec 12 16:53:30 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: dirs.c,v 1.54 2022/12/10 18:49:44 chs Exp $	*/
+/*	$NetBSD: dirs.c,v 1.55 2022/12/12 16:53:30 chs Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)dirs.c	8.7 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: dirs.c,v 1.54 2022/12/10 18:49:44 chs Exp $");
+__RCSID("$NetBSD: dirs.c,v 1.55 2022/12/12 16:53:30 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -675,8 +675,13 @@ setdirmodes(int flags)
 			(uintmax_t)node.ino);
 			continue;
 		}
+		cp = myname(ep);
 		if (!Nflag) {
-			cp = myname(ep);
+			if (myuid != 0)
+(void) chown(cp, myuid, node.gid);
+			else
+(void) chown(cp, node.uid, node.gid);
+			(void) chmod(cp, node.mode);
 			if (node.extsize > 0) {
 if (bufsize >= node.extsize) {
 	set_extattr(-1, cp, buf, node.extsize, SXA_FILE);
@@ -685,11 +690,6 @@ setdirmodes(int flags)
 	"extended attributes for ", cp);
 }
 			}
-			if (myuid != 0)
-(void) chown(cp, myuid, node.gid);
-			else
-(void) chown(cp, node.uid, node.gid);
-			(void) chmod(cp, node.mode);
 			(void) utimens(cp, node.ctimep);
 			(void) utimens(cp, node.mtimep);
 			if (Mtreefile) {

Index: src/sbin/restore/tape.c
diff -u src/sbin/restore/tape.c:1.73 src/sbin/restore/tape.c:1.74
--- src/sbin/restore/tape.c:1.73	Sat Dec 10 18:49:44 2022
+++ src/sbin/restore/tape.c	Mon Dec 12 16:53:30 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tape.c,v 1.73 2022/12/10 18:49:44 chs Exp $	*/
+/*	$NetBSD: tape.c,v 1.74 2022/12/12 16:53:30 chs Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)tape.c	8.9 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: tape.c,v 1.73 2022/12/10 18:49:44 chs Exp $");
+__RCSID("$NetBSD: tape.c,v 1.74 2022/12/12 16:53:30 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -698,13 +698,13 @@ extractfile(char *name)
 		if (uflag)
 			(void) unlink(name);
 		if (linkit(lnkbuf, name, SYMLINK) == GOOD) {
-			if (extsize > 0)
-set_extattr(-1, name, buf, extsize, SXA_LINK);
 			if (setbirth)
 (void) lutimens(name, ctimep);
 			(void) lutimens(name, mtimep);
 			(void) lchown(name, uid, gid);
 			(void) lchmod(name, mode);
+			if (extsize > 0)
+set_extattr(-1, name, buf, extsize, SXA_LINK);
 			if (Mtreefile) {
 writemtree(name, "link",
 uid, gid, mode, flags);
@@ -730,6 +730,8 @@ extractfile(char *name)
 			skipfile();
 			return (FAIL);
 		}
+		(void) chown(name, uid, gid);
+		(void) chmod(name, mode);
 		if (extsize == 0) {
 			skipfile();
 		} else {
@@ -740,8 +742,6 @@ extractfile(char *name)
 		if (setbirth)
 			(void) utimens(name, ctimep);
 		(void) utimens(name, mtimep);
-		(void) chown(name, uid, gid);
-		(void) chmod(name, mode);
 		if (Mtreefile) {
 			writemtree(name,
 			((mode & (S_IFBLK | IFCHR)) == IFBLK) ?
@@ -765,6 +765,8 @@ extractfile(char *name)
 			skipfile();
 			return (FAIL);
 		}
+		(void) chown(name, uid, gid);
+		(void) chmod(name, mode);
 		if (extsize == 0) {
 			skipfile();
 		} else {
@@ -775,8 +777,6 @@ extractfile(char *name)
 		if (setbirth)
 			(void) utimens(name, ctimep);
 		(void) utimens(name, mtimep);
-		(void) chown(name, uid, gid);
-		(void) chmod(name, mode);
 		if (Mtreefile) {
 			writemtree(name, "fifo",
 			uid, gid, mode, flags);
@@ -797,6 +797,8 @@ extractfile(char *name)
 		}
 		if (Dflag)
 			(*ddesc->dd_init)();
+		(void) fchown(ofile, uid, gid);
+		(void) fchmod(ofile, mode);
 		buf = setupextattr(extsize);
 		getfile(xtrfile, xtrattr, xtrskip);
 		if (extsize > 0)
@@ -814,8 +816,6 @@ extractfile(char *name)
 		if (setbirth)
 			(void) futimens(of

CVS commit: src/sbin/restore

2022-12-12 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Dec 12 16:53:30 UTC 2022

Modified Files:
src/sbin/restore: dirs.c tape.c

Log Message:
apply this commit from FreeBSD:

  commit 9dda00df7e8f9279a43d92758df6a7e10a9aed95
  Author: Chuck Silvers 
  Date:   Mon Dec 12 08:14:17 2022 -0800

  restore: fix restore of NFS4 ACLs

  Changing the mode bits on a file with an NFS4 ACL results in the
  NFS4 ACL being replaced by one matching the new mode bits being set,
  so when restoring a file with an NFS4 ACL, set the owner/group/mode first
  and then set the NFS4 ACL, so that setting the mode does not throw away
  the ACL that we just set.

  Reviewed by:mckusick
  Differential Revision:  https://reviews.freebsd.org/D37618


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sbin/restore/dirs.c
cvs rdiff -u -r1.73 -r1.74 src/sbin/restore/tape.c

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



CVS commit: src/sys/dev/tprof

2022-12-10 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Dec 11 01:36:49 UTC 2022

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

Log Message:
make sure error is initialized before we return it.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/tprof/tprof.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/tprof/tprof.c
diff -u src/sys/dev/tprof/tprof.c:1.19 src/sys/dev/tprof/tprof.c:1.20
--- src/sys/dev/tprof/tprof.c:1.19	Thu Dec  1 00:32:52 2022
+++ src/sys/dev/tprof/tprof.c	Sun Dec 11 01:36:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tprof.c,v 1.19 2022/12/01 00:32:52 ryo Exp $	*/
+/*	$NetBSD: tprof.c,v 1.20 2022/12/11 01:36:49 chs Exp $	*/
 
 /*-
  * Copyright (c)2008,2009,2010 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tprof.c,v 1.19 2022/12/01 00:32:52 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tprof.c,v 1.20 2022/12/11 01:36:49 chs Exp $");
 
 #include 
 #include 
@@ -404,6 +404,8 @@ tprof_start(tprof_countermask_t runmask)
 			workqueue_enqueue(tprof_wq, >c_work, ci);
 		}
 	}
+	error = 0;
+
 done:
 	return error;
 }



CVS commit: src/sys/dev/tprof

2022-12-10 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Dec 11 01:36:49 UTC 2022

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

Log Message:
make sure error is initialized before we return it.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/tprof/tprof.c

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



CVS commit: src/sbin/restore

2022-12-10 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sat Dec 10 18:49:44 UTC 2022

Modified Files:
src/sbin/restore: dirs.c tape.c

Log Message:
apply this change from FreeBSD:

  commit c028393d7072f1f88efd8d6e6c77bb9b15b3f3b6
  Author: Kirk McKusick 
  Date:   Fri Apr 11 21:48:14 2008 +

  Correctly set file group when restore is run by a user other than root.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sbin/restore/dirs.c
cvs rdiff -u -r1.72 -r1.73 src/sbin/restore/tape.c

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



CVS commit: src/sbin/restore

2022-12-10 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sat Dec 10 18:49:44 UTC 2022

Modified Files:
src/sbin/restore: dirs.c tape.c

Log Message:
apply this change from FreeBSD:

  commit c028393d7072f1f88efd8d6e6c77bb9b15b3f3b6
  Author: Kirk McKusick 
  Date:   Fri Apr 11 21:48:14 2008 +

  Correctly set file group when restore is run by a user other than root.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sbin/restore/dirs.c
cvs rdiff -u -r1.72 -r1.73 src/sbin/restore/tape.c

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

Modified files:

Index: src/sbin/restore/dirs.c
diff -u src/sbin/restore/dirs.c:1.53 src/sbin/restore/dirs.c:1.54
--- src/sbin/restore/dirs.c:1.53	Wed Jun 23 14:22:08 2021
+++ src/sbin/restore/dirs.c	Sat Dec 10 18:49:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: dirs.c,v 1.53 2021/06/23 14:22:08 riastradh Exp $	*/
+/*	$NetBSD: dirs.c,v 1.54 2022/12/10 18:49:44 chs Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)dirs.c	8.7 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: dirs.c,v 1.53 2021/06/23 14:22:08 riastradh Exp $");
+__RCSID("$NetBSD: dirs.c,v 1.54 2022/12/10 18:49:44 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -598,6 +598,7 @@ setdirmodes(int flags)
 	struct entry *ep;
 	char *cp, *buf;
 	int bufsize;
+	uid_t myuid;
 
 	vprintf(stdout, "Set directory mode, owner, and times.\n");
 	if (command == 'r' || command == 'R')
@@ -618,6 +619,7 @@ setdirmodes(int flags)
 	clearerr(mf);
 	bufsize = 0;
 	buf = NULL;
+	myuid = getuid();
 	for (;;) {
 		(void) fread((char *), 1, sizeof(struct modeinfo), mf);
 		if (ferror(mf)) {
@@ -683,10 +685,13 @@ setdirmodes(int flags)
 	"extended attributes for ", cp);
 }
 			}
+			if (myuid != 0)
+(void) chown(cp, myuid, node.gid);
+			else
+(void) chown(cp, node.uid, node.gid);
+			(void) chmod(cp, node.mode);
 			(void) utimens(cp, node.ctimep);
 			(void) utimens(cp, node.mtimep);
-			(void) chown(cp, node.uid, node.gid);
-			(void) chmod(cp, node.mode);
 			if (Mtreefile) {
 writemtree(cp, "dir",
 node.uid, node.gid, node.mode,

Index: src/sbin/restore/tape.c
diff -u src/sbin/restore/tape.c:1.72 src/sbin/restore/tape.c:1.73
--- src/sbin/restore/tape.c:1.72	Thu May  5 07:45:43 2022
+++ src/sbin/restore/tape.c	Sat Dec 10 18:49:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tape.c,v 1.72 2022/05/05 07:45:43 mrg Exp $	*/
+/*	$NetBSD: tape.c,v 1.73 2022/12/10 18:49:44 chs Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)tape.c	8.9 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: tape.c,v 1.72 2022/05/05 07:45:43 mrg Exp $");
+__RCSID("$NetBSD: tape.c,v 1.73 2022/12/10 18:49:44 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -656,7 +656,9 @@ extractfile(char *name)
 		ctimep[1].tv_nsec = curfile.birthtime_nsec;
 	}
 	extsize = curfile.extsize;
-	uid = curfile.uid;
+	uid = getuid();
+	if (uid == 0)
+		uid = curfile.uid;
 	gid = curfile.gid;
 	mode = curfile.mode;
 	flags = curfile.file_flags;



CVS commit: src/sys/ufs

2022-11-27 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Nov 28 04:52:04 UTC 2022

Modified Files:
src/sys/ufs: files.ufs
src/sys/ufs/ffs: ffs_extattr.c ffs_extern.h

Log Message:
the UFS_EXTATTR option was supposed to affect only UFS1 file systems,
but when the UFS2 extattr code was merged, the UFS_EXTATTR option was
mistakenly changed to affect UFS2 file systems as well.  this commit
changes UFS_EXTATTR back to affecting only UFS1 file systems as originally
intended.  in UFS2 (or rather UFS2ea in NetBSD), extattrs are a
native feature and are always supported.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/ufs/files.ufs
cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/ffs/ffs_extattr.c
cvs rdiff -u -r1.86 -r1.87 src/sys/ufs/ffs/ffs_extern.h

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



CVS commit: src/sys/ufs

2022-11-27 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Nov 28 04:52:04 UTC 2022

Modified Files:
src/sys/ufs: files.ufs
src/sys/ufs/ffs: ffs_extattr.c ffs_extern.h

Log Message:
the UFS_EXTATTR option was supposed to affect only UFS1 file systems,
but when the UFS2 extattr code was merged, the UFS_EXTATTR option was
mistakenly changed to affect UFS2 file systems as well.  this commit
changes UFS_EXTATTR back to affecting only UFS1 file systems as originally
intended.  in UFS2 (or rather UFS2ea in NetBSD), extattrs are a
native feature and are always supported.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/ufs/files.ufs
cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/ffs/ffs_extattr.c
cvs rdiff -u -r1.86 -r1.87 src/sys/ufs/ffs/ffs_extern.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/ufs/files.ufs
diff -u src/sys/ufs/files.ufs:1.49 src/sys/ufs/files.ufs:1.50
--- src/sys/ufs/files.ufs:1.49	Thu Sep 24 17:20:53 2020
+++ src/sys/ufs/files.ufs	Mon Nov 28 04:52:04 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ufs,v 1.49 2020/09/24 17:20:53 riastradh Exp $
+#	$NetBSD: files.ufs,v 1.50 2022/11/28 04:52:04 chs Exp $
 
 deffs	FFS
 deffs	EXT2FS
@@ -52,7 +52,7 @@ define	ffs: vfs, ufs
 file	ufs/ffs/ffs_alloc.c		ffs
 file	ufs/ffs/ffs_balloc.c		ffs
 file	ufs/ffs/ffs_bswap.c		(ffs | mfs) & ffs_ei
-file	ufs/ffs/ffs_extattr.c		ffs & ufs_extattr
+file	ufs/ffs/ffs_extattr.c		ffs
 file	ufs/ffs/ffs_inode.c		ffs
 file	ufs/ffs/ffs_snapshot.c		ffs
 file	ufs/ffs/ffs_subr.c		ffs

Index: src/sys/ufs/ffs/ffs_extattr.c
diff -u src/sys/ufs/ffs/ffs_extattr.c:1.9 src/sys/ufs/ffs/ffs_extattr.c:1.10
--- src/sys/ufs/ffs/ffs_extattr.c:1.9	Thu Nov 17 06:40:40 2022
+++ src/sys/ufs/ffs/ffs_extattr.c	Mon Nov 28 04:52:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_extattr.c,v 1.9 2022/11/17 06:40:40 chs Exp $	*/
+/*	$NetBSD: ffs_extattr.c,v 1.10 2022/11/28 04:52:04 chs Exp $	*/
 
 /*-
  * SPDX-License-Identifier: (BSD-2-Clause-FreeBSD AND BSD-3-Clause)
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_extattr.c,v 1.9 2022/11/17 06:40:40 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_extattr.c,v 1.10 2022/11/28 04:52:04 chs Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -114,7 +114,7 @@ __KERNEL_RCSID(0, "$NetBSD: ffs_extattr.
 #define VI_UNLOCK(vp)		mutex_exit((vp)->v_interlock)
 #define UFS_INODE_SET_FLAG(ip, f)	((ip)->i_flag |= (f))
 #define ASSERT_VOP_ELOCKED(vp, m)	KASSERT(VOP_ISLOCKED(vp))
-#define I_IS_UFS2(ip)		(ITOFS(ip)->fs_magic == FS_UFS2_MAGIC)
+#define I_IS_UFS2(ip)		((ip)->i_ump->um_fstype == UFS2)
 #define	lblktosize(fs, o)	ffs_lblktosize(fs, o)
 #define	lblkno(fs, o)		ffs_lblkno(fs, o)
 #define	blkoff(fs, o)		ffs_blkoff(fs, o)
@@ -151,7 +151,7 @@ ffs_extread(struct vnode *vp, struct uio
 	dp = ip->i_din2;
 
 #ifdef INVARIANTS
-	if (uio->uio_rw != UIO_READ || fs->fs_magic != FS_UFS2_MAGIC)
+	if (uio->uio_rw != UIO_READ || ip->i_ump->um_fstype != UFS2)
 		panic("ffs_extread: mode");
 
 #endif
@@ -269,7 +269,7 @@ ffs_extwrite(struct vnode *vp, struct ui
 	dp = ip->i_din2;
 
 #ifdef INVARIANTS
-	if (uio->uio_rw != UIO_WRITE || fs->fs_magic != FS_UFS2_MAGIC)
+	if (uio->uio_rw != UIO_WRITE || ip->i_ump->um_fstype != UFS2)
 		panic("ffs_extwrite: mode");
 #endif
 
@@ -585,10 +585,9 @@ ffs_openextattr(void *v)
 		struct proc *a_p;
 	} */ *ap = v;
 	struct inode *ip = VTOI(ap->a_vp);
-	struct fs *fs = ip->i_fs;
 
 	/* Not supported for UFS1 file systems. */
-	if (fs->fs_magic == FS_UFS1_MAGIC)
+	if (ip->i_ump->um_fstype == UFS1)
 		return (EOPNOTSUPP);
 
 #ifdef __FreeBSD__
@@ -612,10 +611,9 @@ ffs_closeextattr(void *v)
 		struct proc *a_p;
 	} */ *ap = v;
 	struct inode *ip = VTOI(ap->a_vp);
-	struct fs *fs = ip->i_fs;
 
 	/* Not supported for UFS1 file systems. */
-	if (fs->fs_magic == FS_UFS1_MAGIC)
+	if (ip->i_ump->um_fstype == UFS1)
 		return (EOPNOTSUPP);
 
 #ifdef __FreeBSD__
@@ -646,11 +644,15 @@ ffs_getextattr(void *v)
 	} */ *ap = v;
 	struct vnode *vp = ap->a_vp;
 	struct inode *ip = VTOI(vp);
-	struct fs *fs = ip->i_fs;
 
 	KASSERT(VOP_ISLOCKED(vp));
-	if (fs->fs_magic == FS_UFS1_MAGIC) {
+
+	if (ip->i_ump->um_fstype == UFS1) {
+#ifdef UFS_EXTATTR
 		return ufs_getextattr(ap);
+#else
+		return EOPNOTSUPP;
+#endif
 	}
 
 	u_char *eae, *p;
@@ -708,8 +710,12 @@ ffs_setextattr(void *v)
 	struct fs *fs = ip->i_fs;
 
 	KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
-	if (fs->fs_magic == FS_UFS1_MAGIC) {
+	if (ip->i_ump->um_fstype == UFS1) {
+#ifdef UFS_EXTATTR
 		return ufs_setextattr(ap);
+#else
+		return EOPNOTSUPP;
+#endif
 	}
 
 	struct extattr *eap;
@@ -829,10 +835,13 @@ ffs_listextattr(void *v)
 		struct proc *a_p;
 	} */ *ap = v;
 	struct inode *ip = VTOI(ap->a_vp);
-	struct fs *fs = ip->i_fs;
 
-	if (fs->fs_magic == FS_UFS1_MAGIC) {
+	if (ip->i_ump->um_fstype == UFS1) {
+#ifdef UFS_EXTATTR
 		return ufs_listextattr(ap);
+#else
+		return EOPNOTSUPP;
+#endif
 	}
 
 	

CVS commit: src

2022-11-16 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Thu Nov 17 06:40:41 UTC 2022

Modified Files:
src: UPDATING
src/distrib/sets/lists/tests: mi
src/sbin/badsect: badsect.c
src/sbin/cgdconfig: cgdconfig.c
src/sbin/clri: clri.c
src/sbin/dump: ffs_inode.c
src/sbin/fsck_ffs: extern.h fsck.h fsck_ffs.8 main.c pass1.c pass5.c
setup.c utilities.c
src/sbin/fsdb: fsdb.8 fsdb.c fsdbutil.c
src/sbin/fsirand: fsirand.c
src/sbin/newfs: extern.h mkfs.c newfs.8 newfs.c
src/sbin/resize_ffs: resize_ffs.c
src/sbin/scan_ffs: scan_ffs.c
src/sbin/tunefs: tunefs.c
src/sys/arch/hppa/stand/xxboot: readufs_ffs.c
src/sys/arch/sparc/stand/bootblk: bootblk.fth genfth.cf
src/sys/arch/x68k/stand/boot_ufs: readufs_ffs.c
src/sys/lib/libsa: ffsv1.c ffsv2.c lfsv1.c lfsv2.c ufs.c
src/sys/ufs/ffs: ffs_balloc.c ffs_extattr.c ffs_vfsops.c fs.h
src/sys/ufs/ufs: ufs_bmap.c ufsmount.h
src/tests/fs/ffs: t_extattr.c
src/tests/sbin/fsck_ffs: Makefile
src/usr.sbin/dumpfs: dumpfs.c
src/usr.sbin/fstyp: ufs.c
src/usr.sbin/installboot: ffs.c
src/usr.sbin/makefs: ffs.c ffs.h makefs.8
src/usr.sbin/makefs/ffs: ffs_balloc.c mkfs.c
src/usr.sbin/quot: quot.c
src/usr.sbin/quotacheck: quotacheck.c
src/usr.sbin/sysinst: label.c
Added Files:
src/tests/sbin/fsck_ffs: t_extattr.sh

Log Message:
Restore backward compatibility of UFS2 with previous NetBSD releases by
disabling support in UFS2 for extended attributes (including ACLs).
Add a new variant of UFS2 called "UFS2ea" that does support extended attributes.
Add new fsck_ffs operations "-c ea" and "-c no-ea" to convert file systems
from UFS2 to UFS2ea and vice-versa (both of which delete all existing extended
attributes in the process).


To generate a diff of this commit:
cvs rdiff -u -r1.334 -r1.335 src/UPDATING
cvs rdiff -u -r1.1230 -r1.1231 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.34 -r1.35 src/sbin/badsect/badsect.c
cvs rdiff -u -r1.60 -r1.61 src/sbin/cgdconfig/cgdconfig.c
cvs rdiff -u -r1.24 -r1.25 src/sbin/clri/clri.c
cvs rdiff -u -r1.23 -r1.24 src/sbin/dump/ffs_inode.c
cvs rdiff -u -r1.27 -r1.28 src/sbin/fsck_ffs/extern.h
cvs rdiff -u -r1.55 -r1.56 src/sbin/fsck_ffs/fsck.h
cvs rdiff -u -r1.51 -r1.52 src/sbin/fsck_ffs/fsck_ffs.8
cvs rdiff -u -r1.89 -r1.90 src/sbin/fsck_ffs/main.c
cvs rdiff -u -r1.59 -r1.60 src/sbin/fsck_ffs/pass1.c
cvs rdiff -u -r1.54 -r1.55 src/sbin/fsck_ffs/pass5.c
cvs rdiff -u -r1.103 -r1.104 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.66 -r1.67 src/sbin/fsck_ffs/utilities.c
cvs rdiff -u -r1.27 -r1.28 src/sbin/fsdb/fsdb.8
cvs rdiff -u -r1.52 -r1.53 src/sbin/fsdb/fsdb.c
cvs rdiff -u -r1.23 -r1.24 src/sbin/fsdb/fsdbutil.c
cvs rdiff -u -r1.32 -r1.33 src/sbin/fsirand/fsirand.c
cvs rdiff -u -r1.19 -r1.20 src/sbin/newfs/extern.h
cvs rdiff -u -r1.131 -r1.132 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.85 -r1.86 src/sbin/newfs/newfs.8
cvs rdiff -u -r1.117 -r1.118 src/sbin/newfs/newfs.c
cvs rdiff -u -r1.56 -r1.57 src/sbin/resize_ffs/resize_ffs.c
cvs rdiff -u -r1.35 -r1.36 src/sbin/scan_ffs/scan_ffs.c
cvs rdiff -u -r1.55 -r1.56 src/sbin/tunefs/tunefs.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/hppa/stand/xxboot/readufs_ffs.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sparc/stand/bootblk/bootblk.fth
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc/stand/bootblk/genfth.cf
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x68k/stand/boot_ufs/readufs_ffs.c
cvs rdiff -u -r1.9 -r1.10 src/sys/lib/libsa/ffsv1.c src/sys/lib/libsa/ffsv2.c
cvs rdiff -u -r1.15 -r1.16 src/sys/lib/libsa/lfsv1.c \
src/sys/lib/libsa/lfsv2.c
cvs rdiff -u -r1.86 -r1.87 src/sys/lib/libsa/ufs.c
cvs rdiff -u -r1.65 -r1.66 src/sys/ufs/ffs/ffs_balloc.c
cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/ffs/ffs_extattr.c
cvs rdiff -u -r1.377 -r1.378 src/sys/ufs/ffs/ffs_vfsops.c
cvs rdiff -u -r1.69 -r1.70 src/sys/ufs/ffs/fs.h
cvs rdiff -u -r1.53 -r1.54 src/sys/ufs/ufs/ufs_bmap.c
cvs rdiff -u -r1.43 -r1.44 src/sys/ufs/ufs/ufsmount.h
cvs rdiff -u -r1.2 -r1.3 src/tests/fs/ffs/t_extattr.c
cvs rdiff -u -r1.2 -r1.3 src/tests/sbin/fsck_ffs/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/sbin/fsck_ffs/t_extattr.sh
cvs rdiff -u -r1.65 -r1.66 src/usr.sbin/dumpfs/dumpfs.c
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/fstyp/ufs.c
cvs rdiff -u -r1.32 -r1.33 src/usr.sbin/installboot/ffs.c
cvs rdiff -u -r1.72 -r1.73 src/usr.sbin/makefs/ffs.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/makefs/ffs.h
cvs rdiff -u -r1.70 -r1.71 src/usr.sbin/makefs/makefs.8
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/makefs/ffs/ffs_balloc.c
cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/makefs/ffs/mkfs.c
cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/quot/quot.c
cvs rdiff -u -r1.49 -r1.50 src/usr.sbin/quotacheck/quotacheck.c
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/sysinst/label.c

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

CVS commit: src

2022-11-16 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Thu Nov 17 06:40:41 UTC 2022

Modified Files:
src: UPDATING
src/distrib/sets/lists/tests: mi
src/sbin/badsect: badsect.c
src/sbin/cgdconfig: cgdconfig.c
src/sbin/clri: clri.c
src/sbin/dump: ffs_inode.c
src/sbin/fsck_ffs: extern.h fsck.h fsck_ffs.8 main.c pass1.c pass5.c
setup.c utilities.c
src/sbin/fsdb: fsdb.8 fsdb.c fsdbutil.c
src/sbin/fsirand: fsirand.c
src/sbin/newfs: extern.h mkfs.c newfs.8 newfs.c
src/sbin/resize_ffs: resize_ffs.c
src/sbin/scan_ffs: scan_ffs.c
src/sbin/tunefs: tunefs.c
src/sys/arch/hppa/stand/xxboot: readufs_ffs.c
src/sys/arch/sparc/stand/bootblk: bootblk.fth genfth.cf
src/sys/arch/x68k/stand/boot_ufs: readufs_ffs.c
src/sys/lib/libsa: ffsv1.c ffsv2.c lfsv1.c lfsv2.c ufs.c
src/sys/ufs/ffs: ffs_balloc.c ffs_extattr.c ffs_vfsops.c fs.h
src/sys/ufs/ufs: ufs_bmap.c ufsmount.h
src/tests/fs/ffs: t_extattr.c
src/tests/sbin/fsck_ffs: Makefile
src/usr.sbin/dumpfs: dumpfs.c
src/usr.sbin/fstyp: ufs.c
src/usr.sbin/installboot: ffs.c
src/usr.sbin/makefs: ffs.c ffs.h makefs.8
src/usr.sbin/makefs/ffs: ffs_balloc.c mkfs.c
src/usr.sbin/quot: quot.c
src/usr.sbin/quotacheck: quotacheck.c
src/usr.sbin/sysinst: label.c
Added Files:
src/tests/sbin/fsck_ffs: t_extattr.sh

Log Message:
Restore backward compatibility of UFS2 with previous NetBSD releases by
disabling support in UFS2 for extended attributes (including ACLs).
Add a new variant of UFS2 called "UFS2ea" that does support extended attributes.
Add new fsck_ffs operations "-c ea" and "-c no-ea" to convert file systems
from UFS2 to UFS2ea and vice-versa (both of which delete all existing extended
attributes in the process).


To generate a diff of this commit:
cvs rdiff -u -r1.334 -r1.335 src/UPDATING
cvs rdiff -u -r1.1230 -r1.1231 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.34 -r1.35 src/sbin/badsect/badsect.c
cvs rdiff -u -r1.60 -r1.61 src/sbin/cgdconfig/cgdconfig.c
cvs rdiff -u -r1.24 -r1.25 src/sbin/clri/clri.c
cvs rdiff -u -r1.23 -r1.24 src/sbin/dump/ffs_inode.c
cvs rdiff -u -r1.27 -r1.28 src/sbin/fsck_ffs/extern.h
cvs rdiff -u -r1.55 -r1.56 src/sbin/fsck_ffs/fsck.h
cvs rdiff -u -r1.51 -r1.52 src/sbin/fsck_ffs/fsck_ffs.8
cvs rdiff -u -r1.89 -r1.90 src/sbin/fsck_ffs/main.c
cvs rdiff -u -r1.59 -r1.60 src/sbin/fsck_ffs/pass1.c
cvs rdiff -u -r1.54 -r1.55 src/sbin/fsck_ffs/pass5.c
cvs rdiff -u -r1.103 -r1.104 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.66 -r1.67 src/sbin/fsck_ffs/utilities.c
cvs rdiff -u -r1.27 -r1.28 src/sbin/fsdb/fsdb.8
cvs rdiff -u -r1.52 -r1.53 src/sbin/fsdb/fsdb.c
cvs rdiff -u -r1.23 -r1.24 src/sbin/fsdb/fsdbutil.c
cvs rdiff -u -r1.32 -r1.33 src/sbin/fsirand/fsirand.c
cvs rdiff -u -r1.19 -r1.20 src/sbin/newfs/extern.h
cvs rdiff -u -r1.131 -r1.132 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.85 -r1.86 src/sbin/newfs/newfs.8
cvs rdiff -u -r1.117 -r1.118 src/sbin/newfs/newfs.c
cvs rdiff -u -r1.56 -r1.57 src/sbin/resize_ffs/resize_ffs.c
cvs rdiff -u -r1.35 -r1.36 src/sbin/scan_ffs/scan_ffs.c
cvs rdiff -u -r1.55 -r1.56 src/sbin/tunefs/tunefs.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/hppa/stand/xxboot/readufs_ffs.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sparc/stand/bootblk/bootblk.fth
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc/stand/bootblk/genfth.cf
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x68k/stand/boot_ufs/readufs_ffs.c
cvs rdiff -u -r1.9 -r1.10 src/sys/lib/libsa/ffsv1.c src/sys/lib/libsa/ffsv2.c
cvs rdiff -u -r1.15 -r1.16 src/sys/lib/libsa/lfsv1.c \
src/sys/lib/libsa/lfsv2.c
cvs rdiff -u -r1.86 -r1.87 src/sys/lib/libsa/ufs.c
cvs rdiff -u -r1.65 -r1.66 src/sys/ufs/ffs/ffs_balloc.c
cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/ffs/ffs_extattr.c
cvs rdiff -u -r1.377 -r1.378 src/sys/ufs/ffs/ffs_vfsops.c
cvs rdiff -u -r1.69 -r1.70 src/sys/ufs/ffs/fs.h
cvs rdiff -u -r1.53 -r1.54 src/sys/ufs/ufs/ufs_bmap.c
cvs rdiff -u -r1.43 -r1.44 src/sys/ufs/ufs/ufsmount.h
cvs rdiff -u -r1.2 -r1.3 src/tests/fs/ffs/t_extattr.c
cvs rdiff -u -r1.2 -r1.3 src/tests/sbin/fsck_ffs/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/sbin/fsck_ffs/t_extattr.sh
cvs rdiff -u -r1.65 -r1.66 src/usr.sbin/dumpfs/dumpfs.c
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/fstyp/ufs.c
cvs rdiff -u -r1.32 -r1.33 src/usr.sbin/installboot/ffs.c
cvs rdiff -u -r1.72 -r1.73 src/usr.sbin/makefs/ffs.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/makefs/ffs.h
cvs rdiff -u -r1.70 -r1.71 src/usr.sbin/makefs/makefs.8
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/makefs/ffs/ffs_balloc.c
cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/makefs/ffs/mkfs.c
cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/quot/quot.c
cvs rdiff -u -r1.49 -r1.50 src/usr.sbin/quotacheck/quotacheck.c
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/sysinst/label.c

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

CVS commit: src/sys/uvm

2022-08-05 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sat Aug  6 05:55:37 UTC 2022

Modified Files:
src/sys/uvm: uvm_km.c

Log Message:
allow KMSAN to work again by restoring the limiting of kva even with
NKMEMPAGES_MAX_UNLIMITED.  we used to limit kva to 1/8 of physmem
but limiting to 1/4 should be enough, and 1/4 still gives the kernel
enough kva to map all of the RAM that KMSAN has not stolen.

Reported-by: syzbot+ca3710b4c40cdd61a...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/sys/uvm/uvm_km.c

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



CVS commit: src/sys/uvm

2022-08-05 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sat Aug  6 05:55:37 UTC 2022

Modified Files:
src/sys/uvm: uvm_km.c

Log Message:
allow KMSAN to work again by restoring the limiting of kva even with
NKMEMPAGES_MAX_UNLIMITED.  we used to limit kva to 1/8 of physmem
but limiting to 1/4 should be enough, and 1/4 still gives the kernel
enough kva to map all of the RAM that KMSAN has not stolen.

Reported-by: syzbot+ca3710b4c40cdd61a...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/sys/uvm/uvm_km.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/uvm/uvm_km.c
diff -u src/sys/uvm/uvm_km.c:1.161 src/sys/uvm/uvm_km.c:1.162
--- src/sys/uvm/uvm_km.c:1.161	Wed Aug  3 01:52:11 2022
+++ src/sys/uvm/uvm_km.c	Sat Aug  6 05:55:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_km.c,v 1.161 2022/08/03 01:52:11 chs Exp $	*/
+/*	$NetBSD: uvm_km.c,v 1.162 2022/08/06 05:55:37 chs Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -152,7 +152,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.161 2022/08/03 01:52:11 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.162 2022/08/06 05:55:37 chs Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -226,22 +226,25 @@ kmeminit_nkmempages(void)
 		return;
 	}
 
-#ifdef NKMEMPAGES_MAX_UNLIMITED
+#if defined(NKMEMPAGES_MAX_UNLIMITED) && !defined(KMSAN)
 	npages = physmem;
 #else
 
 #if defined(KMSAN)
-	npages = (physmem / 8);
+	npages = (physmem / 4);
 #elif defined(PMAP_MAP_POOLPAGE)
 	npages = (physmem / 4);
 #else
 	npages = (physmem / 3) * 2;
 #endif /* defined(PMAP_MAP_POOLPAGE) */
 
+#if !defined(NKMEMPAGES_MAX_UNLIMITED)
 	if (npages > NKMEMPAGES_MAX)
 		npages = NKMEMPAGES_MAX;
 #endif
 
+#endif
+
 	if (npages < NKMEMPAGES_MIN)
 		npages = NKMEMPAGES_MIN;
 



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2022-08-02 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Aug  3 01:53:06 UTC 2022

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: arc.c

Log Message:
change the ARC reclaim code to use the pagedaemon's free page target
rather than having a separate target.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c:1.21 src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c:1.22
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c:1.21	Wed May  4 15:49:55 2022
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c	Wed Aug  3 01:53:06 2022
@@ -288,6 +288,7 @@ int arc_procfd;
 #define	freemem		uvm_availmem(false)
 #define	minfree		uvmexp.freemin
 #define	desfree		uvmexp.freetarg
+#define	zfs_arc_free_target desfree
 #define	lotsfree	(desfree * 2)
 #define	availrmem	desfree
 #define	swapfs_minfree	0
@@ -387,7 +388,6 @@ int zfs_arc_grow_retry = 0;
 int zfs_arc_shrink_shift = 0;
 int zfs_arc_p_min_shift = 0;
 uint64_t zfs_arc_average_blocksize = 8 * 1024; /* 8KB */
-u_int zfs_arc_free_target = 0;
 
 /* Absolute min for arc min / max is 16MB. */
 static uint64_t arc_abs_min = 16 << 20;
@@ -395,6 +395,8 @@ static uint64_t arc_abs_min = 16 << 20;
 boolean_t zfs_compressed_arc_enabled = B_TRUE;
 
 #if defined(__FreeBSD__) && defined(_KERNEL)
+u_int zfs_arc_free_target = 0;
+
 static int sysctl_vfs_zfs_arc_free_target(SYSCTL_HANDLER_ARGS);
 static int sysctl_vfs_zfs_arc_meta_limit(SYSCTL_HANDLER_ARGS);
 static int sysctl_vfs_zfs_arc_max(SYSCTL_HANDLER_ARGS);



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2022-08-02 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Aug  3 01:53:06 UTC 2022

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: arc.c

Log Message:
change the ARC reclaim code to use the pagedaemon's free page target
rather than having a separate target.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c

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



CVS commit: src/sys/uvm

2022-08-02 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Aug  3 01:52:11 UTC 2022

Modified Files:
src/sys/uvm: uvm_km.c

Log Message:
for platforms which define NKMEMPAGES_MAX_UNLIMITED, set nkmempages
high enough to allow the kernel to map all of RAM into kmem,
so that free physical pages rather than kernel virtual space is
the limiting factor in allocating kernel memory.  this gives ZFS
more flexibility in tuning how much memory to use for its ARC cache.


To generate a diff of this commit:
cvs rdiff -u -r1.160 -r1.161 src/sys/uvm/uvm_km.c

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



CVS commit: src/sys/uvm

2022-08-02 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Aug  3 01:52:11 UTC 2022

Modified Files:
src/sys/uvm: uvm_km.c

Log Message:
for platforms which define NKMEMPAGES_MAX_UNLIMITED, set nkmempages
high enough to allow the kernel to map all of RAM into kmem,
so that free physical pages rather than kernel virtual space is
the limiting factor in allocating kernel memory.  this gives ZFS
more flexibility in tuning how much memory to use for its ARC cache.


To generate a diff of this commit:
cvs rdiff -u -r1.160 -r1.161 src/sys/uvm/uvm_km.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/uvm/uvm_km.c
diff -u src/sys/uvm/uvm_km.c:1.160 src/sys/uvm/uvm_km.c:1.161
--- src/sys/uvm/uvm_km.c:1.160	Sat Mar 13 15:29:55 2021
+++ src/sys/uvm/uvm_km.c	Wed Aug  3 01:52:11 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_km.c,v 1.160 2021/03/13 15:29:55 skrll Exp $	*/
+/*	$NetBSD: uvm_km.c,v 1.161 2022/08/03 01:52:11 chs Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -152,7 +152,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.160 2021/03/13 15:29:55 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.161 2022/08/03 01:52:11 chs Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -226,6 +226,10 @@ kmeminit_nkmempages(void)
 		return;
 	}
 
+#ifdef NKMEMPAGES_MAX_UNLIMITED
+	npages = physmem;
+#else
+
 #if defined(KMSAN)
 	npages = (physmem / 8);
 #elif defined(PMAP_MAP_POOLPAGE)
@@ -234,7 +238,6 @@ kmeminit_nkmempages(void)
 	npages = (physmem / 3) * 2;
 #endif /* defined(PMAP_MAP_POOLPAGE) */
 
-#ifndef NKMEMPAGES_MAX_UNLIMITED
 	if (npages > NKMEMPAGES_MAX)
 		npages = NKMEMPAGES_MAX;
 #endif



CVS commit: src/sys/arch/m68k/m68k

2022-07-31 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Jul 31 17:11:41 UTC 2022

Modified Files:
src/sys/arch/m68k/m68k: pmap_motorola.c

Log Message:
in pmap_enter_ptpage(), if we are allowed to fail then fail rather than
waiting for memory to be available.  when we are mapping an anon or uobj page
then we will be holding the lock for that page owner, and sleeping to wait
for memory with a page owner lock held is illegal because the pagedaemon
can wait for that lock, which will lead to deadlock.  fixes PR 56932.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/arch/m68k/m68k/pmap_motorola.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/m68k/m68k/pmap_motorola.c
diff -u src/sys/arch/m68k/m68k/pmap_motorola.c:1.76 src/sys/arch/m68k/m68k/pmap_motorola.c:1.77
--- src/sys/arch/m68k/m68k/pmap_motorola.c:1.76	Sat Apr 16 18:15:21 2022
+++ src/sys/arch/m68k/m68k/pmap_motorola.c	Sun Jul 31 17:11:41 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_motorola.c,v 1.76 2022/04/16 18:15:21 andvar Exp $*/
+/*	$NetBSD: pmap_motorola.c,v 1.77 2022/07/31 17:11:41 chs Exp $*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -119,7 +119,7 @@
 #include "opt_m68k_arch.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap_motorola.c,v 1.76 2022/04/16 18:15:21 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_motorola.c,v 1.77 2022/07/31 17:11:41 chs Exp $");
 
 #include 
 #include 
@@ -2585,6 +2585,10 @@ pmap_enter_ptpage(pmap_t pmap, vaddr_t v
 	   va - vm_map_min(kernel_map),
 	   NULL, UVM_PGA_ZERO)) == NULL) {
 			rw_exit(uvm_kernel_object->vmobjlock);
+			if (can_fail) {
+pmap->pm_sref--;
+return ENOMEM;
+			}
 			uvm_wait("ptpage");
 			rw_enter(uvm_kernel_object->vmobjlock, RW_WRITER);
 		}



CVS commit: src/sys/arch/m68k/m68k

2022-07-31 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Jul 31 17:11:41 UTC 2022

Modified Files:
src/sys/arch/m68k/m68k: pmap_motorola.c

Log Message:
in pmap_enter_ptpage(), if we are allowed to fail then fail rather than
waiting for memory to be available.  when we are mapping an anon or uobj page
then we will be holding the lock for that page owner, and sleeping to wait
for memory with a page owner lock held is illegal because the pagedaemon
can wait for that lock, which will lead to deadlock.  fixes PR 56932.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/arch/m68k/m68k/pmap_motorola.c

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



Re: CVS commit: src/sys/arch/m68k/m68k

2022-07-26 Thread Chuck Silvers
On Tue, Jul 26, 2022 at 05:25:01PM +0900, Tetsuya Isaki wrote:
> At Mon, 25 Jul 2022 01:59:26 +,
> Chuck Silvers wrote:
> > Module Name:src
> > Committed By:   chs
> > Date:   Mon Jul 25 01:59:26 UTC 2022
> > 
> > Modified Files:
> > src/sys/arch/m68k/m68k: db_trace.c
> > 
> > Log Message:
> > use the pcb of the thread we are tracing rather than always curlwp.
> > 
> > 
> > To generate a diff of this commit:
> > cvs rdiff -u -r1.59 -r1.60 src/sys/arch/m68k/m68k/db_trace.c
> 
> This commit breaks usr.sbin/crash on m68k.
> curlwp is defined only in _KERNEL.  usr.sbin/crash defines _KMEMUSER
> but not _KERNEL.
> 
> Would you look into?

I fixed it now, sorry about that.

-Chuck


CVS commit: src/sys/arch/m68k/m68k

2022-07-26 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Jul 26 16:51:42 UTC 2022

Modified Files:
src/sys/arch/m68k/m68k: db_trace.c

Log Message:
curlwp is only available for ifdef _KERNEL.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/m68k/m68k/db_trace.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/m68k/m68k/db_trace.c
diff -u src/sys/arch/m68k/m68k/db_trace.c:1.60 src/sys/arch/m68k/m68k/db_trace.c:1.61
--- src/sys/arch/m68k/m68k/db_trace.c:1.60	Mon Jul 25 01:59:26 2022
+++ src/sys/arch/m68k/m68k/db_trace.c	Tue Jul 26 16:51:42 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_trace.c,v 1.60 2022/07/25 01:59:26 chs Exp $	*/
+/*	$NetBSD: db_trace.c,v 1.61 2022/07/26 16:51:42 chs Exp $	*/
 
 /* 
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.60 2022/07/25 01:59:26 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.61 2022/07/26 16:51:42 chs Exp $");
 
 #include 
 #include 
@@ -418,7 +418,9 @@ db_stack_trace_print(db_expr_t addr, boo
 		}
 	}
 
+#ifdef _KERNEL
 	l = curlwp;
+#endif
 	if (!have_addr)
 		stacktop(_regs, , pr);
 	else {
@@ -550,7 +552,7 @@ db_stack_trace_print(db_expr_t addr, boo
 		else
 			(*pr)(") + %lx\n", val);
 
-#if _KERNEL
+#ifdef _KERNEL
 		/*
 		 * Stop tracing if frame ptr no longer points into kernel
 		 * stack.



CVS commit: src/sys/arch/m68k/m68k

2022-07-26 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Jul 26 16:51:42 UTC 2022

Modified Files:
src/sys/arch/m68k/m68k: db_trace.c

Log Message:
curlwp is only available for ifdef _KERNEL.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/m68k/m68k/db_trace.c

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



CVS commit: src/sys/arch/m68k/m68k

2022-07-24 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Jul 25 01:59:26 UTC 2022

Modified Files:
src/sys/arch/m68k/m68k: db_trace.c

Log Message:
use the pcb of the thread we are tracing rather than always curlwp.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/m68k/m68k/db_trace.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/m68k/m68k/db_trace.c
diff -u src/sys/arch/m68k/m68k/db_trace.c:1.59 src/sys/arch/m68k/m68k/db_trace.c:1.60
--- src/sys/arch/m68k/m68k/db_trace.c:1.59	Sun Oct 18 17:13:32 2015
+++ src/sys/arch/m68k/m68k/db_trace.c	Mon Jul 25 01:59:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_trace.c,v 1.59 2015/10/18 17:13:32 maxv Exp $	*/
+/*	$NetBSD: db_trace.c,v 1.60 2022/07/25 01:59:26 chs Exp $	*/
 
 /* 
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.59 2015/10/18 17:13:32 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.60 2022/07/25 01:59:26 chs Exp $");
 
 #include 
 #include 
@@ -393,6 +393,7 @@ db_stack_trace_print(db_expr_t addr, boo
 	const char *	name;
 	struct stackpos pos;
 	struct pcb	*pcb;
+	struct lwp	*l;
 #ifdef _KERNEL
 	bool		kernel_only = true;
 #endif
@@ -417,12 +418,12 @@ db_stack_trace_print(db_expr_t addr, boo
 		}
 	}
 
+	l = curlwp;
 	if (!have_addr)
 		stacktop(_regs, , pr);
 	else {
 		if (trace_thread) {
 			struct proc *p;
-			struct lwp *l;
 
 			if (lwpaddr) {
 l = (struct lwp *)addr;
@@ -554,7 +555,7 @@ db_stack_trace_print(db_expr_t addr, boo
 		 * Stop tracing if frame ptr no longer points into kernel
 		 * stack.
 		 */
-		pcb = lwp_getpcb(curlwp);
+		pcb = lwp_getpcb(l);
 		if (kernel_only && !INKERNEL(pos.k_fp, pcb))
 			break;
 		if (nextframe(, pcb, kernel_only, pr) == 0)



CVS commit: src/sys/arch/m68k/m68k

2022-07-24 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Jul 25 01:59:26 UTC 2022

Modified Files:
src/sys/arch/m68k/m68k: db_trace.c

Log Message:
use the pcb of the thread we are tracing rather than always curlwp.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/m68k/m68k/db_trace.c

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



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2022-05-04 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed May  4 15:49:55 UTC 2022

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: arc.c

Log Message:
fix ARC checks for available memory:
there's an extra check that we inherited from FreeBSD that tries to
detect KVA exhaustion on platforms with limited KVA, but the condition
that decided whether to use the extra check was using a FreeBSDism
that doesn't exist on NetBSD, resulting in this check being used on
all platforms.  on amd64 systems with lots of memory, this extra check
would result in the ARC thinking that it constantly needed to reclaim memory,
resulting in all the xcall threads running all the time but not doing
anything useful.  change this condition so that this extra check for
KVA exhaustion is only used on 32-bit platforms.  fixes PR 55707.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c:1.20 src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c:1.21
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c:1.20	Wed Apr 21 10:02:34 2021
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c	Wed May  4 15:49:55 2022
@@ -3963,7 +3963,7 @@ arc_available_memory(void)
 	}
 
 #endif	/* illumos */
-#if defined(__i386) || !defined(UMA_MD_SMALL_ALLOC)
+#if !defined(_LP64)
 	/*
 	 * If we're on an i386 platform, it's possible that we'll exhaust the
 	 * kernel heap space before we ever run out of available physical
@@ -5750,7 +5750,7 @@ arc_memory_throttle(uint64_t reserve, ui
 	static uint64_t page_load = 0;
 	static uint64_t last_txg = 0;
 
-#if defined(__i386) || !defined(UMA_MD_SMALL_ALLOC)
+#if !defined(_LP64)
 	available_memory =
 	MIN(available_memory, ptob(vmem_size(heap_arena, VMEM_FREE)));
 #endif



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2022-05-04 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed May  4 15:49:55 UTC 2022

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: arc.c

Log Message:
fix ARC checks for available memory:
there's an extra check that we inherited from FreeBSD that tries to
detect KVA exhaustion on platforms with limited KVA, but the condition
that decided whether to use the extra check was using a FreeBSDism
that doesn't exist on NetBSD, resulting in this check being used on
all platforms.  on amd64 systems with lots of memory, this extra check
would result in the ARC thinking that it constantly needed to reclaim memory,
resulting in all the xcall threads running all the time but not doing
anything useful.  change this condition so that this extra check for
KVA exhaustion is only used on 32-bit platforms.  fixes PR 55707.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c

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



CVS commit: src/sys/external/bsd/drm2

2021-12-20 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Dec 20 20:34:59 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu: amdgpu_fb.c
src/sys/external/bsd/drm2/dist/drm/i915/display: intel_fbdev.c
src/sys/external/bsd/drm2/dist/drm/nouveau: nouveau_fbcon.c
src/sys/external/bsd/drm2/dist/drm/radeon: radeon_fb.c
src/sys/external/bsd/drm2/drm: drmfb.c

Log Message:
drm: add missing KERNEL_LOCK around calls to config_found().


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fb.c
cvs rdiff -u -r1.9 -r1.10 \
src/sys/external/bsd/drm2/dist/drm/i915/display/intel_fbdev.c
cvs rdiff -u -r1.15 -r1.16 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c
cvs rdiff -u -r1.14 -r1.15 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c
cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/drm2/drm/drmfb.c

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



CVS commit: src/sys/external/bsd/drm2

2021-12-20 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Dec 20 20:34:59 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu: amdgpu_fb.c
src/sys/external/bsd/drm2/dist/drm/i915/display: intel_fbdev.c
src/sys/external/bsd/drm2/dist/drm/nouveau: nouveau_fbcon.c
src/sys/external/bsd/drm2/dist/drm/radeon: radeon_fb.c
src/sys/external/bsd/drm2/drm: drmfb.c

Log Message:
drm: add missing KERNEL_LOCK around calls to config_found().


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fb.c
cvs rdiff -u -r1.9 -r1.10 \
src/sys/external/bsd/drm2/dist/drm/i915/display/intel_fbdev.c
cvs rdiff -u -r1.15 -r1.16 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c
cvs rdiff -u -r1.14 -r1.15 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c
cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/drm2/drm/drmfb.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/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fb.c
diff -u src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fb.c:1.10 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fb.c:1.11
--- src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fb.c:1.10	Sun Dec 19 12:02:39 2021
+++ src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_fb.c	Mon Dec 20 20:34:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdgpu_fb.c,v 1.10 2021/12/19 12:02:39 riastradh Exp $	*/
+/*	$NetBSD: amdgpu_fb.c,v 1.11 2021/12/20 20:34:58 chs Exp $	*/
 
 /*
  * Copyright © 2007 David Airlie
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_fb.c,v 1.10 2021/12/19 12:02:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_fb.c,v 1.11 2021/12/20 20:34:58 chs Exp $");
 
 #include 
 #include 
@@ -274,8 +274,10 @@ static int amdgpufb_create(struct drm_fb
 	afa.afa_fb_ptr = amdgpu_bo_kptr(abo);
 	afa.afa_fb_linebytes = mode_cmd.pitches[0];
 
+	KERNEL_LOCK(1, NULL);
 	helper->fbdev = config_found(adev->ddev->dev, , NULL,
 	CFARGS(.iattr = "amdgpufbbus"));
+	KERNEL_UNLOCK_ONE(NULL);
 	if (helper->fbdev == NULL) {
 		DRM_ERROR("failed to attach amdgpufb\n");
 		goto out;

Index: src/sys/external/bsd/drm2/dist/drm/i915/display/intel_fbdev.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/display/intel_fbdev.c:1.9 src/sys/external/bsd/drm2/dist/drm/i915/display/intel_fbdev.c:1.10
--- src/sys/external/bsd/drm2/dist/drm/i915/display/intel_fbdev.c:1.9	Sun Dec 19 12:32:15 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/display/intel_fbdev.c	Mon Dec 20 20:34:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel_fbdev.c,v 1.9 2021/12/19 12:32:15 riastradh Exp $	*/
+/*	$NetBSD: intel_fbdev.c,v 1.10 2021/12/20 20:34:58 chs Exp $	*/
 
 /*
  * Copyright © 2007 David Airlie
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intel_fbdev.c,v 1.9 2021/12/19 12:32:15 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_fbdev.c,v 1.10 2021/12/20 20:34:58 chs Exp $");
 
 #include 
 #include 
@@ -264,8 +264,10 @@ static int intelfb_create(struct drm_fb_
 	 * XXX Should do this asynchronously, since we hold
 	 * dev->struct_mutex.
 	 */
+	KERNEL_LOCK(1, NULL);
 	helper->fbdev = config_found(dev->dev, , NULL,
 	CFARGS(.iattr = "intelfbbus"));
+	KERNEL_UNLOCK_ONE(NULL);
 	if (helper->fbdev == NULL) {
 		DRM_ERROR("unable to attach intelfb\n");
 		ret = -ENXIO;

Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c:1.15 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c:1.16
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c:1.15	Sun Dec 19 11:34:44 2021
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fbcon.c	Mon Dec 20 20:34:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_fbcon.c,v 1.15 2021/12/19 11:34:44 riastradh Exp $	*/
+/*	$NetBSD: nouveau_fbcon.c,v 1.16 2021/12/20 20:34:58 chs Exp $	*/
 
 /*
  * Copyright © 2007 David Airlie
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nouveau_fbcon.c,v 1.15 2021/12/19 11:34:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_fbcon.c,v 1.16 2021/12/20 20:34:58 chs Exp $");
 
 #include 
 #include 
@@ -420,8 +420,10 @@ nouveau_fbcon_create(struct drm_fb_helpe
 	nfa.nfa_fb_ptr = nvbo_kmap_obj_iovirtual(nvbo);
 	nfa.nfa_fb_linebytes = mode_cmd.pitches[0];
 
+	KERNEL_LOCK(1, NULL);
 	helper->fbdev = config_found(dev->dev, , nouveau_fbcon_print,
 	CFARGS(.iattr = "nouveaufbbus"));
+	KERNEL_UNLOCK_ONE(NULL);
 	if (helper->fbdev == NULL) {
 		goto out_unlock;
 	}

Index: src/sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c
diff -u src/sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c:1.14 src/sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c:1.15
--- src/sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c:1.14	Sun Dec 19 10:46:44 2021
+++ src/sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c	Mon 

CVS commit: src/sys/ufs/ffs

2021-12-14 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Dec 14 11:06:50 UTC 2021

Modified Files:
src/sys/ufs/ffs: ffs_extattr.c

Log Message:
ffs: fix the creation of device nodes on file systems with ACLs enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/ffs/ffs_extattr.c

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



CVS commit: src/sys/ufs/ffs

2021-12-14 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Dec 14 11:06:50 UTC 2021

Modified Files:
src/sys/ufs/ffs: ffs_extattr.c

Log Message:
ffs: fix the creation of device nodes on file systems with ACLs enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/ffs/ffs_extattr.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/ufs/ffs/ffs_extattr.c
diff -u src/sys/ufs/ffs/ffs_extattr.c:1.7 src/sys/ufs/ffs/ffs_extattr.c:1.8
--- src/sys/ufs/ffs/ffs_extattr.c:1.7	Sat Sep  5 16:30:13 2020
+++ src/sys/ufs/ffs/ffs_extattr.c	Tue Dec 14 11:06:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_extattr.c,v 1.7 2020/09/05 16:30:13 riastradh Exp $	*/
+/*	$NetBSD: ffs_extattr.c,v 1.8 2021/12/14 11:06:50 chs Exp $	*/
 
 /*-
  * SPDX-License-Identifier: (BSD-2-Clause-FreeBSD AND BSD-3-Clause)
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_extattr.c,v 1.7 2020/09/05 16:30:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_extattr.c,v 1.8 2021/12/14 11:06:50 chs Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -587,8 +587,10 @@ ffs_openextattr(void *v)
 	if (fs->fs_magic == FS_UFS1_MAGIC)
 		return (EOPNOTSUPP);
 
+#ifdef __FreeBSD__
 	if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK)
 		return (EOPNOTSUPP);
+#endif
 
 	return (ffs_open_ea(ap->a_vp, ap->a_cred));
 }
@@ -612,8 +614,10 @@ ffs_closeextattr(void *v)
 	if (fs->fs_magic == FS_UFS1_MAGIC)
 		return (EOPNOTSUPP);
 
+#ifdef __FreeBSD__
 	if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK)
 		return (EOPNOTSUPP);
+#endif
 
 	if (ap->a_commit && (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY))
 		return (EROFS);
@@ -649,8 +653,10 @@ ffs_getextattr(void *v)
 	unsigned easize;
 	int error, ealen;
 
+#ifdef __FreeBSD__
 	if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK)
 		return (EOPNOTSUPP);
+#endif
 
 	error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace,
 	ap->a_cred, VREAD);
@@ -892,8 +898,10 @@ ffs_deleteextattr(void *v)
 	u_char *eae;
 	void *tmp;
 
+#ifdef __FreeBSD__
 	if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK)
 		return (EOPNOTSUPP);
+#endif
 
 	if (strlen(ap->a_name) == 0)
 		return (EINVAL);



CVS commit: src/sys/ufs/ffs

2021-12-14 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Dec 14 11:06:12 UTC 2021

Modified Files:
src/sys/ufs/ffs: ffs_vnops.c

Log Message:
ffs: support extattrs (and thus ACLs) on fifos.


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/sys/ufs/ffs/ffs_vnops.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/ufs/ffs/ffs_vnops.c
diff -u src/sys/ufs/ffs/ffs_vnops.c:1.137 src/sys/ufs/ffs/ffs_vnops.c:1.138
--- src/sys/ufs/ffs/ffs_vnops.c:1.137	Sun Jul 18 23:57:15 2021
+++ src/sys/ufs/ffs/ffs_vnops.c	Tue Dec 14 11:06:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vnops.c,v 1.137 2021/07/18 23:57:15 dholland Exp $	*/
+/*	$NetBSD: ffs_vnops.c,v 1.138 2021/12/14 11:06:12 chs Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.137 2021/07/18 23:57:15 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.138 2021/12/14 11:06:12 chs Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -212,9 +212,11 @@ const struct vnodeopv_entry_desc ffs_fif
 	{ _reclaim_desc, ffs_reclaim },		/* reclaim */
 	{ _lock_desc, genfs_lock },			/* lock */
 	{ _unlock_desc, genfs_unlock },		/* unlock */
+	{ _bmap_desc, ufs_bmap },			/* bmap */
 	{ _strategy_desc, ffsext_strategy },	/* strategy */
 	{ _print_desc, ufs_print },			/* print */
 	{ _islocked_desc, genfs_islocked },		/* islocked */
+	{ _pathconf_desc, ufs_pathconf },		/* pathconf */
 	{ _bwrite_desc, vn_bwrite },		/* bwrite */
 	{ _openextattr_desc, ffs_openextattr },	/* openextattr */
 	{ _closeextattr_desc, ffs_closeextattr },	/* closeextattr */



CVS commit: src/sys/ufs/ffs

2021-12-14 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Dec 14 11:06:12 UTC 2021

Modified Files:
src/sys/ufs/ffs: ffs_vnops.c

Log Message:
ffs: support extattrs (and thus ACLs) on fifos.


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/sys/ufs/ffs/ffs_vnops.c

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



CVS commit: src/sys/lib/libkern

2021-12-12 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Dec 13 01:33:32 UTC 2021

Modified Files:
src/sys/lib/libkern: kern_assert.c

Log Message:
revert rev 1.4 ("Add garbage instructions at end of kern_assert after vpanic.")

that change had no effect because vpanic() is marked __dead / noreturn
and thus the compiler would optimize away everything after a call to vpanic().
the original problem has now been fixed differently (but only for x86 so far).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/lib/libkern/kern_assert.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/lib/libkern/kern_assert.c
diff -u src/sys/lib/libkern/kern_assert.c:1.4 src/sys/lib/libkern/kern_assert.c:1.5
--- src/sys/lib/libkern/kern_assert.c:1.4	Tue Mar 14 09:22:37 2017
+++ src/sys/lib/libkern/kern_assert.c	Mon Dec 13 01:33:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_assert.c,v 1.4 2017/03/14 09:22:37 riastradh Exp $	*/
+/*	$NetBSD: kern_assert.c,v 1.5 2021/12/13 01:33:32 chs Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou
@@ -50,13 +50,4 @@ kern_assert(const char *fmt, ...)
 	va_start(ap, fmt);
 	vpanic(fmt, ap);
 	va_end(ap);
-
-	/*
-	 * Force instructions at the return address of vpanic before
-	 * the next symbol, which otherwise the compiler may omit
-	 * because vpanic is marked noreturn.  This prevents seeing
-	 * whatever random symbol came after kern_assert in the linked
-	 * kernel in stack traces for assertion failures.
-	 */
-	asm volatile(".long 0");
 }



CVS commit: src/sys/lib/libkern

2021-12-12 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Dec 13 01:33:32 UTC 2021

Modified Files:
src/sys/lib/libkern: kern_assert.c

Log Message:
revert rev 1.4 ("Add garbage instructions at end of kern_assert after vpanic.")

that change had no effect because vpanic() is marked __dead / noreturn
and thus the compiler would optimize away everything after a call to vpanic().
the original problem has now been fixed differently (but only for x86 so far).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/lib/libkern/kern_assert.c

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



CVS commit: src/sys

2021-12-12 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Dec 13 01:25:29 UTC 2021

Modified Files:
src/sys/arch/amd64/amd64: db_machdep.c
src/sys/arch/i386/i386: db_machdep.c
src/sys/ddb: db_sym.c

Log Message:
ddb: fix function names of "noreturn" functions in stack traces.

when looking up function names for stack traces (where the addresses are the
return addresses of function calls), if the address is the first instruction
in the function, assume that the function being called is marked "noreturn"
and that the function containing the call is actually the function immediately
before the address that we looked up.  to find the correct function name,
do the lookup again with (address - 1) and then add one to the offset within
the function that we find.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/amd64/amd64/db_machdep.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/i386/db_machdep.c
cvs rdiff -u -r1.67 -r1.68 src/sys/ddb/db_sym.c

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



CVS commit: src/sys

2021-12-12 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Dec 13 01:25:29 UTC 2021

Modified Files:
src/sys/arch/amd64/amd64: db_machdep.c
src/sys/arch/i386/i386: db_machdep.c
src/sys/ddb: db_sym.c

Log Message:
ddb: fix function names of "noreturn" functions in stack traces.

when looking up function names for stack traces (where the addresses are the
return addresses of function calls), if the address is the first instruction
in the function, assume that the function being called is marked "noreturn"
and that the function containing the call is actually the function immediately
before the address that we looked up.  to find the correct function name,
do the lookup again with (address - 1) and then add one to the offset within
the function that we find.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/amd64/amd64/db_machdep.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/i386/db_machdep.c
cvs rdiff -u -r1.67 -r1.68 src/sys/ddb/db_sym.c

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

Modified files:

Index: src/sys/arch/amd64/amd64/db_machdep.c
diff -u src/sys/arch/amd64/amd64/db_machdep.c:1.8 src/sys/arch/amd64/amd64/db_machdep.c:1.9
--- src/sys/arch/amd64/amd64/db_machdep.c:1.8	Sat Jun  6 07:03:21 2020
+++ src/sys/arch/amd64/amd64/db_machdep.c	Mon Dec 13 01:25:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.c,v 1.8 2020/06/06 07:03:21 maxv Exp $	*/
+/*	$NetBSD: db_machdep.c,v 1.9 2021/12/13 01:25:29 chs Exp $	*/
 
 /*
  * Mach Operating System
@@ -26,7 +26,7 @@
  * rights to redistribute these changes.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.8 2020/06/06 07:03:21 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.9 2021/12/13 01:25:29 chs Exp $");
 
 #include 
 #include 
@@ -200,6 +200,10 @@ db_frame_info(long *frame, db_addr_t cal
 	const char *name;
 
 	sym = db_search_symbol(callpc, DB_STGY_ANY, );
+	if (sym != 0 && offset == 0) {
+		sym = db_search_symbol(callpc - 1, DB_STGY_ANY, );
+		offset++;
+	}
 	db_symbol_values(sym, , NULL);
 	if (sym == (db_sym_t)0)
 		return (db_sym_t)0;

Index: src/sys/arch/i386/i386/db_machdep.c
diff -u src/sys/arch/i386/i386/db_machdep.c:1.7 src/sys/arch/i386/i386/db_machdep.c:1.8
--- src/sys/arch/i386/i386/db_machdep.c:1.7	Sun Feb 11 08:27:18 2018
+++ src/sys/arch/i386/i386/db_machdep.c	Mon Dec 13 01:25:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.c,v 1.7 2018/02/11 08:27:18 maxv Exp $	*/
+/*	$NetBSD: db_machdep.c,v 1.8 2021/12/13 01:25:29 chs Exp $	*/
 
 /*
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.7 2018/02/11 08:27:18 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.8 2021/12/13 01:25:29 chs Exp $");
 
 #include 
 #include 
@@ -255,6 +255,10 @@ db_frame_info(long *frame, db_addr_t cal
 	const char *name;
 
 	sym = db_search_symbol(callpc, DB_STGY_ANY, );
+	if (sym != 0 && offset == 0) {
+		sym = db_search_symbol(callpc - 1, DB_STGY_ANY, );
+		offset++;
+	}
 	db_symbol_values(sym, , NULL);
 	if (sym == (db_sym_t)0)
 		return (db_sym_t)0;

Index: src/sys/ddb/db_sym.c
diff -u src/sys/ddb/db_sym.c:1.67 src/sys/ddb/db_sym.c:1.68
--- src/sys/ddb/db_sym.c:1.67	Mon Apr 12 02:49:02 2021
+++ src/sys/ddb/db_sym.c	Mon Dec 13 01:25:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_sym.c,v 1.67 2021/04/12 02:49:02 mrg Exp $	*/
+/*	$NetBSD: db_sym.c,v 1.68 2021/12/13 01:25:29 chs Exp $	*/
 
 /*
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_sym.c,v 1.67 2021/04/12 02:49:02 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_sym.c,v 1.68 2021/12/13 01:25:29 chs Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddbparam.h"
@@ -347,6 +347,12 @@ db_symstr(char *buf, size_t buflen, db_e
 	if (ksyms_getname(, , (vaddr_t)off,
 	strategy|KSYMS_CLOSEST) == 0) {
 		(void)ksyms_getval_unlocked(mod, name, NULL, , KSYMS_ANY);
+		if (strategy & KSYMS_PROC && val == off) {
+			if (ksyms_getname(, , (vaddr_t)off - 1,
+	  strategy|KSYMS_CLOSEST) != 0)
+goto out;
+			(void)ksyms_getval_unlocked(mod, name, NULL, , KSYMS_ANY);
+		}
 		if (((off - val) < db_maxoff) && val) {
 			snprintf(buf, buflen, "%s:%s", mod, name);
 			if (off - val) {
@@ -365,6 +371,7 @@ db_symstr(char *buf, size_t buflen, db_e
 			return;
 		}
 	}
+out:
 	strlcpy(buf, db_num_to_str(off), buflen);
 #endif
 }
@@ -418,6 +425,12 @@ db_printsym(db_expr_t off, db_strategy_t
 	if (ksyms_getname(, , (vaddr_t)off,
 	strategy|KSYMS_CLOSEST) == 0) {
 		(void)ksyms_getval_unlocked(mod, name, NULL, , KSYMS_ANY);
+		if (strategy & KSYMS_PROC && uval == off) {
+			if (ksyms_getname(, , (vaddr_t)off - 1,
+	  strategy|KSYMS_CLOSEST) != 0)
+goto out;
+			(void)ksyms_getval_unlocked(mod, name, NULL, , KSYMS_ANY);
+		}
 		val = (long) uval;
 		if (((off - val) < db_maxoff) && val) {
 			(*pr)("%s:%s", mod, name);
@@ -437,6 +450,7 @@ db_printsym(db_expr_t off, db_strategy_t
 		}

CVS commit: [thorpej-futex2] src/sys/kern

2021-11-01 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Nov  1 08:40:16 UTC 2021

Modified Files:
src/sys/kern [thorpej-futex2]: sys_futex.c

Log Message:
merge rev. 1.15 from HEAD:
fix a typo in compare_futex_key().


To generate a diff of this commit:
cvs rdiff -u -r1.12.4.5 -r1.12.4.6 src/sys/kern/sys_futex.c

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

Modified files:

Index: src/sys/kern/sys_futex.c
diff -u src/sys/kern/sys_futex.c:1.12.4.5 src/sys/kern/sys_futex.c:1.12.4.6
--- src/sys/kern/sys_futex.c:1.12.4.5	Sat Aug  7 01:22:33 2021
+++ src/sys/kern/sys_futex.c	Mon Nov  1 08:40:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_futex.c,v 1.12.4.5 2021/08/07 01:22:33 thorpej Exp $	*/
+/*	$NetBSD: sys_futex.c,v 1.12.4.6 2021/11/01 08:40:16 chs Exp $	*/
 
 /*-
  * Copyright (c) 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_futex.c,v 1.12.4.5 2021/08/07 01:22:33 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_futex.c,v 1.12.4.6 2021/11/01 08:40:16 chs Exp $");
 
 /*
  * Futexes
@@ -299,7 +299,7 @@ compare_futex_key(void *cookie, const vo
 	if (fka->fk_private.va < fkb->fk_private.va)
 		return -1;
 	if (fka->fk_private.va > fkb->fk_private.va)
-		return -1;
+		return +1;
 	return 0;
 }
 



CVS commit: [thorpej-futex2] src/sys/kern

2021-11-01 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Nov  1 08:40:16 UTC 2021

Modified Files:
src/sys/kern [thorpej-futex2]: sys_futex.c

Log Message:
merge rev. 1.15 from HEAD:
fix a typo in compare_futex_key().


To generate a diff of this commit:
cvs rdiff -u -r1.12.4.5 -r1.12.4.6 src/sys/kern/sys_futex.c

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



CVS commit: src/sys/kern

2021-11-01 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Nov  1 08:35:17 UTC 2021

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

Log Message:
fix a typo in compare_futex_key().


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/kern/sys_futex.c

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

Modified files:

Index: src/sys/kern/sys_futex.c
diff -u src/sys/kern/sys_futex.c:1.14 src/sys/kern/sys_futex.c:1.15
--- src/sys/kern/sys_futex.c:1.14	Thu Oct 21 13:21:54 2021
+++ src/sys/kern/sys_futex.c	Mon Nov  1 08:35:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_futex.c,v 1.14 2021/10/21 13:21:54 andvar Exp $	*/
+/*	$NetBSD: sys_futex.c,v 1.15 2021/11/01 08:35:17 chs Exp $	*/
 
 /*-
  * Copyright (c) 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_futex.c,v 1.14 2021/10/21 13:21:54 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_futex.c,v 1.15 2021/11/01 08:35:17 chs Exp $");
 
 /*
  * Futexes
@@ -236,7 +236,7 @@ compare_futex_key(void *cookie, const vo
 	if (fka->fk_private.va < fkb->fk_private.va)
 		return -1;
 	if (fka->fk_private.va > fkb->fk_private.va)
-		return -1;
+		return +1;
 	return 0;
 }
 



CVS commit: src/sys/kern

2021-11-01 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Nov  1 08:35:17 UTC 2021

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

Log Message:
fix a typo in compare_futex_key().


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/kern/sys_futex.c

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



CVS commit: src/usr.bin/rlogin

2021-08-03 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Aug  3 23:21:07 UTC 2021

Modified Files:
src/usr.bin/rlogin: rlogin.c

Log Message:
revert rev 1.45:
  "PR/54435: Adjust for new kernel behavior of soreceive(9) clearing MSG_OOB"

That change was trying to make rlogin work again after the SIOCATMARK ioctl
was broken, but that kernel bug has now been fixed, so the original rlogin code
now works again.  Further, the changed rlogin code actually did the wrong thing,
by treating reception of the MSG_OOB byte as meaning that we are now
"at the mark", but that is not true... we are "at the mark" only when
we have reached the point in the stream where the MSG_OOB byte was originally,
as indicated by SIOCATMARK.  So going back to the previous code seems best
all around.  ok'd by christos.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/rlogin/rlogin.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.bin/rlogin/rlogin.c
diff -u src/usr.bin/rlogin/rlogin.c:1.47 src/usr.bin/rlogin/rlogin.c:1.48
--- src/usr.bin/rlogin/rlogin.c:1.47	Sun May  3 16:32:16 2020
+++ src/usr.bin/rlogin/rlogin.c	Tue Aug  3 23:21:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rlogin.c,v 1.47 2020/05/03 16:32:16 christos Exp $	*/
+/*	$NetBSD: rlogin.c,v 1.48 2021/08/03 23:21:07 chs Exp $	*/
 
 /*
  * Copyright (c) 1983, 1990, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)rlogin.c	8.4 (Berkeley) 4/29/95";
 #else
-__RCSID("$NetBSD: rlogin.c,v 1.47 2020/05/03 16:32:16 christos Exp $");
+__RCSID("$NetBSD: rlogin.c,v 1.48 2021/08/03 23:21:07 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -577,34 +577,16 @@ static pid_t ppid;
 static ssize_t rcvcnt, rcvstate;
 static char rcvbuf[8 * 1024];
 
-static int
-recvx(int fd, void *buf, size_t len, int flags, int *msgflags)
-{
-	struct msghdr msg;
-	struct iovec iov;
-	int error;
-
-	memset(, 0, sizeof(msg));
-	msg.msg_iov = 
-	iov.iov_base = buf;
-	iov.iov_len = len;
-	error = recvmsg(fd, , flags);
-	if (error)
-		return error;
-	*msgflags = msg.msg_flags;
-	return 0;
-}
-
 static void
 oob(int signo)
 {
 	struct termios tty;
-	int atmark = 0;
+	int atmark;
 	ssize_t n, rcvd;
 	char waste[BUFSIZ], mark;
 
 	rcvd = 0;
-	while (recvx(rem, , 1, MSG_OOB, ) == -1) {
+	while (recv(rem, , 1, MSG_OOB) == -1) {
 		switch (errno) {
 		case EWOULDBLOCK:
 			/*
@@ -628,7 +610,6 @@ oob(int signo)
 			return;
 		}
 	}
-	atmark &= MSG_OOB;
 	if (mark & TIOCPKT_WINDOW) {
 		/* Let server know about window size changes */
 		(void)kill(ppid, SIGUSR1);
@@ -645,8 +626,17 @@ oob(int signo)
 	}
 	if (mark & TIOCPKT_FLUSHWRITE) {
 		(void)tcflush(1, TCIOFLUSH);
-		if (!atmark)
+		for (;;) {
+			if (ioctl(rem, SIOCATMARK, ) < 0) {
+warn("ioctl SIOCATMARK (ignored)");
+break;
+			}
+			if (atmark)
+break;
 			n = read(rem, waste, sizeof (waste));
+			if (n <= 0)
+break;
+		}
 		/*
 		 * Don't want any pending data to be output, so clear the recv
 		 * buffer.  If we were hanging on a write when interrupted,



CVS commit: src/usr.bin/rlogin

2021-08-03 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Aug  3 23:21:07 UTC 2021

Modified Files:
src/usr.bin/rlogin: rlogin.c

Log Message:
revert rev 1.45:
  "PR/54435: Adjust for new kernel behavior of soreceive(9) clearing MSG_OOB"

That change was trying to make rlogin work again after the SIOCATMARK ioctl
was broken, but that kernel bug has now been fixed, so the original rlogin code
now works again.  Further, the changed rlogin code actually did the wrong thing,
by treating reception of the MSG_OOB byte as meaning that we are now
"at the mark", but that is not true... we are "at the mark" only when
we have reached the point in the stream where the MSG_OOB byte was originally,
as indicated by SIOCATMARK.  So going back to the previous code seems best
all around.  ok'd by christos.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/rlogin/rlogin.c

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



CVS commit: src/sys/kern

2021-08-03 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Aug  3 20:27:08 UTC 2021

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

Log Message:
in sbsavetimestamp(), initialize struct timeval to 0 with memset() so that
the implicit padding is initialized.  this avoids later copying uninitialized
memory out to user space.  detected by KMSAN.


To generate a diff of this commit:
cvs rdiff -u -r1.294 -r1.295 src/sys/kern/uipc_socket.c

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

Modified files:

Index: src/sys/kern/uipc_socket.c
diff -u src/sys/kern/uipc_socket.c:1.294 src/sys/kern/uipc_socket.c:1.295
--- src/sys/kern/uipc_socket.c:1.294	Fri Dec 11 03:00:09 2020
+++ src/sys/kern/uipc_socket.c	Tue Aug  3 20:27:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_socket.c,v 1.294 2020/12/11 03:00:09 thorpej Exp $	*/
+/*	$NetBSD: uipc_socket.c,v 1.295 2021/08/03 20:27:08 chs Exp $	*/
 
 /*
  * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.294 2020/12/11 03:00:09 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.295 2021/08/03 20:27:08 chs Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -2432,6 +2432,7 @@ sbsavetimestamp(int opt, struct mbuf **m
 	struct timeval tv;
 	int error;
 
+	memset(, 0, sizeof(tv));
 	microtime();
 
 	MODULE_HOOK_CALL(uipc_socket_50_sbts_hook, (opt, ), enosys(), error);



CVS commit: src/sys/kern

2021-08-03 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Aug  3 20:27:08 UTC 2021

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

Log Message:
in sbsavetimestamp(), initialize struct timeval to 0 with memset() so that
the implicit padding is initialized.  this avoids later copying uninitialized
memory out to user space.  detected by KMSAN.


To generate a diff of this commit:
cvs rdiff -u -r1.294 -r1.295 src/sys/kern/uipc_socket.c

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



CVS commit: src/sys/kern

2021-08-03 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Aug  3 20:25:43 UTC 2021

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

Log Message:
initialize wc_unused to 0, to avoid writing uninitialized memory to disk.
detected by KMSAN.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/sys/kern/vfs_wapbl.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_wapbl.c
diff -u src/sys/kern/vfs_wapbl.c:1.108 src/sys/kern/vfs_wapbl.c:1.109
--- src/sys/kern/vfs_wapbl.c:1.108	Sun Apr 12 17:02:52 2020
+++ src/sys/kern/vfs_wapbl.c	Tue Aug  3 20:25:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_wapbl.c,v 1.108 2020/04/12 17:02:52 jdolecek Exp $	*/
+/*	$NetBSD: vfs_wapbl.c,v 1.109 2021/08/03 20:25:43 chs Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #define WAPBL_INTERNAL
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.108 2020/04/12 17:02:52 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.109 2021/08/03 20:25:43 chs Exp $");
 
 #include 
 #include 
@@ -2559,6 +2559,7 @@ wapbl_write_blocks(struct wapbl *wl, off
 		wc->wc_type = WAPBL_WC_BLOCKS;
 		wc->wc_len = blocklen;
 		wc->wc_blkcount = 0;
+		wc->wc_unused = 0;
 		while (bp && (wc->wc_blkcount < wl->wl_brperjblock)) {
 			/*
 			 * Make sure all the physical block numbers are up to
@@ -2647,6 +2648,7 @@ wapbl_write_revocations(struct wapbl *wl
 		wc->wc_type = WAPBL_WC_REVOCATIONS;
 		wc->wc_len = blocklen;
 		wc->wc_blkcount = 0;
+		wc->wc_unused = 0;
 		while (wd && (wc->wc_blkcount < wl->wl_brperjblock)) {
 			wc->wc_blocks[wc->wc_blkcount].wc_daddr =
 			wd->wd_blkno;



CVS commit: src/sys/kern

2021-08-03 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Aug  3 20:25:43 UTC 2021

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

Log Message:
initialize wc_unused to 0, to avoid writing uninitialized memory to disk.
detected by KMSAN.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/sys/kern/vfs_wapbl.c

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



CVS commit: src/external/gpl2/gettext/dist/gettext-runtime

2021-08-03 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Aug  3 20:22:15 UTC 2021

Modified Files:
src/external/gpl2/gettext/dist/gettext-runtime: Makefile.in

Log Message:
do not descend into the man or tests directory.
this avoids a problem where git sets the file timestamps differently
than CVS does and accidentally causes make to try to rebuild
various targets that don't work during the tools build.
this matches the change that was made to Makefile.am in our tree.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/gpl2/gettext/dist/gettext-runtime/Makefile.in

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/gettext/dist/gettext-runtime/Makefile.in
diff -u src/external/gpl2/gettext/dist/gettext-runtime/Makefile.in:1.2 src/external/gpl2/gettext/dist/gettext-runtime/Makefile.in:1.3
--- src/external/gpl2/gettext/dist/gettext-runtime/Makefile.in:1.2	Tue Jan 12 22:58:02 2016
+++ src/external/gpl2/gettext/dist/gettext-runtime/Makefile.in	Tue Aug  3 20:22:15 2021
@@ -347,7 +347,7 @@ ACLOCAL_AMFLAGS = -I m4 -I ../autoconf-l
 # The list of subdirectories depends on whether --disable-libasprintf was
 # specified.
 @ENABLE_LIBASPRINTF_TRUE@SUBDIR_libasprintf = libasprintf
-SUBDIRS = doc intl intl-java intl-csharp gnulib-lib $(SUBDIR_libasprintf) src po man m4 tests
+SUBDIRS = doc intl intl-java intl-csharp gnulib-lib $(SUBDIR_libasprintf) src po m4
 
 # Allow users to use "gnulib-tool --update".
 



CVS commit: src/external/gpl2/gettext/dist/gettext-runtime

2021-08-03 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Aug  3 20:22:15 UTC 2021

Modified Files:
src/external/gpl2/gettext/dist/gettext-runtime: Makefile.in

Log Message:
do not descend into the man or tests directory.
this avoids a problem where git sets the file timestamps differently
than CVS does and accidentally causes make to try to rebuild
various targets that don't work during the tools build.
this matches the change that was made to Makefile.am in our tree.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/gpl2/gettext/dist/gettext-runtime/Makefile.in

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



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

2021-07-19 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Jul 19 14:49:45 UTC 2021

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

Log Message:
there is no need to keep pvos for unmanaged mappings on a hidden p/v list,
since "unmanaged" means that we don't want to find such pvos on any p/v list.
instead, just don't put such pvos on any p/v list at all and remove
the two hidden p/v lists for unmanaged mappings.  code mostly from martin,
to implement rin's suggestion of unifying the two hidden lists.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/arch/powerpc/oea/pmap.c

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

Modified files:

Index: src/sys/arch/powerpc/oea/pmap.c
diff -u src/sys/arch/powerpc/oea/pmap.c:1.106 src/sys/arch/powerpc/oea/pmap.c:1.107
--- src/sys/arch/powerpc/oea/pmap.c:1.106	Sun Jun 27 12:26:33 2021
+++ src/sys/arch/powerpc/oea/pmap.c	Mon Jul 19 14:49:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.106 2021/06/27 12:26:33 martin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.107 2021/07/19 14:49:45 chs Exp $	*/
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -63,7 +63,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.106 2021/06/27 12:26:33 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.107 2021/07/19 14:49:45 chs Exp $");
 
 #define	PMAP_NOOPNAMES
 
@@ -328,8 +328,6 @@ struct pvo_entry {
 
 TAILQ_HEAD(pvo_tqhead, pvo_entry);
 struct pvo_tqhead *pmap_pvo_table;	/* pvo entries by ptegroup index */
-static struct pvo_head pmap_pvo_kunmanaged = LIST_HEAD_INITIALIZER(pmap_pvo_kunmanaged);	/* list of unmanaged pages */
-static struct pvo_head pmap_pvo_unmanaged = LIST_HEAD_INITIALIZER(pmap_pvo_unmanaged);	/* list of unmanaged pages */
 
 struct pool pmap_pool;		/* pool for pmap structures */
 struct pool pmap_pvo_pool;	/* pool for pvo entries */
@@ -652,7 +650,7 @@ pa_to_pvoh(paddr_t pa, struct vm_page **
 	if (pg_p != NULL)
 		*pg_p = pg;
 	if (pg == NULL)
-		return _pvo_unmanaged;
+		return NULL;
 	md = VM_PAGE_TO_MD(pg);
 	return >mdpg_pvoh;
 }
@@ -1410,22 +1408,19 @@ pmap_pvo_check(const struct pvo_entry *p
 
 	if (PVO_MANAGED_P(pvo)) {
 		pvo_head = pa_to_pvoh(pvo->pvo_pte.pte_lo & PTE_RPGN, NULL);
-	} else {
-		if (pvo->pvo_vaddr < VM_MIN_KERNEL_ADDRESS) {
-			printf("pmap_pvo_check: pvo %p: non kernel address "
-			"on kernel unmanaged list\n", pvo);
+		LIST_FOREACH(pvo0, pvo_head, pvo_vlink) {
+			if (pvo0 == pvo)
+break;
+		}
+		if (pvo0 == NULL) {
+			printf("pmap_pvo_check: pvo %p: not present "
+			   "on its vlist head %p\n", pvo, pvo_head);
 			failed = 1;
 		}
-		pvo_head = _pvo_kunmanaged;
-	}
-	LIST_FOREACH(pvo0, pvo_head, pvo_vlink) {
-		if (pvo0 == pvo)
-			break;
-	}
-	if (pvo0 == NULL) {
-		printf("pmap_pvo_check: pvo %p: not present "
-		"on its vlist head %p\n", pvo, pvo_head);
-		failed = 1;
+	} else {
+		KASSERT(pvo->pvo_vaddr >= VM_MIN_KERNEL_ADDRESS);
+		if (__predict_false(pvo->pvo_vaddr < VM_MIN_KERNEL_ADDRESS))
+			failed = 1;
 	}
 	if (pvo != pmap_pvo_find_va(pvo->pvo_pmap, pvo->pvo_vaddr, NULL)) {
 		printf("pmap_pvo_check: pvo %p: not present "
@@ -1620,7 +1615,7 @@ pmap_pvo_enter(pmap_t pm, struct pool *p
 	}
 	if (flags & PMAP_WIRED)
 		pvo->pvo_vaddr |= PVO_WIRED;
-	if (pvo_head != _pvo_kunmanaged) {
+	if (pvo_head != NULL) {
 		pvo->pvo_vaddr |= PVO_MANAGED; 
 		PMAPCOUNT(mappings);
 	} else {
@@ -1628,7 +1623,8 @@ pmap_pvo_enter(pmap_t pm, struct pool *p
 	}
 	pmap_pte_create(>pvo_pte, pm, va, pa | pte_lo);
 
-	LIST_INSERT_HEAD(pvo_head, pvo, pvo_vlink);
+	if (pvo_head != NULL)
+		LIST_INSERT_HEAD(pvo_head, pvo, pvo_vlink);
 	if (PVO_WIRED_P(pvo))
 		pvo->pvo_pmap->pm_stats.wired_count++;
 	pvo->pvo_pmap->pm_stats.resident_count++;
@@ -1728,7 +1724,9 @@ pmap_pvo_remove(struct pvo_entry *pvo, i
 		pvo->pvo_pmap->pm_stats.wired_count--;
 
 	/*
-	 * Save the REF/CHG bits into their cache if the page is managed.
+	 * If the page is managed:
+	 * Save the REF/CHG bits into their cache.
+	 * Remove the PVO from the P/V list.
 	 */
 	if (PVO_MANAGED_P(pvo)) {
 		register_t ptelo = pvo->pvo_pte.pte_lo;
@@ -1760,15 +1758,15 @@ pmap_pvo_remove(struct pvo_entry *pvo, i
 
 			pmap_attr_save(pg, ptelo & (PTE_REF|PTE_CHG));
 		}
+		LIST_REMOVE(pvo, pvo_vlink);
 		PMAPCOUNT(unmappings);
 	} else {
 		PMAPCOUNT(kernel_unmappings);
 	}
 
 	/*
-	 * Remove the PVO from its lists and return it to the pool.
+	 * Remove the PVO from its list and return it to the pool.
 	 */
-	LIST_REMOVE(pvo, pvo_vlink);
 	TAILQ_REMOVE(_pvo_table[ptegidx], pvo, pvo_olink);
 	if (pvol) {
 		LIST_INSERT_HEAD(pvol, pvo, pvo_vlink);
@@ -1861,9 +1859,10 @@ pmap_enter(pmap_t pm, vaddr_t va, paddr_
 	PMAP_LOCK();
 
 	if (__predict_false(!pmap_initialized)) {
-		pvo_head = _pvo_kunmanaged;
+		pvo_head = NULL;
 		pg = NULL;
 		was_exec = PTE_EXEC;
+
 	} else {
 		pvo_head = pa_to_pvoh(pa, );
 	}
@@ -1952,7 +1951,6 @@ pmap_enter(pmap_t pm, 

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

2021-07-19 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Jul 19 14:49:45 UTC 2021

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

Log Message:
there is no need to keep pvos for unmanaged mappings on a hidden p/v list,
since "unmanaged" means that we don't want to find such pvos on any p/v list.
instead, just don't put such pvos on any p/v list at all and remove
the two hidden p/v lists for unmanaged mappings.  code mostly from martin,
to implement rin's suggestion of unifying the two hidden lists.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/arch/powerpc/oea/pmap.c

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



CVS commit: src/sys/uvm

2021-07-01 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Thu Jul  1 15:06:01 UTC 2021

Modified Files:
src/sys/uvm: uvm_map.c

Log Message:
in uvm_mapent_forkzero(), if the old entry was an object mapping,
appease a debug check by setting the new entry offset to zero along with
setting the new entry object pointer to NULL.

Reported-by: syzbot+de8e4b223a3838c73...@syzkaller.appspotmail.com
Reported-by: syzbot+efaea991addfdcc5a...@syzkaller.appspotmail.com
Reported-by: syzbot+15d1e19dff9209c2e...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.389 -r1.390 src/sys/uvm/uvm_map.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/uvm/uvm_map.c
diff -u src/sys/uvm/uvm_map.c:1.389 src/sys/uvm/uvm_map.c:1.390
--- src/sys/uvm/uvm_map.c:1.389	Sun Jun 20 07:11:38 2021
+++ src/sys/uvm/uvm_map.c	Thu Jul  1 15:06:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_map.c,v 1.389 2021/06/20 07:11:38 mrg Exp $	*/
+/*	$NetBSD: uvm_map.c,v 1.390 2021/07/01 15:06:01 chs Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.389 2021/06/20 07:11:38 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.390 2021/07/01 15:06:01 chs Exp $");
 
 #include "opt_ddb.h"
 #include "opt_pax.h"
@@ -4451,6 +4451,7 @@ uvm_mapent_forkzero(struct vm_map *new_m
 			new_entry->object.uvm_obj->pgops->pgo_detach(
 			new_entry->object.uvm_obj);
 		new_entry->object.uvm_obj = NULL;
+		new_entry->offset = 0;
 		new_entry->etype &= ~UVM_ET_OBJ;
 	}
 }



CVS commit: src/sys/uvm

2021-07-01 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Thu Jul  1 15:06:01 UTC 2021

Modified Files:
src/sys/uvm: uvm_map.c

Log Message:
in uvm_mapent_forkzero(), if the old entry was an object mapping,
appease a debug check by setting the new entry offset to zero along with
setting the new entry object pointer to NULL.

Reported-by: syzbot+de8e4b223a3838c73...@syzkaller.appspotmail.com
Reported-by: syzbot+efaea991addfdcc5a...@syzkaller.appspotmail.com
Reported-by: syzbot+15d1e19dff9209c2e...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.389 -r1.390 src/sys/uvm/uvm_map.c

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



CVS commit: src/sys

2021-06-28 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Jun 28 17:52:13 UTC 2021

Modified Files:
src/sys/fs/ptyfs: ptyfs_vnops.c
src/sys/miscfs/fdesc: fdesc_vnops.c
src/sys/miscfs/kernfs: kernfs_vnops.c
src/sys/miscfs/procfs: procfs_vnops.c

Log Message:
VOP_BMAP() may be called via ioctl(FIOGETBMAP) on any vnode that applications
can open.  change various pseudo-fs *_bmap methods return an error instead of
panic.

Reported-by: syzbot+8289a3eaf2ba60958...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/fs/ptyfs/ptyfs_vnops.c
cvs rdiff -u -r1.135 -r1.136 src/sys/miscfs/fdesc/fdesc_vnops.c
cvs rdiff -u -r1.166 -r1.167 src/sys/miscfs/kernfs/kernfs_vnops.c
cvs rdiff -u -r1.215 -r1.216 src/sys/miscfs/procfs/procfs_vnops.c

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

Modified files:

Index: src/sys/fs/ptyfs/ptyfs_vnops.c
diff -u src/sys/fs/ptyfs/ptyfs_vnops.c:1.62 src/sys/fs/ptyfs/ptyfs_vnops.c:1.63
--- src/sys/fs/ptyfs/ptyfs_vnops.c:1.62	Fri Nov 27 14:43:57 2020
+++ src/sys/fs/ptyfs/ptyfs_vnops.c	Mon Jun 28 17:52:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptyfs_vnops.c,v 1.62 2020/11/27 14:43:57 christos Exp $	*/
+/*	$NetBSD: ptyfs_vnops.c,v 1.63 2021/06/28 17:52:12 chs Exp $	*/
 
 /*
  * Copyright (c) 1993, 1995
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ptyfs_vnops.c,v 1.62 2020/11/27 14:43:57 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ptyfs_vnops.c,v 1.63 2021/06/28 17:52:12 chs Exp $");
 
 #include 
 #include 
@@ -144,7 +144,7 @@ int	ptyfs_reclaim	(void *);
 int	ptyfs_inactive	(void *);
 #define	ptyfs_lock	genfs_lock
 #define	ptyfs_unlock	genfs_unlock
-#define	ptyfs_bmap	genfs_badop
+#define	ptyfs_bmap	genfs_eopnotsupp
 #define	ptyfs_strategy	genfs_badop
 int	ptyfs_print	(void *);
 int	ptyfs_pathconf	(void *);

Index: src/sys/miscfs/fdesc/fdesc_vnops.c
diff -u src/sys/miscfs/fdesc/fdesc_vnops.c:1.135 src/sys/miscfs/fdesc/fdesc_vnops.c:1.136
--- src/sys/miscfs/fdesc/fdesc_vnops.c:1.135	Sat May  1 15:08:14 2021
+++ src/sys/miscfs/fdesc/fdesc_vnops.c	Mon Jun 28 17:52:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdesc_vnops.c,v 1.135 2021/05/01 15:08:14 hannken Exp $	*/
+/*	$NetBSD: fdesc_vnops.c,v 1.136 2021/06/28 17:52:13 chs Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.135 2021/05/01 15:08:14 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.136 2021/06/28 17:52:13 chs Exp $");
 
 #include 
 #include 
@@ -104,7 +104,7 @@ int	fdesc_inactive(void *);
 int	fdesc_reclaim(void *);
 #define	fdesc_lock	genfs_lock
 #define	fdesc_unlock	genfs_unlock
-#define	fdesc_bmap	genfs_badop
+#define	fdesc_bmap	genfs_eopnotsupp
 #define	fdesc_strategy	genfs_badop
 int	fdesc_print(void *);
 int	fdesc_pathconf(void *);

Index: src/sys/miscfs/kernfs/kernfs_vnops.c
diff -u src/sys/miscfs/kernfs/kernfs_vnops.c:1.166 src/sys/miscfs/kernfs/kernfs_vnops.c:1.167
--- src/sys/miscfs/kernfs/kernfs_vnops.c:1.166	Sat Jun 27 17:29:19 2020
+++ src/sys/miscfs/kernfs/kernfs_vnops.c	Mon Jun 28 17:52:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kernfs_vnops.c,v 1.166 2020/06/27 17:29:19 christos Exp $	*/
+/*	$NetBSD: kernfs_vnops.c,v 1.167 2021/06/28 17:52:13 chs Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.166 2020/06/27 17:29:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.167 2021/06/28 17:52:13 chs Exp $");
 
 #include 
 #include 
@@ -166,7 +166,7 @@ int	kernfs_reclaim(void *);
 #define	kernfs_lock	genfs_lock
 #define	kernfs_unlock	genfs_unlock
 #define	kernfs_bmap	genfs_badop
-#define	kernfs_strategy	genfs_badop
+#define	kernfs_strategy	genfs_eopnotsupp
 int	kernfs_print(void *);
 #define	kernfs_islocked	genfs_islocked
 int	kernfs_pathconf(void *);

Index: src/sys/miscfs/procfs/procfs_vnops.c
diff -u src/sys/miscfs/procfs/procfs_vnops.c:1.215 src/sys/miscfs/procfs/procfs_vnops.c:1.216
--- src/sys/miscfs/procfs/procfs_vnops.c:1.215	Sat Jun 27 17:29:19 2020
+++ src/sys/miscfs/procfs/procfs_vnops.c	Mon Jun 28 17:52:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vnops.c,v 1.215 2020/06/27 17:29:19 christos Exp $	*/
+/*	$NetBSD: procfs_vnops.c,v 1.216 2021/06/28 17:52:13 chs Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -105,7 +105,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.215 2020/06/27 17:29:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.216 2021/06/28 17:52:13 chs Exp $");
 
 #include 
 #include 
@@ -237,7 +237,7 @@ int	procfs_inactive(void *);
 int	procfs_reclaim(void *);
 #define	procfs_lock	genfs_lock
 #define	procfs_unlock	genfs_unlock
-#define	procfs_bmap	genfs_badop
+#define	procfs_bmap	genfs_eopnotsupp
 #define	procfs_strategy	genfs_badop
 int	procfs_print(void *);
 int	procfs_pathconf(void *);



CVS commit: src/sys

2021-06-28 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Jun 28 17:52:13 UTC 2021

Modified Files:
src/sys/fs/ptyfs: ptyfs_vnops.c
src/sys/miscfs/fdesc: fdesc_vnops.c
src/sys/miscfs/kernfs: kernfs_vnops.c
src/sys/miscfs/procfs: procfs_vnops.c

Log Message:
VOP_BMAP() may be called via ioctl(FIOGETBMAP) on any vnode that applications
can open.  change various pseudo-fs *_bmap methods return an error instead of
panic.

Reported-by: syzbot+8289a3eaf2ba60958...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/fs/ptyfs/ptyfs_vnops.c
cvs rdiff -u -r1.135 -r1.136 src/sys/miscfs/fdesc/fdesc_vnops.c
cvs rdiff -u -r1.166 -r1.167 src/sys/miscfs/kernfs/kernfs_vnops.c
cvs rdiff -u -r1.215 -r1.216 src/sys/miscfs/procfs/procfs_vnops.c

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



CVS commit: src/usr.bin/kdump

2021-06-19 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Jun 20 00:25:29 UTC 2021

Modified Files:
src/usr.bin/kdump: kdump.c

Log Message:
fix printf format string for xattr names (the length of the xattr name
needs to be a precision rather than a width).


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/usr.bin/kdump/kdump.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.bin/kdump/kdump.c
diff -u src/usr.bin/kdump/kdump.c:1.139 src/usr.bin/kdump/kdump.c:1.140
--- src/usr.bin/kdump/kdump.c:1.139	Thu Apr 30 15:12:25 2020
+++ src/usr.bin/kdump/kdump.c	Sun Jun 20 00:25:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kdump.c,v 1.139 2020/04/30 15:12:25 martin Exp $	*/
+/*	$NetBSD: kdump.c,v 1.140 2021/06/20 00:25:29 chs Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)kdump.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: kdump.c,v 1.139 2020/04/30 15:12:25 martin Exp $");
+__RCSID("$NetBSD: kdump.c,v 1.140 2021/06/20 00:25:29 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -1288,7 +1288,7 @@ ktruser_soname(const char *name, const v
 static void
 ktruser_xattr_name(const char *name, const void *buf, size_t len)
 {
-	printf("%.*s: [%*s]\n", KTR_USER_MAXIDLEN, name, (int)len,
+	printf("%.*s: [%.*s]\n", KTR_USER_MAXIDLEN, name, (int)len,
 	(const char *)buf);
 }
 



CVS commit: src/usr.bin/kdump

2021-06-19 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Jun 20 00:25:29 UTC 2021

Modified Files:
src/usr.bin/kdump: kdump.c

Log Message:
fix printf format string for xattr names (the length of the xattr name
needs to be a precision rather than a width).


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/usr.bin/kdump/kdump.c

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



  1   2   3   4   5   6   7   8   9   10   >