CVS commit: src/sys/kern

2024-12-07 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sat Dec  7 23:15:38 UTC 2024

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

Log Message:
pool: use "big" (ie. > PAGE_SIZE) default allocators for more cases

When I added the default "big" pool allocators back in 2017,
I added them only for pool_caches and not plain pools, and only for
IPL_NONE pool_caches at that.  But these allocators work fine for
for all pool caches and plain pools as well, so use them automatically
by default when needed for all of those cases.


To generate a diff of this commit:
cvs rdiff -u -r1.290 -r1.291 src/sys/kern/subr_pool.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-12-07 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sat Dec  7 23:23:25 UTC 2024

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

Log Message:
pool: fix pool_sethiwat() to actually do something

The change that I made to the pool code back in April 2020
("slightly change and fix the semantics of pool_set*wat()" ...)
accidental broke pool_sethiwat() by making it have no effect.

This was discovered after the crash reported in PR 58666 was fixed.
The same machine (32-bit, with 10GB RAM) would hang due to the buffer
cache causing the system to run out of kernel virtual space.  The
buffer cache uses a separate pool for buffer data for each power of 2
between DEV_BSIZE and MAXBSIZE, and if the usage pattern of buffer
sizes changes then memory has to be moved between the different pools
in order to create buffers of the new size.  The buffer cache handles
this by using pool_sethiwat() to cause memory freed from the buffer
cache back to the pools to not be cached in the buffer cache pools but
instead be freed back to the pools' back-end allocator (which
allocates from the low-level kva allocator) as soon as possible.  But
since pool_sethiwat() wasn't doing anything, memory would stay cached
in some buffer cache pools and starve other buffer cache pools (and a
few other pools that do no use the kmem layer for memory allocation).

Fix pool_sethiwat() to do what it is supposed to do again.


To generate a diff of this commit:
cvs rdiff -u -r1.291 -r1.292 src/sys/kern/subr_pool.c

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

Modified files:

Index: src/sys/kern/subr_pool.c
diff -u src/sys/kern/subr_pool.c:1.291 src/sys/kern/subr_pool.c:1.292
--- src/sys/kern/subr_pool.c:1.291	Sat Dec  7 23:15:38 2024
+++ src/sys/kern/subr_pool.c	Sat Dec  7 23:23:25 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pool.c,v 1.291 2024/12/07 23:15:38 chs Exp $	*/
+/*	$NetBSD: subr_pool.c,v 1.292 2024/12/07 23:23:25 chs Exp $	*/
 
 /*
  * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010, 2014, 2015, 2018,
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.291 2024/12/07 23:15:38 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.292 2024/12/07 23:23:25 chs Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -889,6 +889,7 @@ pool_init(struct pool *pp, size_t size, 
 	pp->pr_npages = 0;
 	pp->pr_minitems = 0;
 	pp->pr_minpages = 0;
+	pp->pr_maxitems = UINT_MAX;
 	pp->pr_maxpages = UINT_MAX;
 	pp->pr_roflags = flags;
 	pp->pr_flags = 0;
@@ -1330,7 +1331,8 @@ pool_do_put(struct pool *pp, void *v, st
 		pp->pr_nidle++;
 		if (pp->pr_nitems - pp->pr_itemsperpage >= pp->pr_minitems &&
 		pp->pr_npages > pp->pr_minpages &&
-		pp->pr_npages > pp->pr_maxpages) {
+		(pp->pr_npages > pp->pr_maxpages ||
+		 pp->pr_nitems > pp->pr_maxitems)) {
 			pr_rmpage(pp, ph, pq);
 		} else {
 			LIST_REMOVE(ph, ph_pagelist);
@@ -1904,16 +1906,18 @@ pool_print1(struct pool *pp, const char 
 
 	/* Single line output. */
 	if (print_short) {
-		(*pr)(" %s:%p:%u:%u:%u:%u:%u:%u:%u:%u:%u:%u\n",
+		(*pr)(" %s:%p:%u:%u:%u:%u:%u:%u:%u:%u:%u:%u:%zu\n",
 		pp->pr_wchan, pp, pp->pr_size, pp->pr_align, pp->pr_npages,
 		pp->pr_nitems, pp->pr_nout, pp->pr_nget, pp->pr_nput,
-		pp->pr_npagealloc, pp->pr_npagefree, pp->pr_nidle);
+		pp->pr_npagealloc, pp->pr_npagefree, pp->pr_nidle,
+		(size_t)pp->pr_npagealloc * pp->pr_alloc->pa_pagesz);
 		return;
 	}
 
-	(*pr)(" %s: size %u, align %u, ioff %u, roflags 0x%08x\n",
-	pp->pr_wchan, pp->pr_size, pp->pr_align, pp->pr_itemoffset,
-	pp->pr_roflags);
+	(*pr)(" %s: itemsize %u, totalmem %zu align %u, ioff %u, roflags 0x%08x\n",
+	pp->pr_wchan, pp->pr_size,
+	(size_t)pp->pr_npagealloc * pp->pr_alloc->pa_pagesz,
+	pp->pr_align, pp->pr_itemoffset, pp->pr_roflags);
 	(*pr)("\tpool %p, alloc %p\n", pp, pp->pr_alloc);
 	(*pr)("\tminitems %u, minpages %u, maxpages %u, npages %u\n",
 	pp->pr_minitems, pp->pr_minpages, pp->pr_maxpages, pp->pr_npages);



CVS commit: src/sys/kern

2024-12-07 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sat Dec  7 23:23:25 UTC 2024

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

Log Message:
pool: fix pool_sethiwat() to actually do something

The change that I made to the pool code back in April 2020
("slightly change and fix the semantics of pool_set*wat()" ...)
accidental broke pool_sethiwat() by making it have no effect.

This was discovered after the crash reported in PR 58666 was fixed.
The same machine (32-bit, with 10GB RAM) would hang due to the buffer
cache causing the system to run out of kernel virtual space.  The
buffer cache uses a separate pool for buffer data for each power of 2
between DEV_BSIZE and MAXBSIZE, and if the usage pattern of buffer
sizes changes then memory has to be moved between the different pools
in order to create buffers of the new size.  The buffer cache handles
this by using pool_sethiwat() to cause memory freed from the buffer
cache back to the pools to not be cached in the buffer cache pools but
instead be freed back to the pools' back-end allocator (which
allocates from the low-level kva allocator) as soon as possible.  But
since pool_sethiwat() wasn't doing anything, memory would stay cached
in some buffer cache pools and starve other buffer cache pools (and a
few other pools that do no use the kmem layer for memory allocation).

Fix pool_sethiwat() to do what it is supposed to do again.


To generate a diff of this commit:
cvs rdiff -u -r1.291 -r1.292 src/sys/kern/subr_pool.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-12-07 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sat Dec  7 23:15:38 UTC 2024

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

Log Message:
pool: use "big" (ie. > PAGE_SIZE) default allocators for more cases

When I added the default "big" pool allocators back in 2017,
I added them only for pool_caches and not plain pools, and only for
IPL_NONE pool_caches at that.  But these allocators work fine for
for all pool caches and plain pools as well, so use them automatically
by default when needed for all of those cases.


To generate a diff of this commit:
cvs rdiff -u -r1.290 -r1.291 src/sys/kern/subr_pool.c

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

Modified files:

Index: src/sys/kern/subr_pool.c
diff -u src/sys/kern/subr_pool.c:1.290 src/sys/kern/subr_pool.c:1.291
--- src/sys/kern/subr_pool.c:1.290	Sun Apr  9 12:21:59 2023
+++ src/sys/kern/subr_pool.c	Sat Dec  7 23:15:38 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pool.c,v 1.290 2023/04/09 12:21:59 riastradh Exp $	*/
+/*	$NetBSD: subr_pool.c,v 1.291 2024/12/07 23:15:38 chs Exp $	*/
 
 /*
  * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010, 2014, 2015, 2018,
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.290 2023/04/09 12:21:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.291 2024/12/07 23:15:38 chs Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -830,8 +830,18 @@ pool_init(struct pool *pp, size_t size, 
 		mutex_exit(&pool_head_lock);
 #endif
 
-	if (palloc == NULL)
-		palloc = &pool_allocator_kmem;
+	if (palloc == NULL) {
+		if (size > PAGE_SIZE) {
+			int bigidx = pool_bigidx(size);
+
+			palloc = &pool_allocator_big[bigidx];
+			flags |= PR_NOALIGN;
+		} else if (ipl == IPL_NONE) {
+			palloc = &pool_allocator_nointr;
+		} else {
+			palloc = &pool_allocator_kmem;
+		}
+	}
 
 	if (!cold)
 		mutex_enter(&pool_allocator_lock);
@@ -2115,16 +2125,6 @@ pool_cache_bootstrap(pool_cache_t pc, si
 	unsigned int ppflags;
 
 	pp = &pc->pc_pool;
-	if (palloc == NULL && ipl == IPL_NONE) {
-		if (size > PAGE_SIZE) {
-			int bigidx = pool_bigidx(size);
-
-			palloc = &pool_allocator_big[bigidx];
-			flags |= PR_NOALIGN;
-		} else
-			palloc = &pool_allocator_nointr;
-	}
-
 	ppflags = flags;
 	if (ctor == NULL) {
 		ctor = NO_CTOR;



CVS commit: src/sys/kern

2024-12-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Dec  7 15:10:42 UTC 2024

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

Log Message:
sys/kern/vfs_wapbl.c: Provide stub SET_ERROR for userland builds.

Should fix:

/tmp/build/2024.12.07.14.08.54-amd64/src/sys/kern/vfs_wapbl.c: In function 
'wapbl_replay_start':
/tmp/build/2024.12.07.14.08.54-amd64/src/sys/kern/vfs_wapbl.c:2978:24: error: 
implicit declaration of function 'SET_ERROR'; did you mean 'EV_ERROR'? 
[-Werror=implicit-function-declaration]
 2978 | return SET_ERROR(EINVAL);
  |^
  |EV_ERROR


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

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

Modified files:

Index: src/sys/kern/vfs_wapbl.c
diff -u src/sys/kern/vfs_wapbl.c:1.116 src/sys/kern/vfs_wapbl.c:1.117
--- src/sys/kern/vfs_wapbl.c:1.116	Sat Dec  7 02:27:38 2024
+++ src/sys/kern/vfs_wapbl.c	Sat Dec  7 15:10:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_wapbl.c,v 1.116 2024/12/07 02:27:38 riastradh Exp $	*/
+/*	$NetBSD: vfs_wapbl.c,v 1.117 2024/12/07 15:10:42 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #define WAPBL_INTERNAL
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.116 2024/12/07 02:27:38 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.117 2024/12/07 15:10:42 riastradh Exp $");
 
 #include 
 #include 
@@ -93,6 +93,8 @@ static inline size_t wapbl_space_free(si
 #define	wapbl_free(a, s)	free(a)
 #define	wapbl_calloc(n, s)	calloc((n), (s))
 
+#define	SET_ERROR(E)		(E)
+
 #endif /* !_KERNEL */
 
 /*



CVS commit: src/sys/kern

2024-12-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Dec  7 15:10:42 UTC 2024

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

Log Message:
sys/kern/vfs_wapbl.c: Provide stub SET_ERROR for userland builds.

Should fix:

/tmp/build/2024.12.07.14.08.54-amd64/src/sys/kern/vfs_wapbl.c: In function 
'wapbl_replay_start':
/tmp/build/2024.12.07.14.08.54-amd64/src/sys/kern/vfs_wapbl.c:2978:24: error: 
implicit declaration of function 'SET_ERROR'; did you mean 'EV_ERROR'? 
[-Werror=implicit-function-declaration]
 2978 | return SET_ERROR(EINVAL);
  |^
  |EV_ERROR


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

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



CVS commit: src/sys/kern

2024-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Dec  7 02:38:52 UTC 2024

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

Log Message:
sys/kern/sys_aio.c: Sprinkle SET_ERROR dtrace probes.

PR kern/58378: Kernel error code origination lacks dtrace probes


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/kern/sys_aio.c

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

Modified files:

Index: src/sys/kern/sys_aio.c
diff -u src/sys/kern/sys_aio.c:1.49 src/sys/kern/sys_aio.c:1.50
--- src/sys/kern/sys_aio.c:1.49	Sat Dec  7 02:38:35 2024
+++ src/sys/kern/sys_aio.c	Sat Dec  7 02:38:51 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_aio.c,v 1.49 2024/12/07 02:38:35 riastradh Exp $	*/
+/*	$NetBSD: sys_aio.c,v 1.50 2024/12/07 02:38:51 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2007 Mindaugas Rasiukevicius 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_aio.c,v 1.49 2024/12/07 02:38:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_aio.c,v 1.50 2024/12/07 02:38:51 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -54,6 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: sys_aio.c,v 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -124,7 +125,7 @@ aio_fini(bool interface)
 		if (p != NULL) {
 			error = syscall_establish(NULL, aio_syscalls);
 			KASSERT(error == 0);
-			return EBUSY;
+			return SET_ERROR(EBUSY);
 		}
 	}
 
@@ -168,7 +169,7 @@ aio_modcmd(modcmd_t cmd, void *arg)
 	case MODULE_CMD_FINI:
 		return aio_fini(true);
 	default:
-		return ENOTTY;
+		return SET_ERROR(ENOTTY);
 	}
 }
 
@@ -199,7 +200,7 @@ aio_procinit(struct proc *p)
 	uaddr = uvm_uarea_alloc();
 	if (uaddr == 0) {
 		aio_exit(p, aio);
-		return EAGAIN;
+		return SET_ERROR(EAGAIN);
 	}
 	error = lwp_create(curlwp, p, uaddr, 0, NULL, 0, aio_worker,
 	NULL, &l, curlwp->l_class, &curlwp->l_sigmask, &curlwp->l_sigstk);
@@ -360,13 +361,13 @@ aio_process(struct aio_job *a_job)
 		struct uio auio;
 
 		if (aiocbp->aio_nbytes > SSIZE_MAX) {
-			error = EINVAL;
+			error = SET_ERROR(EINVAL);
 			goto done;
 		}
 
 		fp = fd_getfile(fd);
 		if (fp == NULL) {
-			error = EBADF;
+			error = SET_ERROR(EBADF);
 			goto done;
 		}
 
@@ -385,7 +386,7 @@ aio_process(struct aio_job *a_job)
 
 			if ((fp->f_flag & FREAD) == 0) {
 fd_putfile(fd);
-error = EBADF;
+error = SET_ERROR(EBADF);
 goto done;
 			}
 			auio.uio_rw = UIO_READ;
@@ -399,7 +400,7 @@ aio_process(struct aio_job *a_job)
 
 			if ((fp->f_flag & FWRITE) == 0) {
 fd_putfile(fd);
-error = EBADF;
+error = SET_ERROR(EBADF);
 goto done;
 			}
 			auio.uio_rw = UIO_WRITE;
@@ -424,7 +425,7 @@ aio_process(struct aio_job *a_job)
 
 		if ((fp->f_flag & FWRITE) == 0) {
 			fd_putfile(fd);
-			error = EBADF;
+			error = SET_ERROR(EBADF);
 			goto done;
 		}
 
@@ -487,7 +488,7 @@ aio_enqueue_job(int op, void *aiocb_uptr
 
 	/* Non-accurate check for the limit */
 	if (aio_jobs_count + 1 > aio_max)
-		return EAGAIN;
+		return SET_ERROR(EAGAIN);
 
 	/* Get the data structure from user-space */
 	error = copyin(aiocb_uptr, &aiocbp, sizeof(struct aiocb));
