CVS commit: src/usr.sbin/sysinst

2024-04-25 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Apr 25 11:25:09 UTC 2024

Modified Files:
src/usr.sbin/sysinst: msg.mi.de msg.mi.en msg.mi.es msg.mi.pl util.c

Log Message:
Increase length of set description to 40 characters so recent additions fit.

Ok: martin@

Fixes PR install/58188 "sysinst fails to display status of base32 set"


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.sbin/sysinst/msg.mi.de
cvs rdiff -u -r1.50 -r1.51 src/usr.sbin/sysinst/msg.mi.en
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/sysinst/msg.mi.es
cvs rdiff -u -r1.48 -r1.49 src/usr.sbin/sysinst/msg.mi.pl
cvs rdiff -u -r1.76 -r1.77 src/usr.sbin/sysinst/util.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/sysinst/msg.mi.de
diff -u src/usr.sbin/sysinst/msg.mi.de:1.47 src/usr.sbin/sysinst/msg.mi.de:1.48
--- src/usr.sbin/sysinst/msg.mi.de:1.47	Mon Apr 22 14:41:26 2024
+++ src/usr.sbin/sysinst/msg.mi.de	Thu Apr 25 11:25:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg.mi.de,v 1.47 2024/04/22 14:41:26 nia Exp $	*/
+/*	$NetBSD: msg.mi.de,v 1.48 2024/04/25 11:25:08 hannken Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -875,8 +875,8 @@ message cur_distsets
 }
 
 message cur_distsets_header
-{   Distributionspaket   Ausgewählt
-    --
+{   Distributionspaket Ausgewählt
+   -- --
 }
 
 message set_base

Index: src/usr.sbin/sysinst/msg.mi.en
diff -u src/usr.sbin/sysinst/msg.mi.en:1.50 src/usr.sbin/sysinst/msg.mi.en:1.51
--- src/usr.sbin/sysinst/msg.mi.en:1.50	Mon Apr 22 14:41:26 2024
+++ src/usr.sbin/sysinst/msg.mi.en	Thu Apr 25 11:25:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg.mi.en,v 1.50 2024/04/22 14:41:26 nia Exp $	*/
+/*	$NetBSD: msg.mi.en,v 1.51 2024/04/25 11:25:08 hannken Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -809,8 +809,8 @@ message cur_distsets
 }
 
 message cur_distsets_header
-{   Distribution set Selected
-    
+{   Distribution set   Selected
+   -- 
 }
 
 message set_base

Index: src/usr.sbin/sysinst/msg.mi.es
diff -u src/usr.sbin/sysinst/msg.mi.es:1.42 src/usr.sbin/sysinst/msg.mi.es:1.43
--- src/usr.sbin/sysinst/msg.mi.es:1.42	Mon Apr 22 14:41:26 2024
+++ src/usr.sbin/sysinst/msg.mi.es	Thu Apr 25 11:25:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg.mi.es,v 1.42 2024/04/22 14:41:26 nia Exp $	*/
+/*	$NetBSD: msg.mi.es,v 1.43 2024/04/25 11:25:08 hannken Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -834,8 +834,8 @@ message cur_distsets
 }
 
 message cur_distsets_header
-{   Conjunto de distribución Selecc.
-    
+{   Conjunto de distribución   Selecc.
+   -- 
 }
 
 message set_base

Index: src/usr.sbin/sysinst/msg.mi.pl
diff -u src/usr.sbin/sysinst/msg.mi.pl:1.48 src/usr.sbin/sysinst/msg.mi.pl:1.49
--- src/usr.sbin/sysinst/msg.mi.pl:1.48	Mon Apr 22 14:41:26 2024
+++ src/usr.sbin/sysinst/msg.mi.pl	Thu Apr 25 11:25:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg.mi.pl,v 1.48 2024/04/22 14:41:26 nia Exp $	*/
+/*	$NetBSD: msg.mi.pl,v 1.49 2024/04/25 11:25:08 hannken Exp $	*/
 /*	Based on english version: */
 /*	NetBSD: msg.mi.pl,v 1.36 2004/04/17 18:55:35 atatat Exp   */
 
@@ -806,8 +806,8 @@ message cur_distsets
 }
 
 message cur_distsets_header
-{Pakiet dystrybucyjny Uzyc?
-- -
+{Pakiet dystrybucyjny   Uzyc?
+--- -
 }
 
 message set_base

Index: src/usr.sbin/sysinst/util.c
diff -u src/usr.sbin/sysinst/util.c:1.76 src/usr.sbin/sysinst/util.c:1.77
--- src/usr.sbin/sysinst/util.c:1.76	Mon Apr 22 14:41:26 2024
+++ src/usr.sbin/sysinst/util.c	Thu Apr 25 11:25:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: util.c,v 1.76 2024/04/22 14:41:26 nia Exp $	*/
+/*	$NetBSD: util.c,v 1.77 2024/04/25 11:25:08 hannken Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -246,7 +246,7 @@ init_set_status(int flags)
 	i = strlen(msg_all); if (i > len) {len = i; longest = msg_all; }
 	i = strlen(msg_some); if (i > len) {len = i; longest = msg_some; }
 	i = strlen(msg_none); if (i > len) {len = i; longest = msg_none; }
-	select_menu_width = snprintf(NULL, 0, "%-30s %s", "", longest);
+	select_menu_width = snprintf(NULL, 0, "%-40s %s", "", longest);
 
 	/* Give the md code a chance to choose the right kernel, etc. */
 	md_init_set_status(flags);
@@ -870,7 +870,7 @@ set_label(menudesc *menu, int opt, void 
 		}
 	}
 
-	wprintw(menu->mw, "%-30s %s", msg_string(desc), selected);
+	wprintw(menu->mw, "%-40s %s", msg_string(desc), selected);
 }
 
 static int set_sublist(menudesc *menu, void *arg);



CVS commit: src/usr.sbin/sysinst

2024-04-25 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Apr 25 11:25:09 UTC 2024

Modified Files:
src/usr.sbin/sysinst: msg.mi.de msg.mi.en msg.mi.es msg.mi.pl util.c

Log Message:
Increase length of set description to 40 characters so recent additions fit.

Ok: martin@

Fixes PR install/58188 "sysinst fails to display status of base32 set"


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.sbin/sysinst/msg.mi.de
cvs rdiff -u -r1.50 -r1.51 src/usr.sbin/sysinst/msg.mi.en
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/sysinst/msg.mi.es
cvs rdiff -u -r1.48 -r1.49 src/usr.sbin/sysinst/msg.mi.pl
cvs rdiff -u -r1.76 -r1.77 src/usr.sbin/sysinst/util.c

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



CVS commit: src/distrib/sets/lists/debug32

2024-04-12 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Apr 12 14:22:51 UTC 2024

Modified Files:
src/distrib/sets/lists/debug32: md.amd64

Log Message:
Files libgcc_eh_g.a and libgcc_s_g.a are debuglib, not debug.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/distrib/sets/lists/debug32/md.amd64

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



CVS commit: src/distrib/sets/lists/debug32

2024-04-12 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Apr 12 14:22:51 UTC 2024

Modified Files:
src/distrib/sets/lists/debug32: md.amd64

Log Message:
Files libgcc_eh_g.a and libgcc_s_g.a are debuglib, not debug.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/distrib/sets/lists/debug32/md.amd64

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

Modified files:

Index: src/distrib/sets/lists/debug32/md.amd64
diff -u src/distrib/sets/lists/debug32/md.amd64:1.5 src/distrib/sets/lists/debug32/md.amd64:1.6
--- src/distrib/sets/lists/debug32/md.amd64:1.5	Fri Apr 12 11:40:09 2024
+++ src/distrib/sets/lists/debug32/md.amd64	Fri Apr 12 14:22:51 2024
@@ -1,4 +1,4 @@
-# $NetBSD: md.amd64,v 1.5 2024/04/12 11:40:09 wiz Exp $
+# $NetBSD: md.amd64,v 1.6 2024/04/12 14:22:51 hannken Exp $
 ./usr/lib/i386/i18n/libBIG5_g.a			comp-c-debuglib	debuglib,compat
 ./usr/lib/i386/i18n/libDECHanyu_g.a			comp-c-debuglib	debuglib,compat
 ./usr/lib/i386/i18n/libEUCTW_g.a			comp-c-debuglib	debuglib,compat
@@ -63,9 +63,9 @@
 ./usr/lib/i386/libfido2_g.a			comp-c-debuglib	debuglib,compat
 ./usr/lib/i386/libfl_g.a			comp-c-debuglib	debuglib,compat
 ./usr/lib/i386/libform_g.a			comp-c-debuglib	debuglib,compat
-./usr/lib/i386/libgcc_eh_g.a 			comp-sys-debug	debug,compat,gcc
+./usr/lib/i386/libgcc_eh_g.a 			comp-c-debuglib	debuglib,compat,gcc
 ./usr/lib/i386/libgcc_g.a			comp-c-debuglib	debuglib,compat,gcc
-./usr/lib/i386/libgcc_s_g.a			comp-sys-debug	debug,compat,gcc
+./usr/lib/i386/libgcc_s_g.a			comp-c-debuglib	debuglib,compat,gcc
 ./usr/lib/i386/libgcov_g.a			comp-c-debuglib	debuglib,compat,gcc
 ./usr/lib/i386/libgnuctf_g.a			comp-c-debuglib	debuglib,compat,binutils
 ./usr/lib/i386/libgnumalloc_g.a			comp-c-debuglib	debuglib,compat



CVS commit: src/sys/dev/dkwedge

2024-04-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Apr  6 09:51:34 UTC 2024

Modified Files:
src/sys/dev/dkwedge: dkwedge_tos.c

Log Message:
Use "%zu" for type "size_t".  Kernel ALL/i386 compiles again.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/dkwedge/dkwedge_tos.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/dkwedge/dkwedge_tos.c
diff -u src/sys/dev/dkwedge/dkwedge_tos.c:1.1 src/sys/dev/dkwedge/dkwedge_tos.c:1.2
--- src/sys/dev/dkwedge/dkwedge_tos.c:1.1	Tue Apr  2 22:30:03 2024
+++ src/sys/dev/dkwedge/dkwedge_tos.c	Sat Apr  6 09:51:34 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dkwedge_tos.c,v 1.1 2024/04/02 22:30:03 charlotte Exp $ */
+/* $NetBSD: dkwedge_tos.c,v 1.2 2024/04/06 09:51:34 hannken Exp $ */
 
 /*
  * Copyright (c) 2024 The NetBSD Foundation, Inc.
@@ -150,7 +150,7 @@ dkwedge_discover_tos(struct disk *pdk, s
 		safe_type[TOS_PART_TYPE_LEN] = '\0';
 
 		/* Finally, make the wedge. */