@@ -498,12 +499,12 @@ aio_enqueue_job(int op, void *aiocb_uptr
 	sig = &aiocbp.aio_sigevent;
 	if (sig->sigev_signo < 0 || sig->sigev_signo >= NSIG ||
 	sig->sigev_notify < SIGEV_NONE || sig->sigev_notify > SIGEV_SA)
-		return EINVAL;
+		return SET_ERROR(EINVAL);
 
 	/* Buffer and byte count */
 	if (((AIO_SYNC | AIO_DSYNC) & op) == 0)
 		if (aiocbp.aio_buf == NULL || aiocbp.aio_nbytes > SSIZE_MAX)
-			return EINVAL;
+			return SET_ERROR(EINVAL);
 
 	/* Check the opcode, if LIO_NOP - simply ignore */
 	if (op == AIO_LIO) {
@@ -513,7 +514,8 @@ aio_enqueue_job(int op, void *aiocb_uptr
 		else if (aiocbp.aio_lio_opcode == LIO_READ)
 			op = AIO_READ;
 		else
-			return (aiocbp.aio_lio_opcode == LIO_NOP) ? 0 : EINVAL;
+			return (aiocbp.aio_lio_opcode == LIO_NOP) ? 0 :
+			SET_ERROR(EINVAL);
 	} else {
 		KASSERT(lio == NULL);
 	}
@@ -529,7 +531,7 @@ aio_enqueue_job(int op, void *aiocb_uptr
 			if (a_job->aiocb_uptr != aiocb_uptr)
 continue;
 			mutex_exit(&aio->aio_mtx);
-			return EINVAL;
+			return SET_ERROR(EINVAL);
 		}
 		mutex_exit(&aio->aio_mtx);
 	}
@@ -541,7 +543,7 @@ aio_enqueue_job(int op, void *aiocb_uptr
 	 */
 	if (lio == NULL && p->p_aio == NULL)
 		if (aio_procinit(p))
-			return EAGAIN;
+			return SET_ERROR(EAGAIN);
 	aio = p->p_aio;
 
 	/*
@@ -549,7 +551,7 @@ aio_enqueue_job(int op, void *aiocb_uptr
 	 * structure back to the user-space.
 	 */
 	aiocbp._state = JOB_WIP;
-	aiocbp._errno = EINPROGRESS;
+	aiocbp._errno = SET_ERROR(EINPROGRESS);
 	aiocbp._retval = -1;
 	error = copyout(&aiocbp, aiocb_uptr, sizeof(struct aiocb));
 	if (error)
@@ -580,7 +582,7 @@ aio_enqueue_job(int op, void *aiocb_uptr
 		atomic_dec_uint(&aio_jobs_count);
 		mutex_exit(&aio->aio_mtx);
 		pool_put(&aio_job_pool, a_job);
-		return EAGAIN;
+		return SET_ERROR(EAGAIN);
 	}
 
 

CVS commit: src/sys/kern

2024-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Dec  7 02:38:35 UTC 2024

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

Log Message:
sys/kern/sys_aio.c: KNF


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/kern/sys_aio.c

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

Modified files:

Index: src/sys/kern/sys_aio.c
diff -u src/sys/kern/sys_aio.c:1.48 src/sys/kern/sys_aio.c:1.49
--- src/sys/kern/sys_aio.c:1.48	Sat May 23 23:42:43 2020
+++ src/sys/kern/sys_aio.c	Sat Dec  7 02:38:35 2024
@@ -1,9 +1,9 @@
-/*	$NetBSD: sys_aio.c,v 1.48 2020/05/23 23:42:43 ad Exp $	*/
+/*	$NetBSD: sys_aio.c,v 1.49 2024/12/07 02:38:35 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2007 Mindaugas Rasiukevicius 
  * All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -32,19 +32,24 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_aio.c,v 1.48 2020/05/23 23:42:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_aio.c,v 1.49 2024/12/07 02:38:35 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
 #endif
 
 #include 
+#include 
+
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -58,9 +63,6 @@ __KERNEL_RCSID(0, "$NetBSD: sys_aio.c,v 
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
 
 #include 
 
@@ -1084,35 +1086,35 @@ SYSCTL_SETUP(sysctl_aio_init, "aio sysct
 	int rv;
 
 	rv = sysctl_createv(clog, 0, NULL, NULL,
-		CTLFLAG_PERMANENT | CTLFLAG_IMMEDIATE,
-		CTLTYPE_INT, "posix_aio",
-		SYSCTL_DESCR("Version of IEEE Std 1003.1 and its "
-			 "Asynchronous I/O option to which the "
-			 "system attempts to conform"),
-		NULL, _POSIX_ASYNCHRONOUS_IO, NULL, 0,
-		CTL_KERN, CTL_CREATE, CTL_EOL);
+	CTLFLAG_PERMANENT | CTLFLAG_IMMEDIATE,
+	CTLTYPE_INT, "posix_aio",
+	SYSCTL_DESCR("Version of IEEE Std 1003.1 and its "
+		"Asynchronous I/O option to which the "
+		"system attempts to conform"),
+	NULL, _POSIX_ASYNCHRONOUS_IO, NULL, 0,
+	CTL_KERN, CTL_CREATE, CTL_EOL);
 
 	if (rv != 0)
 		return;
 
 	rv = sysctl_createv(clog, 0, NULL, NULL,
-		CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
-		CTLTYPE_INT, "aio_listio_max",
-		SYSCTL_DESCR("Maximum number of asynchronous I/O "
-			 "operations in a single list I/O call"),
-		sysctl_aio_listio_max, 0, &aio_listio_max, 0,
-		CTL_KERN, CTL_CREATE, CTL_EOL);
+	CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+	CTLTYPE_INT, "aio_listio_max",
+	SYSCTL_DESCR("Maximum number of asynchronous I/O "
+		"operations in a single list I/O call"),
+	sysctl_aio_listio_max, 0, &aio_listio_max, 0,
+	CTL_KERN, CTL_CREATE, CTL_EOL);
 
 	if (rv != 0)
 		return;
 
 	rv = sysctl_createv(clog, 0, NULL, NULL,
-		CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
-		CTLTYPE_INT, "aio_max",
-		SYSCTL_DESCR("Maximum number of asynchronous I/O "
-			 "operations"),
-		sysctl_aio_max, 0, &aio_max, 0,
-		CTL_KERN, CTL_CREATE, CTL_EOL);
+	CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+	CTLTYPE_INT, "aio_max",
+	SYSCTL_DESCR("Maximum number of asynchronous I/O "
+		"operations"),
+	sysctl_aio_max, 0, &aio_max, 0,
+	CTL_KERN, CTL_CREATE, CTL_EOL);
 
 	return;
 }



CVS commit: src/sys/kern

2024-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Dec  7 02:31:15 UTC 2024

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

Log Message:
sys/kern/uipc_*.c: Fix leading whitespace issues.

Nix stray spaces before tab indentation.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/kern/uipc_domain.c
cvs rdiff -u -r1.146 -r1.147 src/sys/kern/uipc_socket2.c
cvs rdiff -u -r1.206 -r1.207 src/sys/kern/uipc_usrreq.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-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Dec  7 02:38:52 UTC 2024

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

Log Message:
sys/kern/sys_aio.c: Sprinkle SET_ERROR dtrace probes.

PR kern/58378: Kernel error code origination lacks dtrace probes


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/kern/sys_aio.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-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Dec  7 02:38:35 UTC 2024

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

Log Message:
sys/kern/sys_aio.c: KNF


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/kern/sys_aio.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-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Dec  7 02:27:38 UTC 2024

Modified Files:
src/sys/kern: vfs_acl.c vfs_bio.c vfs_cache.c vfs_getcwd.c vfs_hooks.c
vfs_init.c vfs_lockf.c vfs_lookup.c vfs_mount.c vfs_subr.c
vfs_trans.c vfs_vnode.c vfs_vnops.c vfs_wapbl.c vfs_xattr.c

Log Message:
vfs(9): Sprinkle SET_ERROR dtrace probes.

PR kern/58378: Kernel error code origination lacks dtrace probes


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/kern/vfs_acl.c
cvs rdiff -u -r1.305 -r1.306 src/sys/kern/vfs_bio.c
cvs rdiff -u -r1.158 -r1.159 src/sys/kern/vfs_cache.c
cvs rdiff -u -r1.62 -r1.63 src/sys/kern/vfs_getcwd.c
cvs rdiff -u -r1.8 -r1.9 src/sys/kern/vfs_hooks.c
cvs rdiff -u -r1.66 -r1.67 src/sys/kern/vfs_init.c
cvs rdiff -u -r1.82 -r1.83 src/sys/kern/vfs_lockf.c
cvs rdiff -u -r1.237 -r1.238 src/sys/kern/vfs_lookup.c
cvs rdiff -u -r1.109 -r1.110 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.501 -r1.502 src/sys/kern/vfs_subr.c
cvs rdiff -u -r1.72 -r1.73 src/sys/kern/vfs_trans.c
cvs rdiff -u -r1.155 -r1.156 src/sys/kern/vfs_vnode.c
cvs rdiff -u -r1.243 -r1.244 src/sys/kern/vfs_vnops.c
cvs rdiff -u -r1.115 -r1.116 src/sys/kern/vfs_wapbl.c
cvs rdiff -u -r1.40 -r1.41 src/sys/kern/vfs_xattr.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_acl.c
diff -u src/sys/kern/vfs_acl.c:1.2 src/sys/kern/vfs_acl.c:1.3
--- src/sys/kern/vfs_acl.c:1.2	Sat Dec  7 02:11:42 2024
+++ src/sys/kern/vfs_acl.c	Sat Dec  7 02:27:38 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_acl.c,v 1.2 2024/12/07 02:11:42 riastradh Exp $	*/
+/*	$NetBSD: vfs_acl.c,v 1.3 2024/12/07 02:27:38 riastradh Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -45,7 +45,7 @@
 #if 0
 __FBSDID("$FreeBSD: head/sys/kern/vfs_acl.c 356337 2020-01-03 22:29:58Z mjg $");
 #endif
-__KERNEL_RCSID(0, "$NetBSD: vfs_acl.c,v 1.2 2024/12/07 02:11:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_acl.c,v 1.3 2024/12/07 02:27:38 riastradh Exp $");
 
 #include 
 #include 
@@ -60,6 +60,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_acl.c,v 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -72,7 +73,7 @@ acl_copy_oldacl_into_acl(const struct ol
 	int i;
 
 	if (source->acl_cnt < 0 || source->acl_cnt > OLDACL_MAX_ENTRIES)
-		return EINVAL;
+		return SET_ERROR(EINVAL);
 
 	memset(dest, 0, sizeof(*dest));
 
@@ -94,7 +95,7 @@ acl_copy_acl_into_oldacl(const struct ac
 	int i;
 
 	if (source->acl_cnt > OLDACL_MAX_ENTRIES)
-		return EINVAL;
+		return SET_ERROR(EINVAL);
 
 	memset(dest, 0, sizeof(*dest));
 
@@ -139,7 +140,7 @@ acl_copyin(const void *user_acl, struct 
 	default:
 		error = copyin(user_acl, kernel_acl, sizeof(*kernel_acl));
 		if (kernel_acl->acl_maxcnt != ACL_MAX_ENTRIES)
-			return EINVAL;
+			return SET_ERROR(EINVAL);
 	}
 
 	return error;
@@ -169,7 +170,7 @@ acl_copyout(const struct acl *kernel_acl
 		if (error)
 			return error;
 		if (am != ACL_MAX_ENTRIES)
-			return EINVAL;
+			return SET_ERROR(EINVAL);
 
 		error = copyout(kernel_acl, user_acl, sizeof(*kernel_acl));
 	}

Index: src/sys/kern/vfs_bio.c
diff -u src/sys/kern/vfs_bio.c:1.305 src/sys/kern/vfs_bio.c:1.306
--- src/sys/kern/vfs_bio.c:1.305	Sat Dec  7 02:13:30 2024
+++ src/sys/kern/vfs_bio.c	Sat Dec  7 02:27:38 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_bio.c,v 1.305 2024/12/07 02:13:30 riastradh Exp $	*/
+/*	$NetBSD: vfs_bio.c,v 1.306 2024/12/07 02:27:38 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2019, 2020 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.305 2024/12/07 02:13:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.306 2024/12/07 02:27:38 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_biohist.h"
@@ -322,7 +322,7 @@ buf_setvalimit(vsize_t sz)
 
 	/* We need to accommodate at least NMEMPOOLS of MAXBSIZE each */
 	if (sz < NMEMPOOLS * MAXBSIZE)
-		return EINVAL;
+		return SET_ERROR(EINVAL);
 
 	bufmem_valimit = sz;
 	return 0;
@@ -453,7 +453,7 @@ buf_memcalc(void)
 	if (bufmem_valimit != 0 && n > bufmem_valimit)
 		n = bufmem_valimit;
 
-	return (n);
+	return n;
 }
 
 /*
@@ -735,7 +735,7 @@ bio_doread(struct vnode *vp, daddr_t blk
 			mp->mnt_stat.f_asyncreads++;
 	}
 
-	return (bp);
+	return bp;
 }
 
 /*
@@ -753,7 +753,7 @@ bread(struct vnode *vp, daddr_t blkno, i
 	/* Get buffer for block. */
 	bp = *bpp = bio_doread(vp, blkno, size, 0);
 	if (bp == NULL)
-		return ENOMEM;
+		return SET_ERROR(ENOMEM);
 
 	/* Wait for the read to complete, and return result. */
 	error = biowait(bp);
@@ -782,7 +782,7 @@ breadn(struct vnode *vp, daddr_t blkno, 
 
 	bp = *bpp = bio_doread(vp, blkno, size, 0);
 	if (bp == NULL)
-		return ENOMEM;
+		return SET_ERROR(ENOMEM);
 
 	/*
 	 * For each of the read-ahead blocks, start a read, if necessary.
@@ -864,7 +864,7 @@ bwrite(buf_t *bp)
 	sync = !ISSET(bp->b_flags, B_

CVS commit: src/sys/kern

2024-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Dec  7 02:31:15 UTC 2024

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

Log Message:
sys/kern/uipc_*.c: Fix leading whitespace issues.

Nix stray spaces before tab indentation.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/kern/uipc_domain.c
cvs rdiff -u -r1.146 -r1.147 src/sys/kern/uipc_socket2.c
cvs rdiff -u -r1.206 -r1.207 src/sys/kern/uipc_usrreq.c

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

Modified files:

Index: src/sys/kern/uipc_domain.c
diff -u src/sys/kern/uipc_domain.c:1.111 src/sys/kern/uipc_domain.c:1.112
--- src/sys/kern/uipc_domain.c:1.111	Fri Dec  6 18:44:00 2024
+++ src/sys/kern/uipc_domain.c	Sat Dec  7 02:31:14 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_domain.c,v 1.111 2024/12/06 18:44:00 riastradh Exp $	*/
+/*	$NetBSD: uipc_domain.c,v 1.112 2024/12/07 02:31:14 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.111 2024/12/06 18:44:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.112 2024/12/07 02:31:14 riastradh Exp $");
 
 #include 
 #include 
@@ -593,7 +593,7 @@ sysctl_unpcblist(SYSCTLFN_ARGS)
 	 */
 	sysctl_unlock();
 	if ((dfp = fgetdummy()) == NULL) {
-	 	sysctl_relock();
+		sysctl_relock();
 		return SET_ERROR(ENOMEM);
 	}
 
@@ -647,10 +647,10 @@ sysctl_unpcblist(SYSCTLFN_ARGS)
 	}
 	mutex_exit(&filelist_lock);
 	fputdummy(dfp);
- 	*oldlenp = needed;
+	*oldlenp = needed;
 	if (oldp == NULL)
 		*oldlenp += PCB_SLOP * sizeof(struct kinfo_pcb);
- 	sysctl_relock();
+	sysctl_relock();
 
 	return error;
 }

Index: src/sys/kern/uipc_socket2.c
diff -u src/sys/kern/uipc_socket2.c:1.146 src/sys/kern/uipc_socket2.c:1.147
--- src/sys/kern/uipc_socket2.c:1.146	Fri Dec  6 18:44:00 2024
+++ src/sys/kern/uipc_socket2.c	Sat Dec  7 02:31:14 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_socket2.c,v 1.146 2024/12/06 18:44:00 riastradh Exp $	*/
+/*	$NetBSD: uipc_socket2.c,v 1.147 2024/12/07 02:31:14 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.146 2024/12/06 18:44:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.147 2024/12/07 02:31:14 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1170,7 +1170,7 @@ sbappendaddrchain(struct sockbuf *sb, co
 #endif
 
 		/* Prepend sockaddr to this record (m) of input chain m0 */
-	  	n = m_prepend_sockaddr(sb, m, asa);
+		n = m_prepend_sockaddr(sb, m, asa);
 		if (n == NULL) {
 			error = SET_ERROR(ENOBUFS);
 			goto bad;
@@ -1210,7 +1210,7 @@ bad:
 	 * the input record chain passed to us as m0.
 	 */
 	while ((n = n0) != NULL) {
-	  	struct mbuf *np;
+		struct mbuf *np;
 
 		/* Undo the sballoc() of this record */
 		for (np = n; np; np = np->m_next)

Index: src/sys/kern/uipc_usrreq.c
diff -u src/sys/kern/uipc_usrreq.c:1.206 src/sys/kern/uipc_usrreq.c:1.207
--- src/sys/kern/uipc_usrreq.c:1.206	Fri Dec  6 18:44:00 2024
+++ src/sys/kern/uipc_usrreq.c	Sat Dec  7 02:31:14 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_usrreq.c,v 1.206 2024/12/06 18:44:00 riastradh Exp $	*/
+/*	$NetBSD: uipc_usrreq.c,v 1.207 2024/12/07 02:31:14 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2004, 2008, 2009, 2020 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.206 2024/12/06 18:44:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.207 2024/12/07 02:31:14 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1572,8 +1572,8 @@ unp_internalize(struct mbuf **controlp)
 		}
 		if ((fp = fd_getfile(fd)) == NULL
 		|| fp->f_type == DTYPE_KQUEUE) {
-			if (fp)
-				fd_putfile(fd);
+			if (fp)
+fd_putfile(fd);
 			atomic_dec_uint(&unp_rights);
 			nfds = i;
 			error = SET_ERROR(EBADF);
@@ -1611,7 +1611,7 @@ unp_internalize(struct mbuf **controlp)
 	}
 
  out:
- 	/* Release descriptor references. */
+	/* Release descriptor references. */
 	fdp = (int *)CMSG_DATA(cm);
 	for (i = 0; i < nfds; i++) {
 		fd_putfile(*fdp++);
@@ -1915,7 +1915,7 @@ unp_scan(struct mbuf *m0, void (*op)(fil
 		for (m = m0; m; m = m->m_next) {
 			if (m->m_type != MT_CONTROL ||
 			m->m_len < sizeof(*cm)) {
-				continue;
+continue;
 			}
 			cm = mtod(m, struct cmsghdr *);
 			if (cm->cmsg_level != SOL_SOCKET ||



CVS commit: src/sys/kern

2024-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Dec  7 02:27:38 UTC 2024

Modified Files:
src/sys/kern: vfs_acl.c vfs_bio.c vfs_cache.c vfs_getcwd.c vfs_hooks.c
vfs_init.c vfs_lockf.c vfs_lookup.c vfs_mount.c vfs_subr.c
vfs_trans.c vfs_vnode.c vfs_vnops.c vfs_wapbl.c vfs_xattr.c

Log Message:
vfs(9): Sprinkle SET_ERROR dtrace probes.

PR kern/58378: Kernel error code origination lacks dtrace probes


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/kern/vfs_acl.c
cvs rdiff -u -r1.305 -r1.306 src/sys/kern/vfs_bio.c
cvs rdiff -u -r1.158 -r1.159 src/sys/kern/vfs_cache.c
cvs rdiff -u -r1.62 -r1.63 src/sys/kern/vfs_getcwd.c
cvs rdiff -u -r1.8 -r1.9 src/sys/kern/vfs_hooks.c
cvs rdiff -u -r1.66 -r1.67 src/sys/kern/vfs_init.c
cvs rdiff -u -r1.82 -r1.83 src/sys/kern/vfs_lockf.c
cvs rdiff -u -r1.237 -r1.238 src/sys/kern/vfs_lookup.c
cvs rdiff -u -r1.109 -r1.110 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.501 -r1.502 src/sys/kern/vfs_subr.c
cvs rdiff -u -r1.72 -r1.73 src/sys/kern/vfs_trans.c
cvs rdiff -u -r1.155 -r1.156 src/sys/kern/vfs_vnode.c
cvs rdiff -u -r1.243 -r1.244 src/sys/kern/vfs_vnops.c
cvs rdiff -u -r1.115 -r1.116 src/sys/kern/vfs_wapbl.c
cvs rdiff -u -r1.40 -r1.41 src/sys/kern/vfs_xattr.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-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Dec  7 02:23:10 UTC 2024

Modified Files:
src/sys/kern: vfs_cache.c vfs_hooks.c vfs_init.c vfs_lookup.c
vfs_mount.c vfs_syscalls.c vfs_trans.c vfs_vnode.c vfs_wapbl.c

Log Message:
vfs(9): Fix some more whitespace issues.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/sys/kern/vfs_cache.c
cvs rdiff -u -r1.7 -r1.8 src/sys/kern/vfs_hooks.c
cvs rdiff -u -r1.65 -r1.66 src/sys/kern/vfs_init.c
cvs rdiff -u -r1.236 -r1.237 src/sys/kern/vfs_lookup.c
cvs rdiff -u -r1.108 -r1.109 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.569 -r1.570 src/sys/kern/vfs_syscalls.c
cvs rdiff -u -r1.71 -r1.72 src/sys/kern/vfs_trans.c
cvs rdiff -u -r1.154 -r1.155 src/sys/kern/vfs_vnode.c
cvs rdiff -u -r1.114 -r1.115 src/sys/kern/vfs_wapbl.c

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

Modified files:

Index: src/sys/kern/vfs_cache.c
diff -u src/sys/kern/vfs_cache.c:1.157 src/sys/kern/vfs_cache.c:1.158
--- src/sys/kern/vfs_cache.c:1.157	Sat Dec  7 02:11:42 2024
+++ src/sys/kern/vfs_cache.c	Sat Dec  7 02:23:09 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_cache.c,v 1.157 2024/12/07 02:11:42 riastradh Exp $	*/
+/*	$NetBSD: vfs_cache.c,v 1.158 2024/12/07 02:23:09 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2019, 2020, 2023 The NetBSD Foundation, Inc.
@@ -184,7 +184,7 @@
 #define __NAMECACHE_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.157 2024/12/07 02:11:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.158 2024/12/07 02:23:09 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -561,7 +561,7 @@ cache_lookup(struct vnode *dvp, const ch
 	/* Could the entry be purged below? */
 	if ((cnflags & ISLASTCN) != 0 &&
 	((cnflags & MAKEENTRY) == 0 || nameiop == CREATE)) {
-		op = RW_WRITER;
+		op = RW_WRITER;
 	} else {
 		op = RW_READER;
 	}
@@ -726,9 +726,10 @@ cache_lookup_linked(struct vnode *dvp, c
 		KASSERT(dvi->vi_nc_gid != VNOVAL);
 		error = kauth_authorize_vnode(cred,
 		KAUTH_ACCESS_ACTION(VEXEC,
-		dvp->v_type, dvi->vi_nc_mode & ALLPERMS), dvp, NULL,
+			dvp->v_type, dvi->vi_nc_mode & ALLPERMS),
+		dvp, NULL,
 		genfs_can_access(dvp, cred, dvi->vi_nc_uid, dvi->vi_nc_gid,
-		dvi->vi_nc_mode & ALLPERMS, NULL, VEXEC));
+			dvi->vi_nc_mode & ALLPERMS, NULL, VEXEC));
 		if (error != 0) {
 			if (newlock != NULL) {
 rw_exit(newlock);
@@ -825,11 +826,13 @@ cache_revlookup(struct vnode *vp, struct
 		KASSERT(vi->vi_nc_gid != VNOVAL);
 		error = kauth_authorize_vnode(kauth_cred_get(),
 		KAUTH_ACCESS_ACTION(VEXEC, vp->v_type, vi->vi_nc_mode &
-		ALLPERMS), vp, NULL, genfs_can_access(vp, curlwp->l_cred,
-		vi->vi_nc_uid, vi->vi_nc_gid, vi->vi_nc_mode & ALLPERMS,
-		NULL, accmode));
-		if (error != 0) {
-			rw_exit(&vi->vi_nc_listlock);
+			ALLPERMS),
+		vp, NULL, genfs_can_access(vp, curlwp->l_cred,
+			vi->vi_nc_uid, vi->vi_nc_gid,
+			vi->vi_nc_mode & ALLPERMS,
+			NULL, accmode));
+		if (error != 0) {
+			rw_exit(&vi->vi_nc_listlock);
 			COUNT(ncs_denied);
 			return EACCES;
 		}
@@ -853,7 +856,7 @@ cache_revlookup(struct vnode *vp, struct
 		if (ncp->nc_name[0] == '.') {
 			if (nlen == 1 ||
 			(nlen == 2 && ncp->nc_name[1] == '.')) {
-				break;
+break;
 			}
 		}
 
@@ -1351,7 +1354,7 @@ cache_deactivate(void)
 	/* If we're nowhere near budget yet, don't bother. */
 	total = cache_lru.count[LRU_ACTIVE] + cache_lru.count[LRU_INACTIVE];
 	if (total < (desiredvnodes >> 1)) {
-		return;
+		return;
 	}
 
 	/*

Index: src/sys/kern/vfs_hooks.c
diff -u src/sys/kern/vfs_hooks.c:1.7 src/sys/kern/vfs_hooks.c:1.8
--- src/sys/kern/vfs_hooks.c:1.7	Sat Dec  7 02:11:42 2024
+++ src/sys/kern/vfs_hooks.c	Sat Dec  7 02:23:09 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_hooks.c,v 1.7 2024/12/07 02:11:42 riastradh Exp $	*/
+/*	$NetBSD: vfs_hooks.c,v 1.8 2024/12/07 02:23:09 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_hooks.c,v 1.7 2024/12/07 02:11:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_hooks.c,v 1.8 2024/12/07 02:23:09 riastradh Exp $");
 
 #include 
 
@@ -80,7 +80,7 @@ vfs_hooks_detach(struct vfs_hooks *vfs_h
 }
 }
 if (hp == NULL)
-   		ret = ESRCH;
+		ret = ESRCH;
 	mutex_exit(&vfs_hooks_lock);
 
 	return ret;
@@ -97,9 +97,9 @@ func fargs\
 {	\
 	int error;			\
 	struct vfs_hooks *hp;		\
- 	\
+	\
 	error = EJUSTRETURN;		\
- 	\
+	\
 	mutex_enter(&vfs_hooks_lock);	\
 LIST_FOREACH(hp, &vfs_hooks_head, vfs_hooks_list) {		\
 		if (hp-> hook != NULL) {\
@@ -109,7 +109,7 @@ func fargs\
 		}			\
 	}\
 	mutex_exit(&vfs_hooks_lock);	\
- 	\
+	\
 	return error;			\
 }
 
@@ -123,7 +

CVS commit: src/sys/kern

2024-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Dec  7 02:23:10 UTC 2024

Modified Files:
src/sys/kern: vfs_cache.c vfs_hooks.c vfs_init.c vfs_lookup.c
vfs_mount.c vfs_syscalls.c vfs_trans.c vfs_vnode.c vfs_wapbl.c

Log Message:
vfs(9): Fix some more whitespace issues.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/sys/kern/vfs_cache.c
cvs rdiff -u -r1.7 -r1.8 src/sys/kern/vfs_hooks.c
cvs rdiff -u -r1.65 -r1.66 src/sys/kern/vfs_init.c
cvs rdiff -u -r1.236 -r1.237 src/sys/kern/vfs_lookup.c
cvs rdiff -u -r1.108 -r1.109 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.569 -r1.570 src/sys/kern/vfs_syscalls.c
cvs rdiff -u -r1.71 -r1.72 src/sys/kern/vfs_trans.c
cvs rdiff -u -r1.154 -r1.155 src/sys/kern/vfs_vnode.c
cvs rdiff -u -r1.114 -r1.115 src/sys/kern/vfs_wapbl.c

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



CVS commit: src/sys/kern

2024-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Dec  7 02:13:30 UTC 2024

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

Log Message:
vfs_bio.c: Fix space-before-tab in indentation.

No functional change intended.


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

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



CVS commit: src/sys/kern

2024-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Dec  7 02:13:30 UTC 2024

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

Log Message:
vfs_bio.c: Fix space-before-tab in indentation.

No functional change intended.


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

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

Modified files:

Index: src/sys/kern/vfs_bio.c
diff -u src/sys/kern/vfs_bio.c:1.304 src/sys/kern/vfs_bio.c:1.305
--- src/sys/kern/vfs_bio.c:1.304	Sat Dec  7 02:11:42 2024
+++ src/sys/kern/vfs_bio.c	Sat Dec  7 02:13:30 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_bio.c,v 1.304 2024/12/07 02:11:42 riastradh Exp $	*/
+/*	$NetBSD: vfs_bio.c,v 1.305 2024/12/07 02:13:30 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2019, 2020 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.304 2024/12/07 02:11:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.305 2024/12/07 02:13:30 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_biohist.h"
@@ -1189,8 +1189,8 @@ incore(struct vnode *vp, daddr_t blkno)
 	LIST_FOREACH(bp, BUFHASH(vp, blkno), b_hash) {
 		if (bp->b_lblkno == blkno && bp->b_vp == vp &&
 		!ISSET(bp->b_cflags, BC_INVAL)) {
-			KASSERT(bp->b_objlock == vp->v_interlock);
-			return (bp);
+			KASSERT(bp->b_objlock == vp->v_interlock);
+			return (bp);
 		}
 	}
 
@@ -1431,7 +1431,7 @@ start:
 		}
 	}
 	if (bp != NULL) {
-		KASSERT(!ISSET(bp->b_cflags, BC_BUSY) ||
+		KASSERT(!ISSET(bp->b_cflags, BC_BUSY) ||
 		ISSET(bp->b_cflags, BC_VFLUSH));
 		bremfree(bp);
 
@@ -1474,7 +1474,7 @@ start:
 	}
 
 	KASSERT(ISSET(bp->b_cflags, BC_BUSY));
-	KASSERT(!cv_has_waiters(&bp->b_done));
+	KASSERT(!cv_has_waiters(&bp->b_done));
 
 	/*
 	 * If buffer was a delayed write, start it and return NULL



CVS commit: src/sys/kern

2024-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Dec  7 02:11:43 UTC 2024

Modified Files:
src/sys/kern: vfs_acl.c vfs_bio.c vfs_cache.c vfs_cwd.c vfs_dirhash.c
vfs_getcwd.c vfs_hooks.c vfs_init.c vfs_lockf.c vfs_lookup.c
vfs_mount.c vfs_subr.c vfs_syscalls.c vfs_trans.c vfs_vnode.c
vfs_vnops.c vfs_wapbl.c vfs_xattr.c

Log Message:
vfs(9): Sprinkle KNF.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/kern/vfs_acl.c
cvs rdiff -u -r1.303 -r1.304 src/sys/kern/vfs_bio.c
cvs rdiff -u -r1.156 -r1.157 src/sys/kern/vfs_cache.c
cvs rdiff -u -r1.11 -r1.12 src/sys/kern/vfs_cwd.c
cvs rdiff -u -r1.15 -r1.16 src/sys/kern/vfs_dirhash.c
cvs rdiff -u -r1.61 -r1.62 src/sys/kern/vfs_getcwd.c
cvs rdiff -u -r1.6 -r1.7 src/sys/kern/vfs_hooks.c
cvs rdiff -u -r1.64 -r1.65 src/sys/kern/vfs_init.c
cvs rdiff -u -r1.81 -r1.82 src/sys/kern/vfs_lockf.c
cvs rdiff -u -r1.235 -r1.236 src/sys/kern/vfs_lookup.c
cvs rdiff -u -r1.107 -r1.108 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.500 -r1.501 src/sys/kern/vfs_subr.c
cvs rdiff -u -r1.568 -r1.569 src/sys/kern/vfs_syscalls.c
cvs rdiff -u -r1.70 -r1.71 src/sys/kern/vfs_trans.c
cvs rdiff -u -r1.153 -r1.154 src/sys/kern/vfs_vnode.c
cvs rdiff -u -r1.242 -r1.243 src/sys/kern/vfs_vnops.c
cvs rdiff -u -r1.113 -r1.114 src/sys/kern/vfs_wapbl.c
cvs rdiff -u -r1.39 -r1.40 src/sys/kern/vfs_xattr.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-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 19:17:44 UTC 2024

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

Log Message:
vmem(9): Sort includes, remove sharp edges from macros.

No functional change intended.  (And if changing /* nothing */ to
__nothing changed anything, it was already broken!)


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/kern/subr_vmem.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-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 19:18:00 UTC 2024

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

Log Message:
vmem(9): Sprinkle SET_ERROR dtrace probes.

PR kern/58378: Kernel error code origination lacks dtrace probes


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/kern/subr_vmem.c

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

Modified files:

Index: src/sys/kern/subr_vmem.c
diff -u src/sys/kern/subr_vmem.c:1.117 src/sys/kern/subr_vmem.c:1.118
--- src/sys/kern/subr_vmem.c:1.117	Fri Dec  6 19:17:44 2024
+++ src/sys/kern/subr_vmem.c	Fri Dec  6 19:17:59 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_vmem.c,v 1.117 2024/12/06 19:17:44 riastradh Exp $	*/
+/*	$NetBSD: subr_vmem.c,v 1.118 2024/12/06 19:17:59 riastradh Exp $	*/
 
 /*-
  * Copyright (c)2006,2007,2008,2009 YAMAMOTO Takashi,
@@ -46,7 +46,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.117 2024/12/06 19:17:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.118 2024/12/06 19:17:59 riastradh Exp $");
 
 #if defined(_KERNEL) && defined(_KERNEL_OPT)
 #include "opt_ddb.h"
@@ -66,6 +66,7 @@ __KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,
 #include 	/* hz */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -88,6 +89,8 @@ __KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,
 #include "../sys/vmem.h"
 #include "../sys/vmem_impl.h"
 
+#define	SET_ERROR(E)	(E)
+
 #endif /* defined(_KERNEL) */
 
 #if defined(_KERNEL)
@@ -289,7 +292,7 @@ bt_refill_locked(vmem_t *vm)
 	}
 
 	if (vm->vm_nfreetags <= BT_MINRESERVE) {
-		return ENOMEM;
+		return SET_ERROR(ENOMEM);
 	}
 
 	if (kmem_meta_arena != NULL) {
@@ -754,12 +757,12 @@ vmem_add1(vmem_t *vm, vmem_addr_t addr, 
 
 	btspan = bt_alloc(vm, flags);
 	if (btspan == NULL) {
-		return ENOMEM;
+		return SET_ERROR(ENOMEM);
 	}
 	btfree = bt_alloc(vm, flags);
 	if (btfree == NULL) {
 		bt_free(vm, btspan);
-		return ENOMEM;
+		return SET_ERROR(ENOMEM);
 	}
 
 	btspan->bt_type = spanbttype;
@@ -818,7 +821,7 @@ vmem_import(vmem_t *vm, vmem_size_t size
 	VMEM_ASSERT_LOCKED(vm);
 
 	if (vm->vm_importfn == NULL) {
-		return EINVAL;
+		return SET_ERROR(EINVAL);
 	}
 
 	if (vm->vm_flags & VM_LARGEIMPORT) {
@@ -835,14 +838,14 @@ vmem_import(vmem_t *vm, vmem_size_t size
 	VMEM_LOCK(vm);
 
 	if (rc) {
-		return ENOMEM;
+		return SET_ERROR(ENOMEM);
 	}
 
 	if (vmem_add1(vm, addr, size, flags, BT_TYPE_SPAN) != 0) {
 		VMEM_UNLOCK(vm);
 		(*vm->vm_releasefn)(vm->vm_arg, addr, size);
 		VMEM_LOCK(vm);
-		return ENOMEM;
+		return SET_ERROR(ENOMEM);
 	}
 
 	return 0;
@@ -866,7 +869,7 @@ vmem_rehash(vmem_t *vm, size_t newhashsi
 	newhashlist =
 	xmalloc(sizeof(struct vmem_hashlist) * newhashsize, flags);
 	if (newhashlist == NULL) {
-		return ENOMEM;
+		return SET_ERROR(ENOMEM);
 	}
 	for (i = 0; i < newhashsize; i++) {
 		LIST_INIT(&newhashlist[i]);
@@ -940,7 +943,7 @@ vmem_fit(const bt_t *bt, vmem_size_t siz
 		end = maxaddr;
 	}
 	if (start > end) {
-		return ENOMEM;
+		return SET_ERROR(ENOMEM);
 	}
 
 	start = VMEM_ALIGNUP(start - phase, align) + phase;
@@ -961,7 +964,7 @@ vmem_fit(const bt_t *bt, vmem_size_t siz
 		*addrp = start;
 		return 0;
 	}
-	return ENOMEM;
+	return SET_ERROR(ENOMEM);
 }
 
 /*  vmem API */
@@ -1140,7 +1143,7 @@ vmem_alloc(vmem_t *vm, vmem_size_t size,
 		p = pool_cache_get(qc->qc_cache, vmf_to_prf(flags));
 		if (addrp != NULL)
 			*addrp = (vmem_addr_t)p;
-		error = (p == NULL) ? ENOMEM : 0;
+		error = (p == NULL) ? SET_ERROR(ENOMEM) : 0;
 		goto out;
 	}
 #endif /* defined(QCACHE) */
@@ -1223,13 +1226,13 @@ vmem_xalloc(vmem_t *vm, const vmem_size_
 	btnew = bt_alloc(vm, flags);
 	if (btnew == NULL) {
 		VMEM_UNLOCK(vm);
-		return ENOMEM;
+		return SET_ERROR(ENOMEM);
 	}
 	btnew2 = bt_alloc(vm, flags); /* XXX not necessary if no restrictions */
 	if (btnew2 == NULL) {
 		bt_free(vm, btnew);
 		VMEM_UNLOCK(vm);
-		return ENOMEM;
+		return SET_ERROR(ENOMEM);
 	}
 
 	/*
@@ -1320,7 +1323,7 @@ fail:
 	bt_free(vm, btnew);
 	bt_free(vm, btnew2);
 	VMEM_UNLOCK(vm);
-	return ENOMEM;
+	return SET_ERROR(ENOMEM);
 
 gotit:
 	KASSERT(bt->bt_type == BT_TYPE_FREE);



CVS commit: src/sys/kern

2024-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 19:17:44 UTC 2024

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

Log Message:
vmem(9): Sort includes, remove sharp edges from macros.

No functional change intended.  (And if changing /* nothing */ to
__nothing changed anything, it was already broken!)


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/kern/subr_vmem.c

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

Modified files:

Index: src/sys/kern/subr_vmem.c
diff -u src/sys/kern/subr_vmem.c:1.116 src/sys/kern/subr_vmem.c:1.117
--- src/sys/kern/subr_vmem.c:1.116	Wed Apr 24 02:08:03 2024
+++ src/sys/kern/subr_vmem.c	Fri Dec  6 19:17:44 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_vmem.c,v 1.116 2024/04/24 02:08:03 thorpej Exp $	*/
+/*	$NetBSD: subr_vmem.c,v 1.117 2024/12/06 19:17:44 riastradh Exp $	*/
 
 /*-
  * Copyright (c)2006,2007,2008,2009 YAMAMOTO Takashi,
@@ -46,54 +46,63 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.116 2024/04/24 02:08:03 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.117 2024/12/06 19:17:44 riastradh Exp $");
 
 #if defined(_KERNEL) && defined(_KERNEL_OPT)
 #include "opt_ddb.h"
 #endif /* defined(_KERNEL) && defined(_KERNEL_OPT) */
 
 #include 
+#include 
+
+#include 
 #include 
 #include 
-#include 
 
 #if defined(_KERNEL)
-#include 
-#include 	/* hz */
+
+#include 
 #include 
+#include 	/* hz */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-#include 
+
 #include 
 #include 
 #include 
 #include 
 #include 
+
 #else /* defined(_KERNEL) */
-#include 
-#include 
+
 #include 
+#include 
+#include 
 #include 
 #include 
+
 #include "../sys/vmem.h"
 #include "../sys/vmem_impl.h"
-#endif /* defined(_KERNEL) */
 
+#endif /* defined(_KERNEL) */
 
 #if defined(_KERNEL)
+
 #include 
+
 #define VMEM_EVCNT_DEFINE(name) \
 struct evcnt vmem_evcnt_##name = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, \
 "vmem", #name); \
-EVCNT_ATTACH_STATIC(vmem_evcnt_##name);
-#define VMEM_EVCNT_INCR(ev)	vmem_evcnt_##ev.ev_count++
-#define VMEM_EVCNT_DECR(ev)	vmem_evcnt_##ev.ev_count--
+EVCNT_ATTACH_STATIC(vmem_evcnt_##name)
+#define VMEM_EVCNT_INCR(ev)	(vmem_evcnt_##ev.ev_count++)
+#define VMEM_EVCNT_DECR(ev)	(vmem_evcnt_##ev.ev_count--)
 
-VMEM_EVCNT_DEFINE(static_bt_count)
-VMEM_EVCNT_DEFINE(static_bt_inuse)
+VMEM_EVCNT_DEFINE(static_bt_count);
+VMEM_EVCNT_DEFINE(static_bt_inuse);
 
 #define	VMEM_CONDVAR_INIT(vm, wchan)	cv_init(&vm->vm_cv, wchan)
 #define	VMEM_CONDVAR_DESTROY(vm)	cv_destroy(&vm->vm_cv)
@@ -102,31 +111,32 @@ VMEM_EVCNT_DEFINE(static_bt_inuse)
 
 #else /* defined(_KERNEL) */
 
-#define VMEM_EVCNT_INCR(ev)	/* nothing */
-#define VMEM_EVCNT_DECR(ev)	/* nothing */
+#define VMEM_EVCNT_INCR(ev)	__nothing
+#define VMEM_EVCNT_DECR(ev)	__nothing
 
-#define	VMEM_CONDVAR_INIT(vm, wchan)	/* nothing */
-#define	VMEM_CONDVAR_DESTROY(vm)	/* nothing */
-#define	VMEM_CONDVAR_WAIT(vm)		/* nothing */
-#define	VMEM_CONDVAR_BROADCAST(vm)	/* nothing */
+#define	VMEM_CONDVAR_INIT(vm, wchan)	__nothing
+#define	VMEM_CONDVAR_DESTROY(vm)	__nothing
+#define	VMEM_CONDVAR_WAIT(vm)		__nothing
+#define	VMEM_CONDVAR_BROADCAST(vm)	__nothing
 
 #define	UNITTEST
 #define	KASSERT(a)		assert(a)
 #define	KASSERTMSG(a, m, ...)	assert(a)
-#define	mutex_init(a, b, c)	/* nothing */
-#define	mutex_destroy(a)	/* nothing */
-#define	mutex_enter(a)		/* nothing */
+#define	mutex_init(a, b, c)	__nothing
+#define	mutex_destroy(a)	__nothing
+#define	mutex_enter(a)		__nothing
 #define	mutex_tryenter(a)	true
-#define	mutex_exit(a)		/* nothing */
+#define	mutex_exit(a)		__nothing
 #define	mutex_owned(a)		true
-#define	ASSERT_SLEEPABLE()	/* nothing */
-#define	panic(...)		printf(__VA_ARGS__); abort()
+#define	ASSERT_SLEEPABLE()	__nothing
+#define	panic(...)		(printf(__VA_ARGS__), abort())
+
 #endif /* defined(_KERNEL) */
 
 #if defined(VMEM_SANITY)
 static void vmem_check(vmem_t *);
 #else /* defined(VMEM_SANITY) */
-#define vmem_check(vm)	/* nothing */
+#define vmem_check(vm)	__nothing
 #endif /* defined(VMEM_SANITY) */
 
 #define	VMEM_HASHSIZE_MIN	1	/* XXX */
@@ -174,7 +184,7 @@ static void vmem_xfree_bt(vmem_t *, bt_t
 #define	xfree(p, sz)		free(p)
 #define	bt_alloc(vm, flags)	malloc(sizeof(bt_t))
 #define	bt_free(vm, bt)		free(bt)
-#define	bt_freetrim(vm, l)	/* nothing */
+#define	bt_freetrim(vm, l)	__nothing
 #else /* defined(_KERNEL) */
 
 #define	xmalloc(sz, flags) \



CVS commit: src/sys/kern

2024-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 19:18:00 UTC 2024

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

Log Message:
vmem(9): Sprinkle SET_ERROR dtrace probes.

PR kern/58378: Kernel error code origination lacks dtrace probes


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/kern/subr_vmem.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-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 18:44:00 UTC 2024

Modified Files:
src/sys/kern: sys_socket.c uipc_accf.c uipc_domain.c uipc_mbuf.c
uipc_sem.c uipc_socket.c uipc_socket2.c uipc_syscalls.c
uipc_usrreq.c

Log Message:
sys/kern/sys_socket.c, uipc_*.c: Sprinkle SET_ERROR dtrace probes.

PR kern/58378: Kernel error code origination lacks dtrace probes


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/kern/sys_socket.c
cvs rdiff -u -r1.15 -r1.16 src/sys/kern/uipc_accf.c
cvs rdiff -u -r1.110 -r1.111 src/sys/kern/uipc_domain.c
cvs rdiff -u -r1.253 -r1.254 src/sys/kern/uipc_mbuf.c
cvs rdiff -u -r1.61 -r1.62 src/sys/kern/uipc_sem.c
cvs rdiff -u -r1.312 -r1.313 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.145 -r1.146 src/sys/kern/uipc_socket2.c
cvs rdiff -u -r1.213 -r1.214 src/sys/kern/uipc_syscalls.c
cvs rdiff -u -r1.205 -r1.206 src/sys/kern/uipc_usrreq.c

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

Modified files:

Index: src/sys/kern/sys_socket.c
diff -u src/sys/kern/sys_socket.c:1.83 src/sys/kern/sys_socket.c:1.84
--- src/sys/kern/sys_socket.c:1.83	Fri Dec  6 18:36:47 2024
+++ src/sys/kern/sys_socket.c	Fri Dec  6 18:44:00 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_socket.c,v 1.83 2024/12/06 18:36:47 riastradh Exp $	*/
+/*	$NetBSD: sys_socket.c,v 1.84 2024/12/06 18:44:00 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.83 2024/12/06 18:36:47 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.84 2024/12/06 18:44:00 riastradh Exp $");
 
 #include 
 #include 
@@ -73,6 +73,7 @@ __KERNEL_RCSID(0, "$NetBSD: sys_socket.c
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -279,7 +280,7 @@ soo_fpathconf(struct file *fp, int name,
 		*retval = PIPE_BUF;
 		return 0;
 	default:
-		return EINVAL;
+		return SET_ERROR(EINVAL);
 	}
 }
 
@@ -287,5 +288,5 @@ static int
 soo_posix_fadvise(struct file *fp, off_t offset, off_t len, int advice)
 {
 
-	return ESPIPE;
+	return SET_ERROR(ESPIPE);
 }

Index: src/sys/kern/uipc_accf.c
diff -u src/sys/kern/uipc_accf.c:1.15 src/sys/kern/uipc_accf.c:1.16
--- src/sys/kern/uipc_accf.c:1.15	Fri Dec  6 18:36:47 2024
+++ src/sys/kern/uipc_accf.c	Fri Dec  6 18:44:00 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_accf.c,v 1.15 2024/12/06 18:36:47 riastradh Exp $	*/
+/*	$NetBSD: uipc_accf.c,v 1.16 2024/12/06 18:44:00 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_accf.c,v 1.15 2024/12/06 18:36:47 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_accf.c,v 1.16 2024/12/06 18:44:00 riastradh Exp $");
 
 #define ACCEPT_FILTER_MOD
 
@@ -76,6 +76,7 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_accf.c,
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -118,7 +119,7 @@ accept_filt_add(struct accept_filter *fi
 	LIST_FOREACH(p, &accept_filtlsthd, accf_next) {
 		if (strcmp(p->accf_name, filt->accf_name) == 0)  {
 			rw_exit(&accept_filter_lock);
-			return EEXIST;
+			return SET_ERROR(EEXIST);
 		}
 	}
 	LIST_INSERT_HEAD(&accept_filtlsthd, filt, accf_next);
@@ -134,7 +135,7 @@ accept_filt_del(struct accept_filter *p)
 	rw_enter(&accept_filter_lock, RW_WRITER);
 	if (p->accf_refcnt != 0) {
 		rw_exit(&accept_filter_lock);
-		return EBUSY;
+		return SET_ERROR(EBUSY);
 	}
 	LIST_REMOVE(p, accf_next);
 	rw_exit(&accept_filter_lock);
@@ -208,11 +209,11 @@ accept_filt_getopt(struct socket *so, st
 	KASSERT(solocked(so));
 
 	if ((so->so_options & SO_ACCEPTCONN) == 0) {
-		error = EINVAL;
+		error = SET_ERROR(EINVAL);
 		goto out;
 	}
 	if ((so->so_options & SO_ACCEPTFILTER) == 0) {
-		error = EINVAL;
+		error = SET_ERROR(EINVAL);
 		goto out;
 	}
 
@@ -239,7 +240,7 @@ accept_filt_clear(struct socket *so)
 	KASSERT(solocked(so));
 
 	if ((so->so_options & SO_ACCEPTCONN) == 0) {
-		return EINVAL;
+		return SET_ERROR(EINVAL);
 	}
 	if (so->so_accf != NULL) {
 		/* Break in-flight processing. */
@@ -304,7 +305,7 @@ accept_filt_setopt(struct socket *so, co
 	afp = accept_filt_get(afa.af_name);
 	if (afp == NULL) {
 		solock(so);
-		return ENOENT;
+		return SET_ERROR(ENOENT);
 	}
 	/*
 	 * Allocate the new accept filter instance storage.  We may
@@ -333,7 +334,7 @@ accept_filt_setopt(struct socket *so, co
 	 */
 	solock(so);
 	if ((so->so_options & SO_ACCEPTCONN) == 0 || so->so_accf != NULL) {
-		error = EINVAL;
+		error = SET_ERROR(EINVAL);
 		goto out;
 	}
 
@@ -346,7 +347,7 @@ accept_filt_setopt(struct socket *so, co
 		newaf->so_accept_filter_arg =
 		(*afp->accf_create)(so, afa.af_arg);
 		if (newaf->so_accept_filter_arg == NULL) {
-			error = EINVAL;
+			error = SET_ERROR(EINVAL);
 			goto out;
 		}
 	}

Index: src/sys/kern/uipc_domain.c
diff -u src/sys/kern/uipc_domain.c:1.110 src/sys/ker

CVS commit: src/sys/kern

2024-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 18:44:00 UTC 2024

Modified Files:
src/sys/kern: sys_socket.c uipc_accf.c uipc_domain.c uipc_mbuf.c
uipc_sem.c uipc_socket.c uipc_socket2.c uipc_syscalls.c
uipc_usrreq.c

Log Message:
sys/kern/sys_socket.c, uipc_*.c: Sprinkle SET_ERROR dtrace probes.

PR kern/58378: Kernel error code origination lacks dtrace probes


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/kern/sys_socket.c
cvs rdiff -u -r1.15 -r1.16 src/sys/kern/uipc_accf.c
cvs rdiff -u -r1.110 -r1.111 src/sys/kern/uipc_domain.c
cvs rdiff -u -r1.253 -r1.254 src/sys/kern/uipc_mbuf.c
cvs rdiff -u -r1.61 -r1.62 src/sys/kern/uipc_sem.c
cvs rdiff -u -r1.312 -r1.313 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.145 -r1.146 src/sys/kern/uipc_socket2.c
cvs rdiff -u -r1.213 -r1.214 src/sys/kern/uipc_syscalls.c
cvs rdiff -u -r1.205 -r1.206 src/sys/kern/uipc_usrreq.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-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 18:36:47 UTC 2024

Modified Files:
src/sys/kern: sys_socket.c uipc_accf.c uipc_socket.c uipc_socket2.c
uipc_usrreq.c

Log Message:
sys/kern/sys_socket.c, uipc_*.c: Nix trailing whitespace.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/kern/sys_socket.c
cvs rdiff -u -r1.14 -r1.15 src/sys/kern/uipc_accf.c
cvs rdiff -u -r1.311 -r1.312 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.144 -r1.145 src/sys/kern/uipc_socket2.c
cvs rdiff -u -r1.204 -r1.205 src/sys/kern/uipc_usrreq.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-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 18:36:31 UTC 2024

Modified Files:
src/sys/kern: sys_socket.c uipc_accf.c uipc_domain.c uipc_mbuf.c
uipc_mbufdebug.c uipc_proto.c uipc_sem.c uipc_socket.c
uipc_socket2.c uipc_syscalls.c uipc_usrreq.c

Log Message:
sys/kern/sys_socket.c, uipc_*.c: Sort includes.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/kern/sys_socket.c
cvs rdiff -u -r1.13 -r1.14 src/sys/kern/uipc_accf.c
cvs rdiff -u -r1.109 -r1.110 src/sys/kern/uipc_domain.c
cvs rdiff -u -r1.252 -r1.253 src/sys/kern/uipc_mbuf.c
cvs rdiff -u -r1.7 -r1.8 src/sys/kern/uipc_mbufdebug.c
cvs rdiff -u -r1.23 -r1.24 src/sys/kern/uipc_proto.c
cvs rdiff -u -r1.60 -r1.61 src/sys/kern/uipc_sem.c
cvs rdiff -u -r1.310 -r1.311 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.143 -r1.144 src/sys/kern/uipc_socket2.c
cvs rdiff -u -r1.212 -r1.213 src/sys/kern/uipc_syscalls.c
cvs rdiff -u -r1.203 -r1.204 src/sys/kern/uipc_usrreq.c

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

Modified files:

Index: src/sys/kern/sys_socket.c
diff -u src/sys/kern/sys_socket.c:1.81 src/sys/kern/sys_socket.c:1.82
--- src/sys/kern/sys_socket.c:1.81	Sat Apr 22 13:53:02 2023
+++ src/sys/kern/sys_socket.c	Fri Dec  6 18:36:31 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_socket.c,v 1.81 2023/04/22 13:53:02 riastradh Exp $	*/
+/*	$NetBSD: sys_socket.c,v 1.82 2024/12/06 18:36:31 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,21 +61,22 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.81 2023/04/22 13:53:02 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.82 2024/12/06 18:36:31 riastradh Exp $");
 
 #include 
-#include 
-#include 
+#include 
+
 #include 
+#include 
+#include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
-#include 
 #include 
-#include 
-#include 
-#include 
+#include 
 
 #include 
 #include 

Index: src/sys/kern/uipc_accf.c
diff -u src/sys/kern/uipc_accf.c:1.13 src/sys/kern/uipc_accf.c:1.14
--- src/sys/kern/uipc_accf.c:1.13	Tue Feb 25 18:30:11 2014
+++ src/sys/kern/uipc_accf.c	Fri Dec  6 18:36:31 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_accf.c,v 1.13 2014/02/25 18:30:11 pooka Exp $	*/
+/*	$NetBSD: uipc_accf.c,v 1.14 2024/12/06 18:36:31 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,26 +58,28 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_accf.c,v 1.13 2014/02/25 18:30:11 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_accf.c,v 1.14 2024/12/06 18:36:31 riastradh Exp $");
 
 #define ACCEPT_FILTER_MOD
 
 #include 
-#include 
+#include 
+
+#include 
 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
-#include 
+#include 
+#include 
 #include 
-#include 
+#include 
+#include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
+#include 
+#include 
 
 static krwlock_t accept_filter_lock;
 

Index: src/sys/kern/uipc_domain.c
diff -u src/sys/kern/uipc_domain.c:1.109 src/sys/kern/uipc_domain.c:1.110
--- src/sys/kern/uipc_domain.c:1.109	Thu Mar 30 15:58:21 2023
+++ src/sys/kern/uipc_domain.c	Fri Dec  6 18:36:31 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_domain.c,v 1.109 2023/03/30 15:58:21 riastradh Exp $	*/
+/*	$NetBSD: uipc_domain.c,v 1.110 2024/12/06 18:36:31 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -32,29 +32,31 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.109 2023/03/30 15:58:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.110 2024/12/06 18:36:31 riastradh Exp $");
 
 #include 
-#include 
-#include 
-#include 
+#include 
+
+#include 
 #include 
-#include 
-#include 
+#include 
+#include 
+#include 
 #include 
-#include 
-#include 
-#include 
+#include 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include 
+#include 
+#include 
 #include 
 #include 
-#include 
-#include 
-#include 
 
-#include 
 #include 
+#include 
 #include 
 
 MALLOC_DECLARE(M_SOCKADDR);

Index: src/sys/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.252 src/sys/kern/uipc_mbuf.c:1.253
--- src/sys/kern/uipc_mbuf.c:1.252	Mon Nov 27 02:50:27 2023
+++ src/sys/kern/uipc_mbuf.c	Fri Dec  6 18:36:31 2024
@@ -1,4 +1,5 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.252 2023/11/27 02:50:27 ozaki-r Exp $	*/
+
+/*	$NetBSD: uipc_mbuf.c,v 1.253 2024/12/06 18:36:31 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1999, 2001, 2018 The NetBSD Foundation, Inc.
@@ -62,29 +63,31 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.252 2023/11/27 02:50:27 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.253 2024/12/06 18:36:31 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
+#include "ether.h"
+#include "opt_ddb.h"
 #include "opt_mbuftrace.h"
 #include "opt_nmbclusters.h"
-#include "opt_ddb.h"
-#include "ether.h"
 #endif
 
 #include 
-#include 
+#include 
+
 #include 
 #include 
-#inc

CVS commit: src/sys/kern

2024-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 18:36:47 UTC 2024

Modified Files:
src/sys/kern: sys_socket.c uipc_accf.c uipc_socket.c uipc_socket2.c
uipc_usrreq.c

Log Message:
sys/kern/sys_socket.c, uipc_*.c: Nix trailing whitespace.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/kern/sys_socket.c
cvs rdiff -u -r1.14 -r1.15 src/sys/kern/uipc_accf.c
cvs rdiff -u -r1.311 -r1.312 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.144 -r1.145 src/sys/kern/uipc_socket2.c
cvs rdiff -u -r1.204 -r1.205 src/sys/kern/uipc_usrreq.c

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

Modified files:

Index: src/sys/kern/sys_socket.c
diff -u src/sys/kern/sys_socket.c:1.82 src/sys/kern/sys_socket.c:1.83
--- src/sys/kern/sys_socket.c:1.82	Fri Dec  6 18:36:31 2024
+++ src/sys/kern/sys_socket.c	Fri Dec  6 18:36:47 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_socket.c,v 1.82 2024/12/06 18:36:31 riastradh Exp $	*/
+/*	$NetBSD: sys_socket.c,v 1.83 2024/12/06 18:36:47 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.82 2024/12/06 18:36:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.83 2024/12/06 18:36:47 riastradh Exp $");
 
 #include 
 #include 
@@ -139,7 +139,7 @@ soo_ioctl(file_t *fp, u_long cmd, void *
 		solock(so);
 		if (*(int *)data)
 			so->so_state |= SS_NBIO;
-		else 
+		else
 			so->so_state &= ~SS_NBIO;
 		sounlock(so);
 		break;

Index: src/sys/kern/uipc_accf.c
diff -u src/sys/kern/uipc_accf.c:1.14 src/sys/kern/uipc_accf.c:1.15
--- src/sys/kern/uipc_accf.c:1.14	Fri Dec  6 18:36:31 2024
+++ src/sys/kern/uipc_accf.c	Fri Dec  6 18:36:47 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_accf.c,v 1.14 2024/12/06 18:36:31 riastradh Exp $	*/
+/*	$NetBSD: uipc_accf.c,v 1.15 2024/12/06 18:36:47 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_accf.c,v 1.14 2024/12/06 18:36:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_accf.c,v 1.15 2024/12/06 18:36:47 riastradh Exp $");
 
 #define ACCEPT_FILTER_MOD
 
@@ -120,7 +120,7 @@ accept_filt_add(struct accept_filter *fi
 			rw_exit(&accept_filter_lock);
 			return EEXIST;
 		}
-	}
+	}
 	LIST_INSERT_HEAD(&accept_filtlsthd, filt, accf_next);
 	rw_exit(&accept_filter_lock);
 
@@ -187,7 +187,7 @@ accept_filter_init0(void)
 }
 
 /*
- * Initialization routine: This can also be replaced with 
+ * Initialization routine: This can also be replaced with
  * accept_filt_generic_mod_event for attaching new accept filter.
  */
 

Index: src/sys/kern/uipc_socket.c
diff -u src/sys/kern/uipc_socket.c:1.311 src/sys/kern/uipc_socket.c:1.312
--- src/sys/kern/uipc_socket.c:1.311	Fri Dec  6 18:36:31 2024
+++ src/sys/kern/uipc_socket.c	Fri Dec  6 18:36:47 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_socket.c,v 1.311 2024/12/06 18:36:31 riastradh Exp $	*/
+/*	$NetBSD: uipc_socket.c,v 1.312 2024/12/06 18:36:47 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2002, 2007, 2008, 2009, 2023 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.311 2024/12/06 18:36:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.312 2024/12/06 18:36:47 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -455,7 +455,7 @@ soinit(void)
 	/* Update the SCTP function hooks if necessary*/
 
 vec_sctp_add_ip_address = sctp_add_ip_address;
-vec_sctp_delete_ip_address = sctp_delete_ip_address; 
+vec_sctp_delete_ip_address = sctp_delete_ip_address;
 #endif
 
 	mutex_init(&so_pendfree_lock, MUTEX_DEFAULT, IPL_VM);
@@ -576,7 +576,7 @@ socreate(int dom, struct socket **aso, i
  * Caller is responsible for calling fd_affix() for the returned *fpp once
  * it's socket initialization is finished successfully, or fd_abort() if it's
  * initialization fails.
- * 
+ *
  *
  * => On success, write file descriptor to *fdout and *fpp and return zero.
  * => On failure, return non-zero; *fdout and *fpp will be undefined.

Index: src/sys/kern/uipc_socket2.c
diff -u src/sys/kern/uipc_socket2.c:1.144 src/sys/kern/uipc_socket2.c:1.145
--- src/sys/kern/uipc_socket2.c:1.144	Fri Dec  6 18:36:31 2024
+++ src/sys/kern/uipc_socket2.c	Fri Dec  6 18:36:47 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_socket2.c,v 1.144 2024/12/06 18:36:31 riastradh Exp $	*/
+/*	$NetBSD: uipc_socket2.c,v 1.145 2024/12/06 18:36:47 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.144 2024/12/06 18:36:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.145 2024/12/06 18:36:47 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -578,7 +578,7 @@ sowakeup(s

CVS commit: src/sys/kern

2024-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 18:36:31 UTC 2024

Modified Files:
src/sys/kern: sys_socket.c uipc_accf.c uipc_domain.c uipc_mbuf.c
uipc_mbufdebug.c uipc_proto.c uipc_sem.c uipc_socket.c
uipc_socket2.c uipc_syscalls.c uipc_usrreq.c

Log Message:
sys/kern/sys_socket.c, uipc_*.c: Sort includes.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/kern/sys_socket.c
cvs rdiff -u -r1.13 -r1.14 src/sys/kern/uipc_accf.c
cvs rdiff -u -r1.109 -r1.110 src/sys/kern/uipc_domain.c
cvs rdiff -u -r1.252 -r1.253 src/sys/kern/uipc_mbuf.c
cvs rdiff -u -r1.7 -r1.8 src/sys/kern/uipc_mbufdebug.c
cvs rdiff -u -r1.23 -r1.24 src/sys/kern/uipc_proto.c
cvs rdiff -u -r1.60 -r1.61 src/sys/kern/uipc_sem.c
cvs rdiff -u -r1.310 -r1.311 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.143 -r1.144 src/sys/kern/uipc_socket2.c
cvs rdiff -u -r1.212 -r1.213 src/sys/kern/uipc_syscalls.c
cvs rdiff -u -r1.203 -r1.204 src/sys/kern/uipc_usrreq.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-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 16:48:14 UTC 2024

Modified Files:
src/sys/kern: exec_subr.c kern_exec.c

Log Message:
sys/kern/kern_exec.c, exec_*.c: Nix trailing whitespace.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/kern/exec_subr.c
cvs rdiff -u -r1.524 -r1.525 src/sys/kern/kern_exec.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-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 16:48:14 UTC 2024

Modified Files:
src/sys/kern: exec_subr.c kern_exec.c

Log Message:
sys/kern/kern_exec.c, exec_*.c: Nix trailing whitespace.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/kern/exec_subr.c
cvs rdiff -u -r1.524 -r1.525 src/sys/kern/kern_exec.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/exec_subr.c
diff -u src/sys/kern/exec_subr.c:1.90 src/sys/kern/exec_subr.c:1.91
--- src/sys/kern/exec_subr.c:1.90	Fri Dec  6 16:19:41 2024
+++ src/sys/kern/exec_subr.c	Fri Dec  6 16:48:13 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec_subr.c,v 1.90 2024/12/06 16:19:41 riastradh Exp $	*/
+/*	$NetBSD: exec_subr.c,v 1.91 2024/12/06 16:48:13 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1993, 1994, 1996 Christopher G. Demetriou
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: exec_subr.c,v 1.90 2024/12/06 16:19:41 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exec_subr.c,v 1.91 2024/12/06 16:48:13 riastradh Exp $");
 
 #include "opt_pax.h"
 
@@ -422,7 +422,7 @@ exec_setup_stack(struct lwp *l, struct e
 	max_stack_size);
 
 	l->l_proc->p_stackbase = epp->ep_minsaddr;
-	
+
 	epp->ep_maxsaddr = (vaddr_t)STACK_GROW(epp->ep_minsaddr,
 	max_stack_size);
 

Index: src/sys/kern/kern_exec.c
diff -u src/sys/kern/kern_exec.c:1.524 src/sys/kern/kern_exec.c:1.525
--- src/sys/kern/kern_exec.c:1.524	Fri Dec  6 16:19:41 2024
+++ src/sys/kern/kern_exec.c	Fri Dec  6 16:48:13 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exec.c,v 1.524 2024/12/06 16:19:41 riastradh Exp $	*/
+/*	$NetBSD: kern_exec.c,v 1.525 2024/12/06 16:48:13 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.524 2024/12/06 16:19:41 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.525 2024/12/06 16:48:13 riastradh Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -310,7 +310,7 @@ static struct pool_allocator exec_palloc
 
 static void
 exec_path_free(struct execve_data *data)
-{  
+{
 	pathbuf_stringcopy_put(data->ed_pathbuf, data->ed_pathstring);
 	pathbuf_destroy(data->ed_pathbuf);
 	if (data->ed_resolvedname)
@@ -2224,7 +2224,7 @@ handle_posix_spawn_attrs(struct posix_sp
 	sigact._sa_u._sa_handler = SIG_DFL;
 	sigact.sa_flags = 0;
 
-	/* 
+	/*
 	 * set state to SSTOP so that this proc can be found by pid.
 	 * see proc_enterprp, do_sched_setparam below
 	 */
@@ -2443,7 +2443,7 @@ posix_spawn_fae_path(struct posix_spawn_
 		return NULL;
 	}
 }
-
+
 void
 posix_spawn_fa_free(struct posix_spawn_file_actions *fa, size_t len)
 {
@@ -2604,7 +2604,7 @@ do_posix_spawn(struct lwp *l1, pid_t *pi
 		error = SET_ERROR(ENOMEM);
 		goto error_exit;
 	}
-	
+
 	/*
 	 * Allocate new proc. Borrow proc0 vmspace for it, we will
 	 * replace it with its own before returning to userland
@@ -2867,7 +2867,7 @@ sys_posix_spawn(struct lwp *l1, const st
 		syscallarg(const struct posix_spawnattr *) attrp;
 		syscallarg(char *const *) argv;
 		syscallarg(char *const *) envp;
-	} */	
+	} */
 
 	int error;
 	struct posix_spawn_file_actions *fa = NULL;
@@ -2954,7 +2954,7 @@ dump_vmcmds(const struct exec_package * 
 	if (error == 0)
 		DPRINTF(("vmcmds %u\n", epp->ep_vmcmds.evs_used));
 	else
-		DPRINTF(("vmcmds %zu/%u, error %d\n", x, 
+		DPRINTF(("vmcmds %zu/%u, error %d\n", x,
 		epp->ep_vmcmds.evs_used, error));
 
 	for (j = 0; j < epp->ep_vmcmds.evs_used; j++) {



CVS commit: src/sys/kern

2024-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 16:19:41 UTC 2024

Modified Files:
src/sys/kern: exec_aout.c exec_ecoff.c exec_elf.c exec_elf32.c
exec_elf64.c exec_script.c exec_subr.c kern_exec.c

Log Message:
sys/kern/kern_exec.c, exec_*.c: Sprinkle SET_ERROR dtrace probes.

PR kern/58378: Kernel error code origination lacks dtrace probes


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/kern/exec_aout.c
cvs rdiff -u -r1.33 -r1.34 src/sys/kern/exec_ecoff.c
cvs rdiff -u -r1.106 -r1.107 src/sys/kern/exec_elf.c
cvs rdiff -u -r1.143 -r1.144 src/sys/kern/exec_elf32.c
cvs rdiff -u -r1.8 -r1.9 src/sys/kern/exec_elf64.c
cvs rdiff -u -r1.84 -r1.85 src/sys/kern/exec_script.c
cvs rdiff -u -r1.89 -r1.90 src/sys/kern/exec_subr.c
cvs rdiff -u -r1.523 -r1.524 src/sys/kern/kern_exec.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/exec_aout.c
diff -u src/sys/kern/exec_aout.c:1.42 src/sys/kern/exec_aout.c:1.43
--- src/sys/kern/exec_aout.c:1.42	Fri Dec  6 16:18:41 2024
+++ src/sys/kern/exec_aout.c	Fri Dec  6 16:19:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec_aout.c,v 1.42 2024/12/06 16:18:41 riastradh Exp $	*/
+/*	$NetBSD: exec_aout.c,v 1.43 2024/12/06 16:19:41 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1993, 1994 Christopher G. Demetriou
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: exec_aout.c,v 1.42 2024/12/06 16:18:41 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exec_aout.c,v 1.43 2024/12/06 16:19:41 riastradh Exp $");
 
 #include 
 #include 
@@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: exec_aout.c,
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -75,7 +76,7 @@ exec_aout_modcmd(modcmd_t cmd, void *arg
 		return exec_remove(&exec_aout_execsw, 1);
 
 	default:
-		return ENOTTY;
+		return SET_ERROR(ENOTTY);
 }
 }
 
@@ -100,7 +101,7 @@ exec_aout_makecmds(struct lwp *l, struct
 	struct exec *execp = epp->ep_hdr;
 
 	if (epp->ep_hdrvalid < sizeof(struct exec))
-		return ENOEXEC;
+		return SET_ERROR(ENOEXEC);
 
 	midmag = ntohl(execp->a_midmag);
 	mid = (midmag >> 16) & 0x3ff;

Index: src/sys/kern/exec_ecoff.c
diff -u src/sys/kern/exec_ecoff.c:1.33 src/sys/kern/exec_ecoff.c:1.34
--- src/sys/kern/exec_ecoff.c:1.33	Fri Dec  6 16:18:41 2024
+++ src/sys/kern/exec_ecoff.c	Fri Dec  6 16:19:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec_ecoff.c,v 1.33 2024/12/06 16:18:41 riastradh Exp $	*/
+/*	$NetBSD: exec_ecoff.c,v 1.34 2024/12/06 16:19:41 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1994 Adam Glass
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: exec_ecoff.c,v 1.33 2024/12/06 16:18:41 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exec_ecoff.c,v 1.34 2024/12/06 16:19:41 riastradh Exp $");
 
 #include 
 #include 
@@ -44,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: exec_ecoff.c
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -75,7 +76,7 @@ exec_ecoff_modcmd(modcmd_t cmd, void *ar
 		return exec_remove(&exec_ecoff_execsw, 1);
 
 	default:
-		return ENOTTY;
+		return SET_ERROR(ENOTTY);
 }
 }
 
@@ -97,10 +98,10 @@ exec_ecoff_makecmds(struct lwp *l, struc
 	struct ecoff_exechdr *execp = epp->ep_hdr;
 
 	if (epp->ep_hdrvalid < ECOFF_HDR_SIZE)
-		return ENOEXEC;
+		return SET_ERROR(ENOEXEC);
 
 	if (ECOFF_BADMAG(execp))
-		return ENOEXEC;
+		return SET_ERROR(ENOEXEC);
 
 	error = (*epp->ep_esch->u.ecoff_probe_func)(l, epp);
 
@@ -130,7 +131,7 @@ exec_ecoff_makecmds(struct lwp *l, struc
 		   epp->ep_vp);
 		break;
 	default:
-		return ENOEXEC;
+		return SET_ERROR(ENOEXEC);
 	}
 
 	/* set up the stack */

Index: src/sys/kern/exec_elf.c
diff -u src/sys/kern/exec_elf.c:1.106 src/sys/kern/exec_elf.c:1.107
--- src/sys/kern/exec_elf.c:1.106	Fri Dec  6 16:18:41 2024
+++ src/sys/kern/exec_elf.c	Fri Dec  6 16:19:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec_elf.c,v 1.106 2024/12/06 16:18:41 riastradh Exp $	*/
+/*	$NetBSD: exec_elf.c,v 1.107 2024/12/06 16:19:41 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1994, 2000, 2005, 2015, 2020 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.106 2024/12/06 16:18:41 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.107 2024/12/06 16:19:41 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pax.h"
@@ -76,6 +76,7 @@ __KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -140,7 +141,7 @@ elf_placedynexec(struct exec_package *ep
 	if ((offset & (align - 1)) != 0) {
 		DPRINTF("bad offset=%#jx align=%#jx",
 		(uintmax_t)offset, (uintmax_t)align);
-		return EINVAL;
+		return SET_ERROR(EINVAL);
 	}
 
 	for (i = 0; i < eh->e_phnum; i++)
@@ -292,7 +293,7 @@ elf_check_header(Elf_Ehdr *eh)
 		"e_ident[EI_CLASS] %#x", eh->e_ident[EI_MAG0],
 		eh->e_ident[EI_MAG1], eh->e_ident[EI_MAG2],
 		eh->e_ident[EI_MAG3], eh->e_

CVS commit: src/sys/kern

2024-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 16:19:41 UTC 2024

Modified Files:
src/sys/kern: exec_aout.c exec_ecoff.c exec_elf.c exec_elf32.c
exec_elf64.c exec_script.c exec_subr.c kern_exec.c

Log Message:
sys/kern/kern_exec.c, exec_*.c: Sprinkle SET_ERROR dtrace probes.

PR kern/58378: Kernel error code origination lacks dtrace probes


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/kern/exec_aout.c
cvs rdiff -u -r1.33 -r1.34 src/sys/kern/exec_ecoff.c
cvs rdiff -u -r1.106 -r1.107 src/sys/kern/exec_elf.c
cvs rdiff -u -r1.143 -r1.144 src/sys/kern/exec_elf32.c
cvs rdiff -u -r1.8 -r1.9 src/sys/kern/exec_elf64.c
cvs rdiff -u -r1.84 -r1.85 src/sys/kern/exec_script.c
cvs rdiff -u -r1.89 -r1.90 src/sys/kern/exec_subr.c
cvs rdiff -u -r1.523 -r1.524 src/sys/kern/kern_exec.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-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 16:18:41 UTC 2024

Modified Files:
src/sys/kern: exec_aout.c exec_ecoff.c exec_elf.c exec_script.c
exec_subr.c kern_exec.c

Log Message:
sys/kern/kern_exec.c, exec_*.c: Sort includes.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/kern/exec_aout.c
cvs rdiff -u -r1.32 -r1.33 src/sys/kern/exec_ecoff.c
cvs rdiff -u -r1.105 -r1.106 src/sys/kern/exec_elf.c
cvs rdiff -u -r1.83 -r1.84 src/sys/kern/exec_script.c
cvs rdiff -u -r1.88 -r1.89 src/sys/kern/exec_subr.c
cvs rdiff -u -r1.522 -r1.523 src/sys/kern/kern_exec.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-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 16:18:41 UTC 2024

Modified Files:
src/sys/kern: exec_aout.c exec_ecoff.c exec_elf.c exec_script.c
exec_subr.c kern_exec.c

Log Message:
sys/kern/kern_exec.c, exec_*.c: Sort includes.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/kern/exec_aout.c
cvs rdiff -u -r1.32 -r1.33 src/sys/kern/exec_ecoff.c
cvs rdiff -u -r1.105 -r1.106 src/sys/kern/exec_elf.c
cvs rdiff -u -r1.83 -r1.84 src/sys/kern/exec_script.c
cvs rdiff -u -r1.88 -r1.89 src/sys/kern/exec_subr.c
cvs rdiff -u -r1.522 -r1.523 src/sys/kern/kern_exec.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/exec_aout.c
diff -u src/sys/kern/exec_aout.c:1.41 src/sys/kern/exec_aout.c:1.42
--- src/sys/kern/exec_aout.c:1.41	Wed Nov 20 19:37:53 2019
+++ src/sys/kern/exec_aout.c	Fri Dec  6 16:18:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec_aout.c,v 1.41 2019/11/20 19:37:53 pgoyette Exp $	*/
+/*	$NetBSD: exec_aout.c,v 1.42 2024/12/06 16:18:41 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1993, 1994 Christopher G. Demetriou
@@ -31,16 +31,18 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: exec_aout.c,v 1.41 2019/11/20 19:37:53 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exec_aout.c,v 1.42 2024/12/06 16:18:41 riastradh Exp $");
 
 #include 
-#include 
-#include 
-#include 
+#include 
+
 #include 
 #include 
-#include 
 #include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
 

Index: src/sys/kern/exec_ecoff.c
diff -u src/sys/kern/exec_ecoff.c:1.32 src/sys/kern/exec_ecoff.c:1.33
--- src/sys/kern/exec_ecoff.c:1.32	Wed Nov 20 19:37:53 2019
+++ src/sys/kern/exec_ecoff.c	Fri Dec  6 16:18:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec_ecoff.c,v 1.32 2019/11/20 19:37:53 pgoyette Exp $	*/
+/*	$NetBSD: exec_ecoff.c,v 1.33 2024/12/06 16:18:41 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1994 Adam Glass
@@ -33,17 +33,19 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: exec_ecoff.c,v 1.32 2019/11/20 19:37:53 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exec_ecoff.c,v 1.33 2024/12/06 16:18:41 riastradh Exp $");
 
 #include 
-#include 
-#include 
-#include 
+#include 
+
 #include 
-#include 
-#include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 MODULE(MODULE_CLASS_EXEC, exec_ecoff, NULL);
 

Index: src/sys/kern/exec_elf.c
diff -u src/sys/kern/exec_elf.c:1.105 src/sys/kern/exec_elf.c:1.106
--- src/sys/kern/exec_elf.c:1.105	Thu Aug 17 06:58:26 2023
+++ src/sys/kern/exec_elf.c	Fri Dec  6 16:18:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec_elf.c,v 1.105 2023/08/17 06:58:26 rin Exp $	*/
+/*	$NetBSD: exec_elf.c,v 1.106 2024/12/06 16:18:41 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1994, 2000, 2005, 2015, 2020 The NetBSD Foundation, Inc.
@@ -57,32 +57,34 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.105 2023/08/17 06:58:26 rin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.106 2024/12/06 16:18:41 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pax.h"
 #endif /* _KERNEL_OPT */
 
 #include 
-#include 
-#include 
-#include 
-#include 
+#include 
+
+#include 
+#include 
 #include 
 #include 
-#include 
-#include 
+#include 
+#include 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include 
-#include 
-#include 
+#include 
+#include 
 
-#include 
 #include 
 
 #include 
 
-#include 
 #include 
 
 #define elf_check_header	ELFNAME(check_header)

Index: src/sys/kern/exec_script.c
diff -u src/sys/kern/exec_script.c:1.83 src/sys/kern/exec_script.c:1.84
--- src/sys/kern/exec_script.c:1.83	Mon May  3 10:25:14 2021
+++ src/sys/kern/exec_script.c	Fri Dec  6 16:18:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec_script.c,v 1.83 2021/05/03 10:25:14 fcambus Exp $	*/
+/*	$NetBSD: exec_script.c,v 1.84 2024/12/06 16:18:41 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1993, 1994, 1996 Christopher G. Demetriou
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: exec_script.c,v 1.83 2021/05/03 10:25:14 fcambus Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exec_script.c,v 1.84 2024/12/06 16:18:41 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_script.h"
@@ -42,21 +42,23 @@ __KERNEL_RCSID(0, "$NetBSD: exec_script.
 #endif
 
 #include 
-#include 
-#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
-#include 
+#include 
 #include 
-#include 
+#include 
+#include 
 #ifdef SETUIDSCRIPTS
 #include 
 #endif
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
+#include 
 
 MODULE(MODULE_CLASS_EXEC, exec_script, NULL);
 

Index: src/sys/kern/exec_subr.c
diff -u src/sys/kern/exec_subr.c:1.88 src/sys/kern/exec_subr.c:1.89
--- src/sys/kern/exec_subr.c:1.88	Tue Nov 21 14:35:36 2023
+++ src/sys/kern/exec_subr.c	Fri Dec  6 16:18:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec_subr.c,v 1.88 2023/11/21 14:35:36 riastradh Exp $	*/
+/*	$NetBSD:

CVS commit: src/sys/kern

2024-11-26 Thread Pierre Pronchery
Module Name:src
Committed By:   khorben
Date:   Tue Nov 26 23:10:15 UTC 2024

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

Log Message:
Typo in a comment


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/kern/sys_select.c

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

Modified files:

Index: src/sys/kern/sys_select.c
diff -u src/sys/kern/sys_select.c:1.67 src/sys/kern/sys_select.c:1.68
--- src/sys/kern/sys_select.c:1.67	Fri Oct 18 13:12:34 2024
+++ src/sys/kern/sys_select.c	Tue Nov 26 23:10:15 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_select.c,v 1.67 2024/10/18 13:12:34 kre Exp $	*/
+/*	$NetBSD: sys_select.c,v 1.68 2024/11/26 23:10:15 khorben Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2010, 2019, 2020, 2023
@@ -85,7 +85,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.67 2024/10/18 13:12:34 kre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.68 2024/11/26 23:10:15 khorben Exp $");
 
 #include 
 
@@ -395,7 +395,7 @@ selcommon(register_t *retval, int nd, fd
 	 * Don't allow absurdly large numbers of fds to be selected.
 	 * (used to silently truncate, naughty naughty, no more ...)
 	 *
-	 * The additional FD_SETSISE allows for cases where the limit
+	 * The additional FD_SETSIZE allows for cases where the limit
 	 * is not a round binary number, but the fd_set wants to
 	 * include all the possible fds, as fd_sets are always
 	 * multiples of 32 bits (__NFDBITS extra would be enough).



CVS commit: src/sys/kern

2024-11-26 Thread Pierre Pronchery
Module Name:src
Committed By:   khorben
Date:   Tue Nov 26 23:10:15 UTC 2024

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

Log Message:
Typo in a comment


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/kern/sys_select.c

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



Re: CVS commit: src/sys/kern

2024-11-10 Thread Robert Elz
Date:Sun, 10 Nov 2024 09:35:29 +
From:Taylor R Campbell 
Message-ID:  <20241110093534.e816384...@mail.netbsd.org>

  | Yikes!  Do you have a reproducer handy for this?

Yes, it turns out to be trivially easy to do, once the
bug is understood - just very rare to actually happen in
anything in the wild.

All you need is

main() {
dup3(0, 5, O_CLOEXEC);
/* use fcntl(5, F_GETFD) and verify
   close-on-exec is set if you want */
execl("verifier", "verifier", NULL);
}

plus all the boilerplate (#include) etc, and a little error checking, etc)
to 

where "verifier" is just

#!/bin/sh
fdflags -v

(executable) - or anything else which checks there are no open
fds in the new process which shouldn't be there and none with
close-on-exec set which should be impossible in a newly created
process.

Then you need another main() using fcntl(F_DUPFD_CLOEXEC) (or
also put that in the same one) and another which does whatever
is required to get the kernel fd_clone() function to be called
with flags containing O_CLOEXEC, that one I can't do (now anyway)
because I didn't bother to work out what that would be exactly.

  | Can you file a PR to record the reproducer, and track pullups?

I could, but I don't really think it is needed for this one.

No ATF tests to check it either - the tests can only ever be
for the specific errors (specific ways of turning on close-on-exec
that are done improperly) which would now have to be some new
way (some new added functionality done improperly again) which
we cannot possibly write a test for now, only for the cases that
are already fixed (or were never wrong) which no-one is ever
going to deliberately (or even accidentally) go and break now.

I will submit pullups for it, and make sure they happen, so there
also isn't really a need for tracking anything, beyond what the
releng pullup tickets provide.   There doesn't even need to be
much testing in HEAD for this one before the pullups happen, the
fixes are so obvious, and so obviously correct.

A bigger issue would be if there's another case hiding somewhere
that I didn't find - I can't test for that as I don't know what
it is, if it exists.   However I doubt there is such a thing.

This is rarely observed in anything real, as all it takes is
one instance of setting close-on-exec the right way, even if that
fd is no longer still open when the exec happens, to hide the
existence of the bug in any other fd's which enabled the flag
using a method which the kernel didn't do properly.  So if you
added

fcntl(dup(0), F_SETFD, 1);

to the above program then the broken case dup3() above, would
never be noticed.

Right now I need to work out how my changes to the shell (that
I was testing when I encountered the kernel problem - I was looking
very closely at when close-on-exec happened, and didn't) seem to
have broken the b5 i386 testbed (and perhaps more) quite so badly.

kre


CVS commit: src/sys/kern

2024-11-10 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Nov 10 12:15:46 UTC 2024

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

Log Message:
Add missing rw_exit() in error path.


To generate a diff of this commit:
cvs rdiff -u -r1.521 -r1.522 src/sys/kern/kern_exec.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_exec.c
diff -u src/sys/kern/kern_exec.c:1.521 src/sys/kern/kern_exec.c:1.522
--- src/sys/kern/kern_exec.c:1.521	Sun Oct  8 12:38:58 2023
+++ src/sys/kern/kern_exec.c	Sun Nov 10 12:15:46 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exec.c,v 1.521 2023/10/08 12:38:58 ad Exp $	*/
+/*	$NetBSD: kern_exec.c,v 1.522 2024/11/10 12:15:46 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.521 2023/10/08 12:38:58 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.522 2024/11/10 12:15:46 mlelstv Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -1858,6 +1858,7 @@ exec_add(struct execsw *esp, int count)
 			exec_sigcode_free(it->ex_sw->es_emul);
 			kmem_free(it, sizeof(*it));
 		}
+		rw_exit(&exec_lock);
 		return error;
 	}
 



CVS commit: src/sys/kern

2024-11-10 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Nov 10 12:15:46 UTC 2024

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

Log Message:
Add missing rw_exit() in error path.


To generate a diff of this commit:
cvs rdiff -u -r1.521 -r1.522 src/sys/kern/kern_exec.c

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



Re: CVS commit: src/sys/kern

2024-11-10 Thread Taylor R Campbell
> Module Name:src
> Committed By:   kre
> Date:   Sun Nov 10 00:11:43 UTC 2024
> 
> Modified Files:
> src/sys/kern: kern_descrip.c
> 
> Log Message:
> Make O_CLOEXEC always close specified files on exec
> 
> It turns out that close-on-exec doesn't always close on exec.

Yikes!  Do you have a reproducer handy for this?  Can you file a PR to
record the reproducer, and track pullups?


CVS commit: src/sys/kern

2024-11-09 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Nov 10 00:11:43 UTC 2024

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

Log Message:
Make O_CLOEXEC always close specified files on exec

It turns out that close-on-exec doesn't always close on exec.

If all close-on-exec fd's were made close-on-exec via dup3() or
fcntl(F_DUPFD_CLOEXEC) or use of the internal fd_clone() (whose uses
I did not fully investigate but I think is used to create a fd for
the open of a cloner device, and perhaps other things) then none
of the close-on-exec file descriptors will be closed when an exec
happens - but will be passed through to the new process (still marked,
apparently, as close-on-exec - but still won't be closed if another exec
happens) - that is unless...

If at least one fd in the process has close-on-exec set some other way
(fcntl(F_SETFD), open(O_CLOEXEC) (and the similar functions for sockets,
and epoll) and perhaps others then all close-on-exec file descriptors
in the process will be correctly closed when an exec happens (however
they obtained the close-on-exec status).

There are two steps that need to be taken (in the kernel) when turning
on close on exec - the obvious one of setting the ff_exclose field in
the struct fdfile for the fd.   And second, marking the file descriptor
table (which holds the fdfile's for one or more processes) as containing
file descriptors with close-on-exec set (it is a simple yes/no, and once
set is never cleared until an actual exec happens).  If it was set during
an exec, all the file descriptors are examined, and those marked
close-on-exec are closed.   If the file descriptor table doesn't indicate
that close-on-exec fds exist in the table, none of that happens.

Several places were setting ff_exclose in the struct fdfile but
not bothering to set the fd_exclose field in the file descriptor table.

There's even a function (fd_set_exclose()) whose whole purpose is to do
this properly - but it wasn't being used.

Now it is, everywhere (I hope).


To generate a diff of this commit:
cvs rdiff -u -r1.263 -r1.264 src/sys/kern/kern_descrip.c

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



CVS commit: src/sys/kern

2024-11-09 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Nov 10 00:11:43 UTC 2024

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

Log Message:
Make O_CLOEXEC always close specified files on exec

It turns out that close-on-exec doesn't always close on exec.

If all close-on-exec fd's were made close-on-exec via dup3() or
fcntl(F_DUPFD_CLOEXEC) or use of the internal fd_clone() (whose uses
I did not fully investigate but I think is used to create a fd for
the open of a cloner device, and perhaps other things) then none
of the close-on-exec file descriptors will be closed when an exec
happens - but will be passed through to the new process (still marked,
apparently, as close-on-exec - but still won't be closed if another exec
happens) - that is unless...

If at least one fd in the process has close-on-exec set some other way
(fcntl(F_SETFD), open(O_CLOEXEC) (and the similar functions for sockets,
and epoll) and perhaps others then all close-on-exec file descriptors
in the process will be correctly closed when an exec happens (however
they obtained the close-on-exec status).

There are two steps that need to be taken (in the kernel) when turning
on close on exec - the obvious one of setting the ff_exclose field in
the struct fdfile for the fd.   And second, marking the file descriptor
table (which holds the fdfile's for one or more processes) as containing
file descriptors with close-on-exec set (it is a simple yes/no, and once
set is never cleared until an actual exec happens).  If it was set during
an exec, all the file descriptors are examined, and those marked
close-on-exec are closed.   If the file descriptor table doesn't indicate
that close-on-exec fds exist in the table, none of that happens.

Several places were setting ff_exclose in the struct fdfile but
not bothering to set the fd_exclose field in the file descriptor table.

There's even a function (fd_set_exclose()) whose whole purpose is to do
this properly - but it wasn't being used.

Now it is, everywhere (I hope).


To generate a diff of this commit:
cvs rdiff -u -r1.263 -r1.264 src/sys/kern/kern_descrip.c

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

Modified files:

Index: src/sys/kern/kern_descrip.c
diff -u src/sys/kern/kern_descrip.c:1.263 src/sys/kern/kern_descrip.c:1.264
--- src/sys/kern/kern_descrip.c:1.263	Sun Jul 14 05:10:40 2024
+++ src/sys/kern/kern_descrip.c	Sun Nov 10 00:11:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_descrip.c,v 1.263 2024/07/14 05:10:40 kre Exp $	*/
+/*	$NetBSD: kern_descrip.c,v 1.264 2024/11/10 00:11:43 kre Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009, 2023 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.263 2024/07/14 05:10:40 kre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.264 2024/11/10 00:11:43 kre Exp $");
 
 #include 
 #include 
@@ -747,7 +747,6 @@ int
 fd_dup(file_t *fp, int minfd, int *newp, bool exclose)
 {
 	proc_t *p = curproc;
-	fdtab_t *dt;
 	int error;
 
 	while ((error = fd_alloc(p, minfd, newp)) != 0) {
@@ -757,8 +756,7 @@ fd_dup(file_t *fp, int minfd, int *newp,
 		fd_tryexpand(p);
 	}
 
-	dt = atomic_load_consume(&curlwp->l_fd->fd_dt);
-	dt->dt_ff[*newp]->ff_exclose = exclose;
+	fd_set_exclose(curlwp, *newp, exclose);
 	fd_affix(p, fp, *newp);
 	return 0;
 }
@@ -814,7 +812,7 @@ fd_dup2(file_t *fp, unsigned newfd, int 
 	fd_used(fdp, newfd);
 	mutex_exit(&fdp->fd_lock);
 
-	dt->dt_ff[newfd]->ff_exclose = (flags & O_CLOEXEC) != 0;
+	fd_set_exclose(curlwp, newfd, (flags & O_CLOEXEC) != 0);
 	fp->f_flag |= flags & (FNONBLOCK|FNOSIGPIPE);
 	/* Slot is now allocated.  Insert copy of the file. */
 	fd_affix(curproc, fp, newfd);
@@ -1910,14 +1908,9 @@ int
 fd_clone(file_t *fp, unsigned fd, int flag, const struct fileops *fops,
 	 void *data)
 {
-	fdfile_t *ff;
-	filedesc_t *fdp;
 
 	fp->f_flag = flag & FMASK;
-	fdp = curproc->p_fd;
-	ff = atomic_load_consume(&fdp->fd_dt)->dt_ff[fd];
-	KASSERT(ff != NULL);
-	ff->ff_exclose = (flag & O_CLOEXEC) != 0;
+	fd_set_exclose(curlwp, fd, (flag & O_CLOEXEC) != 0);
 	fp->f_type = DTYPE_MISC;
 	fp->f_ops = fops;
 	fp->f_data = data;



CVS commit: src/sys/kern

2024-10-18 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Fri Oct 18 13:12:34 UTC 2024

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

Log Message:
PR kern/57504 : Check all fds passed in to select

If an application passes in a huge fd_set (select(BIG, ...))
then check every bit in the fd_sets provided, to make sure
they are valid.

If BIG is too big (cannot possibly represent an open fd for
this process, under any circumstances: ie: not just because
that many are not currently open) return EINVAL.

Otherwise, check every set bit to make sure it is valid.  Any
fd bits set above the applications current highest open fd
automatically generate EBADF and quick(ish) exit.

fd's that are within the plausible range are then checked as
they always were (it is possible for there to be a few there
above the max open fd - as everything in select is done in
multiples of __FDBITS (fd_mask) but the max open fd is not so
constrained.  Those always were checked, continue using the
same mechanism.

This should have zero impact on any sane application which
uses the highest fd for which it set a bit, +1, as the first
arg to select.   However, if there are any broken applications
that were relying upon the previous behaviour of simply ignoring
any fd_masks that started beyond the max number of open files,
then they might (if they happen to have any bits set) now fail.

XXX pullup -10 -- but not for a long time.  Someone remind me
sometime next year.  Leave a long settling time in HEAD just to
be sure no issues arise, as in practice, almost nothing should
cause any of the new code to be executed.

pullup -9 -- probably not, what this fixes isn't significant
enough to bother going that far back for (IMO).


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/kern/sys_select.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-10-18 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Fri Oct 18 13:12:34 UTC 2024

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

Log Message:
PR kern/57504 : Check all fds passed in to select

If an application passes in a huge fd_set (select(BIG, ...))
then check every bit in the fd_sets provided, to make sure
they are valid.

If BIG is too big (cannot possibly represent an open fd for
this process, under any circumstances: ie: not just because
that many are not currently open) return EINVAL.

Otherwise, check every set bit to make sure it is valid.  Any
fd bits set above the applications current highest open fd
automatically generate EBADF and quick(ish) exit.

fd's that are within the plausible range are then checked as
they always were (it is possible for there to be a few there
above the max open fd - as everything in select is done in
multiples of __FDBITS (fd_mask) but the max open fd is not so
constrained.  Those always were checked, continue using the
same mechanism.

This should have zero impact on any sane application which
uses the highest fd for which it set a bit, +1, as the first
arg to select.   However, if there are any broken applications
that were relying upon the previous behaviour of simply ignoring
any fd_masks that started beyond the max number of open files,
then they might (if they happen to have any bits set) now fail.

XXX pullup -10 -- but not for a long time.  Someone remind me
sometime next year.  Leave a long settling time in HEAD just to
be sure no issues arise, as in practice, almost nothing should
cause any of the new code to be executed.

pullup -9 -- probably not, what this fixes isn't significant
enough to bother going that far back for (IMO).


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/kern/sys_select.c

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

Modified files:

Index: src/sys/kern/sys_select.c
diff -u src/sys/kern/sys_select.c:1.66 src/sys/kern/sys_select.c:1.67
--- src/sys/kern/sys_select.c:1.66	Sun Oct 15 10:29:34 2023
+++ src/sys/kern/sys_select.c	Fri Oct 18 13:12:34 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_select.c,v 1.66 2023/10/15 10:29:34 riastradh Exp $	*/
+/*	$NetBSD: sys_select.c,v 1.67 2024/10/18 13:12:34 kre Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2010, 2019, 2020, 2023
@@ -85,7 +85,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.66 2023/10/15 10:29:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.67 2024/10/18 13:12:34 kre Exp $");
 
 #include 
 
@@ -353,6 +353,29 @@ state_check:
 	return error;
 }
 
+/* designed to be compatible with FD_SET() FD_ISSET() ... */
+static int
+anyset(void *p, size_t nbits)
+{
+	size_t nwords;
+	__fd_mask mask;
+	__fd_mask *f = (__fd_mask *)p;
+
+	nwords = nbits / __NFDBITS;
+
+	while (nwords-- > 0)
+		if (*f++ != 0)
+			return 1;
+
+	nbits &= __NFDMASK;
+	if (nbits != 0) {
+		mask = (1U << nbits) - 1;
+		if ((*f & mask) != 0)
+			return 1;
+	}
+	return 0;
+}
+
 int
 selcommon(register_t *retval, int nd, fd_set *u_in, fd_set *u_ou,
 fd_set *u_ex, struct timespec *ts, sigset_t *mask)
@@ -360,41 +383,123 @@ selcommon(register_t *retval, int nd, fd
 	char		smallbits[howmany(FD_SETSIZE, NFDBITS) *
 			sizeof(fd_mask) * 6];
 	char 		*bits;
-	int		error, nf;
+	int		error, nf, fb, db;
 	size_t		ni;
 
 	if (nd < 0)
-		return (EINVAL);
+		return EINVAL;
+
 	nf = atomic_load_consume(&curlwp->l_fd->fd_dt)->dt_nfiles;
-	if (nd > nf) {
-		/* forgiving; slightly wrong */
-		nd = nf;
+
+	/*
+	 * Don't allow absurdly large numbers of fds to be selected.
+	 * (used to silently truncate, naughty naughty, no more ...)
+	 *
+	 * The additional FD_SETSISE allows for cases where the limit
+	 * is not a round binary number, but the fd_set wants to
+	 * include all the possible fds, as fd_sets are always
+	 * multiples of 32 bits (__NFDBITS extra would be enough).
+	 *
+	 * The first test handles the case where the res limit has been
+	 * set lower after some fds were opened, we always allow selecting
+	 * up to the highest currently open fd.
+	 */
+	if (nd > nf + FD_SETSIZE &&
+	nd > curlwp->l_proc->p_rlimit[RLIMIT_NOFILE].rlim_max + FD_SETSIZE)
+		return EINVAL;
+
+	fb = howmany(nf, __NFDBITS);		/* how many fd_masks */
+	db = howmany(nd, __NFDBITS);
+
+	if (db > fb) {
+		size_t off;
+
+		/*
+		 * the application wants to supply more fd masks than can
+		 * possibly represent valid file descriptors.
+		 *
+		 * Check the excess fd_masks, if any bits are set in them
+		 * that must be an error (cannot represent valid fd).
+		 *
+		 * Supplying lots of extra cleared fd_masks is dumb,
+		 * but harmless, so allow that.
+		 */
+		ni = (db - fb) * sizeof(fd_mask);	/* excess bytes */
+		bits = smallbits;
+
+		/* skip over the valid fd_masks, those will be checked below */
+		off = howmany(nf, __NFDBITS) * sizeof(__fd_mask);
+
+		nd -= fb * NFDBITS;	/* the number of exce

CVS commit: src/sys/kern

2024-10-13 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Oct 13 22:25:38 UTC 2024

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

Log Message:
avoid spurious warning about uninitialized "bi" here just as we do for "ci".


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/kern/subr_devsw.c

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

Modified files:

Index: src/sys/kern/subr_devsw.c
diff -u src/sys/kern/subr_devsw.c:1.52 src/sys/kern/subr_devsw.c:1.53
--- src/sys/kern/subr_devsw.c:1.52	Fri Aug 16 20:11:18 2024
+++ src/sys/kern/subr_devsw.c	Sun Oct 13 22:25:38 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_devsw.c,v 1.52 2024/08/16 20:11:18 riastradh Exp $	*/
+/*	$NetBSD: subr_devsw.c,v 1.53 2024/10/13 22:25:38 chs Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.52 2024/08/16 20:11:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.53 2024/10/13 22:25:38 chs Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dtrace.h"
@@ -616,7 +616,7 @@ cdevsw_attach(const struct cdevsw *devsw
 static void
 devsw_detach_locked(const struct bdevsw *bdev, const struct cdevsw *cdev)
 {
-	int bi, ci = -1/*XXXGCC*/, di;
+	int bi = -1, ci = -1/*XXXGCC*/, di;
 	struct cfdriver *cd;
 	device_t dv;
 



CVS commit: src/sys/kern

2024-10-13 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Oct 13 22:25:38 UTC 2024

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

Log Message:
avoid spurious warning about uninitialized "bi" here just as we do for "ci".


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/kern/subr_devsw.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-10-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct  9 16:27:28 UTC 2024

Modified Files:
src/sys/kern: syscalls.master sysv_ipc.c

Log Message:
Make semtimedop modular.


To generate a diff of this commit:
cvs rdiff -u -r1.315 -r1.316 src/sys/kern/syscalls.master
cvs rdiff -u -r1.42 -r1.43 src/sys/kern/sysv_ipc.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-10-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct  9 16:27:28 UTC 2024

Modified Files:
src/sys/kern: syscalls.master sysv_ipc.c

Log Message:
Make semtimedop modular.


To generate a diff of this commit:
cvs rdiff -u -r1.315 -r1.316 src/sys/kern/syscalls.master
cvs rdiff -u -r1.42 -r1.43 src/sys/kern/sysv_ipc.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/syscalls.master
diff -u src/sys/kern/syscalls.master:1.315 src/sys/kern/syscalls.master:1.316
--- src/sys/kern/syscalls.master:1.315	Sat Oct  5 14:04:53 2024
+++ src/sys/kern/syscalls.master	Wed Oct  9 12:27:28 2024
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.315 2024/10/05 18:04:53 mlelstv Exp $
+	$NetBSD: syscalls.master,v 1.316 2024/10/09 16:27:28 christos Exp $
 
 ;	@(#)syscalls.master	8.2 (Berkeley) 1/13/94
 
@@ -1065,8 +1065,6 @@
 			const struct timespec *timeout, \
 			const sigset_t *sigmask); }
 505	STD	RUMP	{ int|sys|100|dup3(int from, int to, int flags); }
-#if defined(SYSVSHM) || !defined(_KERNEL_OPT)
-506	STD 		{ int|sys||semtimedop(int semid, \
+506	STD MODULAR sysv_ipc { int|sys||semtimedop(int semid, \
 			struct sembuf *sops, size_t nsops, \
 			struct timespec *timeout); }
-#endif

Index: src/sys/kern/sysv_ipc.c
diff -u src/sys/kern/sysv_ipc.c:1.42 src/sys/kern/sysv_ipc.c:1.43
--- src/sys/kern/sysv_ipc.c:1.42	Sun Mar 27 12:23:08 2022
+++ src/sys/kern/sysv_ipc.c	Wed Oct  9 12:27:28 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysv_ipc.c,v 1.42 2022/03/27 16:23:08 christos Exp $	*/
+/*	$NetBSD: sysv_ipc.c,v 1.43 2024/10/09 16:27:28 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sysv_ipc.c,v 1.42 2022/03/27 16:23:08 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysv_ipc.c,v 1.43 2024/10/09 16:27:28 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sysv.h"
@@ -145,6 +145,7 @@ static const struct syscall_package sysv
 	{ SYS_semget, 0, (sy_call_t *)sys_semget },
 	{ SYS_semop, 0, (sy_call_t *)sys_semop },
 	{ SYS_semconfig, 0, (sy_call_t *)sys_semconfig },
+	{ SYS_semtimedop, 0, (sy_call_t *)sys_semtimedop },
 #endif	/* SYSVSEM */
 
 #if defined(SYSVMSG)



CVS commit: src/sys/kern

2024-10-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Oct  6 22:15:33 UTC 2024

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

Log Message:
Use the syscall arg for IPCID_TO_SEQ like before.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/kern/sysv_sem.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/sysv_sem.c
diff -u src/sys/kern/sysv_sem.c:1.100 src/sys/kern/sysv_sem.c:1.101
--- src/sys/kern/sysv_sem.c:1.100	Thu Oct  3 16:54:08 2024
+++ src/sys/kern/sysv_sem.c	Sun Oct  6 22:15:33 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysv_sem.c,v 1.100 2024/10/03 16:54:08 christos Exp $	*/
+/*	$NetBSD: sysv_sem.c,v 1.101 2024/10/06 22:15:33 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sysv_sem.c,v 1.100 2024/10/03 16:54:08 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysv_sem.c,v 1.101 2024/10/06 22:15:33 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sysv.h"
@@ -873,7 +873,7 @@ restart:
 	}
 
 	semaptr = &sema[semid];
-	seq = IPCID_TO_SEQ(semid);
+	seq = IPCID_TO_SEQ(usemid);
 	if ((semaptr->sem_perm.mode & SEM_ALLOC) == 0 ||
 	semaptr->sem_perm._seq != seq) {
 		error = EINVAL;



CVS commit: src/sys/kern

2024-10-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Oct  6 22:15:33 UTC 2024

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

Log Message:
Use the syscall arg for IPCID_TO_SEQ like before.


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

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



Re: CVS commit: src/sys/kern

2024-10-05 Thread Paul Goyette

On Sat, 5 Oct 2024, Michael van Elst wrote:


Module Name:src
Committed By:   mlelstv
Date:   Sat Oct  5 18:04:53 UTC 2024

Modified Files:
src/sys/kern: syscalls.master

Log Message:
New syscall requires SYSVSEM build option.


Seems to me that the new syscall should be part of the SYSV module...


+-+--+--+
| Paul Goyette (.sig) | PGP Key fingerprint: | E-mail addresses:|
| (Retired)   | 1B11 1849 721C 56C8 F63A | p...@whooppee.com|
| Software Developer  | 6E2E 05FD 15CE 9F2D 5102 | pgoye...@netbsd.org  |
| & Network Engineer  |  | pgoyett...@gmail.com |
+-+--+--+


CVS commit: src/sys/kern

2024-10-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Oct  5 18:04:53 UTC 2024

Modified Files:
src/sys/kern: syscalls.master

Log Message:
New syscall requires SYSVSEM build option.


To generate a diff of this commit:
cvs rdiff -u -r1.314 -r1.315 src/sys/kern/syscalls.master

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/syscalls.master
diff -u src/sys/kern/syscalls.master:1.314 src/sys/kern/syscalls.master:1.315
--- src/sys/kern/syscalls.master:1.314	Thu Oct  3 16:50:52 2024
+++ src/sys/kern/syscalls.master	Sat Oct  5 18:04:53 2024
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.314 2024/10/03 16:50:52 christos Exp $
+	$NetBSD: syscalls.master,v 1.315 2024/10/05 18:04:53 mlelstv Exp $
 
 ;	@(#)syscalls.master	8.2 (Berkeley) 1/13/94
 
@@ -1065,6 +1065,8 @@
 			const struct timespec *timeout, \
 			const sigset_t *sigmask); }
 505	STD	RUMP	{ int|sys|100|dup3(int from, int to, int flags); }
+#if defined(SYSVSHM) || !defined(_KERNEL_OPT)
 506	STD 		{ int|sys||semtimedop(int semid, \
 			struct sembuf *sops, size_t nsops, \
 			struct timespec *timeout); }
+#endif



CVS commit: src/sys/kern

2024-10-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Oct  5 18:04:53 UTC 2024

Modified Files:
src/sys/kern: syscalls.master

Log Message:
New syscall requires SYSVSEM build option.


To generate a diff of this commit:
cvs rdiff -u -r1.314 -r1.315 src/sys/kern/syscalls.master

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-10-03 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Thu Oct  3 20:19:55 UTC 2024

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

Log Message:
s/preudo/pseudo/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/sys/kern/kern_ksyms.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_ksyms.c
diff -u src/sys/kern/kern_ksyms.c:1.108 src/sys/kern/kern_ksyms.c:1.109
--- src/sys/kern/kern_ksyms.c:1.108	Tue Feb 21 11:40:00 2023
+++ src/sys/kern/kern_ksyms.c	Thu Oct  3 20:19:55 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_ksyms.c,v 1.108 2023/02/21 11:40:00 riastradh Exp $	*/
+/*	$NetBSD: kern_ksyms.c,v 1.109 2024/10/03 20:19:55 andvar Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.108 2023/02/21 11:40:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.109 2024/10/03 20:19:55 andvar Exp $");
 
 #if defined(_KERNEL) && defined(_KERNEL_OPT)
 #include "opt_copy_symtab.h"
@@ -244,7 +244,7 @@ findsym(const char *name, struct ksyms_s
 /*
  * ksyms can be loaded even if the kernel has a missing "pseudo-device ksyms"
  * statement because ddb and modules require it. Fixing it properly requires
- * fixing config to warn about required, but missing preudo-devices. For now,
+ * fixing config to warn about required, but missing pseudo-devices. For now,
  * if we don't have the pseudo-device we don't need the attach function; this
  * is fine, as it does nothing.
  */



CVS commit: src/sys/kern

2024-10-03 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Thu Oct  3 20:19:55 UTC 2024

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

Log Message:
s/preudo/pseudo/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/sys/kern/kern_ksyms.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-10-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Oct  3 16:54:08 UTC 2024

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

Log Message:
rename for clarity.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/kern/sysv_sem.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/sysv_sem.c
diff -u src/sys/kern/sysv_sem.c:1.99 src/sys/kern/sysv_sem.c:1.100
--- src/sys/kern/sysv_sem.c:1.99	Thu Oct  3 12:50:52 2024
+++ src/sys/kern/sysv_sem.c	Thu Oct  3 12:54:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysv_sem.c,v 1.99 2024/10/03 16:50:52 christos Exp $	*/
+/*	$NetBSD: sysv_sem.c,v 1.100 2024/10/03 16:54:08 christos Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sysv_sem.c,v 1.99 2024/10/03 16:50:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysv_sem.c,v 1.100 2024/10/03 16:54:08 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sysv.h"
@@ -801,7 +801,7 @@ sys_semget(struct lwp *l, const struct s
 #define SMALL_SOPS 8
 
 static int
-do_semop(struct lwp *l, int semid, struct sembuf *usops,
+do_semop(struct lwp *l, int usemid, struct sembuf *usops,
 size_t nsops, struct timespec *utimeout, register_t *retval)
 {
 	struct proc *p = l->l_proc;
@@ -820,7 +820,7 @@ do_semop(struct lwp *l, int semid, struc
 
 	RUN_ONCE(&exithook_control, seminit_exithook);
 
-	SEM_PRINTF(("call to semop(%d, %p, %zu)\n", semid, usops, nsops));
+	SEM_PRINTF(("call to semop(%d, %p, %zu)\n", usemid, usops, nsops));
 
 	if (__predict_false((p->p_flag & PK_SYSVSEM) == 0)) {
 		mutex_enter(p->p_lock);
@@ -853,7 +853,7 @@ restart:
 	while (__predict_false(sem_realloc_state))
 		cv_wait(&sem_realloc_cv, &semlock);
 
-	semid = IPCID_TO_IX(semid);	/* Convert back to zero origin */
+	semid = IPCID_TO_IX(usemid);	/* Convert back to zero origin */
 	if (semid < 0 || semid >= seminfo.semmni) {
 		error = EINVAL;
 		goto out;



CVS commit: src/sys/kern

2024-10-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Oct  3 16:54:08 UTC 2024

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

Log Message:
rename for clarity.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/kern/sysv_sem.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-08-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 26 15:50:15 UTC 2024

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

Log Message:
entropy(9): Allow unprivileged reads of sysctl kern.entropy.epoch.

Applications need this in order to know when to reseed.  (We should
also expose it through a page shared read-only with userland for
cheaper access, but until we do, let's let applications get at it
through sysctl.)

PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/kern/kern_entropy.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_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.70 src/sys/kern/kern_entropy.c:1.71
--- src/sys/kern/kern_entropy.c:1.70	Mon Aug 26 13:52:56 2024
+++ src/sys/kern/kern_entropy.c	Mon Aug 26 15:50:15 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.70 2024/08/26 13:52:56 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.71 2024/08/26 15:50:15 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.70 2024/08/26 13:52:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.71 2024/08/26 15:50:15 riastradh Exp $");
 
 #include 
 #include 
@@ -400,7 +400,7 @@ entropy_init(void)
 	SYSCTL_DESCR("Number of samples pending on CPUs"),
 	NULL, 0, &E->samplespending, 0, CTL_CREATE, CTL_EOL);
 	sysctl_createv(&entropy_sysctllog, 0, &entropy_sysctlroot, NULL,
-	CTLFLAG_PERMANENT|CTLFLAG_READONLY|CTLFLAG_PRIVATE, CTLTYPE_INT,
+	CTLFLAG_PERMANENT|CTLFLAG_READONLY, CTLTYPE_INT,
 	"epoch", SYSCTL_DESCR("Entropy epoch"),
 	NULL, 0, &E->epoch, 0, CTL_CREATE, CTL_EOL);
 



CVS commit: src/sys/kern

2024-08-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 26 15:50:15 UTC 2024

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

Log Message:
entropy(9): Allow unprivileged reads of sysctl kern.entropy.epoch.

Applications need this in order to know when to reseed.  (We should
also expose it through a page shared read-only with userland for
cheaper access, but until we do, let's let applications get at it
through sysctl.)

PR kern/58632: getentropy(2) and arc4random(3) do not reseed on VM
fork


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/kern/kern_entropy.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-08-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 26 13:48:04 UTC 2024

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

Log Message:
kern.entropy.gather: Fail with EINTR on signal.

Just don't throw away the error code we already have!

PR kern/58646: /dev/random, kern.entropy.*: signal bugs


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/kern/kern_entropy.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_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.68 src/sys/kern/kern_entropy.c:1.69
--- src/sys/kern/kern_entropy.c:1.68	Mon Aug 26 13:47:52 2024
+++ src/sys/kern/kern_entropy.c	Mon Aug 26 13:48:04 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.68 2024/08/26 13:47:52 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.69 2024/08/26 13:48:04 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.68 2024/08/26 13:47:52 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.69 2024/08/26 13:48:04 riastradh Exp $");
 
 #include 
 #include 
@@ -1450,7 +1450,7 @@ sysctl_entropy_gather(SYSCTLFN_ARGS)
 		mutex_exit(&E->lock);
 	}
 
-	return 0;
+	return error;
 }
 
 /*



CVS commit: src/sys/kern

2024-08-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 26 13:48:04 UTC 2024

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

Log Message:
kern.entropy.gather: Fail with EINTR on signal.

Just don't throw away the error code we already have!

PR kern/58646: /dev/random, kern.entropy.*: signal bugs


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/kern/kern_entropy.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-08-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 26 13:47:52 UTC 2024

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

Log Message:
kern.entropy.consolidate, ioctl(RNDCTL): Fail with EINTR on signal.

This can happen if another thread is currently running consolidation
and has the entropy source lock held.  Use the new function
entropy_consolidate_sig to get at EINTR.

PR kern/58646: /dev/random, kern.entropy.*: signal bugs


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/kern/kern_entropy.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_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.67 src/sys/kern/kern_entropy.c:1.68
--- src/sys/kern/kern_entropy.c:1.67	Mon Aug 26 13:46:03 2024
+++ src/sys/kern/kern_entropy.c	Mon Aug 26 13:47:52 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.67 2024/08/26 13:46:03 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.68 2024/08/26 13:47:52 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.67 2024/08/26 13:46:03 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.68 2024/08/26 13:47:52 riastradh Exp $");
 
 #include 
 #include 
@@ -1420,7 +1420,7 @@ sysctl_entropy_consolidate(SYSCTLFN_ARGS
 	if (error || newp == NULL)
 		return error;
 	if (arg)
-		entropy_consolidate();
+		error = entropy_consolidate_sig();
 
 	return error;
 }
@@ -2793,7 +2793,7 @@ entropy_ioctl(unsigned long cmd, void *d
 		/* Enter the data and consolidate entropy.  */
 		rnd_add_data(&seed_rndsource, rdata->data, rdata->len,
 		entropybits);
-		entropy_consolidate();
+		error = entropy_consolidate_sig();
 		break;
 	}
 	default:



CVS commit: src/sys/kern

2024-08-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 26 13:47:52 UTC 2024

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

Log Message:
kern.entropy.consolidate, ioctl(RNDCTL): Fail with EINTR on signal.

This can happen if another thread is currently running consolidation
and has the entropy source lock held.  Use the new function
entropy_consolidate_sig to get at EINTR.

PR kern/58646: /dev/random, kern.entropy.*: signal bugs


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/kern/kern_entropy.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-08-24 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Aug 25 01:14:01 UTC 2024

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

Log Message:
heartbeat(9): Use the cheaper and equally safe time_uptime32.

Since we cache this every 15sec, and check it within a tick, there's
no way for this to wrap around without first triggering a heartbeat
panic.  So just use time_uptime32, the low 32 bits of the number of
seconds of uptime -- cheaper on LP32 platforms.

PR kern/58633: heartbeat(9) makes unnecessary use of time_uptime


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/kern/kern_heartbeat.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_heartbeat.c
diff -u src/sys/kern/kern_heartbeat.c:1.13 src/sys/kern/kern_heartbeat.c:1.14
--- src/sys/kern/kern_heartbeat.c:1.13	Fri Mar  8 23:34:03 2024
+++ src/sys/kern/kern_heartbeat.c	Sun Aug 25 01:14:01 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_heartbeat.c,v 1.13 2024/03/08 23:34:03 riastradh Exp $	*/
+/*	$NetBSD: kern_heartbeat.c,v 1.14 2024/08/25 01:14:01 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_heartbeat.c,v 1.13 2024/03/08 23:34:03 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_heartbeat.c,v 1.14 2024/08/25 01:14:01 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -170,7 +170,7 @@ heartbeat_resume_cpu(struct cpu_info *ci
 	/* XXX KASSERT IPL_SCHED */
 
 	ci->ci_heartbeat_count = 0;
-	ci->ci_heartbeat_uptime_cache = time_uptime;
+	ci->ci_heartbeat_uptime_cache = time_uptime32;
 	ci->ci_heartbeat_uptime_stamp = 0;
 }
 
@@ -283,7 +283,7 @@ set_max_period(unsigned max_period)
 
 	/*
 	 * If we're enabling heartbeat checks, make sure we have a
-	 * reasonably up-to-date time_uptime cache on all CPUs so we
+	 * reasonably up-to-date time_uptime32 cache on all CPUs so we
 	 * don't think we had an instant heart attack.
 	 */
 	if (heartbeat_max_period_secs == 0 && max_period != 0) {
@@ -406,7 +406,7 @@ static void
 heartbeat_intr(void *cookie)
 {
 	unsigned count = atomic_load_relaxed(&curcpu()->ci_heartbeat_count);
-	unsigned uptime = time_uptime;
+	unsigned uptime = time_uptime32;
 
 	atomic_store_relaxed(&curcpu()->ci_heartbeat_uptime_stamp, count);
 	atomic_store_relaxed(&curcpu()->ci_heartbeat_uptime_cache, uptime);
@@ -420,7 +420,15 @@ heartbeat_intr(void *cookie)
 void
 heartbeat_start(void)
 {
-	const unsigned max_period = HEARTBEAT_MAX_PERIOD_DEFAULT;
+	enum { max_period = HEARTBEAT_MAX_PERIOD_DEFAULT };
+
+	/*
+	 * Ensure the maximum period is small enough that we never have
+	 * to worry about 32-bit wraparound even if there's a lot of
+	 * slop.  (In fact this is required to be less than
+	 * UINT_MAX/4/hz, but that's not a compile-time constant.)
+	 */
+	__CTASSERT(max_period < UINT_MAX/4);
 
 	/*
 	 * Establish a softint so we can schedule it once ready.  This
@@ -433,7 +441,7 @@ heartbeat_start(void)
 	/*
 	 * Now that the softint is established, kick off heartbeat
 	 * monitoring with the default period.  This will initialize
-	 * the per-CPU state to an up-to-date cache of time_uptime.
+	 * the per-CPU state to an up-to-date cache of time_uptime32.
 	 */
 	mutex_enter(&heartbeat_lock);
 	set_max_period(max_period);
@@ -651,7 +659,7 @@ heartbeat(void)
 	 * changed, and stop here -- we only do the cross-CPU work once
 	 * per second.
 	 */
-	uptime = time_uptime;
+	uptime = time_uptime32;
 	cache = atomic_load_relaxed(&curcpu()->ci_heartbeat_uptime_cache);
 	if (__predict_true(cache == uptime)) {
 		/*
@@ -661,7 +669,7 @@ heartbeat(void)
 		 * suspended too.
 		 *
 		 * Our own heartbeat count can't roll back, and
-		 * time_uptime should be updated before it wraps
+		 * time_uptime32 should be updated before it wraps
 		 * around, so d should never go negative; hence no
 		 * check for d < UINT_MAX/2.
 		 */
@@ -679,8 +687,10 @@ heartbeat(void)
 	/*
 	 * If the uptime has changed, make sure that it hasn't changed
 	 * so much that softints must be stuck on this CPU.  Since
-	 * time_uptime is monotonic, this can't go negative, hence no
-	 * check for d < UINT_MAX/2.
+	 * time_uptime32 is monotonic and our cache of it is updated at
+	 * most every UINT_MAX/4/hz sec (hence no concern about
+	 * wraparound even after 68 or 136 years), this can't go
+	 * negative, hence no check for d < UINT_MAX/2.
 	 *
 	 * This uses the hard timer interrupt handler on the current
 	 * CPU to ensure soft interrupts at all priority levels have



CVS commit: src/sys/kern

2024-08-24 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Aug 25 01:14:01 UTC 2024

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

Log Message:
heartbeat(9): Use the cheaper and equally safe time_uptime32.

Since we cache this every 15sec, and check it within a tick, there's
no way for this to wrap around without first triggering a heartbeat
panic.  So just use time_uptime32, the low 32 bits of the number of
seconds of uptime -- cheaper on LP32 platforms.

PR kern/58633: heartbeat(9) makes unnecessary use of time_uptime


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/kern/kern_heartbeat.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-08-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Aug 16 21:54:17 UTC 2024

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

Log Message:
localcount: Update per-CPU total at splhigh.

Otherwise localcount_acquire/release in interrupt context may lose
counts.

Duration spent at splhigh is very short.

PR kern/58610: localcount(9) races with interrupts


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

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

Modified files:

Index: src/sys/kern/subr_localcount.c
diff -u src/sys/kern/subr_localcount.c:1.7 src/sys/kern/subr_localcount.c:1.8
--- src/sys/kern/subr_localcount.c:1.7	Fri Nov 17 09:26:36 2017
+++ src/sys/kern/subr_localcount.c	Fri Aug 16 21:54:17 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_localcount.c,v 1.7 2017/11/17 09:26:36 ozaki-r Exp $	*/
+/*	$NetBSD: subr_localcount.c,v 1.8 2024/08/16 21:54:17 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_localcount.c,v 1.7 2017/11/17 09:26:36 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_localcount.c,v 1.8 2024/08/16 21:54:17 riastradh Exp $");
 
 #include 
 #include 
@@ -161,11 +161,14 @@ localcount_xc(void *cookie0, void *cooki
 	struct localcount *lc = cookie0;
 	kmutex_t *interlock = cookie1;
 	int64_t *localp;
+	int s;
 
 	mutex_enter(interlock);
 	localp = percpu_getref(lc->lc_percpu);
+	s = splhigh();
 	*lc->lc_totalp += *localp;
 	*localp -= *localp;		/* ie, *localp = 0; */
+	splx(s);
 	percpu_putref(lc->lc_percpu);
 	mutex_exit(interlock);
 }
@@ -180,9 +183,12 @@ static void
 localcount_adjust(struct localcount *lc, int delta)
 {
 	int64_t *localp;
+	int s;
 
 	localp = percpu_getref(lc->lc_percpu);
+	s = splhigh();
 	*localp += delta;
+	splx(s);
 	percpu_putref(lc->lc_percpu);
 }
 



CVS commit: src/sys/kern

2024-08-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Aug 16 21:54:17 UTC 2024

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

Log Message:
localcount: Update per-CPU total at splhigh.

Otherwise localcount_acquire/release in interrupt context may lose
counts.

Duration spent at splhigh is very short.

PR kern/58610: localcount(9) races with interrupts


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/kern/subr_localcount.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-08-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Aug 16 20:11:18 UTC 2024

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

Log Message:
devsw(9): Don't leak devsw reference on open d_devtounit failure.

PR kern/56816: Deadlock: sleep during unloading module with
kernconfig_lock being held


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/kern/subr_devsw.c

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

Modified files:

Index: src/sys/kern/subr_devsw.c
diff -u src/sys/kern/subr_devsw.c:1.51 src/sys/kern/subr_devsw.c:1.52
--- src/sys/kern/subr_devsw.c:1.51	Wed Feb 15 13:12:45 2023
+++ src/sys/kern/subr_devsw.c	Fri Aug 16 20:11:18 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_devsw.c,v 1.51 2023/02/15 13:12:45 riastradh Exp $	*/
+/*	$NetBSD: subr_devsw.c,v 1.52 2024/08/16 20:11:18 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.51 2023/02/15 13:12:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.52 2024/08/16 20:11:18 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dtrace.h"
@@ -1181,10 +1181,15 @@ bdev_open(dev_t dev, int flag, int devty
 		 * reviewing them all to find and verify a common
 		 * pattern.
 		 */
-		if ((unit = (*d->d_devtounit)(dev)) == -1)
-			return ENXIO;
-		if ((dv = device_lookup_acquire(d->d_cfdriver, unit)) == NULL)
-			return ENXIO;
+		if ((unit = (*d->d_devtounit)(dev)) == -1) {
+			rv = ENXIO;
+			goto out;
+		}
+		if ((dv = device_lookup_acquire(d->d_cfdriver, unit)) ==
+		NULL) {
+			rv = ENXIO;
+			goto out;
+		}
 		SDT_PROBE6(sdt, bdev, open, acquire,
 		d, dev, flag, devtype, unit, dv);
 	}
@@ -1201,7 +1206,7 @@ bdev_open(dev_t dev, int flag, int devty
 		device_release(dv);
 	}
 
-	bdevsw_release(d, lc);
+out:	bdevsw_release(d, lc);
 
 	return rv;
 }
@@ -1412,10 +1417,15 @@ cdev_open(dev_t dev, int flag, int devty
 		 * reviewing them all to find and verify a common
 		 * pattern.
 		 */
-		if ((unit = (*d->d_devtounit)(dev)) == -1)
-			return ENXIO;
-		if ((dv = device_lookup_acquire(d->d_cfdriver, unit)) == NULL)
-			return ENXIO;
+		if ((unit = (*d->d_devtounit)(dev)) == -1) {
+			rv = ENXIO;
+			goto out;
+		}
+		if ((dv = device_lookup_acquire(d->d_cfdriver, unit)) ==
+		NULL) {
+			rv = ENXIO;
+			goto out;
+		}
 		SDT_PROBE6(sdt, cdev, open, acquire,
 		d, dev, flag, devtype, unit, dv);
 	}
@@ -1432,7 +1442,7 @@ cdev_open(dev_t dev, int flag, int devty
 		device_release(dv);
 	}
 
-	cdevsw_release(d, lc);
+out:	cdevsw_release(d, lc);
 
 	return rv;
 }



CVS commit: src/sys/kern

2024-08-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Aug 16 20:11:18 UTC 2024

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

Log Message:
devsw(9): Don't leak devsw reference on open d_devtounit failure.

PR kern/56816: Deadlock: sleep during unloading module with
kernconfig_lock being held


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/kern/subr_devsw.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-08-11 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Sun Aug 11 13:43:20 UTC 2024

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

Log Message:
tweak restoration of asyncflag

Simply update mp->mnt_flag with asyncflag as it contains the correct value.
Use the same pattern as in the other two places (vfs_syscalls.c, ffs_wapbl.c).

NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.567 -r1.568 src/sys/kern/vfs_syscalls.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_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.567 src/sys/kern/vfs_syscalls.c:1.568
--- src/sys/kern/vfs_syscalls.c:1.567	Sun Aug 11 13:09:58 2024
+++ src/sys/kern/vfs_syscalls.c	Sun Aug 11 13:43:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls.c,v 1.567 2024/08/11 13:09:58 bad Exp $	*/
+/*	$NetBSD: vfs_syscalls.c,v 1.568 2024/08/11 13:43:20 bad Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009, 2019, 2020, 2023 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.567 2024/08/11 13:09:58 bad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.568 2024/08/11 13:43:20 bad Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_fileassoc.h"
@@ -749,8 +749,7 @@ do_sys_sync(struct lwp *l)
 			asyncflag = mp->mnt_flag & MNT_ASYNC;
 			mp->mnt_flag &= ~MNT_ASYNC;
 			VFS_SYNC(mp, MNT_NOWAIT, l->l_cred);
-			if (asyncflag)
- mp->mnt_flag |= MNT_ASYNC;
+			mp->mnt_flag |= asyncflag;
 		}
 		mutex_exit(mp->mnt_updating);
 	}



CVS commit: src/sys/kern

2024-08-11 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Sun Aug 11 13:43:20 UTC 2024

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

Log Message:
tweak restoration of asyncflag

Simply update mp->mnt_flag with asyncflag as it contains the correct value.
Use the same pattern as in the other two places (vfs_syscalls.c, ffs_wapbl.c).

NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.567 -r1.568 src/sys/kern/vfs_syscalls.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-08-11 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Sun Aug 11 13:09:58 UTC 2024

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

Log Message:
explain why MNT_ASYNC is temporarily cleared

related to PR kern/58564.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.566 -r1.567 src/sys/kern/vfs_syscalls.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.106 src/sys/kern/vfs_mount.c:1.107
--- src/sys/kern/vfs_mount.c:1.106	Sun Aug 11 12:58:10 2024
+++ src/sys/kern/vfs_mount.c	Sun Aug 11 13:09:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.106 2024/08/11 12:58:10 bad Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.107 2024/08/11 13:09:58 bad Exp $	*/
 
 /*-
  * Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.106 2024/08/11 12:58:10 bad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.107 2024/08/11 13:09:58 bad Exp $");
 
 #include "veriexec.h"
 
@@ -961,6 +961,10 @@ dounmount(struct mount *mp, int flags, s
 
 	mp->mnt_iflag |= IMNT_UNMOUNT;
 	mutex_enter(mp->mnt_updating);
+	/*
+	 * Temporarily clear the MNT_ASYNC flags so that bwrite() doesn't
+	 * convert the sync writes to delayed writes.
+	 */
 	async = mp->mnt_flag & MNT_ASYNC;
 	mp->mnt_flag &= ~MNT_ASYNC;
 	cache_purgevfs(mp);	/* remove cache entries for this file sys */

Index: src/sys/kern/vfs_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.566 src/sys/kern/vfs_syscalls.c:1.567
--- src/sys/kern/vfs_syscalls.c:1.566	Thu Jul  4 16:42:37 2024
+++ src/sys/kern/vfs_syscalls.c	Sun Aug 11 13:09:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls.c,v 1.566 2024/07/04 16:42:37 christos Exp $	*/
+/*	$NetBSD: vfs_syscalls.c,v 1.567 2024/08/11 13:09:58 bad Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009, 2019, 2020, 2023 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.566 2024/07/04 16:42:37 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.567 2024/08/11 13:09:58 bad Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_fileassoc.h"
@@ -741,6 +741,11 @@ do_sys_sync(struct lwp *l)
 	while ((mp = mountlist_iterator_next(iter)) != NULL) {
 		mutex_enter(mp->mnt_updating);
 		if ((mp->mnt_flag & MNT_RDONLY) == 0) {
+			/*
+			 * Temporarily clear the MNT_ASYNC flags so that
+			 * bwrite() doesnt convert the sync writes to
+			 * delayed writes.
+			 */
 			asyncflag = mp->mnt_flag & MNT_ASYNC;
 			mp->mnt_flag &= ~MNT_ASYNC;
 			VFS_SYNC(mp, MNT_NOWAIT, l->l_cred);



CVS commit: src/sys/kern

2024-08-11 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Sun Aug 11 13:09:58 UTC 2024

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

Log Message:
explain why MNT_ASYNC is temporarily cleared

related to PR kern/58564.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.566 -r1.567 src/sys/kern/vfs_syscalls.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-07-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  4 16:42:38 UTC 2024

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

Log Message:
use the proper kernel pointer


To generate a diff of this commit:
cvs rdiff -u -r1.565 -r1.566 src/sys/kern/vfs_syscalls.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_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.565 src/sys/kern/vfs_syscalls.c:1.566
--- src/sys/kern/vfs_syscalls.c:1.565	Thu Jul  4 01:59:05 2024
+++ src/sys/kern/vfs_syscalls.c	Thu Jul  4 12:42:37 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls.c,v 1.565 2024/07/04 05:59:05 mrg Exp $	*/
+/*	$NetBSD: vfs_syscalls.c,v 1.566 2024/07/04 16:42:37 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009, 2019, 2020, 2023 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.565 2024/07/04 05:59:05 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.566 2024/07/04 16:42:37 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_fileassoc.h"
@@ -279,7 +279,7 @@ fd_nameiat_simple_user(struct lwp *l, in
 
 	error = nameiat_simple(dvp, pb, sflags, vp_ret);
 
-	if (fdat != AT_FDCWD && path[0] != '/')
+	if (fdat != AT_FDCWD && p[0] != '/')
 		fd_putfile(fdat);
 
 out:



CVS commit: src/sys/kern

2024-07-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  4 16:42:38 UTC 2024

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

Log Message:
use the proper kernel pointer


To generate a diff of this commit:
cvs rdiff -u -r1.565 -r1.566 src/sys/kern/vfs_syscalls.c

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



Re: CVS commit: src/sys/kern

2024-07-04 Thread Taylor R Campbell
> Module Name:src
> Committed By:   mrg
> Date:   Thu Jul  4 05:59:05 UTC 2024
> 
> Modified Files:
> src/sys/kern: vfs_syscalls.c
> 
> Log Message:
> don't fd_putfile() if you haven't grabbed a ref already.
> 
> the condition to call fd_getvnode() was changed, but the condition
> to call fd_putfile() afterwards was not changed, leading to a panic
> seen by Chavdar on current-users, probably.
> 
> builds, runs, seems obvious.

The automatic testbed is failing to run tests to completion now:

https://releng.netbsd.org/b5reports/i386/commits-2024.07.html#2024.07.04.05.59.05

Our sloppy process for fixing the vfs_syscalls.c issue is obviously
failing now, after days of flailing around with band-aids.  I propose
to back out all of the recent changes:

https://mail-index.netbsd.org/source-changes/2024/06/29/msg152020.html
https://mail-index.netbsd.org/source-changes/2024/07/01/msg152081.html
https://mail-index.netbsd.org/source-changes/2024/07/01/msg152082.html
https://mail-index.netbsd.org/source-changes/2024/07/01/msg152083.html
https://mail-index.netbsd.org/source-changes/2024/07/04/msg152216.html

And then redo them with:

1. A PR that explains the problem, with references, and can track the
   changes in case we need to pull them up.

2. Posting the patch for public review first.

3. Adding automatic tests that exercise all the relevant cases and
   xfail, but that would pass with the fix.

4. _Then_ committing the fix.


CVS commit: src/sys/kern

2024-07-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jul  4 05:59:05 UTC 2024

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

Log Message:
don't fd_putfile() if you haven't grabbed a ref already.

the condition to call fd_getvnode() was changed, but the condition
to call fd_putfile() afterwards was not changed, leading to a panic
seen by Chavdar on current-users, probably.

builds, runs, seems obvious.


To generate a diff of this commit:
cvs rdiff -u -r1.564 -r1.565 src/sys/kern/vfs_syscalls.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_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.564 src/sys/kern/vfs_syscalls.c:1.565
--- src/sys/kern/vfs_syscalls.c:1.564	Mon Jul  1 00:58:04 2024
+++ src/sys/kern/vfs_syscalls.c	Thu Jul  4 05:59:05 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls.c,v 1.564 2024/07/01 00:58:04 christos Exp $	*/
+/*	$NetBSD: vfs_syscalls.c,v 1.565 2024/07/04 05:59:05 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009, 2019, 2020, 2023 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.564 2024/07/01 00:58:04 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.565 2024/07/04 05:59:05 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_fileassoc.h"
@@ -245,7 +245,7 @@ fd_nameiat(struct lwp *l, int fdat, stru
 
 	error = namei(ndp);
 
-	if (fdat != AT_FDCWD)
+	if (fdat != AT_FDCWD && path[0] != '/')
 		fd_putfile(fdat);
 out:
 	pathbuf_stringcopy_put(ndp->ni_pathbuf, path);
@@ -279,7 +279,7 @@ fd_nameiat_simple_user(struct lwp *l, in
 
 	error = nameiat_simple(dvp, pb, sflags, vp_ret);
 
-	if (fdat != AT_FDCWD)
+	if (fdat != AT_FDCWD && path[0] != '/')
 		fd_putfile(fdat);
 
 out:



CVS commit: src/sys/kern

2024-07-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jul  4 05:59:05 UTC 2024

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

Log Message:
don't fd_putfile() if you haven't grabbed a ref already.

the condition to call fd_getvnode() was changed, but the condition
to call fd_putfile() afterwards was not changed, leading to a panic
seen by Chavdar on current-users, probably.

builds, runs, seems obvious.


To generate a diff of this commit:
cvs rdiff -u -r1.564 -r1.565 src/sys/kern/vfs_syscalls.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-06-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jul  1 00:51:11 UTC 2024

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

Log Message:
remove the part of previous that crashes for now.


To generate a diff of this commit:
cvs rdiff -u -r1.562 -r1.563 src/sys/kern/vfs_syscalls.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-06-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jul  1 00:51:11 UTC 2024

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

Log Message:
remove the part of previous that crashes for now.


To generate a diff of this commit:
cvs rdiff -u -r1.562 -r1.563 src/sys/kern/vfs_syscalls.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_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.562 src/sys/kern/vfs_syscalls.c:1.563
--- src/sys/kern/vfs_syscalls.c:1.562	Sat Jun 29 09:31:07 2024
+++ src/sys/kern/vfs_syscalls.c	Sun Jun 30 20:51:11 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls.c,v 1.562 2024/06/29 13:31:07 christos Exp $	*/
+/*	$NetBSD: vfs_syscalls.c,v 1.563 2024/07/01 00:51:11 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009, 2019, 2020, 2023 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.562 2024/06/29 13:31:07 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.563 2024/07/01 00:51:11 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_fileassoc.h"
@@ -260,7 +260,7 @@ fd_nameiat_simple_user(struct lwp *l, in
 	struct vnode *dvp;
 	int error;
 
-	if (fdat != AT_FDCWD && path[0] != '/') {
+	if (fdat != AT_FDCWD) {
 		if ((error = fd_getvnode(fdat, &dfp)) != 0)
 			goto out;
 



CVS commit: src/sys/kern

2024-06-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jun 29 13:31:07 UTC 2024

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

Log Message:
Ignore the file descriptor argument for absolute pathnames, per posix eg:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/access.html


To generate a diff of this commit:
cvs rdiff -u -r1.561 -r1.562 src/sys/kern/vfs_syscalls.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_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.561 src/sys/kern/vfs_syscalls.c:1.562
--- src/sys/kern/vfs_syscalls.c:1.561	Sat Sep  9 14:34:44 2023
+++ src/sys/kern/vfs_syscalls.c	Sat Jun 29 09:31:07 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls.c,v 1.561 2023/09/09 18:34:44 ad Exp $	*/
+/*	$NetBSD: vfs_syscalls.c,v 1.562 2024/06/29 13:31:07 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009, 2019, 2020, 2023 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.561 2023/09/09 18:34:44 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.562 2024/06/29 13:31:07 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_fileassoc.h"
@@ -234,8 +234,9 @@ fd_nameiat(struct lwp *l, int fdat, stru
 {
 	file_t *dfp;
 	int error;
+	const char *path = pathbuf_stringcopy_get(ndp->ni_pathbuf);
 
-	if (fdat != AT_FDCWD) {
+	if (fdat != AT_FDCWD && path[0] != '/') {
 		if ((error = fd_getvnode(fdat, &dfp)) != 0)
 			goto out;
 
@@ -247,6 +248,7 @@ fd_nameiat(struct lwp *l, int fdat, stru
 	if (fdat != AT_FDCWD)
 		fd_putfile(fdat);
 out:
+	pathbuf_stringcopy_put(ndp->ni_pathbuf, path);
 	return error;
 }
 
@@ -258,7 +260,7 @@ fd_nameiat_simple_user(struct lwp *l, in
 	struct vnode *dvp;
 	int error;
 
-	if (fdat != AT_FDCWD) {
+	if (fdat != AT_FDCWD && path[0] != '/') {
 		if ((error = fd_getvnode(fdat, &dfp)) != 0)
 			goto out;
 



CVS commit: src/sys/kern

2024-06-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jun 29 13:31:07 UTC 2024

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

Log Message:
Ignore the file descriptor argument for absolute pathnames, per posix eg:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/access.html


To generate a diff of this commit:
cvs rdiff -u -r1.561 -r1.562 src/sys/kern/vfs_syscalls.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-05-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 19 15:56:55 UTC 2024

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

Log Message:
PR/58266: Collin Funk: Fail if from == to, like FreeBSD and Linux. The test
is done in dup3 before any other tests so even if a bad descriptor it is
passed we will return EINVAL not EBADFD like Linux does.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/kern/sys_descrip.c

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

Modified files:

Index: src/sys/kern/sys_descrip.c
diff -u src/sys/kern/sys_descrip.c:1.48 src/sys/kern/sys_descrip.c:1.49
--- src/sys/kern/sys_descrip.c:1.48	Sun Jul  9 22:31:55 2023
+++ src/sys/kern/sys_descrip.c	Sun May 19 11:56:55 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_descrip.c,v 1.48 2023/07/10 02:31:55 christos Exp $	*/
+/*	$NetBSD: sys_descrip.c,v 1.49 2024/05/19 15:56:55 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_descrip.c,v 1.48 2023/07/10 02:31:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_descrip.c,v 1.49 2024/05/19 15:56:55 christos Exp $");
 
 #include 
 #include 
@@ -156,6 +156,8 @@ sys_dup3(struct lwp *l, const struct sys
 		syscallarg(int)	to;
 		syscallarg(int)	flags;
 	} */
+	if (SCARG(uap, from) == SCARG(uap, to))
+		return EINVAL;
 	return dodup(l, SCARG(uap, from), SCARG(uap, to), SCARG(uap, flags),
 	retval);
 }



CVS commit: src/sys/kern

2024-05-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 19 15:56:55 UTC 2024

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

Log Message:
PR/58266: Collin Funk: Fail if from == to, like FreeBSD and Linux. The test
is done in dup3 before any other tests so even if a bad descriptor it is
passed we will return EINVAL not EBADFD like Linux does.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/kern/sys_descrip.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-05-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon May 13 00:32:09 UTC 2024

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

Log Message:
s/signficant/significant/ in comment.


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

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

Modified files:

Index: src/sys/kern/kern_module.c
diff -u src/sys/kern/kern_module.c:1.161 src/sys/kern/kern_module.c:1.162
--- src/sys/kern/kern_module.c:1.161	Tue Jan 31 13:21:37 2023
+++ src/sys/kern/kern_module.c	Mon May 13 00:32:09 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_module.c,v 1.161 2023/01/31 13:21:37 riastradh Exp $	*/
+/*	$NetBSD: kern_module.c,v 1.162 2024/05/13 00:32:09 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.161 2023/01/31 13:21:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.162 2024/05/13 00:32:09 msaitoh Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -641,7 +641,7 @@ module_init_class(modclass_t modclass)
  *
  *	Return true if the two supplied kernel versions are said to
  *	have the same binary interface for kernel code.  The entire
- *	version is signficant for the development tree (-current),
+ *	version is significant for the development tree (-current),
  *	major and minor versions are significant for official
  *	releases of the system.
  */



CVS commit: src/sys/kern

2024-05-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon May 13 00:32:09 UTC 2024

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

Log Message:
s/signficant/significant/ in comment.


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

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



CVS commit: src/sys/kern

2024-05-10 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat May 11 06:34:45 UTC 2024

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

Log Message:
s/timetamp/timestamp/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/kern/kern_tc.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-05-10 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat May 11 06:34:45 UTC 2024

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

Log Message:
s/timetamp/timestamp/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/kern/kern_tc.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_tc.c
diff -u src/sys/kern/kern_tc.c:1.76 src/sys/kern/kern_tc.c:1.77
--- src/sys/kern/kern_tc.c:1.76	Sun Jul 30 12:39:18 2023
+++ src/sys/kern/kern_tc.c	Sat May 11 06:34:45 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_tc.c,v 1.76 2023/07/30 12:39:18 riastradh Exp $ */
+/* $NetBSD: kern_tc.c,v 1.77 2024/05/11 06:34:45 andvar Exp $ */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
 
 #include 
 /* __FBSDID("$FreeBSD: src/sys/kern/kern_tc.c,v 1.166 2005/09/19 22:16:31 andre Exp $"); */
-__KERNEL_RCSID(0, "$NetBSD: kern_tc.c,v 1.76 2023/07/30 12:39:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_tc.c,v 1.77 2024/05/11 06:34:45 andvar Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ntp.h"
@@ -1128,7 +1128,7 @@ pps_init(struct pps_state *pps)
 }
 
 /*
- * capture a timetamp in the pps structure
+ * capture a timestamp in the pps structure
  */
 void
 pps_capture(struct pps_state *pps)



CVS commit: src/sys/kern

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 13:33:18 UTC 2024

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

Log Message:
Account for trailing NUL bytes when calculating userland buffer size.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/kern/subr_iostat.c

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

Modified files:

Index: src/sys/kern/subr_iostat.c
diff -u src/sys/kern/subr_iostat.c:1.25 src/sys/kern/subr_iostat.c:1.26
--- src/sys/kern/subr_iostat.c:1.25	Wed May 22 08:47:02 2019
+++ src/sys/kern/subr_iostat.c	Sat May  4 13:33:18 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_iostat.c,v 1.25 2019/05/22 08:47:02 hannken Exp $	*/
+/*	$NetBSD: subr_iostat.c,v 1.26 2024/05/04 13:33:18 mlelstv Exp $	*/
 /*	NetBSD: subr_disk.c,v 1.69 2005/05/29 22:24:15 christos Exp	*/
 
 /*-
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_iostat.c,v 1.25 2019/05/22 08:47:02 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_iostat.c,v 1.26 2024/05/04 13:33:18 mlelstv Exp $");
 
 #include 
 #include 
@@ -370,6 +370,8 @@ iostati_getnames(int disk_only, char *ol
 			memset(bf, 0, sizeof(bf));
 			if (first) {
 strncpy(bf, stats->io_name, sizeof(bf));
+/* account for trailing NUL byte */
+needed += 1;
 first = 0;
 			} else {
 bf[0] = ' ';



CVS commit: src/sys/kern

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 13:33:18 UTC 2024

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

Log Message:
Account for trailing NUL bytes when calculating userland buffer size.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/kern/subr_iostat.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-04-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Apr 24 02:08:03 UTC 2024

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

Log Message:
vmem_init(): Ensure that the quantum is a power of 2, and that if private
tags are being used, they are added to the arena before the first span is
added.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/sys/kern/subr_vmem.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-04-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Apr 24 02:08:03 UTC 2024

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

Log Message:
vmem_init(): Ensure that the quantum is a power of 2, and that if private
tags are being used, they are added to the arena before the first span is
added.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/sys/kern/subr_vmem.c

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

Modified files:

Index: src/sys/kern/subr_vmem.c
diff -u src/sys/kern/subr_vmem.c:1.115 src/sys/kern/subr_vmem.c:1.116
--- src/sys/kern/subr_vmem.c:1.115	Sun Dec  3 19:34:08 2023
+++ src/sys/kern/subr_vmem.c	Wed Apr 24 02:08:03 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_vmem.c,v 1.115 2023/12/03 19:34:08 thorpej Exp $	*/
+/*	$NetBSD: subr_vmem.c,v 1.116 2024/04/24 02:08:03 thorpej Exp $	*/
 
 /*-
  * Copyright (c)2006,2007,2008,2009 YAMAMOTO Takashi,
@@ -46,7 +46,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.115 2023/12/03 19:34:08 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.116 2024/04/24 02:08:03 thorpej Exp $");
 
 #if defined(_KERNEL) && defined(_KERNEL_OPT)
 #include "opt_ddb.h"
@@ -971,6 +971,14 @@ vmem_init(vmem_t *vm, const char *name,
 	KASSERT((flags & (VM_SLEEP|VM_NOSLEEP)) != 0);
 	KASSERT((~flags & (VM_SLEEP|VM_NOSLEEP)) != 0);
 	KASSERT(quantum > 0);
+	KASSERT(powerof2(quantum));
+
+	/*
+	 * If private tags are going to be used, they must
+	 * be added to the arena before the first span is
+	 * added.
+	 */
+	KASSERT((flags & VM_PRIVTAGS) == 0 || size == 0);
 
 #if defined(_KERNEL)
 	/* XXX: SMP, we get called early... */



CVS commit: src/sys/kern

2024-04-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Apr 19 00:45:41 UTC 2024

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

Log Message:
dounmount: Avoid &((struct vnode_impl *)NULL)->vi_vnode.

Member access of a null pointer is undefined, even if the result
should also be null because vi_vnode is at the start of vnode_impl.

Reported-by: syzbot+a4b2d13c0d6d4dac2...@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?extid=a4b2d13c0d6d4dac2d07


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 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.104 src/sys/kern/vfs_mount.c:1.105
--- src/sys/kern/vfs_mount.c:1.104	Wed Jan 17 10:17:29 2024
+++ src/sys/kern/vfs_mount.c	Fri Apr 19 00:45:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.104 2024/01/17 10:17:29 hannken Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.105 2024/04/19 00:45:41 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.104 2024/01/17 10:17:29 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.105 2024/04/19 00:45:41 riastradh Exp $");
 
 #include "veriexec.h"
 
@@ -936,7 +936,8 @@ err_mounted:
 int
 dounmount(struct mount *mp, int flags, struct lwp *l)
 {
-	vnode_t *coveredvp, *vp;
+	struct vnode *coveredvp, *vp;
+	struct vnode_impl *vip;
 	int error, async, used_syncer, used_extattr;
 	const bool was_suspended = fstrans_is_owner(mp);
 
@@ -1003,7 +1004,9 @@ dounmount(struct mount *mp, int flags, s
 		vfs_resume(mp);
 
 	mountlist_remove(mp);
-	if ((vp = VIMPL_TO_VNODE(TAILQ_FIRST(&mp->mnt_vnodelist))) != NULL) {
+
+	if ((vip = TAILQ_FIRST(&mp->mnt_vnodelist)) != NULL) {
+		vp = VIMPL_TO_VNODE(vip);
 		vprint("dangling", vp);
 		panic("unmount: dangling vnode");
 	}



CVS commit: src/sys/kern

2024-04-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Apr 19 00:45:41 UTC 2024

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

Log Message:
dounmount: Avoid &((struct vnode_impl *)NULL)->vi_vnode.

Member access of a null pointer is undefined, even if the result
should also be null because vi_vnode is at the start of vnode_impl.

Reported-by: syzbot+a4b2d13c0d6d4dac2...@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?extid=a4b2d13c0d6d4dac2d07


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

2024-04-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr 11 13:51:36 UTC 2024

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

Log Message:
sys_futex.c: Fix illustration of futex(2).

In this illustration, we need to _set_ bit 1 to claim ownership, not
_clear_ bit 1 to claim ownership.

No functional change intended -- comment only.


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

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



CVS commit: src/sys/kern

2024-04-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Apr 11 13:51:36 UTC 2024

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

Log Message:
sys_futex.c: Fix illustration of futex(2).

In this illustration, we need to _set_ bit 1 to claim ownership, not
_clear_ bit 1 to claim ownership.

No functional change intended -- comment only.


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

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

Modified files:

Index: src/sys/kern/sys_futex.c
diff -u src/sys/kern/sys_futex.c:1.19 src/sys/kern/sys_futex.c:1.20
--- src/sys/kern/sys_futex.c:1.19	Fri Feb 24 11:02:27 2023
+++ src/sys/kern/sys_futex.c	Thu Apr 11 13:51:36 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_futex.c,v 1.19 2023/02/24 11:02:27 riastradh Exp $	*/
+/*	$NetBSD: sys_futex.c,v 1.20 2024/04/11 13:51:36 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_futex.c,v 1.19 2023/02/24 11:02:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_futex.c,v 1.20 2024/04/11 13:51:36 riastradh Exp $");
 
 /*
  * Futexes
@@ -62,7 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: sys_futex.c,
  *futex(FUTEX_WAIT, &lock, v | 2, NULL, NULL, 0);
  *continue;
  *			}
- *		} while (atomic_cas_uint(&lock, v, v & ~1) != v);
+ *		} while (atomic_cas_uint(&lock, v, v | 1) != v);
  *		membar_acquire();
  *
  *		...



CVS commit: src/sys/kern

2024-03-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar  8 23:34:03 UTC 2024

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

Log Message:
heartbeat(9): Return early if panicstr is set.

This way we avoid doing unnecessary work -- and print unnecessary
messages -- to _not_ trigger another panic anyway.

PR kern/58011


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/kern/kern_heartbeat.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_heartbeat.c
diff -u src/sys/kern/kern_heartbeat.c:1.12 src/sys/kern/kern_heartbeat.c:1.13
--- src/sys/kern/kern_heartbeat.c:1.12	Wed Feb 28 04:14:47 2024
+++ src/sys/kern/kern_heartbeat.c	Fri Mar  8 23:34:03 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_heartbeat.c,v 1.12 2024/02/28 04:14:47 riastradh Exp $	*/
+/*	$NetBSD: kern_heartbeat.c,v 1.13 2024/03/08 23:34:03 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_heartbeat.c,v 1.12 2024/02/28 04:14:47 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_heartbeat.c,v 1.13 2024/03/08 23:34:03 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -627,11 +627,17 @@ heartbeat(void)
 
 	KASSERT(curcpu_stable());
 
+	/*
+	 * If heartbeat checks are disabled globally, or if they are
+	 * suspended locally, or if we're already panicking so it's not
+	 * helpful to trigger more panics for more reasons, do nothing.
+	 */
 	period_ticks = atomic_load_relaxed(&heartbeat_max_period_ticks);
 	period_secs = atomic_load_relaxed(&heartbeat_max_period_secs);
 	if (__predict_false(period_ticks == 0) ||
 	__predict_false(period_secs == 0) ||
-	__predict_false(curcpu()->ci_heartbeat_suspend))
+	__predict_false(curcpu()->ci_heartbeat_suspend) ||
+	__predict_false(panicstr != NULL))
 		return;
 
 	/*



CVS commit: src/sys/kern

2024-03-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar  8 23:34:03 UTC 2024

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

Log Message:
heartbeat(9): Return early if panicstr is set.

This way we avoid doing unnecessary work -- and print unnecessary
messages -- to _not_ trigger another panic anyway.

PR kern/58011


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/kern/kern_heartbeat.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-03-02 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar  2 08:59:47 UTC 2024

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

Log Message:
Avoid overflow when computing kern.ipc.shmmax. Keep shmmax (bytes) and
shmall (pages) values aligned and use arithmetic everywhere instead
of shifts.
Should fix PR 57979


To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sys/kern/sysv_shm.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/sysv_shm.c
diff -u src/sys/kern/sysv_shm.c:1.141 src/sys/kern/sysv_shm.c:1.142
--- src/sys/kern/sysv_shm.c:1.141	Wed Oct  9 17:47:13 2019
+++ src/sys/kern/sysv_shm.c	Sat Mar  2 08:59:47 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysv_shm.c,v 1.141 2019/10/09 17:47:13 chs Exp $	*/
+/*	$NetBSD: sysv_shm.c,v 1.142 2024/03/02 08:59:47 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.141 2019/10/09 17:47:13 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.142 2024/03/02 08:59:47 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sysv.h"
@@ -961,10 +961,10 @@ shminit(void)
 	ALIGN(shminfo.shmmni * sizeof(struct shmid_ds)));
 
 	if (shminfo.shmmax == 0)
-		shminfo.shmmax = uimax(physmem / 4, 1024) * PAGE_SIZE;
+		shminfo.shmall = uimax(physmem / 4, 1024);
 	else
-		shminfo.shmmax *= PAGE_SIZE;
-	shminfo.shmall = shminfo.shmmax / PAGE_SIZE;
+		shminfo.shmall = shminfo.shmmax / PAGE_SIZE;
+	shminfo.shmmax = (uint64_t)shminfo.shmall * PAGE_SIZE;
 
 	for (i = 0; i < shminfo.shmmni; i++) {
 		cv_init(&shm_cv[i], "shmwait");
@@ -1083,7 +1083,7 @@ sysctl_ipc_shmmax(SYSCTLFN_ARGS)
 		return EINVAL;
 
 	shminfo.shmmax = round_page(newsize);
-	shminfo.shmall = shminfo.shmmax >> PAGE_SHIFT;
+	shminfo.shmall = shminfo.shmmax / PAGE_SIZE;
 
 	return 0;
 }



  1   2   3   4   5   6   7   8   9   10   >