-		snprintf(dkw.dkw_wname, sizeof(dkw.dkw_wname), "ATARI_%s_%02lu",
+		snprintf(dkw.dkw_wname, sizeof(dkw.dkw_wname), "ATARI_%s_%02zu",
 		safe_type, i);
 		dkw.dkw_offset = be32toh(trs->parts[i].offset);
 		dkw.dkw_size = be32toh(trs->parts[i].size);



CVS commit: src/sys/dev/dkwedge

2024-04-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Apr  6 09:51:34 UTC 2024

Modified Files:
src/sys/dev/dkwedge: dkwedge_tos.c

Log Message:
Use "%zu" for type "size_t".  Kernel ALL/i386 compiles again.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/dkwedge/dkwedge_tos.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

2024-03-31 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Mar 31 14:56:41 UTC 2024

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

Log Message:
Using a ccd(4) with GPT (dk* at ccd*) the disk framework will call
ccdstrategy() -> ccdstart() -> ccdbuffer()  from softint context.
Allocating the buffer with PR_WAITOK here is forbidden.

Change ccdstart() / ccdbuffer() to report failure back to caller and
pass PR_WAITOK / PR_NOWAIT as an additional argument.

Call ccdstart() with PR_NOPWAIT from ccdstrategy() and on error defer
to the kthread.  Call ccdstart() with PR_WAITOK from kthread so requests
from kthread always succeed to allocate the buffers.

Remove the (non working) throttling on low memory as it is no longer needed.

Fixes PR kern/58043 "kernel crash in assert_sleepable() in -current,
dk(4) driver?"


To generate a diff of this commit:
cvs rdiff -u -r1.189 -r1.190 src/sys/dev/ccd.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/ccd.c
diff -u src/sys/dev/ccd.c:1.189 src/sys/dev/ccd.c:1.190
--- src/sys/dev/ccd.c:1.189	Mon Mar 28 12:48:35 2022
+++ src/sys/dev/ccd.c	Sun Mar 31 14:56:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ccd.c,v 1.189 2022/03/28 12:48:35 riastradh Exp $	*/
+/*	$NetBSD: ccd.c,v 1.190 2024/03/31 14:56:41 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -88,7 +88,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.189 2022/03/28 12:48:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.190 2024/03/31 14:56:41 hannken Exp $");
 
 #include 
 #include 
@@ -152,7 +152,7 @@ struct ccdbuf {
 /* component buffer pool */
 static pool_cache_t ccd_cache;
 
-#define	CCD_GETBUF()		pool_cache_get(ccd_cache, PR_WAITOK)
+#define	CCD_GETBUF(wait)	pool_cache_get(ccd_cache, wait)
 #define	CCD_PUTBUF(cbp)		pool_cache_put(ccd_cache, cbp)
 
 #define CCDLABELDEV(dev)	\
@@ -168,11 +168,11 @@ static void	ccdinterleave(struct ccd_sof
 static int	ccdinit(struct ccd_softc *, char **, struct vnode **,
 		struct lwp *);
 static struct ccdbuf *ccdbuffer(struct ccd_softc *, struct buf *,
-		daddr_t, void *, long);
+		daddr_t, void *, long, int);
 static void	ccdgetdefaultlabel(struct ccd_softc *, struct disklabel *);
 static void	ccdgetdisklabel(dev_t);
 static void	ccdmakedisklabel(struct ccd_softc *);
-static void	ccdstart(struct ccd_softc *);
+static int	ccdstart(struct ccd_softc *, struct buf *, int);
 static void	ccdthread(void *);
 
 static dev_type_open(ccdopen);
@@ -702,19 +702,12 @@ ccdclose(dev_t dev, int flags, int fmt, 
 	return (0);
 }
 
-static bool
-ccdbackoff(struct ccd_softc *cs)
-{
-
-	/* XXX Arbitrary, should be a uvm call. */
-	return uvm_availmem(true) < (uvmexp.freemin >> 1) &&
-	disk_isbusy(>sc_dkdev);
-}
-
 static void
 ccdthread(void *cookie)
 {
+	int error;
 	struct ccd_softc *cs;
+	struct buf *bp;
 
 	cs = cookie;
 
@@ -725,21 +718,18 @@ ccdthread(void *cookie)
 
 	mutex_enter(cs->sc_iolock);
 	while (__predict_true(!cs->sc_zap)) {
-		if (bufq_peek(cs->sc_bufq) == NULL) {
+		bp = bufq_get(cs->sc_bufq);
+		if (bp == NULL) {
 			/* Nothing to do. */
 			cv_wait(>sc_push, cs->sc_iolock);
 			continue;
 		}
-		if (ccdbackoff(cs)) {
-			/* Wait for memory to become available. */
-			(void)cv_timedwait(>sc_push, cs->sc_iolock, 1);
-			continue;
-		}
 #ifdef DEBUG
  		if (ccddebug & CCDB_FOLLOW)
  			printf("ccdthread: dispatching I/O\n");
 #endif
-		ccdstart(cs);
+		error = ccdstart(cs, bp, PR_WAITOK);
+		KASSERT(error == 0);
 		mutex_enter(cs->sc_iolock);
 	}
 	cs->sc_thread = NULL;
@@ -777,21 +767,16 @@ ccdstrategy(struct buf *bp)
 		return;
 	}
 
-	/* Defer to thread if system is low on memory. */
-	bufq_put(cs->sc_bufq, bp);
-	if (__predict_false(ccdbackoff(cs))) {
+	if (ccdstart(cs, bp, PR_NOWAIT) != 0) {
+		/* Defer to thread if system is low on memory. */
+		bufq_put(cs->sc_bufq, bp);
+		cv_broadcast(>sc_push);
 		mutex_exit(cs->sc_iolock);
-#ifdef DEBUG
- 		if (ccddebug & CCDB_FOLLOW)
- 			printf("ccdstrategy: holding off on I/O\n");
-#endif
-		return;
 	}
-	ccdstart(cs);
 }
 
-static void
-ccdstart(struct ccd_softc *cs)
+static int
+ccdstart(struct ccd_softc *cs, struct buf *bp, int wait)
 {
 	daddr_t blkno;
 	int wlabel;
@@ -801,11 +786,9 @@ ccdstart(struct ccd_softc *cs)
 	char *addr;
 	daddr_t bn;
 	vnode_t *vp;
-	buf_t *bp;
+	SIMPLEQ_HEAD(, ccdbuf) cbufq;
 
 	KASSERT(mutex_owned(cs->sc_iolock));
-
-	bp = bufq_get(cs->sc_bufq);
 	KASSERT(bp != NULL);
 
 	disk_busy(>sc_dkdev);
@@ -836,15 +819,32 @@ ccdstart(struct ccd_softc *cs)
 	mutex_exit(cs->sc_iolock);
 	bp->b_rawblkno = blkno;
 
-	/* Allocate the component buffers and start I/O! */
+	/* Allocate the component buffers. */
+	SIMPLEQ_INIT();
 	bp->b_resid = bp->b_bcount;
 	bn = bp->b_rawblkno;
 	addr = bp->b_data;
 	for (bcount = bp->b_bcount; bcount > 0; bcount -= rcount) {
-		cbp = ccdbuffer(cs, bp, bn, addr, bcount);
+		cbp = ccdbuffer(cs, 

CVS commit: src/sys/dev

2024-03-31 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Mar 31 14:56:41 UTC 2024

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

Log Message:
Using a ccd(4) with GPT (dk* at ccd*) the disk framework will call
ccdstrategy() -> ccdstart() -> ccdbuffer()  from softint context.
Allocating the buffer with PR_WAITOK here is forbidden.

Change ccdstart() / ccdbuffer() to report failure back to caller and
pass PR_WAITOK / PR_NOWAIT as an additional argument.

Call ccdstart() with PR_NOPWAIT from ccdstrategy() and on error defer
to the kthread.  Call ccdstart() with PR_WAITOK from kthread so requests
from kthread always succeed to allocate the buffers.

Remove the (non working) throttling on low memory as it is no longer needed.

Fixes PR kern/58043 "kernel crash in assert_sleepable() in -current,
dk(4) driver?"


To generate a diff of this commit:
cvs rdiff -u -r1.189 -r1.190 src/sys/dev/ccd.c

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



CVS commit: src/sys/fs/cd9660

2024-02-03 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Feb  3 15:26:35 UTC 2024

Modified Files:
src/sys/fs/cd9660: cd9660_vfsops.c

Log Message:
cd9660_mountroot: must initialize new args "fmask" and "dmask".


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/fs/cd9660/cd9660_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/fs/cd9660/cd9660_vfsops.c
diff -u src/sys/fs/cd9660/cd9660_vfsops.c:1.98 src/sys/fs/cd9660/cd9660_vfsops.c:1.99
--- src/sys/fs/cd9660/cd9660_vfsops.c:1.98	Fri Feb  2 20:27:26 2024
+++ src/sys/fs/cd9660/cd9660_vfsops.c	Sat Feb  3 15:26:35 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660_vfsops.c,v 1.98 2024/02/02 20:27:26 christos Exp $	*/
+/*	$NetBSD: cd9660_vfsops.c,v 1.99 2024/02/03 15:26:35 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1994
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.98 2024/02/02 20:27:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.99 2024/02/03 15:26:35 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -192,6 +192,8 @@ cd9660_mountroot(void)
 	}
 
 	args.flags = ISOFSMNT_ROOT;
+	args.fmask = S_IRWXU|S_IRWXG|S_IRWXO;
+	args.dmask = S_IRWXU|S_IRWXG|S_IRWXO;
 	if ((error = iso_mountfs(rootvp, mp, l, )) != 0) {
 		vfs_unbusy(mp);
 		vfs_rele(mp);



CVS commit: src/sys/fs/cd9660

2024-02-03 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Feb  3 15:26:35 UTC 2024

Modified Files:
src/sys/fs/cd9660: cd9660_vfsops.c

Log Message:
cd9660_mountroot: must initialize new args "fmask" and "dmask".


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/fs/cd9660/cd9660_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/miscfs/procfs

2024-01-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jan 17 10:21:01 UTC 2024

Modified Files:
src/sys/miscfs/procfs: procfs_vfsops.c

Log Message:
Remove all procfs nodes for this process on process exit.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/miscfs/procfs/procfs_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/miscfs/procfs/procfs_vfsops.c
diff -u src/sys/miscfs/procfs/procfs_vfsops.c:1.113 src/sys/miscfs/procfs/procfs_vfsops.c:1.114
--- src/sys/miscfs/procfs/procfs_vfsops.c:1.113	Wed Jan 17 10:20:12 2024
+++ src/sys/miscfs/procfs/procfs_vfsops.c	Wed Jan 17 10:21:01 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vfsops.c,v 1.113 2024/01/17 10:20:12 hannken Exp $	*/
+/*	$NetBSD: procfs_vfsops.c,v 1.114 2024/01/17 10:21:01 hannken Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.113 2024/01/17 10:20:12 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.114 2024/01/17 10:21:01 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -112,9 +112,12 @@ MODULE(MODULE_CLASS_VFS, procfs, "ptrace
 VFS_PROTOS(procfs);
 
 #define PROCFS_HASHSIZE	256
+#define PROCFS_EXEC_HOOK ((void *)1)
+#define PROCFS_EXIT_HOOK ((void *)2)
 
 static kauth_listener_t procfs_listener;
 static void *procfs_exechook;
+static void *procfs_exithook;
 LIST_HEAD(hashhead, pfsnode);
 static u_long procfs_hashmask;
 static struct hashhead *procfs_hashtab;
@@ -522,7 +525,7 @@ procfs_exechook_cb(struct proc *p, void 
 	struct vnode *vp;
 	int error;
 
-	if (!(p->p_flag & PK_SUGID))
+	if (arg == PROCFS_EXEC_HOOK && !(p->p_flag & PK_SUGID))
 		return;
 
 	head = procfs_hashhead(p->p_pid);
@@ -616,7 +619,10 @@ procfs_modcmd(modcmd_t cmd, void *arg)
 		procfs_listener = kauth_listen_scope(KAUTH_SCOPE_PROCESS,
 		procfs_listener_cb, NULL);
 
-		procfs_exechook = exechook_establish(procfs_exechook_cb, NULL);
+		procfs_exechook = exechook_establish(procfs_exechook_cb,
+		PROCFS_EXEC_HOOK);
+		procfs_exithook = exithook_establish(procfs_exechook_cb,
+		PROCFS_EXIT_HOOK);
 
 		mutex_init(_hashlock, MUTEX_DEFAULT, IPL_NONE);
 		procfs_hashtab = hashinit(PROCFS_HASHSIZE, HASH_LIST, true,
@@ -629,6 +635,7 @@ procfs_modcmd(modcmd_t cmd, void *arg)
 			break;
 		kauth_unlisten_scope(procfs_listener);
 		exechook_disestablish(procfs_exechook);
+		exithook_disestablish(procfs_exithook);
 		mutex_destroy(_hashlock);
 		hashdone(procfs_hashtab, HASH_LIST, procfs_hashmask);
 		break;



CVS commit: src/sys/miscfs/procfs

2024-01-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jan 17 10:21:01 UTC 2024

Modified Files:
src/sys/miscfs/procfs: procfs_vfsops.c

Log Message:
Remove all procfs nodes for this process on process exit.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/miscfs/procfs/procfs_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/miscfs/procfs

2024-01-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jan 17 10:20:12 UTC 2024

Modified Files:
src/sys/miscfs/procfs: procfs.h procfs_subr.c procfs_vfsops.c

Log Message:
Using the exechook to revoke procfs nodes is racy and may deadlock:

one thread runs doexechooks() -> procfs_revoke_vnodes() and wants to suspend
the file system for vgone(), while another thread runs a forced unmount,
has the file system suspended, tries to disestablish the exechook and
waits for doexechooks() to complete.

Establish/disestablish the exechook on module load/unload instead
mount/unmount and use the hashmap to access all procfs nodes for this pid.

May fix PR kern/57775 ""panic: unmount: dangling vnode" while umounting procfs"


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/miscfs/procfs/procfs.h
cvs rdiff -u -r1.116 -r1.117 src/sys/miscfs/procfs/procfs_subr.c
cvs rdiff -u -r1.112 -r1.113 src/sys/miscfs/procfs/procfs_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/miscfs/procfs/procfs.h
diff -u src/sys/miscfs/procfs/procfs.h:1.83 src/sys/miscfs/procfs/procfs.h:1.84
--- src/sys/miscfs/procfs/procfs.h:1.83	Wed Jan 17 10:19:21 2024
+++ src/sys/miscfs/procfs/procfs.h	Wed Jan 17 10:20:12 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs.h,v 1.83 2024/01/17 10:19:21 hannken Exp $	*/
+/*	$NetBSD: procfs.h,v 1.84 2024/01/17 10:20:12 hannken Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -192,7 +192,6 @@ procfs_fileno(pid_t _pid, pfstype _type,
 #define PROCFS_TYPE(type)	((type) % PFSlast)
 
 struct procfsmount {
-	void *pmnt_exechook;
 	int pmnt_flags;
 };
 
@@ -272,7 +271,6 @@ int procfs_dolimit(struct lwp *, struct 
 struct uio *);
 
 void procfs_hashrem(struct pfsnode *);
-void procfs_revoke_vnodes(struct proc *, void *);
 int procfs_getfp(struct pfsnode *, struct proc *, struct file **);
 
 /* functions to check whether or not files should be displayed */

Index: src/sys/miscfs/procfs/procfs_subr.c
diff -u src/sys/miscfs/procfs/procfs_subr.c:1.116 src/sys/miscfs/procfs/procfs_subr.c:1.117
--- src/sys/miscfs/procfs/procfs_subr.c:1.116	Sat May 23 23:42:43 2020
+++ src/sys/miscfs/procfs/procfs_subr.c	Wed Jan 17 10:20:12 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_subr.c,v 1.116 2020/05/23 23:42:43 ad Exp $	*/
+/*	$NetBSD: procfs_subr.c,v 1.117 2024/01/17 10:20:12 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -102,7 +102,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.116 2020/05/23 23:42:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.117 2024/01/17 10:20:12 hannken Exp $");
 
 #include 
 #include 
@@ -358,57 +358,6 @@ vfs_findname(const vfs_namemap_t *nm, co
 	return (0);
 }
 
-static bool
-procfs_revoke_selector(void *arg, struct vnode *vp)
-{
-	struct proc *p = arg;
-	struct pfsnode *pfs;
-
-	KASSERT(mutex_owned(vp->v_interlock));
-
-	pfs = VTOPFS(vp);
-
-	return (pfs != NULL && pfs->pfs_pid == p->p_pid);
-}
-
-void
-procfs_revoke_vnodes(struct proc *p, void *arg)
-{
-	int error;
-	bool suspended;
-	struct vnode *vp;
-	struct vnode_iterator *marker;
-	struct mount *mp = (struct mount *)arg;
-
-	if (!(p->p_flag & PK_SUGID))
-		return;
-
-	suspended = false;
-	vfs_vnode_iterator_init(mp, );
-
-	while ((vp = vfs_vnode_iterator_next(marker,
-	procfs_revoke_selector, p)) != NULL) {
-		if (vrecycle(vp))
-			continue;
-		/* Vnode is busy, we have to suspend the mount for vgone(). */
-		while (! suspended) {
-			error = vfs_suspend(mp, 0);
-			if (error == 0) {
-suspended = true;
-			} else if (error != EINTR && error != ERESTART) {
-KASSERT(error == EOPNOTSUPP);
-break;
-			}
-		}
-		vgone(vp);
-	}
-
-	if (suspended)
-		vfs_resume(mp);
-
-	vfs_vnode_iterator_destroy(marker);
-}
-
 bool
 procfs_use_linux_compat(struct mount *mp)
 {

Index: src/sys/miscfs/procfs/procfs_vfsops.c
diff -u src/sys/miscfs/procfs/procfs_vfsops.c:1.112 src/sys/miscfs/procfs/procfs_vfsops.c:1.113
--- src/sys/miscfs/procfs/procfs_vfsops.c:1.112	Wed Jan 17 10:19:21 2024
+++ src/sys/miscfs/procfs/procfs_vfsops.c	Wed Jan 17 10:20:12 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vfsops.c,v 1.112 2024/01/17 10:19:21 hannken Exp $	*/
+/*	$NetBSD: procfs_vfsops.c,v 1.113 2024/01/17 10:20:12 hannken Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.112 2024/01/17 10:19:21 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.113 2024/01/17 10:20:12 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -88,6 +88,7 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_vfsop
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -113,6 +114,7 @@ VFS_PROTOS(procfs);
 #define PROCFS_HASHSIZE	256
 
 static kauth_listener_t procfs_listener;
+static void *procfs_exechook;
 LIST_HEAD(hashhead, pfsnode);
 static u_long procfs_hashmask;
 

CVS commit: src/sys/miscfs/procfs

2024-01-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jan 17 10:20:12 UTC 2024

Modified Files:
src/sys/miscfs/procfs: procfs.h procfs_subr.c procfs_vfsops.c

Log Message:
Using the exechook to revoke procfs nodes is racy and may deadlock:

one thread runs doexechooks() -> procfs_revoke_vnodes() and wants to suspend
the file system for vgone(), while another thread runs a forced unmount,
has the file system suspended, tries to disestablish the exechook and
waits for doexechooks() to complete.

Establish/disestablish the exechook on module load/unload instead
mount/unmount and use the hashmap to access all procfs nodes for this pid.

May fix PR kern/57775 ""panic: unmount: dangling vnode" while umounting procfs"


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/miscfs/procfs/procfs.h
cvs rdiff -u -r1.116 -r1.117 src/sys/miscfs/procfs/procfs_subr.c
cvs rdiff -u -r1.112 -r1.113 src/sys/miscfs/procfs/procfs_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/miscfs/procfs

2024-01-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jan 17 10:19:21 UTC 2024

Modified Files:
src/sys/miscfs/procfs: procfs.h procfs_vfsops.c procfs_vnops.c

Log Message:
Add a hashmap to access all procfs nodes by pid.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/miscfs/procfs/procfs.h
cvs rdiff -u -r1.111 -r1.112 src/sys/miscfs/procfs/procfs_vfsops.c
cvs rdiff -u -r1.229 -r1.230 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/miscfs/procfs/procfs.h
diff -u src/sys/miscfs/procfs/procfs.h:1.82 src/sys/miscfs/procfs/procfs.h:1.83
--- src/sys/miscfs/procfs/procfs.h:1.82	Wed Jan 19 10:23:00 2022
+++ src/sys/miscfs/procfs/procfs.h	Wed Jan 17 10:19:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs.h,v 1.82 2022/01/19 10:23:00 martin Exp $	*/
+/*	$NetBSD: procfs.h,v 1.83 2024/01/17 10:19:21 hannken Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -129,7 +129,9 @@ struct pfskey {
 	int		pk_fd;		/* associated fd if not -1 */
 };
 struct pfsnode {
+	LIST_ENTRY(pfsnode) pfs_hash;	/* per pid hash list */
 	struct vnode	*pfs_vnode;	/* vnode associated with this pfsnode */
+	struct mount	*pfs_mount;	/* mount associated with this pfsnode */
 	struct pfskey	pfs_key;
 #define pfs_type pfs_key.pk_type
 #define pfs_pid pfs_key.pk_pid
@@ -269,6 +271,7 @@ int procfs_doauxv(struct lwp *, struct p
 int procfs_dolimit(struct lwp *, struct proc *, struct pfsnode *,
 struct uio *);
 
+void procfs_hashrem(struct pfsnode *);
 void procfs_revoke_vnodes(struct proc *, void *);
 int procfs_getfp(struct pfsnode *, struct proc *, struct file **);
 

Index: src/sys/miscfs/procfs/procfs_vfsops.c
diff -u src/sys/miscfs/procfs/procfs_vfsops.c:1.111 src/sys/miscfs/procfs/procfs_vfsops.c:1.112
--- src/sys/miscfs/procfs/procfs_vfsops.c:1.111	Mon Jan 17 11:20:00 2022
+++ src/sys/miscfs/procfs/procfs_vfsops.c	Wed Jan 17 10:19:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vfsops.c,v 1.111 2022/01/17 11:20:00 bouyer Exp $	*/
+/*	$NetBSD: procfs_vfsops.c,v 1.112 2024/01/17 10:19:21 hannken Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.111 2022/01/17 11:20:00 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.112 2024/01/17 10:19:21 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -110,7 +110,29 @@ MODULE(MODULE_CLASS_VFS, procfs, "ptrace
 
 VFS_PROTOS(procfs);
 
+#define PROCFS_HASHSIZE	256
+
 static kauth_listener_t procfs_listener;
+LIST_HEAD(hashhead, pfsnode);
+static u_long procfs_hashmask;
+static struct hashhead *procfs_hashtab;
+static kmutex_t procfs_hashlock;
+
+static struct hashhead *
+procfs_hashhead(pid_t pid)
+{
+
+	return _hashtab[pid & procfs_hashmask];
+}
+
+void
+procfs_hashrem(struct pfsnode *pfs)
+{
+
+	mutex_enter(_hashlock);
+	LIST_REMOVE(pfs, pfs_hash);
+	mutex_exit(_hashlock);
+}
 
 /*
  * VFS Operations.
@@ -279,6 +301,7 @@ procfs_loadvnode(struct mount *mp, struc
 	pfs->pfs_type = pfskey.pk_type;
 	pfs->pfs_fd = pfskey.pk_fd;
 	pfs->pfs_vnode = vp;
+	pfs->pfs_mount = mp;
 	pfs->pfs_flags = 0;
 	pfs->pfs_fileno =
 	PROCFS_FILENO(pfs->pfs_pid, pfs->pfs_type, pfs->pfs_fd);
@@ -421,6 +444,10 @@ procfs_loadvnode(struct mount *mp, struc
 		panic("procfs_allocvp");
 	}
 
+	mutex_enter(_hashlock);
+	LIST_INSERT_HEAD(procfs_hashhead(pfs->pfs_pid), pfs, pfs_hash);
+	mutex_exit(_hashlock);
+
 	uvm_vnp_setsize(vp, 0);
 	*new_key = >pfs_key;
 

Index: src/sys/miscfs/procfs/procfs_vnops.c
diff -u src/sys/miscfs/procfs/procfs_vnops.c:1.229 src/sys/miscfs/procfs/procfs_vnops.c:1.230
--- src/sys/miscfs/procfs/procfs_vnops.c:1.229	Fri Jun 17 14:30:37 2022
+++ src/sys/miscfs/procfs/procfs_vnops.c	Wed Jan 17 10:19:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_vnops.c,v 1.229 2022/06/17 14:30:37 shm Exp $	*/
+/*	$NetBSD: procfs_vnops.c,v 1.230 2024/01/17 10:19:21 hannken 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.229 2022/06/17 14:30:37 shm Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.230 2024/01/17 10:19:21 hannken Exp $");
 
 #include 
 #include 
@@ -437,6 +437,7 @@ procfs_reclaim(void *v)
 	mutex_enter(vp->v_interlock);
 	vp->v_data = NULL;
 	mutex_exit(vp->v_interlock);
+	procfs_hashrem(pfs);
 	kmem_free(pfs, sizeof(*pfs));
 	return 0;
 }



CVS commit: src/sys/miscfs/procfs

2024-01-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jan 17 10:19:21 UTC 2024

Modified Files:
src/sys/miscfs/procfs: procfs.h procfs_vfsops.c procfs_vnops.c

Log Message:
Add a hashmap to access all procfs nodes by pid.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/miscfs/procfs/procfs.h
cvs rdiff -u -r1.111 -r1.112 src/sys/miscfs/procfs/procfs_vfsops.c
cvs rdiff -u -r1.229 -r1.230 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/sys/kern

2024-01-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jan 17 10:18:41 UTC 2024

Modified Files:
src/sys/kern: init_main.c kern_hook.c

Log Message:
Protect kernel hooks exechook, exithook and forkhook with rwlock.
Lock as writer on establish/disestablish and as reader on list traverse.

For exechook ride "exec_lock" as it is already take as reader when
traversing the list.  Add local locks for exithook and forkhook.

Move exec_init before signal_init as signal_init calls exechook_establish()
that needs "exec_lock".

PR kern/39913 "exec, fork, exit hooks need locking"


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

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

Modified files:

Index: src/sys/kern/init_main.c
diff -u src/sys/kern/init_main.c:1.546 src/sys/kern/init_main.c:1.547
--- src/sys/kern/init_main.c:1.546	Sat Sep 23 18:21:11 2023
+++ src/sys/kern/init_main.c	Wed Jan 17 10:18:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: init_main.c,v 1.546 2023/09/23 18:21:11 ad Exp $	*/
+/*	$NetBSD: init_main.c,v 1.547 2024/01/17 10:18:41 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009, 2019, 2023 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.546 2023/09/23 18:21:11 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.547 2024/01/17 10:18:41 hannken Exp $");
 
 #include "opt_cnmagic.h"
 #include "opt_ddb.h"
@@ -407,6 +407,9 @@ main(void)
 	/* Must be called after lwpinit (lwpinit_specificdata) */
 	psref_init();
 
+	/* Initialize exec structures */
+	exec_init(1);		/* signal_init calls exechook_establish() */
+
 	/* Initialize signal-related data structures. */
 	signal_init();
 
@@ -579,9 +582,6 @@ main(void)
 
 	vmem_rehash_start();	/* must be before exec_init */
 
-	/* Initialize exec structures */
-	exec_init(1);		/* seminit calls exithook_establish() */
-
 #if NVERIEXEC > 0
 	/*
 	 * Initialise the Veriexec subsystem.

Index: src/sys/kern/kern_hook.c
diff -u src/sys/kern/kern_hook.c:1.14 src/sys/kern/kern_hook.c:1.15
--- src/sys/kern/kern_hook.c:1.14	Wed Oct 26 23:21:06 2022
+++ src/sys/kern/kern_hook.c	Wed Jan 17 10:18:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_hook.c,v 1.14 2022/10/26 23:21:06 riastradh Exp $	*/
+/*	$NetBSD: kern_hook.c,v 1.15 2024/01/17 10:18:41 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_hook.c,v 1.14 2022/10/26 23:21:06 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_hook.c,v 1.15 2024/01/17 10:18:41 hannken Exp $");
 
 #include 
 
@@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_hook.c,
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -74,25 +75,48 @@ struct khook_list {
 
 int	powerhook_debug = 0;
 
+static ONCE_DECL(hook_control);
+static krwlock_t exithook_lock;
+static krwlock_t forkhook_lock;
+
+static int
+hook_init(void)
+{
+
+	rw_init(_lock);
+	rw_init(_lock);
+
+	return 0;
+}
+
 static void *
-hook_establish(hook_list_t *list, void (*fn)(void *), void *arg)
+hook_establish(hook_list_t *list, krwlock_t *lock,
+void (*fn)(void *), void *arg)
 {
 	struct hook_desc *hd;
 
-	hd = malloc(sizeof(*hd), M_DEVBUF, M_NOWAIT);
-	if (hd == NULL)
-		return (NULL);
+	RUN_ONCE(_control, hook_init);
 
-	hd->hk_fn = fn;
-	hd->hk_arg = arg;
-	LIST_INSERT_HEAD(list, hd, hk_list);
+	hd = malloc(sizeof(*hd), M_DEVBUF, M_NOWAIT);
+	if (hd != NULL) {
+		if (lock)
+			rw_enter(lock, RW_WRITER);
+		hd->hk_fn = fn;
+		hd->hk_arg = arg;
+		LIST_INSERT_HEAD(list, hd, hk_list);
+		if (lock)
+			rw_exit(lock);
+	}
 
 	return (hd);
 }
 
 static void
-hook_disestablish(hook_list_t *list, void *vhook)
+hook_disestablish(hook_list_t *list, krwlock_t *lock, void *vhook)
 {
+
+	if (lock)
+		rw_enter(lock, RW_WRITER);
 #ifdef DIAGNOSTIC
 	struct hook_desc *hd;
 
@@ -106,6 +130,8 @@ hook_disestablish(hook_list_t *list, voi
 #endif
 	LIST_REMOVE((struct hook_desc *)vhook, hk_list);
 	free(vhook, M_DEVBUF);
+	if (lock)
+		rw_exit(lock);
 }
 
 static void
@@ -120,14 +146,20 @@ hook_destroy(hook_list_t *list)
 }
 
 static void
-hook_proc_run(hook_list_t *list, struct proc *p)
+hook_proc_run(hook_list_t *list, krwlock_t *lock, struct proc *p)
 {
 	struct hook_desc *hd;
 
+	RUN_ONCE(_control, hook_init);
+
+	if (lock)
+		rw_enter(lock, RW_READER);
 	LIST_FOREACH(hd, list, hk_list) {
 		__FPTRCAST(void (*)(struct proc *, void *), *hd->hk_fn)(p,
 		hd->hk_arg);
 	}
+	if (lock)
+		rw_exit(lock);
 }
 
 /*
@@ -146,13 +178,13 @@ static hook_list_t shutdownhook_list = L
 void *
 shutdownhook_establish(void (*fn)(void *), void *arg)
 {
-	return hook_establish(_list, fn, arg);
+	return hook_establish(_list, NULL, fn, arg);
 }
 
 void
 shutdownhook_disestablish(void *vhook)
 {
-	hook_disestablish(_list, vhook);
+	

CVS commit: src/sys/kern

2024-01-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jan 17 10:18:41 UTC 2024

Modified Files:
src/sys/kern: init_main.c kern_hook.c

Log Message:
Protect kernel hooks exechook, exithook and forkhook with rwlock.
Lock as writer on establish/disestablish and as reader on list traverse.

For exechook ride "exec_lock" as it is already take as reader when
traversing the list.  Add local locks for exithook and forkhook.

Move exec_init before signal_init as signal_init calls exechook_establish()
that needs "exec_lock".

PR kern/39913 "exec, fork, exit hooks need locking"


To generate a diff of this commit:
cvs rdiff -u -r1.546 -r1.547 src/sys/kern/init_main.c
cvs rdiff -u -r1.14 -r1.15 src/sys/kern/kern_hook.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

2024-01-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jan 17 10:17:29 UTC 2024

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

Log Message:
Print dangling vnode before panic() to help debug.

PR kern/57775 ""panic: unmount: dangling vnode" while umounting procfs"


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/kern/vfs_mount.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_mount.c
diff -u src/sys/kern/vfs_mount.c:1.103 src/sys/kern/vfs_mount.c:1.104
--- src/sys/kern/vfs_mount.c:1.103	Thu Dec 28 12:48:08 2023
+++ src/sys/kern/vfs_mount.c	Wed Jan 17 10:17:29 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.103 2023/12/28 12:48:08 hannken Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.104 2024/01/17 10:17:29 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.103 2023/12/28 12:48:08 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.104 2024/01/17 10:17:29 hannken Exp $");
 
 #include "veriexec.h"
 
@@ -936,7 +936,7 @@ err_mounted:
 int
 dounmount(struct mount *mp, int flags, struct lwp *l)
 {
-	vnode_t *coveredvp;
+	vnode_t *coveredvp, *vp;
 	int error, async, used_syncer, used_extattr;
 	const bool was_suspended = fstrans_is_owner(mp);
 
@@ -1003,8 +1003,10 @@ dounmount(struct mount *mp, int flags, s
 		vfs_resume(mp);
 
 	mountlist_remove(mp);
-	if (TAILQ_FIRST(>mnt_vnodelist) != NULL)
+	if ((vp = VIMPL_TO_VNODE(TAILQ_FIRST(>mnt_vnodelist))) != NULL) {
+		vprint("dangling", vp);
 		panic("unmount: dangling vnode");
+	}
 	vfs_hooks_unmount(mp);
 
 	vfs_set_lowermount(mp, NULL);



CVS commit: src/sys/kern

2024-01-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jan 17 10:17:29 UTC 2024

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

Log Message:
Print dangling vnode before panic() to help debug.

PR kern/57775 ""panic: unmount: dangling vnode" while umounting procfs"


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/kern/vfs_mount.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

2023-12-28 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Dec 28 12:49:06 UTC 2023

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

Log Message:
Initialize mutex fileassoc_global.lock.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/kern/kern_fileassoc.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

2023-12-28 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Dec 28 12:49:06 UTC 2023

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

Log Message:
Initialize mutex fileassoc_global.lock.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/kern/kern_fileassoc.c

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

Modified files:

Index: src/sys/kern/kern_fileassoc.c
diff -u src/sys/kern/kern_fileassoc.c:1.37 src/sys/kern/kern_fileassoc.c:1.38
--- src/sys/kern/kern_fileassoc.c:1.37	Wed Aug  2 07:11:31 2023
+++ src/sys/kern/kern_fileassoc.c	Thu Dec 28 12:49:06 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_fileassoc.c,v 1.37 2023/08/02 07:11:31 riastradh Exp $ */
+/* $NetBSD: kern_fileassoc.c,v 1.38 2023/12/28 12:49:06 hannken Exp $ */
 
 /*-
  * Copyright (c) 2006 Elad Efrat 
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_fileassoc.c,v 1.37 2023/08/02 07:11:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_fileassoc.c,v 1.38 2023/12/28 12:49:06 hannken Exp $");
 
 #include "opt_fileassoc.h"
 
@@ -219,6 +219,8 @@ fileassoc_init(void)
 	}
 	fileassoc_domain = specificdata_domain_create();
 
+	mutex_init(_global.lock, MUTEX_DEFAULT, IPL_NONE);
+
 	return 0;
 }
 



CVS commit: src/sys/kern

2023-12-28 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Dec 28 12:48:09 UTC 2023

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

Log Message:
Include "veriexec.h" and  to run
veriexec_unmountchk() on "NVERIEXEC > 0".


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/kern/vfs_mount.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_mount.c
diff -u src/sys/kern/vfs_mount.c:1.102 src/sys/kern/vfs_mount.c:1.103
--- src/sys/kern/vfs_mount.c:1.102	Fri Feb 24 11:02:27 2023
+++ src/sys/kern/vfs_mount.c	Thu Dec 28 12:48:08 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.102 2023/02/24 11:02:27 riastradh Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.103 2023/12/28 12:48:08 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,9 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.102 2023/02/24 11:02:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.103 2023/12/28 12:48:08 hannken Exp $");
+
+#include "veriexec.h"
 
 #include 
 #include 
@@ -85,6 +87,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 



CVS commit: src/sys/kern

2023-12-28 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Dec 28 12:48:09 UTC 2023

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

Log Message:
Include "veriexec.h" and  to run
veriexec_unmountchk() on "NVERIEXEC > 0".


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/kern/vfs_mount.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

2023-11-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Nov 27 16:13:59 UTC 2023

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

Log Message:
Restore kpause() accidentially removed with last commit.


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 src/sys/kern/vfs_vnode.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

2023-11-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Nov 27 16:13:59 UTC 2023

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

Log Message:
Restore kpause() accidentially removed with last commit.


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 src/sys/kern/vfs_vnode.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_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.152 src/sys/kern/vfs_vnode.c:1.153
--- src/sys/kern/vfs_vnode.c:1.152	Mon Nov 27 10:03:40 2023
+++ src/sys/kern/vfs_vnode.c	Mon Nov 27 16:13:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.152 2023/11/27 10:03:40 hannken Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.153 2023/11/27 16:13:59 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011, 2019, 2020 The NetBSD Foundation, Inc.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.152 2023/11/27 10:03:40 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.153 2023/11/27 16:13:59 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pax.h"
@@ -709,7 +709,7 @@ vdrain_task(struct threadpool_job *job)
 	mutex_enter(_lock);
 
 	while (!vdrain_one(target))
-		;
+		kpause("vdrain", false, 1, _lock);
 
 	threadpool_job_done(job);
 	mutex_exit(_lock);



CVS commit: src/sys/kern

2023-11-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Nov 27 10:03:40 UTC 2023

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

Log Message:
Implement and use an iterator over LRU lists.

Replace the vdrain kernel thread with two threadpool jobs,
one to process deferred vrele and
one to keep the number of allocated vnodes below limit.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/sys/kern/vfs_vnode.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_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.151 src/sys/kern/vfs_vnode.c:1.152
--- src/sys/kern/vfs_vnode.c:1.151	Wed Nov 22 13:19:50 2023
+++ src/sys/kern/vfs_vnode.c	Mon Nov 27 10:03:40 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.151 2023/11/22 13:19:50 riastradh Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.152 2023/11/27 10:03:40 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011, 2019, 2020 The NetBSD Foundation, Inc.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.151 2023/11/22 13:19:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.152 2023/11/27 10:03:40 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pax.h"
@@ -164,7 +164,6 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -172,6 +171,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -198,14 +198,17 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,
  * private cache line as vnodes migrate between them while under the same
  * lock (vdrain_lock).
  */
+
+typedef struct {
+	vnode_impl_t *li_marker;
+} lru_iter_t;
+
 u_int			numvnodes		__cacheline_aligned;
 static vnodelst_t	lru_list[LRU_COUNT]	__cacheline_aligned;
+static struct threadpool *threadpool;
+static struct threadpool_job vdrain_job;
+static struct threadpool_job vrele_job;
 static kmutex_t		vdrain_lock		__cacheline_aligned;
-static kcondvar_t	vdrain_cv;
-static int		vdrain_gen;
-static kcondvar_t	vdrain_gen_cv;
-static bool		vdrain_retry;
-static lwp_t *		vdrain_lwp;
 SLIST_HEAD(hashhead, vnode_impl);
 static kmutex_t		vcache_lock		__cacheline_aligned;
 static kcondvar_t	vcache_cv;
@@ -215,16 +218,22 @@ static struct hashhead	*vcache_hashtab;
 static pool_cache_t	vcache_pool;
 static void		lru_requeue(vnode_t *, vnodelst_t *);
 static vnodelst_t *	lru_which(vnode_t *);
+static vnode_impl_t *	lru_iter_first(int, lru_iter_t *);
+static vnode_impl_t *	lru_iter_next(lru_iter_t *);
+static void		lru_iter_release(lru_iter_t *);
 static vnode_impl_t *	vcache_alloc(void);
 static void		vcache_dealloc(vnode_impl_t *);
 static void		vcache_free(vnode_impl_t *);
 static void		vcache_init(void);
 static void		vcache_reinit(void);
 static void		vcache_reclaim(vnode_t *);
+static void		vrele_deferred(vnode_impl_t *);
 static void		vrelel(vnode_t *, int, int);
-static void		vdrain_thread(void *);
 static void		vnpanic(vnode_t *, const char *, ...)
 __printflike(2, 3);
+static bool		vdrain_one(u_int);
+static void		vdrain_task(struct threadpool_job *);
+static void		vrele_task(struct threadpool_job *);
 
 /* Routines having to do with the management of the vnode table. */
 
@@ -424,11 +433,10 @@ vfs_vnode_sysinit(void)
 	}
 	vcache_init();
 
-	cv_init(_cv, "vdrain");
-	cv_init(_gen_cv, "vdrainwt");
-	error = kthread_create(PRI_VM, KTHREAD_MPSAFE, NULL, vdrain_thread,
-	NULL, _lwp, "vdrain");
-	KASSERTMSG((error == 0), "kthread_create(vdrain) failed: %d", error);
+	error = threadpool_get(, PRI_NONE);
+	KASSERTMSG((error == 0), "threadpool_get failed: %d", error);
+	threadpool_job_init(_job, vdrain_task, _lock, "vdrain");
+	threadpool_job_init(_job, vrele_task, _lock, "vrele");
 }
 
 /*
@@ -536,189 +544,208 @@ lru_requeue(vnode_t *vp, vnodelst_t *lis
 		 */
 		numvnodes += d;
 	}
-	if ((d > 0 && numvnodes > desiredvnodes) ||
-	listhd == _list[LRU_VRELE])
-		cv_signal(_cv);
+	if (listhd == _list[LRU_VRELE])
+		threadpool_schedule_job(threadpool, _job);
+	if (d > 0 && numvnodes > desiredvnodes)
+		threadpool_schedule_job(threadpool, _job);
 	if (d > 0 && numvnodes > desiredvnodes + desiredvnodes / 16)
 		kpause("vnfull", false, MAX(1, mstohz(10)), _lock);
 	mutex_exit(_lock);
 }
 
 /*
- * Release deferred vrele vnodes for this mount.
- * Called with file system suspended.
+ * LRU list iterator.
+ * Caller holds vdrain_lock.
  */
-void
-vrele_flush(struct mount *mp)
+static vnode_impl_t *
+lru_iter_first(int idx, lru_iter_t *iterp)
 {
-	vnode_impl_t *vip, *marker;
-	vnode_t *vp;
-	int when = 0;
+	vnode_impl_t *marker;
 
-	KASSERT(fstrans_is_owner(mp));
+	KASSERT(mutex_owned(_lock));
 
+	mutex_exit(_lock);
 	marker = VNODE_TO_VIMPL(vnalloc_marker(NULL));
-
 	mutex_enter(_lock);
-	TAILQ_INSERT_HEAD(_list[LRU_VRELE], marker, vi_lrulist);
+	marker->vi_lrulisthd = _list[idx];
+	iterp->li_marker = marker;
 
-	while ((vip 

CVS commit: src/sys/kern

2023-11-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Nov 27 10:03:40 UTC 2023

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

Log Message:
Implement and use an iterator over LRU lists.

Replace the vdrain kernel thread with two threadpool jobs,
one to process deferred vrele and
one to keep the number of allocated vnodes below limit.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/sys/kern/vfs_vnode.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

2023-11-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Nov  6 12:18:59 UTC 2023

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

Log Message:
Print the inode numbers of persistent snapshots.

PR kern/57675 "persistent file system snapshots aren't obvious"


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 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.c
diff -u src/usr.sbin/dumpfs/dumpfs.c:1.68 src/usr.sbin/dumpfs/dumpfs.c:1.69
--- src/usr.sbin/dumpfs/dumpfs.c:1.68	Sat Jan  7 19:41:30 2023
+++ src/usr.sbin/dumpfs/dumpfs.c	Mon Nov  6 12:18:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: dumpfs.c,v 1.68 2023/01/07 19:41:30 chs Exp $	*/
+/*	$NetBSD: dumpfs.c,v 1.69 2023/11/06 12:18:59 hannken 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.68 2023/01/07 19:41:30 chs Exp $");
+__RCSID("$NetBSD: dumpfs.c,v 1.69 2023/11/06 12:18:59 hannken Exp $");
 #endif
 #endif /* not lint */
 
@@ -410,6 +410,11 @@ print_superblock(struct fs *fs, uint16_t
 	fs->fs_journallocs[0], fs->fs_journallocs[1]);
 	printf("\tloc2 %" PRIu64 "\tloc3 %" PRIu64 "\n",
 	fs->fs_journallocs[2], fs->fs_journallocs[3]);
+	printf("snapshot inodes");
+	for (int s = 0; s < FSMAXSNAP; s++) {
+		printf(" %u", fs->fs_snapinum[s]);
+	}
+	printf("\n");
 	printf("usrquota %" PRIu64 "\tgrpquota %" PRIu64 "\n",
 		fs->fs_quotafile[USRQUOTA], fs->fs_quotafile[GRPQUOTA]);
 	printf("flags\t");



CVS commit: src/usr.sbin/dumpfs

2023-11-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Nov  6 12:18:59 UTC 2023

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

Log Message:
Print the inode numbers of persistent snapshots.

PR kern/57675 "persistent file system snapshots aren't obvious"


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 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/sys/kern

2023-11-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Nov  6 12:17:50 UTC 2023

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

Log Message:
As the number of allocated vnodes goes beyond 106% of desiredvnodes
start throttling threads allocating new vnodes at a rate of ~100 new
vnodes per second and thread.


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/sys/kern/vfs_vnode.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_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.149 src/sys/kern/vfs_vnode.c:1.150
--- src/sys/kern/vfs_vnode.c:1.149	Fri Feb 24 11:02:27 2023
+++ src/sys/kern/vfs_vnode.c	Mon Nov  6 12:17:50 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.149 2023/02/24 11:02:27 riastradh Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.150 2023/11/06 12:17:50 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011, 2019, 2020 The NetBSD Foundation, Inc.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.149 2023/02/24 11:02:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.150 2023/11/06 12:17:50 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pax.h"
@@ -539,6 +539,8 @@ lru_requeue(vnode_t *vp, vnodelst_t *lis
 	if ((d > 0 && numvnodes > desiredvnodes) ||
 	listhd == _list[LRU_VRELE])
 		cv_signal(_cv);
+	if (d > 0 && numvnodes > desiredvnodes + desiredvnodes / 16)
+		kpause("vnfull", false, mstohz(10), _lock);
 	mutex_exit(_lock);
 }
 
@@ -689,7 +691,7 @@ vdrain_thread(void *cookie)
 
 	for (;;) {
 		vdrain_retry = false;
-		target = desiredvnodes - desiredvnodes/10;
+		target = desiredvnodes - desiredvnodes / 16;
 
 		for (i = 0; i < LRU_COUNT; i++) {
 			TAILQ_INSERT_HEAD(_list[i], marker, vi_lrulist);



CVS commit: src/sys/kern

2023-11-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Nov  6 12:17:50 UTC 2023

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

Log Message:
As the number of allocated vnodes goes beyond 106% of desiredvnodes
start throttling threads allocating new vnodes at a rate of ~100 new
vnodes per second and thread.


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/sys/kern/vfs_vnode.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/usb

2023-11-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Nov  6 12:16:52 UTC 2023

Modified Files:
src/sys/dev/usb: ugen.c

Log Message:
Undo the DPRINTFN part of the last commit.  It breaks i386 at least
when KERNHIST_LOG casts the pointer to uintmax_t.

Kernel ALL/i386 compiles again.


To generate a diff of this commit:
cvs rdiff -u -r1.174 -r1.175 src/sys/dev/usb/ugen.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/usb

2023-11-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Nov  6 12:16:52 UTC 2023

Modified Files:
src/sys/dev/usb: ugen.c

Log Message:
Undo the DPRINTFN part of the last commit.  It breaks i386 at least
when KERNHIST_LOG casts the pointer to uintmax_t.

Kernel ALL/i386 compiles again.


To generate a diff of this commit:
cvs rdiff -u -r1.174 -r1.175 src/sys/dev/usb/ugen.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/usb/ugen.c
diff -u src/sys/dev/usb/ugen.c:1.174 src/sys/dev/usb/ugen.c:1.175
--- src/sys/dev/usb/ugen.c:1.174	Tue Oct 10 10:58:03 2023
+++ src/sys/dev/usb/ugen.c	Mon Nov  6 12:16:52 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ugen.c,v 1.174 2023/10/10 10:58:03 simonb Exp $	*/
+/*	$NetBSD: ugen.c,v 1.175 2023/11/06 12:16:52 hannken Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.174 2023/10/10 10:58:03 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.175 2023/11/06 12:16:52 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1346,8 +1346,8 @@ ugenintr(struct usbd_xfer *xfer, void *a
 	usbd_get_xfer_status(xfer, NULL, NULL, , NULL);
 	ibuf = sce->ibuf;
 
-	DPRINTFN(5, "xfer=%p status=%d count=%d",
-		 xfer, status, count, 0);
+	DPRINTFN(5, "xfer=%#jx status=%d count=%d",
+		 (uintptr_t)xfer, status, count, 0);
 	DPRINTFN(5, "  data = %02x %02x %02x",
 		 ibuf[0], ibuf[1], ibuf[2], 0);
 



CVS commit: src/sys

2023-06-15 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Jun 15 09:15:54 UTC 2023

Modified Files:
src/sys/dev/raidframe: rf_netbsdkintf.c
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
Undo unlock/relock for VOP_IOCTL().

PR kern/57450 (unplugging hung USB disk triggers panic via _vstate_assert)


To generate a diff of this commit:
cvs rdiff -u -r1.411 -r1.412 src/sys/dev/raidframe/rf_netbsdkintf.c
cvs rdiff -u -r1.380 -r1.381 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

2023-06-15 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Jun 15 09:15:54 UTC 2023

Modified Files:
src/sys/dev/raidframe: rf_netbsdkintf.c
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
Undo unlock/relock for VOP_IOCTL().

PR kern/57450 (unplugging hung USB disk triggers panic via _vstate_assert)


To generate a diff of this commit:
cvs rdiff -u -r1.411 -r1.412 src/sys/dev/raidframe/rf_netbsdkintf.c
cvs rdiff -u -r1.380 -r1.381 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/dev/raidframe/rf_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.411 src/sys/dev/raidframe/rf_netbsdkintf.c:1.412
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.411	Thu Mar 30 11:02:15 2023
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Thu Jun 15 09:15:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.411 2023/03/30 11:02:15 riastradh Exp $	*/
+/*	$NetBSD: rf_netbsdkintf.c,v 1.412 2023/06/15 09:15:54 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  ***/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.411 2023/03/30 11:02:15 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.412 2023/06/15 09:15:54 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_raid_autoconfig.h"
@@ -2956,7 +2956,6 @@ rf_find_raid_components(void)
 continue;
 			}
 
-			VOP_UNLOCK(vp);
 			error = getdisksize(vp, , );
 			if (error) {
 /*
@@ -2968,7 +2967,6 @@ rf_find_raid_components(void)
 	printf("RAIDframe: can't get disk size"
 	" for dev %s (%d)\n",
 	device_xname(dv), error);
-vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 VOP_CLOSE(vp, FREAD | FWRITE, NOCRED);
 vput(vp);
 continue;
@@ -2980,19 +2978,18 @@ rf_find_raid_components(void)
 if (error) {
 	printf("RAIDframe: can't get wedge info for "
 	"dev %s (%d)\n", device_xname(dv), error);
-	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 	VOP_CLOSE(vp, FREAD | FWRITE, NOCRED);
 	vput(vp);
 	continue;
 }
 
 if (strcmp(dkw.dkw_ptype, DKW_PTYPE_RAIDFRAME) != 0) {
-	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 	VOP_CLOSE(vp, FREAD | FWRITE, NOCRED);
 	vput(vp);
 	continue;
 }
 
+VOP_UNLOCK(vp);
 ac_list = rf_get_component(ac_list, dev, vp,
 device_xname(dv), dkw.dkw_size, numsecs, secsize);
 rf_part_found = 1; /*There is a raid component on this disk*/
@@ -3013,7 +3010,6 @@ rf_find_raid_components(void)
 
 			/* don't need this any more.  We'll allocate it again
 			   a little later if we really do... */
-			vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 			VOP_CLOSE(vp, FREAD | FWRITE, NOCRED);
 			vput(vp);
 

Index: src/sys/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.380 src/sys/ufs/ffs/ffs_vfsops.c:1.381
--- src/sys/ufs/ffs/ffs_vfsops.c:1.380	Mon Jun  5 04:59:46 2023
+++ src/sys/ufs/ffs/ffs_vfsops.c	Thu Jun 15 09:15:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.380 2023/06/05 04:59:46 rin Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.381 2023/06/15 09:15:54 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.380 2023/06/05 04:59:46 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.381 2023/06/15 09:15:54 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -2523,9 +2523,7 @@ ffs_vfs_fsync(vnode_t *vp, int flags)
 		 * contains no dirty buffers that could be in the log.
 		 */
 		if (!LIST_EMPTY(>v_dirtyblkhd)) {
-			VOP_UNLOCK(vp);
 			error = wapbl_flush(mp->mnt_wapbl, 0);
-			vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 			if (error)
 return error;
 		}
@@ -2544,10 +2542,8 @@ ffs_vfs_fsync(vnode_t *vp, int flags)
 	error = vflushbuf(vp, flags);
 	if (error == 0 && (flags & FSYNC_CACHE) != 0) {
 		i = 1;
-		VOP_UNLOCK(vp);
 		(void)VOP_IOCTL(vp, DIOCCACHESYNC, , FWRITE,
 		kauth_cred_get());
-		vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 	}
 
 	return error;



CVS commit: src/sys

2023-06-15 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Jun 15 09:15:13 UTC 2023

Modified Files:
src/sys/kern: vnode_if.c
src/sys/rump/include/rump: rumpvnode_if.h
src/sys/rump/librump/rumpvfs: rumpvnode_if.c
src/sys/sys: vnode_if.h

Log Message:
Regen.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/kern/vnode_if.c
cvs rdiff -u -r1.40 -r1.41 src/sys/rump/include/rump/rumpvnode_if.h
cvs rdiff -u -r1.40 -r1.41 src/sys/rump/librump/rumpvfs/rumpvnode_if.c
cvs rdiff -u -r1.111 -r1.112 src/sys/sys/vnode_if.h

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



CVS commit: src/sys

2023-06-15 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Jun 15 09:15:13 UTC 2023

Modified Files:
src/sys/kern: vnode_if.c
src/sys/rump/include/rump: rumpvnode_if.h
src/sys/rump/librump/rumpvfs: rumpvnode_if.c
src/sys/sys: vnode_if.h

Log Message:
Regen.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/kern/vnode_if.c
cvs rdiff -u -r1.40 -r1.41 src/sys/rump/include/rump/rumpvnode_if.h
cvs rdiff -u -r1.40 -r1.41 src/sys/rump/librump/rumpvfs/rumpvnode_if.c
cvs rdiff -u -r1.111 -r1.112 src/sys/sys/vnode_if.h

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

Modified files:

Index: src/sys/kern/vnode_if.c
diff -u src/sys/kern/vnode_if.c:1.118 src/sys/kern/vnode_if.c:1.119
--- src/sys/kern/vnode_if.c:1.118	Mon Jul 18 04:32:35 2022
+++ src/sys/kern/vnode_if.c	Thu Jun 15 09:15:13 2023
@@ -1,13 +1,13 @@
-/*	$NetBSD: vnode_if.c,v 1.118 2022/07/18 04:32:35 thorpej Exp $	*/
+/*	$NetBSD: vnode_if.c,v 1.119 2023/06/15 09:15:13 hannken Exp $	*/
 
 /*
  * Warning: DO NOT EDIT! This file is automatically generated!
  * (Modifications made here may easily be lost!)
  *
  * Created from the file:
- *	NetBSD: vnode_if.src,v 1.84 2022/05/03 08:33:59 hannken Exp
+ *	NetBSD: vnode_if.src,v 1.85 2023/06/15 09:13:36 hannken Exp
  * by the script:
- *	NetBSD: vnode_if.sh,v 1.76 2022/07/18 04:30:30 thorpej Exp
+ *	NetBSD: vnode_if.sh,v 1.77 2022/10/26 23:39:43 riastradh Exp
  */
 
 /*
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vnode_if.c,v 1.118 2022/07/18 04:32:35 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnode_if.c,v 1.119 2023/06/15 09:15:13 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_vnode_lockdebug.h"
@@ -54,6 +54,8 @@ __KERNEL_RCSID(0, "$NetBSD: vnode_if.c,v
 #include 
 #include 
 
+#include 
+
 enum fst_op { FST_NO, FST_YES, FST_LAZY, FST_TRY };
 
 static inline int
@@ -236,8 +238,6 @@ do {	\
 
 #define	vop_close_post(ap, e)		\
 do {	\
-	extern int (**dead_vnodeop_p)(void *);\
-	\
 	/* See the definition of VN_KNOTE() in . */	\
 	if (__predict_false(VN_KEVENT_INTEREST((ap)->a_vp,		\
 	NOTE_CLOSE_WRITE | NOTE_CLOSE) && (e) == 0)) {		\
@@ -927,7 +927,6 @@ VOP_IOCTL(struct vnode *vp,
 	a.a_data = data;
 	a.a_fflag = fflag;
 	a.a_cred = cred;
-	assert_vop_unlocked(vp, "vop_ioctl: vp");
 	error = vop_pre(vp, , , FST_NO);
 	if (error)
 		return error;

Index: src/sys/rump/include/rump/rumpvnode_if.h
diff -u src/sys/rump/include/rump/rumpvnode_if.h:1.40 src/sys/rump/include/rump/rumpvnode_if.h:1.41
--- src/sys/rump/include/rump/rumpvnode_if.h:1.40	Mon Jul 18 04:32:35 2022
+++ src/sys/rump/include/rump/rumpvnode_if.h	Thu Jun 15 09:15:13 2023
@@ -1,13 +1,13 @@
-/*	$NetBSD: rumpvnode_if.h,v 1.40 2022/07/18 04:32:35 thorpej Exp $	*/
+/*	$NetBSD: rumpvnode_if.h,v 1.41 2023/06/15 09:15:13 hannken Exp $	*/
 
 /*
  * Warning: DO NOT EDIT! This file is automatically generated!
  * (Modifications made here may easily be lost!)
  *
  * Created from the file:
- *	NetBSD: vnode_if.src,v 1.84 2022/05/03 08:33:59 hannken Exp
+ *	NetBSD: vnode_if.src,v 1.85 2023/06/15 09:13:36 hannken Exp
  * by the script:
- *	NetBSD: vnode_if.sh,v 1.76 2022/07/18 04:30:30 thorpej Exp
+ *	NetBSD: vnode_if.sh,v 1.77 2022/10/26 23:39:43 riastradh Exp
  */
 
 /*

Index: src/sys/rump/librump/rumpvfs/rumpvnode_if.c
diff -u src/sys/rump/librump/rumpvfs/rumpvnode_if.c:1.40 src/sys/rump/librump/rumpvfs/rumpvnode_if.c:1.41
--- src/sys/rump/librump/rumpvfs/rumpvnode_if.c:1.40	Mon Jul 18 04:32:35 2022
+++ src/sys/rump/librump/rumpvfs/rumpvnode_if.c	Thu Jun 15 09:15:13 2023
@@ -1,13 +1,13 @@
-/*	$NetBSD: rumpvnode_if.c,v 1.40 2022/07/18 04:32:35 thorpej Exp $	*/
+/*	$NetBSD: rumpvnode_if.c,v 1.41 2023/06/15 09:15:13 hannken Exp $	*/
 
 /*
  * Warning: DO NOT EDIT! This file is automatically generated!
  * (Modifications made here may easily be lost!)
  *
  * Created from the file:
- *	NetBSD: vnode_if.src,v 1.84 2022/05/03 08:33:59 hannken Exp
+ *	NetBSD: vnode_if.src,v 1.85 2023/06/15 09:13:36 hannken Exp
  * by the script:
- *	NetBSD: vnode_if.sh,v 1.76 2022/07/18 04:30:30 thorpej Exp
+ *	NetBSD: vnode_if.sh,v 1.77 2022/10/26 23:39:43 riastradh Exp
  */
 
 /*
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rumpvnode_if.c,v 1.40 2022/07/18 04:32:35 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rumpvnode_if.c,v 1.41 2023/06/15 09:15:13 hannken Exp $");
 
 #include 
 #include 

Index: src/sys/sys/vnode_if.h
diff -u src/sys/sys/vnode_if.h:1.111 src/sys/sys/vnode_if.h:1.112
--- src/sys/sys/vnode_if.h:1.111	Mon Jul 18 04:32:35 2022
+++ src/sys/sys/vnode_if.h	Thu Jun 15 09:15:13 2023
@@ -1,13 +1,13 @@
-/*	$NetBSD: vnode_if.h,v 1.111 2022/07/18 04:32:35 thorpej Exp $	*/
+/*	$NetBSD: vnode_if.h,v 1.112 2023/06/15 09:15:13 hannken Exp $	*/
 
 /*
  * Warning: DO NOT EDIT! This file is automatically generated!
  * (Modifications made here may easily be lost!)
  *
  * 

CVS commit: src

2023-06-15 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Jun 15 09:13:36 UTC 2023

Modified Files:
src/share/man/man9: vnodeops.9
src/sys/kern: vnode_if.src

Log Message:
VOP_IOCTL() is a wrapper around spec_ioctl() aka Xdev_ioctl() and
protected with spec_io_enter()/spec_io_exit() so there is no need
to force specific vnode locking.

Set locking requirement to '= = =' (unchanged, locked or unlocked).

PR kern/57450 (unplugging hung USB disk triggers panic via _vstate_assert)


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/share/man/man9/vnodeops.9
cvs rdiff -u -r1.84 -r1.85 src/sys/kern/vnode_if.src

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



CVS commit: src

2023-06-15 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Jun 15 09:13:36 UTC 2023

Modified Files:
src/share/man/man9: vnodeops.9
src/sys/kern: vnode_if.src

Log Message:
VOP_IOCTL() is a wrapper around spec_ioctl() aka Xdev_ioctl() and
protected with spec_io_enter()/spec_io_exit() so there is no need
to force specific vnode locking.

Set locking requirement to '= = =' (unchanged, locked or unlocked).

PR kern/57450 (unplugging hung USB disk triggers panic via _vstate_assert)


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/share/man/man9/vnodeops.9
cvs rdiff -u -r1.84 -r1.85 src/sys/kern/vnode_if.src

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

Modified files:

Index: src/share/man/man9/vnodeops.9
diff -u src/share/man/man9/vnodeops.9:1.100 src/share/man/man9/vnodeops.9:1.101
--- src/share/man/man9/vnodeops.9:1.100	Sun Nov 19 21:06:10 2017
+++ src/share/man/man9/vnodeops.9	Thu Jun 15 09:13:36 2023
@@ -1,4 +1,4 @@
-.\" $NetBSD: vnodeops.9,v 1.100 2017/11/19 21:06:10 christos Exp $
+.\" $NetBSD: vnodeops.9,v 1.101 2023/06/15 09:13:36 hannken Exp $
 .\"
 .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd November 19, 2017
+.Dd June 15, 2023
 .Dt VNODEOPS 9
 .Os
 .Sh NAME
@@ -709,7 +709,7 @@ existing data, or some other data, or tr
 Perform device-specific I/O.
 The argument
 .Fa vp
-is the locked vnode of the file, normally representing a device.
+is the vnode of the file, normally representing a device.
 The argument
 .Fa command
 specifies the device-specific operation to perform and

Index: src/sys/kern/vnode_if.src
diff -u src/sys/kern/vnode_if.src:1.84 src/sys/kern/vnode_if.src:1.85
--- src/sys/kern/vnode_if.src:1.84	Tue May  3 08:33:59 2022
+++ src/sys/kern/vnode_if.src	Thu Jun 15 09:13:36 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: vnode_if.src,v 1.84 2022/05/03 08:33:59 hannken Exp $
+#	$NetBSD: vnode_if.src,v 1.85 2023/06/15 09:13:36 hannken Exp $
 #
 # Copyright (c) 1992, 1993
 #	The Regents of the University of California.  All rights reserved.
@@ -217,11 +217,11 @@ vop_fdiscard {
 };
 
 #
-#% ioctl  vp  U U U
+#% ioctl  vp  = = =
 #
 vop_ioctl {
 	FSTRANS=NO
-	IN LOCKED=NO struct vnode *vp;
+	IN struct vnode *vp;
 	IN u_long command;
 	IN void *data;
 	IN int fflag;



CVS commit: src/tests

2023-05-28 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun May 28 08:17:00 UTC 2023

Modified Files:
src/tests/fs/nfs: t_rquotad.sh
src/tests/lib/librumphijack: t_tcpip.sh t_vfs.sh

Log Message:
Add RUMPHIJACK option "blanket=/DEV" so mount_ffs may canonicalise
and mount the device path.  Cannot use "/rump/DEV" here as the device
path is embedded in "struct ufs_args" where it doesnt get hijacked.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/fs/nfs/t_rquotad.sh
cvs rdiff -u -r1.21 -r1.22 src/tests/lib/librumphijack/t_tcpip.sh
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/librumphijack/t_vfs.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/fs/nfs/t_rquotad.sh
diff -u src/tests/fs/nfs/t_rquotad.sh:1.9 src/tests/fs/nfs/t_rquotad.sh:1.10
--- src/tests/fs/nfs/t_rquotad.sh:1.9	Thu Aug 20 13:58:30 2020
+++ src/tests/fs/nfs/t_rquotad.sh	Sun May 28 08:17:00 2023
@@ -1,4 +1,4 @@
-# $NetBSD: t_rquotad.sh,v 1.9 2020/08/20 13:58:30 riastradh Exp $
+# $NetBSD: t_rquotad.sh,v 1.10 2023/05/28 08:17:00 hannken Exp $
 #
 #  Copyright (c) 2011 Manuel Bouyer
 #  All rights reserved.
@@ -110,7 +110,8 @@ get_nfs_quota()
 	/bin/echo "/export -noresvport -noresvmnt 10.1.1.100" | \
 		dd of=/rump/etc/exports 2> /dev/null
 
-	atf_check -s exit:0 -e ignore mount_ffs /dk /rump/export
+	atf_check -s exit:0 -e ignore env RUMPHIJACK='path=/rump,blanket=/dk' \
+		mount_ffs /dk /rump/export
 
 #set a quota limit (and check that we can read it back)
 	for q in ${expect} ; do

Index: src/tests/lib/librumphijack/t_tcpip.sh
diff -u src/tests/lib/librumphijack/t_tcpip.sh:1.21 src/tests/lib/librumphijack/t_tcpip.sh:1.22
--- src/tests/lib/librumphijack/t_tcpip.sh:1.21	Thu Nov 11 07:38:21 2021
+++ src/tests/lib/librumphijack/t_tcpip.sh	Sun May 28 08:17:00 2023
@@ -1,4 +1,4 @@
-#   $NetBSD: t_tcpip.sh,v 1.21 2021/11/11 07:38:21 gson Exp $
+#   $NetBSD: t_tcpip.sh,v 1.22 2023/05/28 08:17:00 hannken Exp $
 #
 # Copyright (c) 2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -182,7 +182,8 @@ test_nfs()
 
 	atf_check -s exit:0 rump.sysctl -q -w kern.module.autoload=1
 
-	atf_check -s exit:0 -e ignore mount_ffs /dk /rump/export
+	atf_check -s exit:0 -e ignore env RUMPHIJACK='path=/rump,blanket=/dk' \
+		mount_ffs /dk /rump/export
 	atf_check -s exit:0 -x "echo ${magicstr} > /rump/export/im_alive"
 
 	# start rpcbind.  we want /var/run/rpcbind.sock

Index: src/tests/lib/librumphijack/t_vfs.sh
diff -u src/tests/lib/librumphijack/t_vfs.sh:1.6 src/tests/lib/librumphijack/t_vfs.sh:1.7
--- src/tests/lib/librumphijack/t_vfs.sh:1.6	Sat Aug  4 03:56:47 2012
+++ src/tests/lib/librumphijack/t_vfs.sh	Sun May 28 08:17:00 2023
@@ -1,4 +1,4 @@
-#   $NetBSD: t_vfs.sh,v 1.6 2012/08/04 03:56:47 riastradh Exp $
+#   $NetBSD: t_vfs.sh,v 1.7 2023/05/28 08:17:00 hannken Exp $
 #
 # Copyright (c) 2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -35,7 +35,8 @@ domount()
 
 	mntdir=$1
 	[ $# -eq 0 ] && mntdir=/rump/mnt
-	atf_check -s exit:0 -e ignore mount_ffs /img ${mntdir}
+	atf_check -s exit:0 -e ignore env RUMPHIJACK='path=/rump,blanket=/img' \
+		mount_ffs /img ${mntdir}
 }
 
 dounmount()



CVS commit: src/tests

2023-05-28 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun May 28 08:17:00 UTC 2023

Modified Files:
src/tests/fs/nfs: t_rquotad.sh
src/tests/lib/librumphijack: t_tcpip.sh t_vfs.sh

Log Message:
Add RUMPHIJACK option "blanket=/DEV" so mount_ffs may canonicalise
and mount the device path.  Cannot use "/rump/DEV" here as the device
path is embedded in "struct ufs_args" where it doesnt get hijacked.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/fs/nfs/t_rquotad.sh
cvs rdiff -u -r1.21 -r1.22 src/tests/lib/librumphijack/t_tcpip.sh
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/librumphijack/t_vfs.sh

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



CVS commit: src/external/bsd/unbound/include

2023-05-23 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue May 23 20:07:21 UTC 2023

Modified Files:
src/external/bsd/unbound/include: config.h

Log Message:
Set PID path back to "/var/run/unbound.pid" so rc scripts work again.

Ok: Christos Zoulas

PR bin/57242 unbound rc.d script does not work with chrooted unbound


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/unbound/include/config.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/bsd/unbound/include/config.h
diff -u src/external/bsd/unbound/include/config.h:1.10 src/external/bsd/unbound/include/config.h:1.11
--- src/external/bsd/unbound/include/config.h:1.10	Sat Sep 24 18:11:43 2022
+++ src/external/bsd/unbound/include/config.h	Tue May 23 20:07:21 2023
@@ -773,7 +773,7 @@
 #define PACKAGE_VERSION "1.16.3"
 
 /* default pidfile location */
-#define PIDFILE CHROOT_DIR "/var/run/unbound.pid"
+#define PIDFILE "/var/run/unbound.pid"
 
 /* Define to necessary symbol if this constant uses a non-standard name on
your system. */



CVS commit: src/external/bsd/unbound/include

2023-05-23 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue May 23 20:07:21 UTC 2023

Modified Files:
src/external/bsd/unbound/include: config.h

Log Message:
Set PID path back to "/var/run/unbound.pid" so rc scripts work again.

Ok: Christos Zoulas

PR bin/57242 unbound rc.d script does not work with chrooted unbound


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/unbound/include/config.h

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



CVS commit: src/sys/sys

2023-04-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Apr 22 14:30:54 UTC 2023

Modified Files:
src/sys/sys: mount.h

Log Message:
Remove unused mount member mnt_transinfo.

Ride 10.99.4


To generate a diff of this commit:
cvs rdiff -u -r1.240 -r1.241 src/sys/sys/mount.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/sys/mount.h
diff -u src/sys/sys/mount.h:1.240 src/sys/sys/mount.h:1.241
--- src/sys/sys/mount.h:1.240	Fri Nov  4 11:20:40 2022
+++ src/sys/sys/mount.h	Sat Apr 22 14:30:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: mount.h,v 1.240 2022/11/04 11:20:40 hannken Exp $	*/
+/*	$NetBSD: mount.h,v 1.241 2023/04/22 14:30:54 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993
@@ -141,7 +141,6 @@ struct mount {
 	struct vfsops	*mnt_op;		/* operations on fs */
 	struct vnode	*mnt_vnodecovered;	/* vnode we mounted on */
 	struct mount	*mnt_lower;		/* fs mounted on */
-	void		*mnt_transinfo;		/* for FS-internal use */
 	void		*mnt_data;		/* private data */
 	kmutex_t	*mnt_renamelock;	/* per-fs rename lock */
 	int		mnt_flag;		/* flags */



CVS commit: src/sys/sys

2023-04-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Apr 22 14:30:54 UTC 2023

Modified Files:
src/sys/sys: mount.h

Log Message:
Remove unused mount member mnt_transinfo.

Ride 10.99.4


To generate a diff of this commit:
cvs rdiff -u -r1.240 -r1.241 src/sys/sys/mount.h

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



CVS commit: src/sys/miscfs/specfs

2023-04-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Apr 22 14:30:17 UTC 2023

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c specdev.h

Log Message:
Remove unused specdev member sd_rdev.

Ride 10.99.4


To generate a diff of this commit:
cvs rdiff -u -r1.216 -r1.217 src/sys/miscfs/specfs/spec_vnops.c
cvs rdiff -u -r1.53 -r1.54 src/sys/miscfs/specfs/specdev.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/miscfs/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.216 src/sys/miscfs/specfs/spec_vnops.c:1.217
--- src/sys/miscfs/specfs/spec_vnops.c:1.216	Sat Oct 15 15:20:46 2022
+++ src/sys/miscfs/specfs/spec_vnops.c	Sat Apr 22 14:30:16 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.216 2022/10/15 15:20:46 riastradh Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.217 2023/04/22 14:30:16 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.216 2022/10/15 15:20:46 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.217 2023/04/22 14:30:16 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -397,7 +397,6 @@ spec_node_init(vnode_t *vp, dev_t rdev)
 	}
 	if (vp2 == NULL) {
 		/* No existing record, create a new one. */
-		sd->sd_rdev = rdev;
 		sd->sd_mountpoint = NULL;
 		sd->sd_lockf = NULL;
 		sd->sd_refcnt = 1;

Index: src/sys/miscfs/specfs/specdev.h
diff -u src/sys/miscfs/specfs/specdev.h:1.53 src/sys/miscfs/specfs/specdev.h:1.54
--- src/sys/miscfs/specfs/specdev.h:1.53	Wed Oct 26 23:40:08 2022
+++ src/sys/miscfs/specfs/specdev.h	Sat Apr 22 14:30:16 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: specdev.h,v 1.53 2022/10/26 23:40:08 riastradh Exp $	*/
+/*	$NetBSD: specdev.h,v 1.54 2023/04/22 14:30:16 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -77,7 +77,6 @@ typedef struct specdev {
 	vnode_t		*sd_bdevvp;
 	u_int		sd_opencnt;	/* # of opens; close when ->0 */
 	u_int		sd_refcnt;	/* # of specnodes referencing this */
-	dev_t		sd_rdev;
 	volatile u_int	sd_iocnt;	/* # bdev/cdev_* operations active */
 	bool		sd_opened;	/* true if successfully opened */
 	bool		sd_closing;	/* true when bdev/cdev_close ongoing */



CVS commit: src/sys/miscfs/specfs

2023-04-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Apr 22 14:30:17 UTC 2023

Modified Files:
src/sys/miscfs/specfs: spec_vnops.c specdev.h

Log Message:
Remove unused specdev member sd_rdev.

Ride 10.99.4


To generate a diff of this commit:
cvs rdiff -u -r1.216 -r1.217 src/sys/miscfs/specfs/spec_vnops.c
cvs rdiff -u -r1.53 -r1.54 src/sys/miscfs/specfs/specdev.h

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



CVS commit: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common

2023-04-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Apr  6 09:49:12 UTC 2023

Modified Files:
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common:
sanitizer_mutex.h

Log Message:
Fix StaticSpinMutex::CheckLocked() on sparc32.

The lock gets set with atomic_exchange() -> __sync_lock_test_and_set()
which sets the value to 255 instead of 1.  Check for a taken lock
with "!= 0" instead of "== 1".  This should work on all architectures.

Ok: Matthew Green


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_mutex.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_mutex.h
diff -u src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_mutex.h:1.2 src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_mutex.h:1.3
--- src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_mutex.h:1.2	Sun Apr 11 23:54:27 2021
+++ src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_mutex.h	Thu Apr  6 09:49:12 2023
@@ -39,7 +39,7 @@ class StaticSpinMutex {
   }
 
   void CheckLocked() {
-CHECK_EQ(atomic_load(_, memory_order_relaxed), 1);
+CHECK_NE(atomic_load(_, memory_order_relaxed), 0);
   }
 
  private:



CVS commit: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common

2023-04-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Apr  6 09:49:12 UTC 2023

Modified Files:
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common:
sanitizer_mutex.h

Log Message:
Fix StaticSpinMutex::CheckLocked() on sparc32.

The lock gets set with atomic_exchange() -> __sync_lock_test_and_set()
which sets the value to 255 instead of 1.  Check for a taken lock
with "!= 0" instead of "== 1".  This should work on all architectures.

Ok: Matthew Green


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_mutex.h

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



CVS commit: src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common

2023-04-05 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Apr  5 07:41:38 UTC 2023

Modified Files:
src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common:
sanitizer_mutex.h

Log Message:
Fix StaticSpinMutex::CheckLocked() on sparc32.

The lock gets set with atomic_exchange() -> __sync_lock_test_and_set()
which sets the value to 255 instead of 1.  Check for a taken lock
with "!= 0" instead of "== 1".  This should work on all architectures.

Ok: Matthew Green


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \

src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_mutex.h

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



CVS commit: src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common

2023-04-05 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Apr  5 07:41:38 UTC 2023

Modified Files:
src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common:
sanitizer_mutex.h

Log Message:
Fix StaticSpinMutex::CheckLocked() on sparc32.

The lock gets set with atomic_exchange() -> __sync_lock_test_and_set()
which sets the value to 255 instead of 1.  Check for a taken lock
with "!= 0" instead of "== 1".  This should work on all architectures.

Ok: Matthew Green


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \

src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_mutex.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_mutex.h
diff -u src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_mutex.h:1.8 src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_mutex.h:1.9
--- src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_mutex.h:1.8	Fri Apr  9 23:14:55 2021
+++ src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_mutex.h	Wed Apr  5 07:41:38 2023
@@ -39,7 +39,7 @@ class StaticSpinMutex {
   }
 
   void CheckLocked() {
-CHECK_EQ(atomic_load(_, memory_order_relaxed), 1);
+CHECK_NE(atomic_load(_, memory_order_relaxed), 0);
   }
 
  private:



CVS commit: src/sys/dev

2023-03-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Mar 22 21:14:46 UTC 2023

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

Log Message:
Pass B_PHYS when reading from device.  Xbd(4) at least checks
this flag and may trigger an assertion.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/dev/fss.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/fss.c
diff -u src/sys/dev/fss.c:1.113 src/sys/dev/fss.c:1.114
--- src/sys/dev/fss.c:1.113	Sat Sep 24 23:18:54 2022
+++ src/sys/dev/fss.c	Wed Mar 22 21:14:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fss.c,v 1.113 2022/09/24 23:18:54 thorpej Exp $	*/
+/*	$NetBSD: fss.c,v 1.114 2023/03/22 21:14:46 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.113 2022/09/24 23:18:54 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.114 2023/03/22 21:14:46 hannken Exp $");
 
 #include 
 #include 
@@ -1285,7 +1285,7 @@ fss_bs_thread(void *arg)
 
 			/* Not on backing store, read from device. */
 			nbp = getiobuf(NULL, true);
-			nbp->b_flags = B_READ;
+			nbp->b_flags = B_READ | (bp->b_flags & B_PHYS);
 			nbp->b_resid = nbp->b_bcount = bp->b_bcount;
 			nbp->b_bufsize = bp->b_bcount;
 			nbp->b_data = bp->b_data;



CVS commit: src/sys/dev

2023-03-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Mar 22 21:14:46 UTC 2023

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

Log Message:
Pass B_PHYS when reading from device.  Xbd(4) at least checks
this flag and may trigger an assertion.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/dev/fss.c

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



CVS commit: src/bin/sh

2023-03-21 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Mar 21 08:31:30 UTC 2023

Modified Files:
src/bin/sh: error.h

Log Message:
Use "sigjmp_buf loc" after switch to sigsetjmp()/siglongjmp().

Fixes errors and aborts on sparc at least.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/bin/sh/error.h

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

Modified files:

Index: src/bin/sh/error.h
diff -u src/bin/sh/error.h:1.24 src/bin/sh/error.h:1.25
--- src/bin/sh/error.h:1.24	Sun Mar 19 17:47:48 2023
+++ src/bin/sh/error.h	Tue Mar 21 08:31:30 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: error.h,v 1.24 2023/03/19 17:47:48 kre Exp $	*/
+/*	$NetBSD: error.h,v 1.25 2023/03/21 08:31:30 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -58,7 +58,7 @@
 #include 
 
 struct jmploc {
-	jmp_buf loc;
+	sigjmp_buf loc;
 };
 
 extern volatile int errors_suppressed;



CVS commit: src/bin/sh

2023-03-21 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Mar 21 08:31:30 UTC 2023

Modified Files:
src/bin/sh: error.h

Log Message:
Use "sigjmp_buf loc" after switch to sigsetjmp()/siglongjmp().

Fixes errors and aborts on sparc at least.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/bin/sh/error.h

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



CVS commit: src

2023-03-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Mar 20 11:19:30 UTC 2023

Modified Files:
src/sys/arch/sparc/sparc: syscall.c vm_machdep.c
src/tests/lib/libc/sys: t_ptrace_syscall_wait.h

Log Message:
Adjust pc/npc before syscall allowing EJUSTRETURN to return
to the next instruction.  Only ERESTART should return to
the same instruction.  Differences to sparc64 reduced.

Test t_ptrace_wait:syscallemu1 now passes on sparc.

Fixes PR kern/52166 "syscallemu does not work on sparc (32-bit)"

Ok: Martin Husemann


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/sparc/sparc/syscall.c
cvs rdiff -u -r1.107 -r1.108 src/sys/arch/sparc/sparc/vm_machdep.c
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_ptrace_syscall_wait.h

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

Modified files:

Index: src/sys/arch/sparc/sparc/syscall.c
diff -u src/sys/arch/sparc/sparc/syscall.c:1.31 src/sys/arch/sparc/sparc/syscall.c:1.32
--- src/sys/arch/sparc/sparc/syscall.c:1.31	Sat Apr  6 11:54:20 2019
+++ src/sys/arch/sparc/sparc/syscall.c	Mon Mar 20 11:19:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: syscall.c,v 1.31 2019/04/06 11:54:20 kamil Exp $ */
+/*	$NetBSD: syscall.c,v 1.32 2023/03/20 11:19:29 hannken Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.31 2019/04/06 11:54:20 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.32 2023/03/20 11:19:29 hannken Exp $");
 
 #include "opt_sparc_arch.h"
 #include "opt_multiprocessor.h"
@@ -106,6 +106,17 @@ handle_new(struct trapframe *tf, registe
 {
 	int new = *code & (SYSCALL_G7RFLAG|SYSCALL_G2RFLAG|SYSCALL_G5RFLAG);
 	*code &= ~(SYSCALL_G7RFLAG|SYSCALL_G2RFLAG|SYSCALL_G5RFLAG);
+	if (new) {
+		/* jmp %g5, (or %g2 or %g7, deprecated) on success */
+		if (__predict_true((new & SYSCALL_G5RFLAG) == SYSCALL_G5RFLAG))
+			tf->tf_pc = tf->tf_global[5];
+		else if (new & SYSCALL_G2RFLAG)
+			tf->tf_pc = tf->tf_global[2];
+		else
+			tf->tf_pc = tf->tf_global[7];
+	} else {
+		tf->tf_pc = tf->tf_npc;
+	}
 	return new;
 }
 
@@ -207,7 +218,7 @@ syscall(register_t code, struct trapfram
 	int error, new;
 	union args args;
 	union rval rval;
-	register_t i;
+	int opc, onpc;
 	u_quad_t sticks;
 
 	curcpu()->ci_data.cpu_nsyscall++;	/* XXXSMP */
@@ -221,8 +232,18 @@ syscall(register_t code, struct trapfram
 #ifdef FPU_DEBUG
 	save_fpu(tf);
 #endif
+
+	/*
+	 * save pc/npc in case of ERESTART
+	 * adjust pc/npc to new values
+	 */
+	opc = tf->tf_pc;
+	onpc = tf->tf_npc;
+
 	new = handle_new(tf, );
 
+	tf->tf_npc = tf->tf_pc + 4;
+
 	if ((error = getargs(p, tf, , , )) != 0)
 		goto bad;
 
@@ -236,29 +257,17 @@ syscall(register_t code, struct trapfram
 		/* Note: fork() does not return here in the child */
 		tf->tf_out[0] = rval.o[0];
 		tf->tf_out[1] = rval.o[1];
-		if (new) {
-			/* jmp %g5, (or %g2 or %g7, deprecated) on success */
-			if (__predict_true((new & SYSCALL_G5RFLAG) ==
-	SYSCALL_G5RFLAG))
-i = tf->tf_global[5];
-			else if (new & SYSCALL_G2RFLAG)
-i = tf->tf_global[2];
-			else
-i = tf->tf_global[7];
-			if (i & 3) {
-error = EINVAL;
-goto bad;
-			}
-		} else {
+		if (!new) {
 			/* old system call convention: clear C on success */
 			tf->tf_psr &= ~PSR_C;	/* success */
-			i = tf->tf_npc;
 		}
-		tf->tf_pc = i;
-		tf->tf_npc = i + 4;
 		break;
 
 	case ERESTART:
+		tf->tf_pc = opc;
+		tf->tf_npc = onpc;
+		break;
+
 	case EJUSTRETURN:
 		/* nothing to do */
 		break;
@@ -269,9 +278,8 @@ syscall(register_t code, struct trapfram
 			error = p->p_emul->e_errno[error];
 		tf->tf_out[0] = error;
 		tf->tf_psr |= PSR_C;	/* fail */
-		i = tf->tf_npc;
-		tf->tf_pc = i;
-		tf->tf_npc = i + 4;
+		tf->tf_pc = onpc;
+		tf->tf_npc = tf->tf_pc + 4;
 		break;
 	}
 

Index: src/sys/arch/sparc/sparc/vm_machdep.c
diff -u src/sys/arch/sparc/sparc/vm_machdep.c:1.107 src/sys/arch/sparc/sparc/vm_machdep.c:1.108
--- src/sys/arch/sparc/sparc/vm_machdep.c:1.107	Sun Feb 19 21:06:30 2012
+++ src/sys/arch/sparc/sparc/vm_machdep.c	Mon Mar 20 11:19:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_machdep.c,v 1.107 2012/02/19 21:06:30 rmind Exp $ */
+/*	$NetBSD: vm_machdep.c,v 1.108 2023/03/20 11:19:29 hannken Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.107 2012/02/19 21:06:30 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.108 2023/03/20 11:19:29 hannken Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -268,8 +268,6 @@ cpu_lwp_fork(struct lwp *l1, struct lwp 
 	 * to user mode.
 	 */
 	/*tf2->tf_psr &= ~PSR_C;   -* success */
-	tf2->tf_pc = tf2->tf_npc;
-	tf2->tf_npc = tf2->tf_pc + 4;
 
 	/* Set return values in child mode */
 	tf2->tf_out[0] = 0;

Index: src/tests/lib/libc/sys/t_ptrace_syscall_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_syscall_wait.h:1.2 src/tests/lib/libc/sys/t_ptrace_syscall_wait.h:1.3
--- 

CVS commit: src

2023-03-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Mar 20 11:19:30 UTC 2023

Modified Files:
src/sys/arch/sparc/sparc: syscall.c vm_machdep.c
src/tests/lib/libc/sys: t_ptrace_syscall_wait.h

Log Message:
Adjust pc/npc before syscall allowing EJUSTRETURN to return
to the next instruction.  Only ERESTART should return to
the same instruction.  Differences to sparc64 reduced.

Test t_ptrace_wait:syscallemu1 now passes on sparc.

Fixes PR kern/52166 "syscallemu does not work on sparc (32-bit)"

Ok: Martin Husemann


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/sparc/sparc/syscall.c
cvs rdiff -u -r1.107 -r1.108 src/sys/arch/sparc/sparc/vm_machdep.c
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_ptrace_syscall_wait.h

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



CVS commit: src/sys/dev

2023-03-14 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Mar 14 12:55:43 UTC 2023

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

Log Message:
Do not limit the number of pending requests for the worker thread.

With wedge on vnd it prevents a deadlock when requests get queued with
biodone() -> dkstart() -> vndstrategy().

Fixes PR kern/57263 "vnd locks up when using vn_rdwr"


To generate a diff of this commit:
cvs rdiff -u -r1.287 -r1.288 src/sys/dev/vnd.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/vnd.c
diff -u src/sys/dev/vnd.c:1.287 src/sys/dev/vnd.c:1.288
--- src/sys/dev/vnd.c:1.287	Sun Sep  4 21:56:38 2022
+++ src/sys/dev/vnd.c	Tue Mar 14 12:55:43 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnd.c,v 1.287 2022/09/04 21:56:38 mlelstv Exp $	*/
+/*	$NetBSD: vnd.c,v 1.288 2023/03/14 12:55:43 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008, 2020 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.287 2022/09/04 21:56:38 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.288 2023/03/14 12:55:43 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vnd.h"
@@ -553,11 +553,18 @@ vndstrategy(struct buf *bp)
 		printf("vndstrategy(%p): unit %d\n", bp, unit);
 #endif
 	if ((vnd->sc_flags & VNF_USE_VN_RDWR)) {
-		KASSERT(vnd->sc_pending >= 0 &&
-		vnd->sc_pending <= VND_MAXPENDING(vnd));
-		while (vnd->sc_pending == VND_MAXPENDING(vnd))
-			tsleep(>sc_pending, PRIBIO, "vndpc", 0);
+		/*
+		 * Limit the number of pending requests to not exhaust
+		 * resources needed for I/O but always allow the worker
+		 * thread to add requests, as a wedge on vnd queues
+		 * requests with biodone() -> dkstart() -> vndstrategy().
+		 */
+		if (curlwp != vnd->sc_kthread) {
+			while (vnd->sc_pending >= VND_MAXPENDING(vnd))
+tsleep(>sc_pending, PRIBIO, "vndpc", 0);
+		}
 		vnd->sc_pending++;
+		KASSERT(vnd->sc_pending > 0);
 	}
 	bufq_put(vnd->sc_tab, bp);
 	wakeup(>sc_tab);
@@ -674,8 +681,7 @@ vndthread(void *arg)
 			continue;
 		};
 		if ((vnd->sc_flags & VNF_USE_VN_RDWR)) {
-			KASSERT(vnd->sc_pending > 0 &&
-			vnd->sc_pending <= VND_MAXPENDING(vnd));
+			KASSERT(vnd->sc_pending > 0);
 			if (vnd->sc_pending-- == VND_MAXPENDING(vnd))
 wakeup(>sc_pending);
 		}



CVS commit: src/sys/dev

2023-03-14 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Mar 14 12:55:43 UTC 2023

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

Log Message:
Do not limit the number of pending requests for the worker thread.

With wedge on vnd it prevents a deadlock when requests get queued with
biodone() -> dkstart() -> vndstrategy().

Fixes PR kern/57263 "vnd locks up when using vn_rdwr"


To generate a diff of this commit:
cvs rdiff -u -r1.287 -r1.288 src/sys/dev/vnd.c

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



CVS commit: src/sys/miscfs/genfs

2023-03-03 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Mar  3 10:02:51 UTC 2023

Modified Files:
src/sys/miscfs/genfs: genfs_vnops.c

Log Message:
Fix genfs_can_chtimes() to also handle the condition:

  If the time pointer is null, then write permission
  on the file is also sufficient.

>From FreeBSD.

Should fix PR kern/57246 "NFS group permissions regression"


To generate a diff of this commit:
cvs rdiff -u -r1.219 -r1.220 src/sys/miscfs/genfs/genfs_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/miscfs/genfs/genfs_vnops.c
diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.219 src/sys/miscfs/genfs/genfs_vnops.c:1.220
--- src/sys/miscfs/genfs/genfs_vnops.c:1.219	Sun Mar 27 17:10:55 2022
+++ src/sys/miscfs/genfs/genfs_vnops.c	Fri Mar  3 10:02:51 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_vnops.c,v 1.219 2022/03/27 17:10:55 christos Exp $	*/
+/*	$NetBSD: genfs_vnops.c,v 1.220 2023/03/03 10:02:51 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.219 2022/03/27 17:10:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.220 2023/03/03 10:02:51 hannken Exp $");
 
 #include 
 #include 
@@ -1315,23 +1315,14 @@ genfs_can_chtimes(vnode_t *vp, kauth_cre
 	 * will be allowed to set the times [..] to the current 
 	 * server time.
 	 */
-	if ((error = VOP_ACCESSX(vp, VWRITE_ATTRIBUTES, cred)) != 0)
-		return (vaflags & VA_UTIMES_NULL) == 0 ? EPERM : EACCES;
-
-	/* Must be owner, or... */
-	if (kauth_cred_geteuid(cred) == owner_uid)
-		return (0);
-
-	/* set the times to the current time, and... */
-	if ((vaflags & VA_UTIMES_NULL) == 0)
-		return (EPERM);
+	error = VOP_ACCESSX(vp, VWRITE_ATTRIBUTES, cred);
+	if (error != 0 && (vaflags & VA_UTIMES_NULL) != 0)
+		error = VOP_ACCESS(vp, VWRITE, cred);
 
-	/* have write access. */
-	error = VOP_ACCESS(vp, VWRITE, cred);
 	if (error)
-		return (error);
+		return (vaflags & VA_UTIMES_NULL) == 0 ? EPERM : EACCES;
 
-	return (0);
+	return 0;
 }
 
 /*



CVS commit: src/sys/miscfs/genfs

2023-03-03 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Mar  3 10:02:51 UTC 2023

Modified Files:
src/sys/miscfs/genfs: genfs_vnops.c

Log Message:
Fix genfs_can_chtimes() to also handle the condition:

  If the time pointer is null, then write permission
  on the file is also sufficient.

>From FreeBSD.

Should fix PR kern/57246 "NFS group permissions regression"


To generate a diff of this commit:
cvs rdiff -u -r1.219 -r1.220 src/sys/miscfs/genfs/genfs_vnops.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

2023-03-03 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Mar  3 10:01:31 UTC 2023

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

Log Message:
Adapt zfs_netbsd_access() to ACL support.  As ZFS itself only
handles VREAD, VWRITE, VEXEC and VAPPEND we use kauth_authorize_vnode()
to handle VADMIN.

>From FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.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

2023-03-03 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Mar  3 10:01:31 UTC 2023

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

Log Message:
Adapt zfs_netbsd_access() to ACL support.  As ZFS itself only
handles VREAD, VWRITE, VEXEC and VAPPEND we use kauth_authorize_vnode()
to handle VADMIN.

>From FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_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/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.80 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.81
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c:1.80	Mon Oct  3 16:04:19 2022
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c	Fri Mar  3 10:01:31 2023
@@ -5169,33 +5169,47 @@ zfs_netbsd_access(void *v)
 		accmode_t a_accmode;
 		kauth_cred_t a_cred;
 	} */ *ap = v;
-	struct vnode *vp = ap->a_vp;
-	accmode_t accmode = ap->a_accmode;
-	mode_t zfs_mode = 0;
+	vnode_t *vp = ap->a_vp;
+	znode_t *zp = VTOZ(vp);
+	accmode_t accmode;
 	kauth_cred_t cred = ap->a_cred;
-	int error;
+	int error = 0;
 
 	/*
-	 * XXX This is really random, especially the left shift by six,
-	 * and it exists only because of randomness in zfs_unix_to_v4
-	 * and zfs_zaccess_rwx in zfs_acl.c.
+	 * ZFS itself only knowns about VREAD, VWRITE, VEXEC and VAPPEND,
 	 */
-	if (accmode & VREAD)
-		zfs_mode |= S_IROTH;
-	if (accmode & VWRITE)
-		zfs_mode |= S_IWOTH;
-	if (accmode & VEXEC)
-		zfs_mode |= S_IXOTH;
-	zfs_mode <<= 6;
+	accmode = ap->a_accmode & (VREAD|VWRITE|VEXEC|VAPPEND);
+	if (accmode != 0)
+		error = zfs_access(vp, accmode, 0, cred, NULL);
 
-	KASSERT(VOP_ISLOCKED(vp));
-	error = zfs_access(vp, zfs_mode, 0, cred, NULL);
+	/*
+	 * VADMIN has to be handled by kauth_authorize_vnode().
+	 */
+	if (error == 0) {
+		accmode = ap->a_accmode & ~(VREAD|VWRITE|VEXEC|VAPPEND);
+		if (accmode != 0) {
+			error = kauth_authorize_vnode(cred,
+			KAUTH_ACCESS_ACTION(accmode, vp->v_type,
+			zp->z_mode & ALLPERMS), vp, NULL,
+			genfs_can_access(vp, cred, zp->z_uid,
+			zp->z_gid, zp->z_mode & ALLPERMS, NULL, accmode));
+		}
+	}
+
+	/*
+	 * For VEXEC, ensure that at least one execute bit is set for
+	 * non-directories.
+	 */
+	if (error == 0 && (ap->a_accmode & VEXEC) != 0 && vp->v_type != VDIR &&
+	(zp->z_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0) {
+		error = EACCES;
+	}
 
 	/* We expect EACCES as common error. */
 	if (error == EPERM)
 		error = EACCES;
 
-	return (error);
+	return error;
 }
 
 static int



CVS commit: src/sys/fs/union

2023-02-13 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Feb 13 08:39:40 UTC 2023

Modified Files:
src/sys/fs/union: union_vfsops.c

Log Message:
When mounting a union file system set its lower mount only on success.

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


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/fs/union/union_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/fs/union/union_vfsops.c
diff -u src/sys/fs/union/union_vfsops.c:1.86 src/sys/fs/union/union_vfsops.c:1.87
--- src/sys/fs/union/union_vfsops.c:1.86	Mon Feb  6 10:33:32 2023
+++ src/sys/fs/union/union_vfsops.c	Mon Feb 13 08:39:40 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: union_vfsops.c,v 1.86 2023/02/06 10:33:32 hannken Exp $	*/
+/*	$NetBSD: union_vfsops.c,v 1.87 2023/02/13 08:39:40 hannken Exp $	*/
 
 /*
  * Copyright (c) 1994 The Regents of the University of California.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.86 2023/02/06 10:33:32 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.87 2023/02/13 08:39:40 hannken Exp $");
 
 #include 
 #include 
@@ -255,15 +255,16 @@ union_mount(struct mount *mp, const char
 
 	mp->mnt_data = um;
 	vfs_getnewfsid(mp);
-	error = vfs_set_lowermount(mp, um->um_uppervp->v_mount);
-	if (error)
-		goto bad;
 
 	error = set_statvfs_info(path, UIO_USERSPACE, NULL, UIO_USERSPACE,
 	mp->mnt_op->vfs_name, mp, l);
 	if (error)
 		goto bad;
 
+	error = vfs_set_lowermount(mp, um->um_uppervp->v_mount);
+	if (error)
+		goto bad;
+
 	switch (um->um_op) {
 	case UNMNT_ABOVE:
 		cp = ":";



CVS commit: src/sys/fs/union

2023-02-13 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Feb 13 08:39:40 UTC 2023

Modified Files:
src/sys/fs/union: union_vfsops.c

Log Message:
When mounting a union file system set its lower mount only on success.

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


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/fs/union/union_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/fs/union

2023-02-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Feb  6 10:33:32 UTC 2023

Modified Files:
src/sys/fs/union: union_vfsops.c

Log Message:
Set IMNT_MPSAFE only if all lower layers have it set.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/fs/union/union_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/fs/union/union_vfsops.c
diff -u src/sys/fs/union/union_vfsops.c:1.85 src/sys/fs/union/union_vfsops.c:1.86
--- src/sys/fs/union/union_vfsops.c:1.85	Mon Nov 21 10:37:14 2022
+++ src/sys/fs/union/union_vfsops.c	Mon Feb  6 10:33:32 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: union_vfsops.c,v 1.85 2022/11/21 10:37:14 hannken Exp $	*/
+/*	$NetBSD: union_vfsops.c,v 1.86 2023/02/06 10:33:32 hannken Exp $	*/
 
 /*
  * Copyright (c) 1994 The Regents of the University of California.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.85 2022/11/21 10:37:14 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.86 2023/02/06 10:33:32 hannken Exp $");
 
 #include 
 #include 
@@ -198,7 +198,14 @@ union_mount(struct mount *mp, const char
 		goto bad;
 	}
 
-	mp->mnt_iflag |= IMNT_MPSAFE;
+	/*
+	 * This mount is mp-safe if both lower mounts are mp-safe.
+	 */
+
+	if (((um->um_lowervp == NULLVP) ||
+	(um->um_lowervp->v_mount->mnt_iflag & IMNT_MPSAFE)) &&
+	(um->um_uppervp->v_mount->mnt_iflag & IMNT_MPSAFE))
+		mp->mnt_iflag |= IMNT_MPSAFE;
 
 	/*
 	 * Unless the mount is readonly, ensure that the top layer



CVS commit: src/sys/fs/union

2023-02-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Feb  6 10:33:32 UTC 2023

Modified Files:
src/sys/fs/union: union_vfsops.c

Log Message:
Set IMNT_MPSAFE only if all lower layers have it set.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/fs/union/union_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/miscfs/nullfs

2023-02-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Feb  6 10:32:58 UTC 2023

Modified Files:
src/sys/miscfs/nullfs: null_vfsops.c

Log Message:
Set IMNT_MPSAFE only if the lower layer has it set.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/miscfs/nullfs/null_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/miscfs/nullfs

2023-02-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Feb  6 10:32:58 UTC 2023

Modified Files:
src/sys/miscfs/nullfs: null_vfsops.c

Log Message:
Set IMNT_MPSAFE only if the lower layer has it set.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/miscfs/nullfs/null_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/miscfs/nullfs/null_vfsops.c
diff -u src/sys/miscfs/nullfs/null_vfsops.c:1.100 src/sys/miscfs/nullfs/null_vfsops.c:1.101
--- src/sys/miscfs/nullfs/null_vfsops.c:1.100	Fri Nov  4 11:20:39 2022
+++ src/sys/miscfs/nullfs/null_vfsops.c	Mon Feb  6 10:32:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: null_vfsops.c,v 1.100 2022/11/04 11:20:39 hannken Exp $	*/
+/*	$NetBSD: null_vfsops.c,v 1.101 2023/02/06 10:32:58 hannken Exp $	*/
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: null_vfsops.c,v 1.100 2022/11/04 11:20:39 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: null_vfsops.c,v 1.101 2023/02/06 10:32:58 hannken Exp $");
 
 #include 
 #include 
@@ -138,7 +138,7 @@ nullfs_mount(struct mount *mp, const cha
 	/* Create the mount point. */
 	nmp = kmem_zalloc(sizeof(struct null_mount), KM_SLEEP);
 	mp->mnt_data = nmp;
-	mp->mnt_iflag |= IMNT_MPSAFE;
+	mp->mnt_iflag |= lowerrootvp->v_mount->mnt_iflag & IMNT_MPSAFE;
 	mp->mnt_iflag |= lowerrootvp->v_mount->mnt_iflag & IMNT_SHRLOOKUP;
 
 	/*



CVS commit: src/sys/dev

2023-01-13 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jan 13 15:46:40 UTC 2023

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

Log Message:
It is not sufficient to have a comment /* Sanity check the size. */,
also check the size is greater than zero and a multiple of DEV_BSIZE.

Reported-by: syzbot+318187e5124846542...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/dev/md.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/md.c
diff -u src/sys/dev/md.c:1.86 src/sys/dev/md.c:1.87
--- src/sys/dev/md.c:1.86	Sat Sep 24 23:20:13 2022
+++ src/sys/dev/md.c	Fri Jan 13 15:46:40 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: md.c,v 1.86 2022/09/24 23:20:13 thorpej Exp $	*/
+/*	$NetBSD: md.c,v 1.87 2023/01/13 15:46:40 hannken Exp $	*/
 
 /*
  * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.86 2022/09/24 23:20:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.87 2023/01/13 15:46:40 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_md.h"
@@ -589,10 +589,13 @@ md_ioctl_kalloc(struct md_softc *sc, str
 	vaddr_t addr;
 	vsize_t size;
 
-	mutex_exit(>sc_lock);
-
 	/* Sanity check the size. */
 	size = umd->md_size;
+	if (size < DEV_BSIZE || (size % DEV_BSIZE) != 0)
+		return EINVAL;
+
+	mutex_exit(>sc_lock);
+
 	addr = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_WIRED|UVM_KMF_ZERO);
 
 	mutex_enter(>sc_lock);



CVS commit: src/sys/dev

2023-01-13 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jan 13 15:46:40 UTC 2023

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

Log Message:
It is not sufficient to have a comment /* Sanity check the size. */,
also check the size is greater than zero and a multiple of DEV_BSIZE.

Reported-by: syzbot+318187e5124846542...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/dev/md.c

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



CVS commit: src/external/gpl3/binutils/usr.bin/c++filt

2023-01-03 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jan  3 18:30:33 UTC 2023

Modified Files:
src/external/gpl3/binutils/usr.bin/c++filt: Makefile

Log Message:
One more fix to build binutils with read-only source trees:

don't try to rebuild .../dist/binutils/doc/c++filt.1

Ok: Matthew Green


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/gpl3/binutils/usr.bin/c++filt/Makefile

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/binutils/usr.bin/c++filt/Makefile
diff -u src/external/gpl3/binutils/usr.bin/c++filt/Makefile:1.2 src/external/gpl3/binutils/usr.bin/c++filt/Makefile:1.3
--- src/external/gpl3/binutils/usr.bin/c++filt/Makefile:1.2	Tue Jan 26 19:37:47 2016
+++ src/external/gpl3/binutils/usr.bin/c++filt/Makefile	Tue Jan  3 18:30:33 2023
@@ -1,13 +1,8 @@
-#	$NetBSD: Makefile,v 1.2 2016/01/26 19:37:47 christos Exp $
+#	$NetBSD: Makefile,v 1.3 2023/01/03 18:30:33 hannken Exp $
 
 PROG=		c++filt
 CPPFLAGS+=	-DMAIN
-CLEANFILES+=	c++filt.1
 
 .include "${.CURDIR}/../common/Makefile.prog"
 
 .PATH: ${DIST}/libiberty
-
-c++filt.1: ${DIST}/binutils/doc/cxxfilt.man
-	${_MKTARGET_CREATE}
-	${TOOL_SED} -e "s/@PROGRAM@/${PROG}/" < $> > $@



CVS commit: src/external/gpl3/binutils/usr.bin/c++filt

2023-01-03 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jan  3 18:30:33 UTC 2023

Modified Files:
src/external/gpl3/binutils/usr.bin/c++filt: Makefile

Log Message:
One more fix to build binutils with read-only source trees:

don't try to rebuild .../dist/binutils/doc/c++filt.1

Ok: Matthew Green


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/gpl3/binutils/usr.bin/c++filt/Makefile

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



CVS commit: src/external/gpl3/binutils/dist/bfd

2023-01-02 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Jan  2 20:49:59 UTC 2023

Modified Files:
src/external/gpl3/binutils/dist/bfd: Makefile.in

Log Message:
Fix typo "zecho" -> "echo".


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/gpl3/binutils/dist/bfd/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/gpl3/binutils/dist/bfd/Makefile.in
diff -u src/external/gpl3/binutils/dist/bfd/Makefile.in:1.12 src/external/gpl3/binutils/dist/bfd/Makefile.in:1.13
--- src/external/gpl3/binutils/dist/bfd/Makefile.in:1.12	Mon Jan  2 00:55:45 2023
+++ src/external/gpl3/binutils/dist/bfd/Makefile.in	Mon Jan  2 20:49:59 2023
@@ -1781,7 +1781,7 @@ doc/$(am__dirstamp):
 	@: > doc/$(am__dirstamp)
 
 doc/bfd.info: doc/bfd.texi $(doc_bfd_TEXINFOS)
-	@zecho "NOT REBUILDING $@"
+	@echo "NOT REBUILDING $@"
 NetBSD_DISABLED_doc/bfd.info:
 	@test -f doc/$(am__dirstamp) || $(MAKE) $(AM_MAKEFLAGS) doc/$(am__dirstamp)
 	$(AM_V_MAKEINFO)restore=: && backupdir="$(am__leading_dot)am" && \



CVS commit: src/external/gpl3/binutils/dist/bfd

2023-01-02 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Jan  2 20:49:59 UTC 2023

Modified Files:
src/external/gpl3/binutils/dist/bfd: Makefile.in

Log Message:
Fix typo "zecho" -> "echo".


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/gpl3/binutils/dist/bfd/Makefile.in

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



CVS commit: src/sbin/fsck

2023-01-02 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Jan  2 16:08:13 UTC 2023

Modified Files:
src/sbin/fsck: partutil.c

Log Message:
Change getdiskinfo() to no longer infer the partition from the device name.
Since 2016-06-16 we create disk devices "<" as an alias
for "<" where "" is the raw partition.
These devices are treated as invalid partitions and a zero geometry
is returned.

Take the partition from "st_rdev" instead.

Fix for PR kern/57134: st_size of stat on vnd raw partition sometimes
is 0, causing newfs to fail


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sbin/fsck/partutil.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/partutil.c
diff -u src/sbin/fsck/partutil.c:1.17 src/sbin/fsck/partutil.c:1.18
--- src/sbin/fsck/partutil.c:1.17	Sat Sep 28 18:03:18 2019
+++ src/sbin/fsck/partutil.c	Mon Jan  2 16:08:13 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: partutil.c,v 1.17 2019/09/28 18:03:18 bad Exp $	*/
+/*	$NetBSD: partutil.c,v 1.18 2023/01/02 16:08:13 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: partutil.c,v 1.17 2019/09/28 18:03:18 bad Exp $");
+__RCSID("$NetBSD: partutil.c,v 1.18 2023/01/02 16:08:13 hannken Exp $");
 
 #include 
 #include 
@@ -155,9 +155,8 @@ getdiskinfo(const char *s, int fd, const
 	if (stat(s, ) == -1)
 		return 0;
 
-	ptn = strchr(s, '\0')[-1] - 'a';
-	if ((unsigned)ptn >= lp->d_npartitions ||
-	(devminor_t)ptn != DISKPART(sb.st_rdev))
+	ptn = DISKPART(sb.st_rdev);
+	if (ptn < 0 || ptn >= lp->d_npartitions)
 		return 0;
 
 	pp = >d_partitions[ptn];



CVS commit: src/sbin/fsck

2023-01-02 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Jan  2 16:08:13 UTC 2023

Modified Files:
src/sbin/fsck: partutil.c

Log Message:
Change getdiskinfo() to no longer infer the partition from the device name.
Since 2016-06-16 we create disk devices "<" as an alias
for "<" where "" is the raw partition.
These devices are treated as invalid partitions and a zero geometry
is returned.

Take the partition from "st_rdev" instead.

Fix for PR kern/57134: st_size of stat on vnd raw partition sometimes
is 0, causing newfs to fail


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sbin/fsck/partutil.c

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



CVS commit: src/sys/nfs

2022-12-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Dec 20 09:40:09 UTC 2022

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

Log Message:
When partitioning a mbuf chain with m_split() the last mbuf of the returned
tail chain is not necessarily the same as the last mbuf of the initial chain.

Always set "slp->ns_rawend" to the last mbuf of the tail chain to prevent
mbuf leaks and corruption.


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

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

Modified files:

Index: src/sys/nfs/nfs_srvsocket.c
diff -u src/sys/nfs/nfs_srvsocket.c:1.4 src/sys/nfs/nfs_srvsocket.c:1.5
--- src/sys/nfs/nfs_srvsocket.c:1.4	Thu Sep  3 20:59:12 2009
+++ src/sys/nfs/nfs_srvsocket.c	Tue Dec 20 09:40:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_srvsocket.c,v 1.4 2009/09/03 20:59:12 tls Exp $	*/
+/*	$NetBSD: nfs_srvsocket.c,v 1.5 2022/12/20 09:40:09 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_srvsocket.c,v 1.4 2009/09/03 20:59:12 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_srvsocket.c,v 1.5 2022/12/20 09:40:09 hannken Exp $");
 
 #include 
 #include 
@@ -323,8 +323,9 @@ nfsrv_getstream(struct nfssvc_sock *slp,
 			}
 			m_claimm(recm, _mowner);
 			slp->ns_raw = m;
-			if (m->m_next == NULL)
-slp->ns_rawend = m;
+			while (m->m_next)
+m = m->m_next;
+			slp->ns_rawend = m;
 			slp->ns_cc -= slp->ns_reclen;
 			slp->ns_reclen = 0;
 		} else {



CVS commit: src/sys/nfs

2022-12-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Dec 20 09:40:09 UTC 2022

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

Log Message:
When partitioning a mbuf chain with m_split() the last mbuf of the returned
tail chain is not necessarily the same as the last mbuf of the initial chain.

Always set "slp->ns_rawend" to the last mbuf of the tail chain to prevent
mbuf leaks and corruption.


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

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



CVS commit: src/sys

2022-12-09 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Dec  9 10:33:18 UTC 2022

Modified Files:
src/sys/kern: vfs_mount.c
src/sys/miscfs/genfs: layer_vfsops.c

Log Message:
Harden layered file systems usage of field "mnt_lower" against
forced unmounts of the lower layer.

- Dont allow "dead_rootmount" as lower layer.

- Take file system busy before a vfs operation walks down the stack.

Reported-by: syzbot+27b35e5675b1753ce...@syzkaller.appspotmail.com
Reported-by: syzbot+99071492e3de2eff4...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.55 -r1.56 src/sys/miscfs/genfs/layer_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/kern/vfs_mount.c
diff -u src/sys/kern/vfs_mount.c:1.100 src/sys/kern/vfs_mount.c:1.101
--- src/sys/kern/vfs_mount.c:1.100	Thu Nov 10 10:55:00 2022
+++ src/sys/kern/vfs_mount.c	Fri Dec  9 10:33:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.100 2022/11/10 10:55:00 hannken Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.101 2022/12/09 10:33:18 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.100 2022/11/10 10:55:00 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.101 2022/12/09 10:33:18 hannken Exp $");
 
 #include 
 #include 
@@ -91,6 +91,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,
 #include 
 #include 
 
+#include 
 #include 
 #include 
 
@@ -418,6 +419,8 @@ vfs_set_lowermount(struct mount *mp, str
 #endif
 
 	if (lowermp) {
+		if (lowermp == dead_rootmount)
+			return ENOENT;
 		error = vfs_busy(lowermp);
 		if (error)
 			return error;

Index: src/sys/miscfs/genfs/layer_vfsops.c
diff -u src/sys/miscfs/genfs/layer_vfsops.c:1.55 src/sys/miscfs/genfs/layer_vfsops.c:1.56
--- src/sys/miscfs/genfs/layer_vfsops.c:1.55	Mon Jul 18 04:30:30 2022
+++ src/sys/miscfs/genfs/layer_vfsops.c	Fri Dec  9 10:33:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: layer_vfsops.c,v 1.55 2022/07/18 04:30:30 thorpej Exp $	*/
+/*	$NetBSD: layer_vfsops.c,v 1.56 2022/12/09 10:33:18 hannken Exp $	*/
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -74,7 +74,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.55 2022/07/18 04:30:30 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.56 2022/12/09 10:33:18 hannken Exp $");
 
 #include 
 #include 
@@ -146,8 +146,15 @@ layerfs_root(struct mount *mp, int lktyp
 int
 layerfs_quotactl(struct mount *mp, struct quotactl_args *args)
 {
+	int error;
+
+	error = vfs_busy(mp);
+	if (error == 0) {
+		error = VFS_QUOTACTL(mp->mnt_lower, args);
+		vfs_unbusy(mp);
+	}
 
-	return VFS_QUOTACTL(mp->mnt_lower, args);
+	return error;
 }
 
 int
@@ -157,7 +164,11 @@ layerfs_statvfs(struct mount *mp, struct
 	int error;
 
 	sbuf = kmem_zalloc(sizeof(*sbuf), KM_SLEEP);
-	error = VFS_STATVFS(mp->mnt_lower, sbuf);
+	error = vfs_busy(mp);
+	if (error == 0) {
+		error = VFS_STATVFS(mp->mnt_lower, sbuf);
+		vfs_unbusy(mp);
+	}
 	if (error) {
 		goto done;
 	}
@@ -234,7 +245,11 @@ layerfs_vget(struct mount *mp, ino_t ino
 	struct vnode *vp;
 	int error;
 
-	error = VFS_VGET(mp->mnt_lower, ino, lktype, );
+	error = vfs_busy(mp);
+	if (error == 0) {
+		error = VFS_VGET(mp->mnt_lower, ino, lktype, );
+		vfs_unbusy(mp);
+	}
 	if (error) {
 		*vpp = NULL;
 		return error;
@@ -262,7 +277,11 @@ layerfs_fhtovp(struct mount *mp, struct 
 	struct vnode *vp;
 	int error;
 
-	error = VFS_FHTOVP(mp->mnt_lower, fidp, lktype, );
+	error = vfs_busy(mp);
+	if (error == 0) {
+		error = VFS_FHTOVP(mp->mnt_lower, fidp, lktype, );
+		vfs_unbusy(mp);
+	}
 	if (error) {
 		*vpp = NULL;
 		return error;



CVS commit: src/sys

2022-12-09 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Dec  9 10:33:18 UTC 2022

Modified Files:
src/sys/kern: vfs_mount.c
src/sys/miscfs/genfs: layer_vfsops.c

Log Message:
Harden layered file systems usage of field "mnt_lower" against
forced unmounts of the lower layer.

- Dont allow "dead_rootmount" as lower layer.

- Take file system busy before a vfs operation walks down the stack.

Reported-by: syzbot+27b35e5675b1753ce...@syzkaller.appspotmail.com
Reported-by: syzbot+99071492e3de2eff4...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.55 -r1.56 src/sys/miscfs/genfs/layer_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/fs/union

2022-11-21 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Nov 21 10:37:14 UTC 2022

Modified Files:
src/sys/fs/union: union_vfsops.c

Log Message:
When testing whiteout support on the underlying file system
union_mount() should not use a NULL componentname as not all
file systems can handle it.

Use static { LOOKUP, NOCRED } componentname instead.

Reported-by: syzbot+ecda308a1dd965283...@syzkaller.appspotmail.com
Reported-by: syzbot+9b687847ee5f43e94...@syzkaller.appspotmail.com
Reported-by: syzbot+9f9d1a841734f9f50...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/fs/union/union_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/fs/union/union_vfsops.c
diff -u src/sys/fs/union/union_vfsops.c:1.84 src/sys/fs/union/union_vfsops.c:1.85
--- src/sys/fs/union/union_vfsops.c:1.84	Fri Nov  4 11:20:39 2022
+++ src/sys/fs/union/union_vfsops.c	Mon Nov 21 10:37:14 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: union_vfsops.c,v 1.84 2022/11/04 11:20:39 hannken Exp $	*/
+/*	$NetBSD: union_vfsops.c,v 1.85 2022/11/21 10:37:14 hannken Exp $	*/
 
 /*
  * Copyright (c) 1994 The Regents of the University of California.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.84 2022/11/04 11:20:39 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.85 2022/11/21 10:37:14 hannken Exp $");
 
 #include 
 #include 
@@ -205,9 +205,13 @@ union_mount(struct mount *mp, const char
 	 * supports whiteout operations
 	 */
 	if ((mp->mnt_flag & MNT_RDONLY) == 0) {
+		static struct componentname nullcn = {
+			.cn_nameiop = LOOKUP,
+			.cn_cred = NOCRED
+		};
+
 		vn_lock(um->um_uppervp, LK_EXCLUSIVE | LK_RETRY);
-		error = VOP_WHITEOUT(um->um_uppervp,
-		(struct componentname *) 0, LOOKUP);
+		error = VOP_WHITEOUT(um->um_uppervp, , LOOKUP);
 		VOP_UNLOCK(um->um_uppervp);
 		if (error)
 			goto bad;



CVS commit: src/sys/fs/union

2022-11-21 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Nov 21 10:37:14 UTC 2022

Modified Files:
src/sys/fs/union: union_vfsops.c

Log Message:
When testing whiteout support on the underlying file system
union_mount() should not use a NULL componentname as not all
file systems can handle it.

Use static { LOOKUP, NOCRED } componentname instead.

Reported-by: syzbot+ecda308a1dd965283...@syzkaller.appspotmail.com
Reported-by: syzbot+9b687847ee5f43e94...@syzkaller.appspotmail.com
Reported-by: syzbot+9f9d1a841734f9f50...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/fs/union/union_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/kern

2022-11-10 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Nov 10 10:55:01 UTC 2022

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

Log Message:
If built with DEBUG Limit the depth of file system stack so kernel sanitizers
may stress mount/unmount without exhausting the kernel stack.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/kern/vfs_mount.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_mount.c
diff -u src/sys/kern/vfs_mount.c:1.99 src/sys/kern/vfs_mount.c:1.100
--- src/sys/kern/vfs_mount.c:1.99	Fri Nov  4 11:20:39 2022
+++ src/sys/kern/vfs_mount.c	Thu Nov 10 10:55:00 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.99 2022/11/04 11:20:39 hannken Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.100 2022/11/10 10:55:00 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.99 2022/11/04 11:20:39 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.100 2022/11/10 10:55:00 hannken Exp $");
 
 #include 
 #include 
@@ -403,6 +403,20 @@ vfs_set_lowermount(struct mount *mp, str
 	struct mount *oldlowermp;
 	int error;
 
+#ifdef DEBUG
+	/*
+	 * Limit the depth of file system stack so kernel sanitizers
+	 * may stress mount/unmount without exhausting the kernel stack.
+	 */
+	int depth;
+	struct mount *mp2;
+
+	for (depth = 0, mp2 = lowermp; mp2; depth++, mp2 = mp2->mnt_lower) {
+		if (depth == 23)
+			return EINVAL;
+	}
+#endif
+
 	if (lowermp) {
 		error = vfs_busy(lowermp);
 		if (error)



CVS commit: src/sys/kern

2022-11-10 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Nov 10 10:55:01 UTC 2022

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

Log Message:
If built with DEBUG Limit the depth of file system stack so kernel sanitizers
may stress mount/unmount without exhausting the kernel stack.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/kern/vfs_mount.c

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



CVS commit: src/sys/fs/tmpfs

2022-11-10 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Nov 10 10:54:14 UTC 2022

Modified Files:
src/sys/fs/tmpfs: tmpfs_vfsops.c

Log Message:
Tmpfs_mount() uses tmpfs_unmount() for cleanup if set_statvfs_info() fails.
This will not work as tmpfs_unmount() needs a suspended file system.

Just call set_statvfs_info() before allocating the root vnode and add
and use a common error exit label.

Reported-by: syzbot+343f2bfea65a32ab4...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/fs/tmpfs/tmpfs_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/fs/tmpfs/tmpfs_vfsops.c
diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.77 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.78
--- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.77	Sat Apr  4 20:49:30 2020
+++ src/sys/fs/tmpfs/tmpfs_vfsops.c	Thu Nov 10 10:54:14 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_vfsops.c,v 1.77 2020/04/04 20:49:30 ad Exp $	*/
+/*	$NetBSD: tmpfs_vfsops.c,v 1.78 2022/11/10 10:54:14 hannken Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.77 2020/04/04 20:49:30 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.78 2022/11/10 10:54:14 hannken Exp $");
 
 #include 
 #include 
@@ -196,6 +196,11 @@ tmpfs_mount(struct mount *mp, const char
 	tmpfs_mntmem_init(tmp, memlimit);
 	mp->mnt_data = tmp;
 
+	error = set_statvfs_info(path, UIO_USERSPACE, "tmpfs", UIO_SYSSPACE,
+	mp->mnt_op->vfs_name, mp, curlwp);
+	if (error)
+		goto errout;
+
 	/* Allocate the root node. */
 	vattr_null();
 	va.va_type = VDIR;
@@ -203,13 +208,8 @@ tmpfs_mount(struct mount *mp, const char
 	va.va_uid = args->ta_root_uid;
 	va.va_gid = args->ta_root_gid;
 	error = vcache_new(mp, NULL, , NOCRED, NULL, );
-	if (error) {
-		mp->mnt_data = NULL;
-		tmpfs_mntmem_destroy(tmp);
-		mutex_destroy(>tm_lock);
-		kmem_free(tmp, sizeof(*tmp));
-		return error;
-	}
+	if (error)
+		goto errout;
 	KASSERT(vp != NULL);
 	root = VP_TO_TMPFS_NODE(vp);
 	KASSERT(root != NULL);
@@ -224,11 +224,14 @@ tmpfs_mount(struct mount *mp, const char
 	tmp->tm_root = root;
 	vrele(vp);
 
-	error = set_statvfs_info(path, UIO_USERSPACE, "tmpfs", UIO_SYSSPACE,
-	mp->mnt_op->vfs_name, mp, curlwp);
-	if (error) {
-		(void)tmpfs_unmount(mp, MNT_FORCE);
-	}
+	return 0;
+
+errout:
+	mp->mnt_data = NULL;
+	tmpfs_mntmem_destroy(tmp);
+	mutex_destroy(>tm_lock);
+	kmem_free(tmp, sizeof(*tmp));
+
 	return error;
 }
 



CVS commit: src/sys/fs/tmpfs

2022-11-10 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Nov 10 10:54:14 UTC 2022

Modified Files:
src/sys/fs/tmpfs: tmpfs_vfsops.c

Log Message:
Tmpfs_mount() uses tmpfs_unmount() for cleanup if set_statvfs_info() fails.
This will not work as tmpfs_unmount() needs a suspended file system.

Just call set_statvfs_info() before allocating the root vnode and add
and use a common error exit label.

Reported-by: syzbot+343f2bfea65a32ab4...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/fs/tmpfs/tmpfs_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/ufs/ffs

2022-11-10 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Nov 10 10:53:29 UTC 2022

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

Log Message:
Some changes to "fs->fs_fmod" and "fs->fs_clean":
- clear "fs->fs_fmod" after reading the super block.
- assert we don't write a super block when mounted read-only.
- make sure "fs->fs_clean" is one of FS_ISCLEAN or FS_WASCLEAN.
- print "file system not clean" on every mount.

Should fix PR kern/57010: ffs: mounting unclean non-root fs read-only
causes spurious write to superblock


To generate a diff of this commit:
cvs rdiff -u -r1.376 -r1.377 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.376 src/sys/ufs/ffs/ffs_vfsops.c:1.377
--- src/sys/ufs/ffs/ffs_vfsops.c:1.376	Sat Apr 16 08:00:55 2022
+++ src/sys/ufs/ffs/ffs_vfsops.c	Thu Nov 10 10:53:29 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.376 2022/04/16 08:00:55 hannken Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.377 2022/11/10 10:53:29 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.376 2022/04/16 08:00:55 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.377 2022/11/10 10:53:29 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -683,7 +683,8 @@ ffs_mount(struct mount *mp, const char *
 			}
 #endif
 			fs->fs_ronly = 0;
-			fs->fs_clean <<= 1;
+			fs->fs_clean =
+			fs->fs_clean == FS_ISCLEAN ? FS_WASCLEAN : 0;
 			fs->fs_fmod = 1;
 #ifdef WAPBL
 			if (fs->fs_flags & FS_DOWAPBL) {
@@ -743,20 +744,22 @@ ffs_mount(struct mount *mp, const char *
 	DPRINTF("set_statvfs_info returned %d", error);
 	}
 	fs->fs_flags &= ~FS_DOSOFTDEP;
-	if (fs->fs_fmod != 0) {	/* XXX */
+
+	if ((fs->fs_ronly && (fs->fs_clean & FS_ISCLEAN) == 0) ||
+	(!fs->fs_ronly && (fs->fs_clean & FS_WASCLEAN) == 0)) {
+		printf("%s: file system not clean (fs_clean=%#x); "
+		"please fsck(8)\n", mp->mnt_stat.f_mntfromname,
+		fs->fs_clean);
+	}
+
+	if (fs->fs_fmod != 0) {
 		int err;
 
-		fs->fs_fmod = 0;
+		KASSERT(!fs->fs_ronly);
+
 		if (fs->fs_clean & FS_WASCLEAN)
 			fs->fs_time = time_second;
-		else {
-			printf("%s: file system not clean (fs_clean=%#x); "
-			"please fsck(8)\n", mp->mnt_stat.f_mntfromname,
-			fs->fs_clean);
-			printf("%s: lost blocks %" PRId64 " files %d\n",
-			mp->mnt_stat.f_mntfromname, fs->fs_pendingblocks,
-			fs->fs_pendinginodes);
-		}
+		fs->fs_fmod = 0;
 		err = UFS_WAPBL_BEGIN(mp);
 		if (err == 0) {
 			(void) ffs_cgupdate(ump, MNT_WAIT);
@@ -1346,6 +1349,7 @@ ffs_mountfs(struct vnode *devvp, struct 
 		}
 	}
 
+	fs->fs_fmod = 0;
 	if (fs->fs_pendingblocks != 0 || fs->fs_pendinginodes != 0) {
 		fs->fs_pendingblocks = 0;
 		fs->fs_pendinginodes = 0;
@@ -1427,7 +1431,8 @@ ffs_mountfs(struct vnode *devvp, struct 
 	/* Don't bump fs_clean if we're replaying journal */
 	if (!((fs->fs_flags & FS_DOWAPBL) && (fs->fs_clean & FS_WASCLEAN))) {
 		if (ronly == 0) {
-			fs->fs_clean <<= 1;
+			fs->fs_clean =
+			fs->fs_clean == FS_ISCLEAN ? FS_WASCLEAN : 0;
 			fs->fs_fmod = 1;
 		}
 	}



CVS commit: src/sys/ufs/ffs

2022-11-10 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Nov 10 10:53:29 UTC 2022

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

Log Message:
Some changes to "fs->fs_fmod" and "fs->fs_clean":
- clear "fs->fs_fmod" after reading the super block.
- assert we don't write a super block when mounted read-only.
- make sure "fs->fs_clean" is one of FS_ISCLEAN or FS_WASCLEAN.
- print "file system not clean" on every mount.

Should fix PR kern/57010: ffs: mounting unclean non-root fs read-only
causes spurious write to superblock


To generate a diff of this commit:
cvs rdiff -u -r1.376 -r1.377 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

2022-11-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Nov  4 11:20:40 UTC 2022

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_ctldir.c
src/sys/fs/union: union_vfsops.c
src/sys/kern: vfs_mount.c vfs_trans.c
src/sys/miscfs/nullfs: null_vfsops.c
src/sys/miscfs/overlay: overlay_vfsops.c
src/sys/miscfs/umapfs: umap_vfsops.c
src/sys/sys: mount.h

Log Message:
Add a helper to set or clear lower mount and use it.
Always add a reference to the lower mount.

Ride 9.99.105


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c
cvs rdiff -u -r1.83 -r1.84 src/sys/fs/union/union_vfsops.c
cvs rdiff -u -r1.98 -r1.99 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.69 -r1.70 src/sys/kern/vfs_trans.c
cvs rdiff -u -r1.99 -r1.100 src/sys/miscfs/nullfs/null_vfsops.c
cvs rdiff -u -r1.72 -r1.73 src/sys/miscfs/overlay/overlay_vfsops.c
cvs rdiff -u -r1.103 -r1.104 src/sys/miscfs/umapfs/umap_vfsops.c
cvs rdiff -u -r1.239 -r1.240 src/sys/sys/mount.h

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



CVS commit: src

2022-11-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Nov  4 11:20:40 UTC 2022

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_ctldir.c
src/sys/fs/union: union_vfsops.c
src/sys/kern: vfs_mount.c vfs_trans.c
src/sys/miscfs/nullfs: null_vfsops.c
src/sys/miscfs/overlay: overlay_vfsops.c
src/sys/miscfs/umapfs: umap_vfsops.c
src/sys/sys: mount.h

Log Message:
Add a helper to set or clear lower mount and use it.
Always add a reference to the lower mount.

Ride 9.99.105


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c
cvs rdiff -u -r1.83 -r1.84 src/sys/fs/union/union_vfsops.c
cvs rdiff -u -r1.98 -r1.99 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.69 -r1.70 src/sys/kern/vfs_trans.c
cvs rdiff -u -r1.99 -r1.100 src/sys/miscfs/nullfs/null_vfsops.c
cvs rdiff -u -r1.72 -r1.73 src/sys/miscfs/overlay/overlay_vfsops.c
cvs rdiff -u -r1.103 -r1.104 src/sys/miscfs/umapfs/umap_vfsops.c
cvs rdiff -u -r1.239 -r1.240 src/sys/sys/mount.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/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c:1.13 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c:1.14
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c:1.13	Sun Jul  4 11:25:07 2021
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c	Fri Nov  4 11:20:39 2022
@@ -1343,7 +1343,9 @@ sfs_snapshot_mount(vnode_t *vp, const ch
 	set_statvfs_info(path, UIO_SYSSPACE, vfsp->mnt_stat.f_mntfromname,
 	UIO_SYSSPACE, vfsp->mnt_op->vfs_name, vfsp, curlwp);
 
-	vfsp->mnt_lower = vp->v_vfsp;
+	error = vfs_set_lowermount(vfsp, vp->v_vfsp);
+	if (error)
+		goto out;
 
 	mountlist_append(vfsp);
 	vref(vp);

Index: src/sys/fs/union/union_vfsops.c
diff -u src/sys/fs/union/union_vfsops.c:1.83 src/sys/fs/union/union_vfsops.c:1.84
--- src/sys/fs/union/union_vfsops.c:1.83	Mon Sep 12 13:11:41 2022
+++ src/sys/fs/union/union_vfsops.c	Fri Nov  4 11:20:39 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: union_vfsops.c,v 1.83 2022/09/12 13:11:41 christos Exp $	*/
+/*	$NetBSD: union_vfsops.c,v 1.84 2022/11/04 11:20:39 hannken Exp $	*/
 
 /*
  * Copyright (c) 1994 The Regents of the University of California.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.83 2022/09/12 13:11:41 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.84 2022/11/04 11:20:39 hannken Exp $");
 
 #include 
 #include 
@@ -244,7 +244,9 @@ union_mount(struct mount *mp, const char
 
 	mp->mnt_data = um;
 	vfs_getnewfsid(mp);
-	mp->mnt_lower = um->um_uppervp->v_mount;
+	error = vfs_set_lowermount(mp, um->um_uppervp->v_mount);
+	if (error)
+		goto bad;
 
 	error = set_statvfs_info(path, UIO_USERSPACE, NULL, UIO_USERSPACE,
 	mp->mnt_op->vfs_name, mp, l);

Index: src/sys/kern/vfs_mount.c
diff -u src/sys/kern/vfs_mount.c:1.98 src/sys/kern/vfs_mount.c:1.99
--- src/sys/kern/vfs_mount.c:1.98	Wed Oct 26 23:39:10 2022
+++ src/sys/kern/vfs_mount.c	Fri Nov  4 11:20:39 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.98 2022/10/26 23:39:10 riastradh Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.99 2022/11/04 11:20:39 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.98 2022/10/26 23:39:10 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.99 2022/11/04 11:20:39 hannken Exp $");
 
 #include 
 #include 
@@ -391,6 +391,37 @@ vfs_unbusy(struct mount *mp)
 	vfs_rele(mp);
 }
 
+/*
+ * Change a file systems lower mount.
+ * Both the current and the new lower mount may be NULL.  The caller
+ * guarantees exclusive access to the mount and holds a pre-existing
+ * reference to the new lower mount.
+ */
+int
+vfs_set_lowermount(struct mount *mp, struct mount *lowermp)
+{
+	struct mount *oldlowermp;
+	int error;
+
+	if (lowermp) {
+		error = vfs_busy(lowermp);
+		if (error)
+			return error;
+		vfs_ref(lowermp);
+	}
+
+	oldlowermp = mp->mnt_lower;
+	mp->mnt_lower = lowermp;
+
+	if (lowermp)
+		vfs_unbusy(lowermp);
+
+	if (oldlowermp)
+		vfs_rele(oldlowermp);
+
+	return 0;
+}
+
 struct vnode_iterator {
 	vnode_impl_t vi_vnode;
 };
@@ -874,6 +905,7 @@ err_mounted:
 	mutex_exit(mp->mnt_updating);
 	if (error2 == 0)
 		vfs_resume(mp);
+	vfs_set_lowermount(mp, NULL);
 	vfs_rele(mp);
 
 	return error;
@@ -959,6 +991,7 @@ dounmount(struct mount *mp, int flags, s
 		panic("unmount: dangling vnode");
 	vfs_hooks_unmount(mp);
 
+	vfs_set_lowermount(mp, NULL);
 	vfs_rele(mp);	/* reference from mount() */
 	if (coveredvp != NULLVP) {
 		vrele(coveredvp);

Index: src/sys/kern/vfs_trans.c
diff -u src/sys/kern/vfs_trans.c:1.69 src/sys/kern/vfs_trans.c:1.70
--- src/sys/kern/vfs_trans.c:1.69	Wed Oct 26 23:39:43 2022
+++ 

CVS commit: src/sys/kern

2022-08-26 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Aug 26 11:03:53 UTC 2022

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

Log Message:
Two defects in vfs_getnewfsid():

- Parallel mounts may get the same fsid.  Always increment "xxxfs_mntid"
  to make it unlikely.

- Directly walk "mountlist" to prevent a rare deadlock where one thread
  holds a vnode locked, calls vfs_getnewfsid() and the iterator has to
  wait for a suspended file system while the thread suspending needs
  this vnode lock.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/kern/vfs_mount.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_mount.c
diff -u src/sys/kern/vfs_mount.c:1.95 src/sys/kern/vfs_mount.c:1.96
--- src/sys/kern/vfs_mount.c:1.95	Mon Aug 22 09:14:24 2022
+++ src/sys/kern/vfs_mount.c	Fri Aug 26 11:03:53 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.95 2022/08/22 09:14:24 hannken Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.96 2022/08/26 11:03:53 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.95 2022/08/22 09:14:24 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.96 2022/08/26 11:03:53 hannken Exp $");
 
 #include 
 #include 
@@ -220,23 +220,41 @@ void
 vfs_getnewfsid(struct mount *mp)
 {
 	static u_short xxxfs_mntid;
+	struct mountlist_entry *me;
 	fsid_t tfsid;
 	int mtype;
 
 	mutex_enter(_lock);
-	mtype = makefstype(mp->mnt_op->vfs_name);
-	mp->mnt_stat.f_fsidx.__fsid_val[0] = makedev(mtype, 0);
-	mp->mnt_stat.f_fsidx.__fsid_val[1] = mtype;
-	mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0];
 	if (xxxfs_mntid == 0)
 		++xxxfs_mntid;
+	mtype = makefstype(mp->mnt_op->vfs_name);
 	tfsid.__fsid_val[0] = makedev(mtype & 0xff, xxxfs_mntid);
 	tfsid.__fsid_val[1] = mtype;
-	while (vfs_getvfs()) {
-		tfsid.__fsid_val[0]++;
-		xxxfs_mntid++;
+	/* Always increment to not return the same fsid to parallel mounts. */
+	xxxfs_mntid++;
+
+	/*
+	 * Directly walk mountlist to prevent deadlock through
+	 * mountlist_iterator_next() -> vfs_busy().
+	 */
+	mutex_enter(_lock);
+	for (me = TAILQ_FIRST(); me != TAILQ_END(); ) {
+		if (me->me_type == ME_MOUNT &&
+		me->me_mount->mnt_stat.f_fsidx.__fsid_val[0] ==
+		tfsid.__fsid_val[0] &&
+		me->me_mount->mnt_stat.f_fsidx.__fsid_val[1] ==
+		tfsid.__fsid_val[1]) {
+			tfsid.__fsid_val[0]++;
+			xxxfs_mntid++;
+			me = TAILQ_FIRST();
+		} else {
+			me = TAILQ_NEXT(me, me_list);
+		}
 	}
+	mutex_exit(_lock);
+
 	mp->mnt_stat.f_fsidx.__fsid_val[0] = tfsid.__fsid_val[0];
+	mp->mnt_stat.f_fsidx.__fsid_val[1] = tfsid.__fsid_val[1];
 	mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0];
 	mutex_exit(_lock);
 }



CVS commit: src/sys/kern

2022-08-26 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Aug 26 11:03:53 UTC 2022

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

Log Message:
Two defects in vfs_getnewfsid():

- Parallel mounts may get the same fsid.  Always increment "xxxfs_mntid"
  to make it unlikely.

- Directly walk "mountlist" to prevent a rare deadlock where one thread
  holds a vnode locked, calls vfs_getnewfsid() and the iterator has to
  wait for a suspended file system while the thread suspending needs
  this vnode lock.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/kern/vfs_mount.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

2022-08-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Aug 22 13:57:24 UTC 2022

Modified Files:
src/sys/arch/amd64/include: asan.h
src/sys/arch/x86/x86: kgdb_machdep.c

Log Message:
Sprinkle "#include ", kernel ALL/amd64
compiles again.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amd64/include/asan.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/x86/kgdb_machdep.c

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

Modified files:

Index: src/sys/arch/amd64/include/asan.h
diff -u src/sys/arch/amd64/include/asan.h:1.10 src/sys/arch/amd64/include/asan.h:1.11
--- src/sys/arch/amd64/include/asan.h:1.10	Sat Aug 20 23:15:36 2022
+++ src/sys/arch/amd64/include/asan.h	Mon Aug 22 13:57:24 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.h,v 1.10 2022/08/20 23:15:36 riastradh Exp $	*/
+/*	$NetBSD: asan.h,v 1.11 2022/08/22 13:57:24 hannken Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net
@@ -37,6 +37,8 @@
 
 #include 
 
+#include 
+
 #ifdef __HAVE_PCPU_AREA
 #error "PCPU area not allowed with KASAN"
 #endif

Index: src/sys/arch/x86/x86/kgdb_machdep.c
diff -u src/sys/arch/x86/x86/kgdb_machdep.c:1.5 src/sys/arch/x86/x86/kgdb_machdep.c:1.6
--- src/sys/arch/x86/x86/kgdb_machdep.c:1.5	Sun Apr 21 06:37:21 2019
+++ src/sys/arch/x86/x86/kgdb_machdep.c	Mon Aug 22 13:57:24 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kgdb_machdep.c,v 1.5 2019/04/21 06:37:21 maxv Exp $	*/
+/*	$NetBSD: kgdb_machdep.c,v 1.6 2022/08/22 13:57:24 hannken Exp $	*/
 
 /*
  * Copyright (c) 1997, 2017 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.5 2019/04/21 06:37:21 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.6 2022/08/22 13:57:24 hannken Exp $");
 
 #include "opt_ddb.h"
 
@@ -70,6 +70,7 @@ __KERNEL_RCSID(0, "$NetBSD: kgdb_machdep
 #include 
 #include 
 
+#include 
 #include 
 #include 
 



CVS commit: src/sys/arch

2022-08-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Aug 22 13:57:24 UTC 2022

Modified Files:
src/sys/arch/amd64/include: asan.h
src/sys/arch/x86/x86: kgdb_machdep.c

Log Message:
Sprinkle "#include ", kernel ALL/amd64
compiles again.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amd64/include/asan.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/x86/kgdb_machdep.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

2022-08-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Aug 22 09:14:59 UTC 2022

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

Log Message:
Use fstrans_start()/fstrans_done() to cross the mount in lookup_crossmount().
It is sufficient here as it prevents the file system from unmount and
makes it safe to use VFS_ROOT() here.

Removes a rare deadlock where one thread has "foundobj" locked and waits
for "foundobj->v_mountedhere" to resume while the thread holding the file
system suspended tries to lookup a node and needs a lock on "foundobj".


To generate a diff of this commit:
cvs rdiff -u -r1.231 -r1.232 src/sys/kern/vfs_lookup.c

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

Modified files:

Index: src/sys/kern/vfs_lookup.c
diff -u src/sys/kern/vfs_lookup.c:1.231 src/sys/kern/vfs_lookup.c:1.232
--- src/sys/kern/vfs_lookup.c:1.231	Thu Feb 10 10:59:12 2022
+++ src/sys/kern/vfs_lookup.c	Mon Aug 22 09:14:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_lookup.c,v 1.231 2022/02/10 10:59:12 hannken Exp $	*/
+/*	$NetBSD: vfs_lookup.c,v 1.232 2022/08/22 09:14:59 hannken Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.231 2022/02/10 10:59:12 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.232 2022/08/22 09:14:59 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_magiclinks.h"
@@ -51,6 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -948,31 +949,16 @@ lookup_crossmount(struct namei_state *st
 			vrele(foundobj);
 			foundobj = vp;
 		} else {
-			/* First get the vnode stable. */
-			error = vn_lock(foundobj, LK_SHARED);
-			if (error != 0) {
-vrele(foundobj);
-foundobj = NULL;
-break;
-			}
-
-			/*
-			 * Check to see if something is still mounted on it.
-			 */
-			if ((mp = foundobj->v_mountedhere) == NULL) {
-VOP_UNLOCK(foundobj);
-break;
+			/* First get the vnodes mount stable. */
+			while ((mp = foundobj->v_mountedhere) != NULL) {
+fstrans_start(mp);
+if (fstrans_held(mp) &&
+mp == foundobj->v_mountedhere) {
+	break;
+}
+fstrans_done(mp);
 			}
-
-			/*
-			 * Get a reference to the mountpoint, and unlock
-			 * foundobj.
-			 */
-			error = vfs_busy(mp);
-			VOP_UNLOCK(foundobj);
-			if (error != 0) {
-vrele(foundobj);
-foundobj = NULL;
+			if (mp == NULL) {
 break;
 			}
 
@@ -992,7 +978,7 @@ lookup_crossmount(struct namei_state *st
 
 			/* Finally, drop references to foundobj & mountpoint. */
 			vrele(foundobj);
-			vfs_unbusy(mp);
+			fstrans_done(mp);
 			if (error) {
 foundobj = NULL;
 break;



CVS commit: src/sys/kern

2022-08-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Aug 22 09:14:59 UTC 2022

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

Log Message:
Use fstrans_start()/fstrans_done() to cross the mount in lookup_crossmount().
It is sufficient here as it prevents the file system from unmount and
makes it safe to use VFS_ROOT() here.

Removes a rare deadlock where one thread has "foundobj" locked and waits
for "foundobj->v_mountedhere" to resume while the thread holding the file
system suspended tries to lookup a node and needs a lock on "foundobj".


To generate a diff of this commit:
cvs rdiff -u -r1.231 -r1.232 src/sys/kern/vfs_lookup.c

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



CVS commit: src/sys/kern

2022-08-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Aug 22 09:14:24 UTC 2022

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

Log Message:
Protect changing "v_mountedhere" with file system suspension instead
of vnode lock.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/kern/vfs_mount.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_mount.c
diff -u src/sys/kern/vfs_mount.c:1.94 src/sys/kern/vfs_mount.c:1.95
--- src/sys/kern/vfs_mount.c:1.94	Fri Jul  8 07:43:19 2022
+++ src/sys/kern/vfs_mount.c	Mon Aug 22 09:14:24 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.94 2022/07/08 07:43:19 hannken Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.95 2022/08/22 09:14:24 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.94 2022/07/08 07:43:19 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.95 2022/08/22 09:14:24 hannken Exp $");
 
 #include 
 #include 
@@ -929,14 +929,12 @@ dounmount(struct mount *mp, int flags, s
 	 * vfs_busy() from succeeding.
 	 */
 	mp->mnt_iflag |= IMNT_GONE;
-	if (!was_suspended)
-		vfs_resume(mp);
-
 	if ((coveredvp = mp->mnt_vnodecovered) != NULLVP) {
-		vn_lock(coveredvp, LK_EXCLUSIVE | LK_RETRY);
 		coveredvp->v_mountedhere = NULL;
-		VOP_UNLOCK(coveredvp);
 	}
+	if (!was_suspended)
+		vfs_resume(mp);
+
 	mountlist_remove(mp);
 	if (TAILQ_FIRST(>mnt_vnodelist) != NULL)
 		panic("unmount: dangling vnode");



CVS commit: src/sys/kern

2022-08-22 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Aug 22 09:14:24 UTC 2022

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

Log Message:
Protect changing "v_mountedhere" with file system suspension instead
of vnode lock.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/kern/vfs_mount.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   >