CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Mar 11 18:04:54 UTC 2024 Modified Files: src/sys/kern [netbsd-8]: sysv_shm.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1945): sys/kern/sysv_shm.c: revision 1.142 (patch) 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.131.10.2 -r1.131.10.3 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.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Mar 11 18:04:54 UTC 2024 Modified Files: src/sys/kern [netbsd-8]: sysv_shm.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1945): sys/kern/sysv_shm.c: revision 1.142 (patch) 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.131.10.2 -r1.131.10.3 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.131.10.2 src/sys/kern/sysv_shm.c:1.131.10.3 --- src/sys/kern/sysv_shm.c:1.131.10.2 Tue Jan 21 18:12:54 2020 +++ src/sys/kern/sysv_shm.c Mon Mar 11 18:04:54 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: sysv_shm.c,v 1.131.10.2 2020/01/21 18:12:54 martin Exp $ */ +/* $NetBSD: sysv_shm.c,v 1.131.10.3 2024/03/11 18:04:54 martin Exp $ */ /*- * Copyright (c) 1999, 2007 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.131.10.2 2020/01/21 18:12:54 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.131.10.3 2024/03/11 18:04:54 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_sysv.h" @@ -1004,10 +1004,10 @@ shminit(struct sysctllog **clog) ALIGN(shminfo.shmmni * sizeof(struct shmid_ds))); if (shminfo.shmmax == 0) - shminfo.shmmax = max(physmem / 4, 1024) * PAGE_SIZE; + shminfo.shmall = max(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(_cv[i], "shmwait"); @@ -1129,7 +1129,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; }
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Wed Nov 29 12:29:06 UTC 2023 Modified Files: src/sys/kern [netbsd-8]: exec_subr.c Log Message: Additionally pull up the following for ticket #1920: sys/kern/exec_subr.c1.87 Fix build for kernels w/o PAX_MPROTECT. To generate a diff of this commit: cvs rdiff -u -r1.78.2.4 -r1.78.2.5 src/sys/kern/exec_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/exec_subr.c diff -u src/sys/kern/exec_subr.c:1.78.2.4 src/sys/kern/exec_subr.c:1.78.2.5 --- src/sys/kern/exec_subr.c:1.78.2.4 Tue Nov 28 13:00:52 2023 +++ src/sys/kern/exec_subr.c Wed Nov 29 12:29:05 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: exec_subr.c,v 1.78.2.4 2023/11/28 13:00:52 martin Exp $ */ +/* $NetBSD: exec_subr.c,v 1.78.2.5 2023/11/29 12:29:05 martin Exp $ */ /* * Copyright (c) 1993, 1994, 1996 Christopher G. Demetriou @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: exec_subr.c,v 1.78.2.4 2023/11/28 13:00:52 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exec_subr.c,v 1.78.2.5 2023/11/29 12:29:05 martin Exp $"); #include "opt_pax.h" @@ -162,7 +162,7 @@ static int vmcmd_get_prot(struct lwp *l, const struct exec_vmcmd *cmd, vm_prot_t *prot, vm_prot_t *maxprot) { - vm_prot_t extraprot = PROT_MPROTECT_EXTRACT(cmd->ev_prot); + vm_prot_t extraprot __unused = PROT_MPROTECT_EXTRACT(cmd->ev_prot); *prot = cmd->ev_prot & UVM_PROT_ALL; *maxprot = PAX_MPROTECT_MAXPROTECT(l, *prot, extraprot, UVM_PROT_ALL);
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Wed Nov 29 12:29:06 UTC 2023 Modified Files: src/sys/kern [netbsd-8]: exec_subr.c Log Message: Additionally pull up the following for ticket #1920: sys/kern/exec_subr.c1.87 Fix build for kernels w/o PAX_MPROTECT. To generate a diff of this commit: cvs rdiff -u -r1.78.2.4 -r1.78.2.5 src/sys/kern/exec_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Fri Aug 4 13:58:11 UTC 2023 Modified Files: src/sys/kern [netbsd-8]: init_main.c Log Message: Apply patch, requested by riastradh in ticket #1882 (issue solved differently in -current): sys/kern/init_main.c(apply patch) PR kern/55906: create the aiodone workqueue before running mountroothooks. To generate a diff of this commit: cvs rdiff -u -r1.490.6.2 -r1.490.6.3 src/sys/kern/init_main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Fri Aug 4 13:58:11 UTC 2023 Modified Files: src/sys/kern [netbsd-8]: init_main.c Log Message: Apply patch, requested by riastradh in ticket #1882 (issue solved differently in -current): sys/kern/init_main.c(apply patch) PR kern/55906: create the aiodone workqueue before running mountroothooks. To generate a diff of this commit: cvs rdiff -u -r1.490.6.2 -r1.490.6.3 src/sys/kern/init_main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/init_main.c diff -u src/sys/kern/init_main.c:1.490.6.2 src/sys/kern/init_main.c:1.490.6.3 --- src/sys/kern/init_main.c:1.490.6.2 Sat Feb 6 15:22:19 2021 +++ src/sys/kern/init_main.c Fri Aug 4 13:58:11 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.490.6.2 2021/02/06 15:22:19 martin Exp $ */ +/* $NetBSD: init_main.c,v 1.490.6.3 2023/08/04 13:58:11 martin Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -97,7 +97,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.490.6.2 2021/02/06 15:22:19 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.490.6.3 2023/08/04 13:58:11 martin Exp $"); #include "opt_ddb.h" #include "opt_inet.h" @@ -638,6 +638,11 @@ main(void) cpu_rootconf(); cpu_dumpconf(); + /* Create the aiodone daemon kernel thread. */ + if (workqueue_create(_queue, "aiodoned", + uvm_aiodone_worker, NULL, PRI_VM, IPL_NONE, WQ_MPSAFE)) + panic("fork aiodoned"); + /* Mount the root file system. */ do { domountroothook(root_device); @@ -697,11 +702,6 @@ main(void) NULL, NULL, "ioflush")) panic("fork syncer"); - /* Create the aiodone daemon kernel thread. */ - if (workqueue_create(_queue, "aiodoned", - uvm_aiodone_worker, NULL, PRI_VM, IPL_NONE, WQ_MPSAFE)) - panic("fork aiodoned"); - /* Wait for final configure threads to complete. */ config_finalize_mountroot();
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Jul 31 16:29:56 UTC 2023 Modified Files: src/sys/kern [netbsd-8]: uipc_domain.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1867): sys/kern/uipc_domain.c: revision 1.109 sockaddr_alloc(9): Avoid uninitialized buffer in sockaddr_checklen. Manifests only under DIAGNOSTIC because the DIAGNOSTIC check itself uses an uninitialized buffer. To generate a diff of this commit: cvs rdiff -u -r1.96.10.2 -r1.96.10.3 src/sys/kern/uipc_domain.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/uipc_domain.c diff -u src/sys/kern/uipc_domain.c:1.96.10.2 src/sys/kern/uipc_domain.c:1.96.10.3 --- src/sys/kern/uipc_domain.c:1.96.10.2 Tue Jan 16 13:04:33 2018 +++ src/sys/kern/uipc_domain.c Mon Jul 31 16:29:56 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_domain.c,v 1.96.10.2 2018/01/16 13:04:33 martin Exp $ */ +/* $NetBSD: uipc_domain.c,v 1.96.10.3 2023/07/31 16:29:56 martin Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.96.10.2 2018/01/16 13:04:33 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.96.10.3 2023/07/31 16:29:56 martin Exp $"); #include #include @@ -322,6 +322,15 @@ sockaddr_alloc(sa_family_t af, socklen_t struct sockaddr *sa; socklen_t reallen = MAX(socklen, offsetof(struct sockaddr, sa_data[0])); +#ifdef DIAGNOSTIC + /* + * sockaddr_checklen passes sa to sockaddr_format which + * requires it to be fully initialized. + * + * XXX This should be factored better. + */ + flags |= M_ZERO; +#endif if ((sa = malloc(reallen, M_SOCKADDR, flags)) == NULL) return NULL;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Jul 31 16:29:56 UTC 2023 Modified Files: src/sys/kern [netbsd-8]: uipc_domain.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1867): sys/kern/uipc_domain.c: revision 1.109 sockaddr_alloc(9): Avoid uninitialized buffer in sockaddr_checklen. Manifests only under DIAGNOSTIC because the DIAGNOSTIC check itself uses an uninitialized buffer. To generate a diff of this commit: cvs rdiff -u -r1.96.10.2 -r1.96.10.3 src/sys/kern/uipc_domain.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Jul 31 14:49:37 UTC 2023 Modified Files: src/sys/kern [netbsd-8]: kern_rwlock.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1861): sys/kern/kern_rwlock.c: revision 1.68 (patch) rwlock(9): Fix membars. rw_downgrade must be a release operation, and rw_tryupgrade must be an acquire operation. membar_producer is not enough -- need to use membar_release and membar_acquire. Discussed on tech-kern: https://mail-index.netbsd.org/tech-kern/2023/02/22/msg028726.html To generate a diff of this commit: cvs rdiff -u -r1.46.6.3 -r1.46.6.4 src/sys/kern/kern_rwlock.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_rwlock.c diff -u src/sys/kern/kern_rwlock.c:1.46.6.3 src/sys/kern/kern_rwlock.c:1.46.6.4 --- src/sys/kern/kern_rwlock.c:1.46.6.3 Mon Jul 31 14:42:45 2023 +++ src/sys/kern/kern_rwlock.c Mon Jul 31 14:49:37 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_rwlock.c,v 1.46.6.3 2023/07/31 14:42:45 martin Exp $ */ +/* $NetBSD: kern_rwlock.c,v 1.46.6.4 2023/07/31 14:49:37 martin Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.46.6.3 2023/07/31 14:42:45 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.46.6.4 2023/07/31 14:49:37 martin Exp $"); #define __RWLOCK_PRIVATE @@ -592,8 +592,7 @@ rw_downgrade(krwlock_t *rw) __USE(curthread); #endif - - membar_producer(); + membar_exit(); owner = rw->rw_owner; if ((owner & RW_HAS_WAITERS) == 0) { /* @@ -689,7 +688,7 @@ rw_tryupgrade(krwlock_t *rw) newown = curthread | RW_WRITE_LOCKED | (owner & ~RW_THREAD); next = rw_cas(rw, owner, newown); if (__predict_true(next == owner)) { - membar_producer(); + membar_enter(); /* XXX membar_acquire */ break; } }
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Jul 31 14:49:37 UTC 2023 Modified Files: src/sys/kern [netbsd-8]: kern_rwlock.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1861): sys/kern/kern_rwlock.c: revision 1.68 (patch) rwlock(9): Fix membars. rw_downgrade must be a release operation, and rw_tryupgrade must be an acquire operation. membar_producer is not enough -- need to use membar_release and membar_acquire. Discussed on tech-kern: https://mail-index.netbsd.org/tech-kern/2023/02/22/msg028726.html To generate a diff of this commit: cvs rdiff -u -r1.46.6.3 -r1.46.6.4 src/sys/kern/kern_rwlock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Jul 31 14:42:46 UTC 2023 Modified Files: src/sys/kern [netbsd-8]: kern_lock.c kern_mutex.c kern_rwlock.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1860): sys/kern/kern_rwlock.c: revision 1.67 sys/kern/kern_lock.c: revision 1.182 sys/kern/kern_mutex.c: revision 1.102 (all via patch) Sprinkle __predict_{true,false} for panicstr checks To generate a diff of this commit: cvs rdiff -u -r1.158.6.2 -r1.158.6.3 src/sys/kern/kern_lock.c cvs rdiff -u -r1.65.2.2 -r1.65.2.3 src/sys/kern/kern_mutex.c cvs rdiff -u -r1.46.6.2 -r1.46.6.3 src/sys/kern/kern_rwlock.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_lock.c diff -u src/sys/kern/kern_lock.c:1.158.6.2 src/sys/kern/kern_lock.c:1.158.6.3 --- src/sys/kern/kern_lock.c:1.158.6.2 Sat Jan 13 21:57:11 2018 +++ src/sys/kern/kern_lock.c Mon Jul 31 14:42:45 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_lock.c,v 1.158.6.2 2018/01/13 21:57:11 snj Exp $ */ +/* $NetBSD: kern_lock.c,v 1.158.6.3 2023/07/31 14:42:45 martin Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.158.6.2 2018/01/13 21:57:11 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.158.6.3 2023/07/31 14:42:45 martin Exp $"); #include #include @@ -63,7 +63,7 @@ assert_sleepable(void) uint64_t pctr; bool idle; - if (panicstr != NULL) { + if (__predict_false(panicstr != NULL)) { return; } Index: src/sys/kern/kern_mutex.c diff -u src/sys/kern/kern_mutex.c:1.65.2.2 src/sys/kern/kern_mutex.c:1.65.2.3 --- src/sys/kern/kern_mutex.c:1.65.2.2 Mon Apr 2 09:07:52 2018 +++ src/sys/kern/kern_mutex.c Mon Jul 31 14:42:45 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_mutex.c,v 1.65.2.2 2018/04/02 09:07:52 martin Exp $ */ +/* $NetBSD: kern_mutex.c,v 1.65.2.3 2023/07/31 14:42:45 martin Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ #define __MUTEX_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.65.2.2 2018/04/02 09:07:52 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.65.2.3 2023/07/31 14:42:45 martin Exp $"); #include #include @@ -516,7 +516,7 @@ mutex_vector_enter(kmutex_t *mtx) MUTEX_ASSERT(mtx, curthread != 0); MUTEX_WANTLOCK(mtx); - if (panicstr == NULL) { + if (__predict_true(panicstr == NULL)) { LOCKDEBUG_BARRIER(_lock, 1); } Index: src/sys/kern/kern_rwlock.c diff -u src/sys/kern/kern_rwlock.c:1.46.6.2 src/sys/kern/kern_rwlock.c:1.46.6.3 --- src/sys/kern/kern_rwlock.c:1.46.6.2 Mon Apr 2 09:07:52 2018 +++ src/sys/kern/kern_rwlock.c Mon Jul 31 14:42:45 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_rwlock.c,v 1.46.6.2 2018/04/02 09:07:52 martin Exp $ */ +/* $NetBSD: kern_rwlock.c,v 1.46.6.3 2023/07/31 14:42:45 martin Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.46.6.2 2018/04/02 09:07:52 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.46.6.3 2023/07/31 14:42:45 martin Exp $"); #define __RWLOCK_PRIVATE @@ -186,7 +186,7 @@ static void __noinline rw_abort(const char *func, size_t line, krwlock_t *rw, const char *msg) { - if (panicstr != NULL) + if (__predict_false(panicstr != NULL)) return; LOCKDEBUG_ABORT(func, line, rw, _lockops, msg); @@ -290,7 +290,7 @@ rw_vector_enter(krwlock_t *rw, const krw RW_ASSERT(rw, curthread != 0); RW_WANTLOCK(rw, op); - if (panicstr == NULL) { + if (__predict_true(panicstr == NULL)) { LOCKDEBUG_BARRIER(_lock, 1); }
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Jul 31 14:42:46 UTC 2023 Modified Files: src/sys/kern [netbsd-8]: kern_lock.c kern_mutex.c kern_rwlock.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1860): sys/kern/kern_rwlock.c: revision 1.67 sys/kern/kern_lock.c: revision 1.182 sys/kern/kern_mutex.c: revision 1.102 (all via patch) Sprinkle __predict_{true,false} for panicstr checks To generate a diff of this commit: cvs rdiff -u -r1.158.6.2 -r1.158.6.3 src/sys/kern/kern_lock.c cvs rdiff -u -r1.65.2.2 -r1.65.2.3 src/sys/kern/kern_mutex.c cvs rdiff -u -r1.46.6.2 -r1.46.6.3 src/sys/kern/kern_rwlock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Apr 17 18:13:44 UTC 2023 Modified Files: src/sys/kern [netbsd-8]: subr_prf.c Log Message: Fix merge mishap in applying the changes from rev 1.171 in ticket #1804: patch accidently applied the change to a nearby very similar function (aprint_verbose_internal instead of aprint_error_internal). To generate a diff of this commit: cvs rdiff -u -r1.160.8.1 -r1.160.8.2 src/sys/kern/subr_prf.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_prf.c diff -u src/sys/kern/subr_prf.c:1.160.8.1 src/sys/kern/subr_prf.c:1.160.8.2 --- src/sys/kern/subr_prf.c:1.160.8.1 Fri Feb 24 14:17:18 2023 +++ src/sys/kern/subr_prf.c Mon Apr 17 18:13:44 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_prf.c,v 1.160.8.1 2023/02/24 14:17:18 martin Exp $ */ +/* $NetBSD: subr_prf.c,v 1.160.8.2 2023/04/17 18:13:44 martin Exp $ */ /*- * Copyright (c) 1986, 1988, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.160.8.1 2023/02/24 14:17:18 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.160.8.2 2023/04/17 18:13:44 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -804,6 +804,7 @@ aprint_error_internal(const char *prefix if (prefix) kprintf_internal("%s: ", flags, NULL, NULL, prefix); + kprintf_internal("autoconfiguration error: ", TOLOG, NULL, NULL); kprintf(fmt, flags, NULL, NULL, ap); kprintf_unlock(); @@ -907,7 +908,6 @@ aprint_verbose_internal(const char *pref if (prefix) kprintf_internal("%s: ", flags, NULL, NULL, prefix); - kprintf_internal("autoconfiguration error: ", TOLOG, NULL, NULL); kprintf(fmt, flags, NULL, NULL, ap); kprintf_unlock();
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Apr 17 18:13:44 UTC 2023 Modified Files: src/sys/kern [netbsd-8]: subr_prf.c Log Message: Fix merge mishap in applying the changes from rev 1.171 in ticket #1804: patch accidently applied the change to a nearby very similar function (aprint_verbose_internal instead of aprint_error_internal). To generate a diff of this commit: cvs rdiff -u -r1.160.8.1 -r1.160.8.2 src/sys/kern/subr_prf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Tue Mar 7 20:02:57 UTC 2023 Modified Files: src/sys/kern [netbsd-8]: vfs_syscalls.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1806): sys/kern/vfs_syscalls.c: revision 1.557 open(2): Don't map ERESTART to EINTR. If a file or device's open function returns ERESTART, respect that -- restart the syscall; don't pretend a signal has been delivered when it was not. If an SA_RESTART signal was delivered, POSIX does not allow it to fail with EINTR: SA_RESTART This flag affects the behavior of interruptible functions; that is, those specified to fail with errno set to [EINTR]. If set, and a function specified as interruptible is interrupted by this signal, the function shall restart and shall not fail with [EINTR] unless otherwise specified. If an interruptible function which uses a timeout is restarted, the duration of the timeout following the restart is set to an unspecified value that does not exceed the original timeout value. If the flag is not set, interruptible functions interrupted by this signal shall fail with errno set to [EINTR]. https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaction.html Nothing in the POSIX definition of open specifies otherwise. In 1990, Kirk McKusick added these lines with a mysterious commit message: Author: Kirk McKusick Date: Tue Apr 10 19:36:33 1990 -0800 eliminate longjmp from the kernel (for karels) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 7bc7b39bbf..d572d3a32d 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -14,7 +14,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#)vfs_syscalls.c 7.42 (Berkeley) 3/26/90 + * @(#)vfs_syscalls.c 7.43 (Berkeley) 4/10/90 */ #include "param.h" @@ -530,8 +530,10 @@ copen(scp, fmode, cmode, ndp, resultfd) if (error = vn_open(ndp, fmode, (cmode & 0) &~ S_ISVTX)) { crfree(fp->f_cred); fp->f_count--; - if (error == -1)/* XXX from fdopen */ - return (0); /* XXX from fdopen */ + if (error == EJUSTRETURN) /* XXX from fdopen */ + return (0); /* XXX from fdopen */ + if (error == ERESTART) + error = EINTR; scp->sc_ofile[indx] = NULL; return (error); } (found via this git import of the CSRG history: https://github.com/robohack/ucb-csrg-bsd/commit/cce2869b7ae5d360921eb411005b328a29c4a3fe This change appears to have served two related purposes: 1. The fdopen function (the erstwhile open routine for /dev/fd/N) used to return -1 as a hack to mean it had just duplicated the fd; it was recently changed by Mike Karels, in kern_descrip.c 7.9, to return EJUSTRETURN, now defined to be -2, presumably to avoid a conflict with ERESTART, defined to be -1. So this change finished part of the change by Mike Karels to use a different magic return code from fdopen. Of course, today we use still another disgusting hack, EDUPFD, for the same purpose, so none of this is relevant any more. 2. Prior to April 1990, the kernel handled signals during tsleep(9) by longjmping out to the system call entry point or similar. In April 1990, Mike Karels worked to convert all of that into explicit unwind logic by passing through EINTR or ERESTART as appropriate, instead of setjmp at each entry point. However, it's not clear to me why this setjmp/longjmp and fdopen/-1/EJUSTRETURN renovation justifies unconditional logic to map ERESTART to EINTR in open(2). I suspect it was a mistake. In 2013, the corresponding logic to map ERESTART to EINTR in open(2) was removed from FreeBSD: r246472 | kib | 2013-02-07 14:53:33 + (Thu, 07 Feb 2013) | 11 lines Stop translating the ERESTART error from the open(2) into EINTR. Posix requires that open(2) is restartable for SA_RESTART. For non-posix objects, in particular, devfs nodes, still disable automatic restart of the opens. The open call to a driver could have significant side effects for the hardware. Noted and reviewed by: jilles Discussed with: bde MFC after: 2 weeks Index: vfs_syscalls.c === --- vfs_syscalls.c (revision 246471) +++ vfs_syscalls.c (revision 246472) @@ -1106,8 +1106,6 @@ goto success; } - if (error == ERESTART) - error = EINTR; goto bad; } td->td_dupfd = 0;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Tue Mar 7 20:02:57 UTC 2023 Modified Files: src/sys/kern [netbsd-8]: vfs_syscalls.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1806): sys/kern/vfs_syscalls.c: revision 1.557 open(2): Don't map ERESTART to EINTR. If a file or device's open function returns ERESTART, respect that -- restart the syscall; don't pretend a signal has been delivered when it was not. If an SA_RESTART signal was delivered, POSIX does not allow it to fail with EINTR: SA_RESTART This flag affects the behavior of interruptible functions; that is, those specified to fail with errno set to [EINTR]. If set, and a function specified as interruptible is interrupted by this signal, the function shall restart and shall not fail with [EINTR] unless otherwise specified. If an interruptible function which uses a timeout is restarted, the duration of the timeout following the restart is set to an unspecified value that does not exceed the original timeout value. If the flag is not set, interruptible functions interrupted by this signal shall fail with errno set to [EINTR]. https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaction.html Nothing in the POSIX definition of open specifies otherwise. In 1990, Kirk McKusick added these lines with a mysterious commit message: Author: Kirk McKusick Date: Tue Apr 10 19:36:33 1990 -0800 eliminate longjmp from the kernel (for karels) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 7bc7b39bbf..d572d3a32d 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -14,7 +14,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#)vfs_syscalls.c 7.42 (Berkeley) 3/26/90 + * @(#)vfs_syscalls.c 7.43 (Berkeley) 4/10/90 */ #include "param.h" @@ -530,8 +530,10 @@ copen(scp, fmode, cmode, ndp, resultfd) if (error = vn_open(ndp, fmode, (cmode & 0) &~ S_ISVTX)) { crfree(fp->f_cred); fp->f_count--; - if (error == -1)/* XXX from fdopen */ - return (0); /* XXX from fdopen */ + if (error == EJUSTRETURN) /* XXX from fdopen */ + return (0); /* XXX from fdopen */ + if (error == ERESTART) + error = EINTR; scp->sc_ofile[indx] = NULL; return (error); } (found via this git import of the CSRG history: https://github.com/robohack/ucb-csrg-bsd/commit/cce2869b7ae5d360921eb411005b328a29c4a3fe This change appears to have served two related purposes: 1. The fdopen function (the erstwhile open routine for /dev/fd/N) used to return -1 as a hack to mean it had just duplicated the fd; it was recently changed by Mike Karels, in kern_descrip.c 7.9, to return EJUSTRETURN, now defined to be -2, presumably to avoid a conflict with ERESTART, defined to be -1. So this change finished part of the change by Mike Karels to use a different magic return code from fdopen. Of course, today we use still another disgusting hack, EDUPFD, for the same purpose, so none of this is relevant any more. 2. Prior to April 1990, the kernel handled signals during tsleep(9) by longjmping out to the system call entry point or similar. In April 1990, Mike Karels worked to convert all of that into explicit unwind logic by passing through EINTR or ERESTART as appropriate, instead of setjmp at each entry point. However, it's not clear to me why this setjmp/longjmp and fdopen/-1/EJUSTRETURN renovation justifies unconditional logic to map ERESTART to EINTR in open(2). I suspect it was a mistake. In 2013, the corresponding logic to map ERESTART to EINTR in open(2) was removed from FreeBSD: r246472 | kib | 2013-02-07 14:53:33 + (Thu, 07 Feb 2013) | 11 lines Stop translating the ERESTART error from the open(2) into EINTR. Posix requires that open(2) is restartable for SA_RESTART. For non-posix objects, in particular, devfs nodes, still disable automatic restart of the opens. The open call to a driver could have significant side effects for the hardware. Noted and reviewed by: jilles Discussed with: bde MFC after: 2 weeks Index: vfs_syscalls.c === --- vfs_syscalls.c (revision 246471) +++ vfs_syscalls.c (revision 246472) @@ -1106,8 +1106,6 @@ goto success; } - if (error == ERESTART) - error = EINTR; goto bad; } td->td_dupfd = 0;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Fri Feb 24 14:17:18 UTC 2023 Modified Files: src/sys/kern [netbsd-8]: subr_prf.c Log Message: Pull up following revision(s) (requested by msaitoh in ticket #1804): sys/kern/subr_prf.c: revision 1.171 Make identification of accounted aprint_error()s possible by putting a big ugly "autoconfiguration error: " in the log when they occur. To generate a diff of this commit: cvs rdiff -u -r1.160 -r1.160.8.1 src/sys/kern/subr_prf.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_prf.c diff -u src/sys/kern/subr_prf.c:1.160 src/sys/kern/subr_prf.c:1.160.8.1 --- src/sys/kern/subr_prf.c:1.160 Wed Jul 27 09:57:26 2016 +++ src/sys/kern/subr_prf.c Fri Feb 24 14:17:18 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_prf.c,v 1.160 2016/07/27 09:57:26 skrll Exp $ */ +/* $NetBSD: subr_prf.c,v 1.160.8.1 2023/02/24 14:17:18 martin Exp $ */ /*- * Copyright (c) 1986, 1988, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.160 2016/07/27 09:57:26 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.160.8.1 2023/02/24 14:17:18 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -907,6 +907,7 @@ aprint_verbose_internal(const char *pref if (prefix) kprintf_internal("%s: ", flags, NULL, NULL, prefix); + kprintf_internal("autoconfiguration error: ", TOLOG, NULL, NULL); kprintf(fmt, flags, NULL, NULL, ap); kprintf_unlock();
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Fri Feb 24 14:17:18 UTC 2023 Modified Files: src/sys/kern [netbsd-8]: subr_prf.c Log Message: Pull up following revision(s) (requested by msaitoh in ticket #1804): sys/kern/subr_prf.c: revision 1.171 Make identification of accounted aprint_error()s possible by putting a big ugly "autoconfiguration error: " in the log when they occur. To generate a diff of this commit: cvs rdiff -u -r1.160 -r1.160.8.1 src/sys/kern/subr_prf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sat Sep 10 08:21:49 UTC 2022 Modified Files: src/sys/kern [netbsd-8]: kern_core.c Log Message: Pull up following revision(s) (requested by mrg in ticket #1761): sys/kern/kern_core.c: revision 1.37 avoid a GCC warning (happens on -current, -9, and -8.) To generate a diff of this commit: cvs rdiff -u -r1.24.10.1 -r1.24.10.2 src/sys/kern/kern_core.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_core.c diff -u src/sys/kern/kern_core.c:1.24.10.1 src/sys/kern/kern_core.c:1.24.10.2 --- src/sys/kern/kern_core.c:1.24.10.1 Fri Sep 9 18:24:20 2022 +++ src/sys/kern/kern_core.c Sat Sep 10 08:21:49 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_core.c,v 1.24.10.1 2022/09/09 18:24:20 martin Exp $ */ +/* $NetBSD: kern_core.c,v 1.24.10.2 2022/09/10 08:21:49 martin Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.24.10.1 2022/09/09 18:24:20 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.24.10.2 2022/09/10 08:21:49 martin Exp $"); #include #include @@ -102,7 +102,7 @@ coredump(struct lwp *l, const char *patt struct coredump_iostate io; struct plimit *lim; int error, error1; - char *name, *lastslash; + char *name, *lastslash = NULL /* XXXgcc */; name = PNBUF_GET();
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sat Sep 10 08:21:49 UTC 2022 Modified Files: src/sys/kern [netbsd-8]: kern_core.c Log Message: Pull up following revision(s) (requested by mrg in ticket #1761): sys/kern/kern_core.c: revision 1.37 avoid a GCC warning (happens on -current, -9, and -8.) To generate a diff of this commit: cvs rdiff -u -r1.24.10.1 -r1.24.10.2 src/sys/kern/kern_core.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Fri Sep 9 18:24:20 UTC 2022 Modified Files: src/sys/kern [netbsd-8]: kern_core.c Log Message: Pull up following revision(s) (requested by christos in ticket #1760): sys/kern/kern_core.c: revision 1.36 Don't forget to free the cred we just held. Thanks to Chris J-D (chris at accessvector dot net) While here, de-duplicate the mutex exit sequence. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.24.10.1 src/sys/kern/kern_core.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_core.c diff -u src/sys/kern/kern_core.c:1.24 src/sys/kern/kern_core.c:1.24.10.1 --- src/sys/kern/kern_core.c:1.24 Thu Jul 7 06:55:43 2016 +++ src/sys/kern/kern_core.c Fri Sep 9 18:24:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_core.c,v 1.24 2016/07/07 06:55:43 msaitoh Exp $ */ +/* $NetBSD: kern_core.c,v 1.24.10.1 2022/09/09 18:24:20 martin Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.24 2016/07/07 06:55:43 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.24.10.1 2022/09/09 18:24:20 martin Exp $"); #include #include @@ -95,7 +95,7 @@ coredump(struct lwp *l, const char *patt struct vnode *vp; struct proc *p; struct vmspace *vm; - kauth_cred_t cred; + kauth_cred_t cred = NULL; struct pathbuf *pb; struct nameidata nd; struct vattr vattr; @@ -120,9 +120,7 @@ coredump(struct lwp *l, const char *patt if (USPACE + ctob(vm->vm_dsize + vm->vm_ssize) >= p->p_rlimit[RLIMIT_CORE].rlim_cur) { error = EFBIG; /* better error code? */ - mutex_exit(p->p_lock); - mutex_exit(proc_lock); - goto done; + goto release; } /* @@ -139,9 +137,7 @@ coredump(struct lwp *l, const char *patt if (p->p_flag & PK_SUGID) { if (!security_setidcore_dump) { error = EPERM; - mutex_exit(p->p_lock); - mutex_exit(proc_lock); - goto done; + goto release; } pattern = security_setidcore_path; } @@ -155,11 +151,8 @@ coredump(struct lwp *l, const char *patt error = coredump_buildname(p, name, pattern, MAXPATHLEN); mutex_exit(>pl_lock); - if (error) { - mutex_exit(p->p_lock); - mutex_exit(proc_lock); - goto done; - } + if (error) + goto release; /* * On a simple filename, see if the filesystem allow us to write @@ -173,6 +166,7 @@ coredump(struct lwp *l, const char *patt error = EPERM; } +release: mutex_exit(p->p_lock); mutex_exit(proc_lock); if (error) @@ -260,6 +254,8 @@ coredump(struct lwp *l, const char *patt if (error == 0) error = error1; done: + if (cred != NULL) + kauth_cred_free(cred); if (name != NULL) PNBUF_PUT(name); return error;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Fri Sep 9 18:24:20 UTC 2022 Modified Files: src/sys/kern [netbsd-8]: kern_core.c Log Message: Pull up following revision(s) (requested by christos in ticket #1760): sys/kern/kern_core.c: revision 1.36 Don't forget to free the cred we just held. Thanks to Chris J-D (chris at accessvector dot net) While here, de-duplicate the mutex exit sequence. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.24.10.1 src/sys/kern/kern_core.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Fri Oct 8 14:59:59 UTC 2021 Modified Files: src/sys/kern [netbsd-8]: sys_pipe.c Log Message: Pull up following revision(s) (requested by hannken in ticket #1698): sys/kern/sys_pipe.c: revision 1.157 Fix a deadlock where one thread writes to a pipe, has more data and no space in the pipe and waits on "pipe_wcv" while the reader is closing the pipe and waits on "pipe_draincv". Swap the test for "PIPE_EOF" and the "cv_wait_sig()" in "pipe_write()". PR bin/56422 "zgrep -l sometimes hangs" To generate a diff of this commit: cvs rdiff -u -r1.140.12.1 -r1.140.12.2 src/sys/kern/sys_pipe.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_pipe.c diff -u src/sys/kern/sys_pipe.c:1.140.12.1 src/sys/kern/sys_pipe.c:1.140.12.2 --- src/sys/kern/sys_pipe.c:1.140.12.1 Wed May 1 14:51:17 2019 +++ src/sys/kern/sys_pipe.c Fri Oct 8 14:59:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_pipe.c,v 1.140.12.1 2019/05/01 14:51:17 martin Exp $ */ +/* $NetBSD: sys_pipe.c,v 1.140.12.2 2021/10/08 14:59:59 martin Exp $ */ /*- * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.140.12.1 2019/05/01 14:51:17 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.140.12.2 2021/10/08 14:59:59 martin Exp $"); #include #include @@ -1017,11 +1017,6 @@ pipe_write(file_t *fp, off_t *offset, st break; } - pipeunlock(wpipe); - error = cv_wait_sig(>pipe_wcv, lock); - (void)pipelock(wpipe, false); - if (error != 0) -break; /* * If read side wants to go away, we just issue a signal * to ourselves. @@ -1030,6 +1025,12 @@ pipe_write(file_t *fp, off_t *offset, st error = EPIPE; break; } + + pipeunlock(wpipe); + error = cv_wait_sig(>pipe_wcv, lock); + (void)pipelock(wpipe, false); + if (error != 0) +break; wakeup_state = wpipe->pipe_state; } }
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Fri Oct 8 14:59:59 UTC 2021 Modified Files: src/sys/kern [netbsd-8]: sys_pipe.c Log Message: Pull up following revision(s) (requested by hannken in ticket #1698): sys/kern/sys_pipe.c: revision 1.157 Fix a deadlock where one thread writes to a pipe, has more data and no space in the pipe and waits on "pipe_wcv" while the reader is closing the pipe and waits on "pipe_draincv". Swap the test for "PIPE_EOF" and the "cv_wait_sig()" in "pipe_write()". PR bin/56422 "zgrep -l sometimes hangs" To generate a diff of this commit: cvs rdiff -u -r1.140.12.1 -r1.140.12.2 src/sys/kern/sys_pipe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: bouyer Date: Mon May 3 09:15:31 UTC 2021 Modified Files: src/sys/kern [netbsd-8]: kern_exec.c Log Message: Pull up following revision(s) (requested by martin in ticket #1677): sys/kern/kern_exec.c: revision 1.505 via patch Fix copy in handling of POSIX_SPAWN_RESETIDS in posix_spawn(3) To generate a diff of this commit: cvs rdiff -u -r1.442.4.7 -r1.442.4.8 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: [netbsd-8] src/sys/kern
Module Name:src Committed By: bouyer Date: Mon May 3 09:15:31 UTC 2021 Modified Files: src/sys/kern [netbsd-8]: kern_exec.c Log Message: Pull up following revision(s) (requested by martin in ticket #1677): sys/kern/kern_exec.c: revision 1.505 via patch Fix copy in handling of POSIX_SPAWN_RESETIDS in posix_spawn(3) To generate a diff of this commit: cvs rdiff -u -r1.442.4.7 -r1.442.4.8 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.442.4.7 src/sys/kern/kern_exec.c:1.442.4.8 --- src/sys/kern/kern_exec.c:1.442.4.7 Mon Aug 5 14:47:49 2019 +++ src/sys/kern/kern_exec.c Mon May 3 09:15:30 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.442.4.7 2019/08/05 14:47:49 martin Exp $ */ +/* $NetBSD: kern_exec.c,v 1.442.4.8 2021/05/03 09:15:30 bouyer Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.442.4.7 2019/08/05 14:47:49 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.442.4.8 2021/05/03 09:15:30 bouyer Exp $"); #include "opt_exec.h" #include "opt_execfmt.h" @@ -2143,7 +2143,7 @@ spawn_return(void *arg) /* Reset user ID's */ if (spawn_data->sed_attrs->sa_flags & POSIX_SPAWN_RESETIDS) { - error = do_setresuid(l, -1, + error = do_setresgid(l, -1, kauth_cred_getgid(l->l_cred), -1, ID_E_EQ_R | ID_E_EQ_S); if (error)
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sun Jun 7 17:08:12 UTC 2020 Modified Files: src/sys/kern [netbsd-8]: subr_pcu.c Log Message: Pull up following revision(s) (requested by thorpej in ticket #949): sys/kern/subr_pcu.c: revision 1.22 Relax the KASSERT() in pcu_discard_all() to allow non-curlwp if it is in LSIDL state, which can happen if the new LWP is exiting before it's ever run, e.g. if an error occurs in _lwp_create(2). To generate a diff of this commit: cvs rdiff -u -r1.20.6.1 -r1.20.6.2 src/sys/kern/subr_pcu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sun Jun 7 17:08:12 UTC 2020 Modified Files: src/sys/kern [netbsd-8]: subr_pcu.c Log Message: Pull up following revision(s) (requested by thorpej in ticket #949): sys/kern/subr_pcu.c: revision 1.22 Relax the KASSERT() in pcu_discard_all() to allow non-curlwp if it is in LSIDL state, which can happen if the new LWP is exiting before it's ever run, e.g. if an error occurs in _lwp_create(2). To generate a diff of this commit: cvs rdiff -u -r1.20.6.1 -r1.20.6.2 src/sys/kern/subr_pcu.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_pcu.c diff -u src/sys/kern/subr_pcu.c:1.20.6.1 src/sys/kern/subr_pcu.c:1.20.6.2 --- src/sys/kern/subr_pcu.c:1.20.6.1 Tue Oct 24 09:14:59 2017 +++ src/sys/kern/subr_pcu.c Sun Jun 7 17:08:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_pcu.c,v 1.20.6.1 2017/10/24 09:14:59 snj Exp $ */ +/* $NetBSD: subr_pcu.c,v 1.20.6.2 2020/06/07 17:08:12 martin Exp $ */ /*- * Copyright (c) 2011, 2014 The NetBSD Foundation, Inc. @@ -52,7 +52,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_pcu.c,v 1.20.6.1 2017/10/24 09:14:59 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_pcu.c,v 1.20.6.2 2020/06/07 17:08:12 martin Exp $"); #include #include @@ -130,7 +130,12 @@ pcu_discard_all(lwp_t *l) { const uint32_t pcu_valid = l->l_pcu_valid; - KASSERT(l == curlwp || ((l->l_flag & LW_SYSTEM) && pcu_valid == 0)); + /* + * The check for LSIDL here is to catch the case where the LWP exits + * due to an error in the LWP creation path before it ever runs. + */ + KASSERT(l == curlwp || l->l_stat == LSIDL || + ((l->l_flag & LW_SYSTEM) && pcu_valid == 0)); if (__predict_true(pcu_valid == 0)) { /* PCUs are not in use. */
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Thu Apr 30 15:35:57 UTC 2020 Modified Files: src/sys/kern [netbsd-8]: subr_cprng.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1543): sys/kern/subr_cprng.c: revision 1.34 Disable rngtest on output of cprng_strong. We already do a self-test for correctenss of Hash_DRBG output; applying rngtest to it does nothing but give everyone warning fatigue about spurious rngtest failures. To generate a diff of this commit: cvs rdiff -u -r1.27.10.2 -r1.27.10.3 src/sys/kern/subr_cprng.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Thu Apr 30 15:35:57 UTC 2020 Modified Files: src/sys/kern [netbsd-8]: subr_cprng.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1543): sys/kern/subr_cprng.c: revision 1.34 Disable rngtest on output of cprng_strong. We already do a self-test for correctenss of Hash_DRBG output; applying rngtest to it does nothing but give everyone warning fatigue about spurious rngtest failures. To generate a diff of this commit: cvs rdiff -u -r1.27.10.2 -r1.27.10.3 src/sys/kern/subr_cprng.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_cprng.c diff -u src/sys/kern/subr_cprng.c:1.27.10.2 src/sys/kern/subr_cprng.c:1.27.10.3 --- src/sys/kern/subr_cprng.c:1.27.10.2 Mon Nov 25 16:03:08 2019 +++ src/sys/kern/subr_cprng.c Thu Apr 30 15:35:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_cprng.c,v 1.27.10.2 2019/11/25 16:03:08 martin Exp $ */ +/* $NetBSD: subr_cprng.c,v 1.27.10.3 2020/04/30 15:35:57 martin Exp $ */ /*- * Copyright (c) 2011-2013 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.27.10.2 2019/11/25 16:03:08 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.27.10.3 2020/04/30 15:35:57 martin Exp $"); #include #include @@ -49,9 +49,6 @@ __KERNEL_RCSID(0, "$NetBSD: subr_cprng.c #include #include #include -#if DIAGNOSTIC -#include -#endif #include @@ -66,9 +63,6 @@ static void cprng_strong_generate(struct static void cprng_strong_reseed(struct cprng_strong *); static void cprng_strong_reseed_from(struct cprng_strong *, const void *, size_t, bool); -#if DIAGNOSTIC -static void cprng_strong_rngtest(struct cprng_strong *); -#endif static rndsink_callback_t cprng_strong_rndsink_callback; @@ -450,48 +444,8 @@ cprng_strong_reseed_from(struct cprng_st /* XXX Fix nist_hash_drbg API so this can't happen. */ panic("cprng %s: NIST Hash_DRBG reseed failed", cprng->cs_name); - -#if DIAGNOSTIC - cprng_strong_rngtest(cprng); -#endif } -#if DIAGNOSTIC -/* - * Generate some output and apply a statistical RNG test to it. - */ -static void -cprng_strong_rngtest(struct cprng_strong *cprng) -{ - - KASSERT(mutex_owned(>cs_lock)); - - /* XXX Switch to a pool cache instead? */ - rngtest_t *const rt = kmem_intr_alloc(sizeof(*rt), KM_NOSLEEP); - if (rt == NULL) - /* XXX Warn? */ - return; - - (void)strlcpy(rt->rt_name, cprng->cs_name, sizeof(rt->rt_name)); - - if (nist_hash_drbg_generate(>cs_drbg, rt->rt_b, - sizeof(rt->rt_b), NULL, 0)) - panic("cprng %s: NIST Hash_DRBG failed after reseed", - cprng->cs_name); - - if (rngtest(rt)) { - printf("cprng %s: failed statistical RNG test\n", - cprng->cs_name); - /* XXX Not clear that this does any good... */ - cprng->cs_ready = false; - rndsink_schedule(cprng->cs_rndsink); - } - - explicit_memset(rt, 0, sizeof(*rt)); /* paranoia */ - kmem_intr_free(rt, sizeof(*rt)); -} -#endif - /* * Feed entropy from an rndsink request into the CPRNG for which the * request was issued.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sun Mar 8 09:47:28 UTC 2020 Modified Files: src/sys/kern [netbsd-8]: sys_select.c Log Message: Pull up following revision(s) (requested by mlelstv in ticket #1515): sys/kern/sys_select.c: revision 1.42-1.45 PR/54158: Anthony Mallet: poll(2) does not allow polling all possible fds (hardcoded limit to 1000 + #). Changed to limit by the max of the resource limit of open descriptors and the above. Remove the slop code. Suggested by mrg@ Use the max limit (aka maxfiles or the moral equivalent of OPEN_MAX) which makes poll(2) align with the Posix documentation (which allows EINVAL if nfds > OPEN_MAX). From: Anthony Mallet Add slop of 1000 and explain why. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.40.2.1 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: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sun Mar 8 09:47:28 UTC 2020 Modified Files: src/sys/kern [netbsd-8]: sys_select.c Log Message: Pull up following revision(s) (requested by mlelstv in ticket #1515): sys/kern/sys_select.c: revision 1.42-1.45 PR/54158: Anthony Mallet: poll(2) does not allow polling all possible fds (hardcoded limit to 1000 + #). Changed to limit by the max of the resource limit of open descriptors and the above. Remove the slop code. Suggested by mrg@ Use the max limit (aka maxfiles or the moral equivalent of OPEN_MAX) which makes poll(2) align with the Posix documentation (which allows EINVAL if nfds > OPEN_MAX). From: Anthony Mallet Add slop of 1000 and explain why. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.40.2.1 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.40 src/sys/kern/sys_select.c:1.40.2.1 --- src/sys/kern/sys_select.c:1.40 Thu Jun 1 02:45:13 2017 +++ src/sys/kern/sys_select.c Sun Mar 8 09:47:28 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_select.c,v 1.40 2017/06/01 02:45:13 chs Exp $ */ +/* $NetBSD: sys_select.c,v 1.40.2.1 2020/03/08 09:47:28 martin Exp $ */ /*- * Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc. @@ -84,7 +84,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.40 2017/06/01 02:45:13 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.40.2.1 2020/03/08 09:47:28 martin Exp $"); #include #include @@ -488,15 +488,28 @@ pollcommon(register_t *retval, struct po int error; size_t ni; - if (nfds > 1000 + curlwp->l_fd->fd_dt->dt_nfiles) { + if (nfds > curlwp->l_proc->p_rlimit[RLIMIT_NOFILE].rlim_max + 1000) { /* - * Either the user passed in a very sparse 'fds' or junk! - * The kmem_alloc() call below would be bad news. - * We could process the 'fds' array in chunks, but that + * Prevent userland from causing over-allocation. + * Raising the default limit too high can still cause + * a lot of memory to be allocated, but this also means + * that the file descriptor array will also be large. + * + * To reduce the memory requirements here, we could + * process the 'fds' array in chunks, but that * is a lot of code that isn't normally useful. * (Or just move the copyin/out into pollscan().) + * * Historically the code silently truncated 'fds' to * dt_nfiles entries - but that does cause issues. + * + * Using the max limit equivalent to sysctl + * kern.maxfiles is the moral equivalent of OPEN_MAX + * as specified by POSIX. + * + * We add a slop of 1000 in case the resource limit was + * changed after opening descriptors or the same descriptor + * was specified more than once. */ return EINVAL; }
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Tue Feb 25 19:12:14 UTC 2020 Modified Files: src/sys/kern [netbsd-8]: uipc_socket.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1509): sys/kern/uipc_socket.c: revision 1.288 Zero out 'tv', to prevent uninitialized bytes in its padding from leaking to userland. Found by kMSan. To generate a diff of this commit: cvs rdiff -u -r1.255.2.4 -r1.255.2.5 src/sys/kern/uipc_socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/uipc_socket.c diff -u src/sys/kern/uipc_socket.c:1.255.2.4 src/sys/kern/uipc_socket.c:1.255.2.5 --- src/sys/kern/uipc_socket.c:1.255.2.4 Mon Nov 12 09:43:19 2018 +++ src/sys/kern/uipc_socket.c Tue Feb 25 19:12:14 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.255.2.4 2018/11/12 09:43:19 martin Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.255.2.5 2020/02/25 19:12:14 martin Exp $ */ /*- * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.255.2.4 2018/11/12 09:43:19 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.255.2.5 2020/02/25 19:12:14 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -2015,6 +2015,7 @@ sogetopt1(struct socket *so, struct sock optval = (opt == SO_SNDTIMEO ? so->so_snd.sb_timeo : so->so_rcv.sb_timeo); + memset(, 0, sizeof(tv)); tv.tv_sec = optval / hz; tv.tv_usec = (optval % hz) * tick;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Tue Feb 25 19:12:14 UTC 2020 Modified Files: src/sys/kern [netbsd-8]: uipc_socket.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1509): sys/kern/uipc_socket.c: revision 1.288 Zero out 'tv', to prevent uninitialized bytes in its padding from leaking to userland. Found by kMSan. To generate a diff of this commit: cvs rdiff -u -r1.255.2.4 -r1.255.2.5 src/sys/kern/uipc_socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Tue Jan 21 16:59:57 UTC 2020 Modified Files: src/sys/kern [netbsd-8]: files.kern Log Message: Apply patch, requested by pgoyette in ticket #1486: PR kern/54874: fix load failure of the exec_aout kernel module. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.15.2.1 src/sys/kern/files.kern Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Tue Jan 21 16:59:57 UTC 2020 Modified Files: src/sys/kern [netbsd-8]: files.kern Log Message: Apply patch, requested by pgoyette in ticket #1486: PR kern/54874: fix load failure of the exec_aout kernel module. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.15.2.1 src/sys/kern/files.kern 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/files.kern diff -u src/sys/kern/files.kern:1.15 src/sys/kern/files.kern:1.15.2.1 --- src/sys/kern/files.kern:1.15 Fri May 19 00:01:33 2017 +++ src/sys/kern/files.kern Tue Jan 21 16:59:57 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.kern,v 1.15 2017/05/19 00:01:33 pgoyette Exp $ +# $NetBSD: files.kern,v 1.15.2.1 2020/01/21 16:59:57 martin Exp $ # # kernel sources @@ -14,7 +14,8 @@ file kern/bufq_priocscan.c bufq_priocsc file kern/bufq_readprio.c bufq_readprio | new_bufq_strategy file kern/core_elf32.c exec_elf32 file kern/core_elf64.c exec_elf64 -file kern/core_netbsd.c exec_aout | exec_coff | exec_ecoff +file kern/core_netbsd.c exec_aout | exec_coff | exec_ecoff | + modular file kern/cnmagic.c kern file kern/exec_aout.c exec_aout file kern/exec_ecoff.c exec_ecoff
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Tue Jan 7 11:59:49 UTC 2020 Modified Files: src/sys/kern [netbsd-8]: kern_ksyms.c Log Message: Pull up following revision(s) (requested by pgoyette in ticket #1482): sys/kern/kern_ksyms.c: revision 1.88 (patch) When reading from /dev/ksyms we need to skip over entries that have been marked as sd_gone. Otherwise we might try to uiomove() data from memory that has been unmapped, resulting in EFAULT. XXX This (along with other pre-existing checks st->sd_gone) is still racy, but it's an improvement over current code. Ideally we would make a complete copy of the symbol table when we open /dev/ksyms so we could ignore any changes that occur. ad@ says "good enough for now" XXX Pullup to -9 and -8 To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.84.10.1 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.84 src/sys/kern/kern_ksyms.c:1.84.10.1 --- src/sys/kern/kern_ksyms.c:1.84 Thu Jul 7 06:55:43 2016 +++ src/sys/kern/kern_ksyms.c Tue Jan 7 11:59:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_ksyms.c,v 1.84 2016/07/07 06:55:43 msaitoh Exp $ */ +/* $NetBSD: kern_ksyms.c,v 1.84.10.1 2020/01/07 11:59:48 martin Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.84 2016/07/07 06:55:43 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.84.10.1 2020/01/07 11:59:48 martin Exp $"); #if defined(_KERNEL) && defined(_KERNEL_OPT) #include "opt_copy_symtab.h" @@ -754,9 +754,9 @@ ksyms_modunload(const char *name) if (strcmp(name, st->sd_name) != 0) continue; st->sd_gone = true; + ksyms_sizes_calc(); if (!ksyms_isopen) { TAILQ_REMOVE(_symtabs, st, sd_queue); - ksyms_sizes_calc(); kmem_free(st, sizeof(*st)); } break; @@ -843,6 +843,8 @@ ksyms_sizes_calc(void) ksyms_symsz = ksyms_strsz = 0; TAILQ_FOREACH(st, _symtabs, sd_queue) { + if (__predict_false(st->sd_gone)) + continue; delta = ksyms_strsz - st->sd_usroffset; if (delta != 0) { for (i = 0; i < st->sd_symsize/sizeof(Elf_Sym); i++) @@ -1019,6 +1021,8 @@ ksymsread(dev_t dev, struct uio *uio, in */ filepos = sizeof(struct ksyms_hdr); TAILQ_FOREACH(st, _symtabs, sd_queue) { + if (__predict_false(st->sd_gone)) + continue; if (uio->uio_resid == 0) return 0; if (uio->uio_offset <= st->sd_symsize + filepos) { @@ -1037,6 +1041,8 @@ ksymsread(dev_t dev, struct uio *uio, in KASSERT(filepos == sizeof(struct ksyms_hdr) + ksyms_hdr.kh_shdr[SYMTAB].sh_size); TAILQ_FOREACH(st, _symtabs, sd_queue) { + if (__predict_false(st->sd_gone)) + continue; if (uio->uio_resid == 0) return 0; if (uio->uio_offset <= st->sd_strsize + filepos) {
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Tue Jan 7 11:59:49 UTC 2020 Modified Files: src/sys/kern [netbsd-8]: kern_ksyms.c Log Message: Pull up following revision(s) (requested by pgoyette in ticket #1482): sys/kern/kern_ksyms.c: revision 1.88 (patch) When reading from /dev/ksyms we need to skip over entries that have been marked as sd_gone. Otherwise we might try to uiomove() data from memory that has been unmapped, resulting in EFAULT. XXX This (along with other pre-existing checks st->sd_gone) is still racy, but it's an improvement over current code. Ideally we would make a complete copy of the symbol table when we open /dev/ksyms so we could ignore any changes that occur. ad@ says "good enough for now" XXX Pullup to -9 and -8 To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.84.10.1 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: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Nov 25 16:03:08 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: subr_cprng.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1459): sys/kern/subr_cprng.c: revision 1.33 Use cprng_strong, not cprng_fast, for sysctl kern.arnd. To generate a diff of this commit: cvs rdiff -u -r1.27.10.1 -r1.27.10.2 src/sys/kern/subr_cprng.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_cprng.c diff -u src/sys/kern/subr_cprng.c:1.27.10.1 src/sys/kern/subr_cprng.c:1.27.10.2 --- src/sys/kern/subr_cprng.c:1.27.10.1 Tue Sep 3 12:08:22 2019 +++ src/sys/kern/subr_cprng.c Mon Nov 25 16:03:08 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_cprng.c,v 1.27.10.1 2019/09/03 12:08:22 martin Exp $ */ +/* $NetBSD: subr_cprng.c,v 1.27.10.2 2019/11/25 16:03:08 martin Exp $ */ /*- * Copyright (c) 2011-2013 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.27.10.1 2019/09/03 12:08:22 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.27.10.2 2019/11/25 16:03:08 martin Exp $"); #include #include @@ -507,6 +507,7 @@ cprng_strong_rndsink_callback(void *cont mutex_exit(>cs_lock); } +static ONCE_DECL(sysctl_prng_once); static cprng_strong_t *sysctl_prng; static int @@ -526,10 +527,9 @@ makeprng(void) static int sysctl_kern_urnd(SYSCTLFN_ARGS) { - static ONCE_DECL(control); int v, rv; - RUN_ONCE(, makeprng); + RUN_ONCE(_prng_once, makeprng); rv = cprng_strong(sysctl_prng, , sizeof(v), 0); if (rv == sizeof(v)) { struct sysctlnode node = *rnode; @@ -558,6 +558,7 @@ sysctl_kern_arnd(SYSCTLFN_ARGS) int error; void *v; struct sysctlnode node = *rnode; + size_t n __diagused; switch (*oldlenp) { case 0: @@ -566,8 +567,10 @@ sysctl_kern_arnd(SYSCTLFN_ARGS) if (*oldlenp > 256) { return E2BIG; } + RUN_ONCE(_prng_once, makeprng); v = kmem_alloc(*oldlenp, KM_SLEEP); - cprng_fast(v, *oldlenp); + n = cprng_strong(sysctl_prng, v, *oldlenp, 0); + KASSERT(n == *oldlenp); node.sysctl_data = v; node.sysctl_size = *oldlenp; error = sysctl_lookup(SYSCTLFN_CALL());
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Nov 25 16:03:08 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: subr_cprng.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1459): sys/kern/subr_cprng.c: revision 1.33 Use cprng_strong, not cprng_fast, for sysctl kern.arnd. To generate a diff of this commit: cvs rdiff -u -r1.27.10.1 -r1.27.10.2 src/sys/kern/subr_cprng.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sun Nov 24 08:15:17 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: sys_ptrace_common.c Log Message: Pull up following revision(s) (requested by rin in ticket #1456): sys/kern/sys_ptrace_common.c: revision 1.73 Fix regression introduced to ptrace_regs() in rev 1.27: http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/sys_ptrace_common.c#rev1.27 Size of registers should be determined from tracer, NOT tracee. Now, 64-bit tracer can manipulate registers of 32-bit tracee again. gdb for amd64 works for i386 binaries to some extent. XXX pullup to netbsd-9 and -8. To generate a diff of this commit: cvs rdiff -u -r1.22.2.7 -r1.22.2.8 src/sys/kern/sys_ptrace_common.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_ptrace_common.c diff -u src/sys/kern/sys_ptrace_common.c:1.22.2.7 src/sys/kern/sys_ptrace_common.c:1.22.2.8 --- src/sys/kern/sys_ptrace_common.c:1.22.2.7 Tue Nov 19 10:50:25 2019 +++ src/sys/kern/sys_ptrace_common.c Sun Nov 24 08:15:17 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_ptrace_common.c,v 1.22.2.7 2019/11/19 10:50:25 martin Exp $ */ +/* $NetBSD: sys_ptrace_common.c,v 1.22.2.8 2019/11/24 08:15:17 martin Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -118,7 +118,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.22.2.7 2019/11/19 10:50:25 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.22.2.8 2019/11/24 08:15:17 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_ptrace.h" @@ -775,9 +775,12 @@ ptrace_regs(struct lwp *l, struct lwp ** void *addr, size_t data) { int error; - struct proc *t = (*lt)->l_proc; + struct proc *p, *t; struct vmspace *vm; + p = l->l_proc; /* tracer */ + t = (*lt)->l_proc; /* traced */ + if ((error = ptrace_update_lwp(t, lt, data)) != 0) return error; @@ -791,7 +794,7 @@ ptrace_regs(struct lwp *l, struct lwp ** case_PT_SETREGS if (!process_validregs(*lt)) return EINVAL; - size = PROC_REGSZ(t); + size = PROC_REGSZ(p); func = ptm->ptm_doregs; break; #endif @@ -800,7 +803,7 @@ ptrace_regs(struct lwp *l, struct lwp ** case_PT_SETFPREGS if (!process_validfpregs(*lt)) return EINVAL; - size = PROC_FPREGSZ(t); + size = PROC_FPREGSZ(p); func = ptm->ptm_dofpregs; break; #endif @@ -809,7 +812,7 @@ ptrace_regs(struct lwp *l, struct lwp ** case_PT_SETDBREGS if (!process_validdbregs(*lt)) return EINVAL; - size = PROC_DBREGSZ(t); + size = PROC_DBREGSZ(p); func = ptm->ptm_dodbregs; break; #endif
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sun Nov 24 08:15:17 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: sys_ptrace_common.c Log Message: Pull up following revision(s) (requested by rin in ticket #1456): sys/kern/sys_ptrace_common.c: revision 1.73 Fix regression introduced to ptrace_regs() in rev 1.27: http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/sys_ptrace_common.c#rev1.27 Size of registers should be determined from tracer, NOT tracee. Now, 64-bit tracer can manipulate registers of 32-bit tracee again. gdb for amd64 works for i386 binaries to some extent. XXX pullup to netbsd-9 and -8. To generate a diff of this commit: cvs rdiff -u -r1.22.2.7 -r1.22.2.8 src/sys/kern/sys_ptrace_common.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Tue Nov 19 10:50:26 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: sys_ptrace_common.c Log Message: Pull up following revision(s) (requested by rin in ticket #1452): sys/kern/sys_ptrace_common.c: revision 1.72 Fix pointer arithmetic for 32-bit process on LP64 kernel in process_auxv_offset(). Now, PIOD_READ_AUXV works fine with COMPAT_NETBSD32. XXX pullup to netbsd-9 and netbsd-8 To generate a diff of this commit: cvs rdiff -u -r1.22.2.6 -r1.22.2.7 src/sys/kern/sys_ptrace_common.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Fri Nov 1 09:29:25 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: subr_disk.c Log Message: Pull up following revision(s) (requested by cnst in ticket #1397): sys/kern/subr_disk.c: revision 1.129 kern/subr_disk: bounds_check_with_label: really protect against div by zero Solves kernel panic in NetBSD 8.1 amd64 on VirtualBox 6.0.12 r133076. Triggered with an NVMe controller without any actual discs behind it: nvme0 at pci0 dev 14 function 0: vendor 80ee product 4e56 (rev. 0x00) nvme0: NVMe 1.2 nvme0: interrupting at ioapic0 pin 22 nvme0: ORCL-VBOX-NVME-VER12, firmware 1.0, serial VB1234-56789 ld0 at nvme0 nsid 1 ld0: 0, 0 cyl, 16 head, 63 sec, 1 bytes/sect x 0 sectors Code path is reached 4 times during normal boot, each time after wd0a is already mounted; this patch avoids a crash with a dirty filesystem. To generate a diff of this commit: cvs rdiff -u -r1.119.2.1 -r1.119.2.2 src/sys/kern/subr_disk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Fri Nov 1 09:29:25 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: subr_disk.c Log Message: Pull up following revision(s) (requested by cnst in ticket #1397): sys/kern/subr_disk.c: revision 1.129 kern/subr_disk: bounds_check_with_label: really protect against div by zero Solves kernel panic in NetBSD 8.1 amd64 on VirtualBox 6.0.12 r133076. Triggered with an NVMe controller without any actual discs behind it: nvme0 at pci0 dev 14 function 0: vendor 80ee product 4e56 (rev. 0x00) nvme0: NVMe 1.2 nvme0: interrupting at ioapic0 pin 22 nvme0: ORCL-VBOX-NVME-VER12, firmware 1.0, serial VB1234-56789 ld0 at nvme0 nsid 1 ld0: 0, 0 cyl, 16 head, 63 sec, 1 bytes/sect x 0 sectors Code path is reached 4 times during normal boot, each time after wd0a is already mounted; this patch avoids a crash with a dirty filesystem. To generate a diff of this commit: cvs rdiff -u -r1.119.2.1 -r1.119.2.2 src/sys/kern/subr_disk.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_disk.c diff -u src/sys/kern/subr_disk.c:1.119.2.1 src/sys/kern/subr_disk.c:1.119.2.2 --- src/sys/kern/subr_disk.c:1.119.2.1 Fri Apr 5 08:40:19 2019 +++ src/sys/kern/subr_disk.c Fri Nov 1 09:29:25 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_disk.c,v 1.119.2.1 2019/04/05 08:40:19 msaitoh Exp $ */ +/* $NetBSD: subr_disk.c,v 1.119.2.2 2019/11/01 09:29:25 martin Exp $ */ /*- * Copyright (c) 1996, 1997, 1999, 2000, 2009 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.119.2.1 2019/04/05 08:40:19 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.119.2.2 2019/11/01 09:29:25 martin Exp $"); #include #include @@ -374,7 +374,7 @@ bounds_check_with_label(struct disk *dk, } /* Protect against division by zero. XXX: Should never happen?!?! */ - if (lp->d_secpercyl == 0) { + if ((lp->d_secsize / DEV_BSIZE) == 0 || lp->d_secpercyl == 0) { bp->b_error = EINVAL; return -1; }
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Oct 14 19:20:14 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: vnode_if.c Log Message: regen (for ticket #1405) To generate a diff of this commit: cvs rdiff -u -r1.104.2.2 -r1.104.2.3 src/sys/kern/vnode_if.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/vnode_if.c diff -u src/sys/kern/vnode_if.c:1.104.2.2 src/sys/kern/vnode_if.c:1.104.2.3 --- src/sys/kern/vnode_if.c:1.104.2.2 Tue Jul 25 01:29:56 2017 +++ src/sys/kern/vnode_if.c Mon Oct 14 19:20:14 2019 @@ -1,13 +1,13 @@ -/* $NetBSD: vnode_if.c,v 1.104.2.2 2017/07/25 01:29:56 snj Exp $ */ +/* $NetBSD: vnode_if.c,v 1.104.2.3 2019/10/14 19:20:14 martin Exp $ */ /* * Warning: DO NOT EDIT! This file is automatically generated! * (Modifications made here may easily be lost!) * * Created from the file: - * NetBSD: vnode_if.src,v 1.75.2.2 2017/07/25 01:29:23 snj Exp + * NetBSD: vnode_if.src,v 1.75.2.3 2019/10/14 17:43:58 martin Exp * by the script: - * NetBSD: vnode_if.sh,v 1.64.4.1 2017/06/04 20:35:01 bouyer Exp + * NetBSD: vnode_if.sh,v 1.64.4.2 2019/10/14 17:43:58 martin Exp */ /* @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnode_if.c,v 1.104.2.2 2017/07/25 01:29:56 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnode_if.c,v 1.104.2.3 2019/10/14 19:20:14 martin Exp $"); #include #include @@ -49,7 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: vnode_if.c,v #include #include -enum fst_op { FST_NO, FST_YES, FST_TRY }; +enum fst_op { FST_NO, FST_YES, FST_LAZY, FST_TRY }; static inline int vop_pre(vnode_t *vp, struct mount **mp, bool *mpsafe, enum fst_op op) @@ -62,7 +62,7 @@ vop_pre(vnode_t *vp, struct mount **mp, KERNEL_LOCK(1, curlwp); } - if (op == FST_YES || op == FST_TRY) { + if (op == FST_YES || op == FST_LAZY || op == FST_TRY) { for (;;) { *mp = vp->v_mount; if (op == FST_TRY) { @@ -73,6 +73,8 @@ vop_pre(vnode_t *vp, struct mount **mp, } return error; } + } else if (op == FST_LAZY) { +fstrans_start_lazy(*mp); } else { fstrans_start(*mp); } @@ -91,7 +93,7 @@ static inline void vop_post(vnode_t *vp, struct mount *mp, bool mpsafe, enum fst_op op) { - if (op == FST_YES) { + if (op == FST_YES || op == FST_LAZY) { fstrans_done(mp); } @@ -1378,11 +1380,11 @@ VOP_STRATEGY(struct vnode *vp, a.a_desc = VDESC(vop_strategy); a.a_vp = vp; a.a_bp = bp; - error = vop_pre(vp, , , FST_YES); + error = vop_pre(vp, , , FST_LAZY); if (error) return error; error = (VCALL(vp, VOFFSET(vop_strategy), )); - vop_post(vp, mp, mpsafe, FST_YES); + vop_post(vp, mp, mpsafe, FST_LAZY); return error; }
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Oct 14 19:20:14 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: vnode_if.c Log Message: regen (for ticket #1405) To generate a diff of this commit: cvs rdiff -u -r1.104.2.2 -r1.104.2.3 src/sys/kern/vnode_if.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Oct 14 17:43:58 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: vnode_if.sh vnode_if.src Log Message: Pull up following revision(s) (requested by hannken in ticket #1405): sys/kern/vnode_if.sh: revision 1.67 sys/kern/vnode_if.src: revision 1.78 As VOP_STRATEGY() usually calls itself on the file system holding "/dev" it may deadlock on suspension of this file system. Add fstrans type LAZY and use it for VOP_STRATEGY(). Adress PR kern/53624 (dom0 freeze on domU exit) is still there To generate a diff of this commit: cvs rdiff -u -r1.64.4.1 -r1.64.4.2 src/sys/kern/vnode_if.sh cvs rdiff -u -r1.75.2.2 -r1.75.2.3 src/sys/kern/vnode_if.src Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sun Aug 11 10:04:03 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: sys_lwp.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1333): sys/kern/sys_lwp.c: revision 1.69 (patch) Fix info leak: instead of using SS_INIT as a literal compound, use a global variable from rodata. The compound gets pushed on the stack, the padding of the structure was therefore not initialized, and was getting leaked to userland in sys___sigaltstack14(). To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.61.2.1 src/sys/kern/sys_lwp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sun Aug 11 10:04:03 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: sys_lwp.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1333): sys/kern/sys_lwp.c: revision 1.69 (patch) Fix info leak: instead of using SS_INIT as a literal compound, use a global variable from rodata. The compound gets pushed on the stack, the padding of the structure was therefore not initialized, and was getting leaked to userland in sys___sigaltstack14(). To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.61.2.1 src/sys/kern/sys_lwp.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_lwp.c diff -u src/sys/kern/sys_lwp.c:1.61 src/sys/kern/sys_lwp.c:1.61.2.1 --- src/sys/kern/sys_lwp.c:1.61 Thu Jun 1 02:45:13 2017 +++ src/sys/kern/sys_lwp.c Sun Aug 11 10:04:03 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_lwp.c,v 1.61 2017/06/01 02:45:13 chs Exp $ */ +/* $NetBSD: sys_lwp.c,v 1.61.2.1 2019/08/11 10:04:03 martin Exp $ */ /*- * Copyright (c) 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_lwp.c,v 1.61 2017/06/01 02:45:13 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_lwp.c,v 1.61.2.1 2019/08/11 10:04:03 martin Exp $"); #include #include @@ -53,6 +53,8 @@ __KERNEL_RCSID(0, "$NetBSD: sys_lwp.c,v #define LWP_UNPARK_MAX 1024 +static const stack_t lwp_ss_init = SS_INIT; + static syncobj_t lwp_park_sobj = { SOBJ_SLEEPQ_LIFO, sleepq_unsleep, @@ -86,7 +88,7 @@ do_lwp_create(lwp_t *l, void *arg, u_lon return ENOMEM; error = lwp_create(l, p, uaddr, flags & LWP_DETACHED, NULL, 0, - p->p_emul->e_startlwp, arg, , l->l_class, sigmask, _INIT); + p->p_emul->e_startlwp, arg, , l->l_class, sigmask, _ss_init); if (__predict_false(error)) { uvm_uarea_free(uaddr); return error;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Wed Aug 7 08:21:55 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: uipc_socket2.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1330): sys/kern/uipc_socket2.c: revision 1.134 Fix info leaks: the alignment of the structures causes uninitialized heap memory to be copied to userland in sys_recvmsg(). To generate a diff of this commit: cvs rdiff -u -r1.124.8.3 -r1.124.8.4 src/sys/kern/uipc_socket2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Wed Aug 7 08:21:55 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: uipc_socket2.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1330): sys/kern/uipc_socket2.c: revision 1.134 Fix info leaks: the alignment of the structures causes uninitialized heap memory to be copied to userland in sys_recvmsg(). To generate a diff of this commit: cvs rdiff -u -r1.124.8.3 -r1.124.8.4 src/sys/kern/uipc_socket2.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_socket2.c diff -u src/sys/kern/uipc_socket2.c:1.124.8.3 src/sys/kern/uipc_socket2.c:1.124.8.4 --- src/sys/kern/uipc_socket2.c:1.124.8.3 Tue Jul 31 17:01:20 2018 +++ src/sys/kern/uipc_socket2.c Wed Aug 7 08:21:55 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket2.c,v 1.124.8.3 2018/07/31 17:01:20 martin Exp $ */ +/* $NetBSD: uipc_socket2.c,v 1.124.8.4 2019/08/07 08:21:55 martin Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.124.8.3 2018/07/31 17:01:20 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.124.8.4 2019/08/07 08:21:55 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -1419,6 +1419,10 @@ sbcreatecontrol1(void **p, int size, int cp->cmsg_len = CMSG_LEN(size); cp->cmsg_level = level; cp->cmsg_type = type; + + memset(cp + 1, 0, CMSG_LEN(0) - sizeof(*cp)); + memset((uint8_t *)*p + size, 0, CMSG_ALIGN(size) - size); + return m; }
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Aug 5 14:47:49 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: kern_exec.c Log Message: Fix editor mistake in previous To generate a diff of this commit: cvs rdiff -u -r1.442.4.6 -r1.442.4.7 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: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Aug 5 14:47:49 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: kern_exec.c Log Message: Fix editor mistake in previous To generate a diff of this commit: cvs rdiff -u -r1.442.4.6 -r1.442.4.7 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.442.4.6 src/sys/kern/kern_exec.c:1.442.4.7 --- src/sys/kern/kern_exec.c:1.442.4.6 Mon Aug 5 14:43:54 2019 +++ src/sys/kern/kern_exec.c Mon Aug 5 14:47:49 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.442.4.6 2019/08/05 14:43:54 martin Exp $ */ +/* $NetBSD: kern_exec.c,v 1.442.4.7 2019/08/05 14:47:49 martin Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.442.4.6 2019/08/05 14:43:54 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.442.4.7 2019/08/05 14:47:49 martin Exp $"); #include "opt_exec.h" #include "opt_execfmt.h" @@ -677,7 +677,7 @@ execve_loadvm(struct lwp *l, const char struct proc *p; char *dp; u_int modgen; - size_t offss = 0; // XXX: GCC + size_t offs = 0; // XXX: GCC KASSERT(data != NULL);
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Aug 5 14:43:54 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: kern_exec.c Log Message: Backout the pullup of r1.476: remove offs initialization and XXX gcc comment. While actually the "offs" variable is always initialized when used, the gcc version on this branch is not smart enough to recognize that. To generate a diff of this commit: cvs rdiff -u -r1.442.4.5 -r1.442.4.6 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.442.4.5 src/sys/kern/kern_exec.c:1.442.4.6 --- src/sys/kern/kern_exec.c:1.442.4.5 Sun Aug 4 11:25:43 2019 +++ src/sys/kern/kern_exec.c Mon Aug 5 14:43:54 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.442.4.5 2019/08/04 11:25:43 martin Exp $ */ +/* $NetBSD: kern_exec.c,v 1.442.4.6 2019/08/05 14:43:54 martin Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.442.4.5 2019/08/04 11:25:43 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.442.4.6 2019/08/05 14:43:54 martin Exp $"); #include "opt_exec.h" #include "opt_execfmt.h" @@ -677,7 +677,7 @@ execve_loadvm(struct lwp *l, const char struct proc *p; char *dp; u_int modgen; - size_t offs; + size_t offss = 0; // XXX: GCC KASSERT(data != NULL);
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sun Aug 4 11:25:44 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: kern_exec.c Log Message: Pull up the following revisions, requested by maxv in ticket #1324: sys/kern/kern_exec.c1.469-1.478 (via patch) Fix off-by-one and info leak. To generate a diff of this commit: cvs rdiff -u -r1.442.4.4 -r1.442.4.5 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: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sun Aug 4 11:25:44 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: kern_exec.c Log Message: Pull up the following revisions, requested by maxv in ticket #1324: sys/kern/kern_exec.c1.469-1.478 (via patch) Fix off-by-one and info leak. To generate a diff of this commit: cvs rdiff -u -r1.442.4.4 -r1.442.4.5 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.442.4.4 src/sys/kern/kern_exec.c:1.442.4.5 --- src/sys/kern/kern_exec.c:1.442.4.4 Wed Nov 21 11:58:32 2018 +++ src/sys/kern/kern_exec.c Sun Aug 4 11:25:43 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.442.4.4 2018/11/21 11:58:32 martin Exp $ */ +/* $NetBSD: kern_exec.c,v 1.442.4.5 2019/08/04 11:25:43 martin Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.442.4.4 2018/11/21 11:58:32 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.442.4.5 2019/08/04 11:25:43 martin Exp $"); #include "opt_exec.h" #include "opt_execfmt.h" @@ -541,6 +541,12 @@ sys_execve(struct lwp *l, const struct s SCARG(uap, envp), execve_fetch_element); } +/* + * Copy the user or kernel supplied upath to the allocated pathbuffer pbp + * making it absolute in the process, by prepending the current working + * directory if it is not. If offs is supplied it will contain the offset + * where the original supplied copy of upath starts. + */ int sys_fexecve(struct lwp *l, const struct sys_fexecve_args *uap, register_t *retval) @@ -610,11 +616,8 @@ makepathbuf(struct lwp *l, const char *u path = PNBUF_GET(); error = copyinstr(upath, path, MAXPATHLEN, ); - if (error) { - PNBUF_PUT(path); - DPRINTF(("%s: copyin path @%p %d\n", __func__, upath, error)); - return error; - } + if (error) + goto err; if (path[0] == '/') { *offs = 0; @@ -622,8 +625,10 @@ makepathbuf(struct lwp *l, const char *u } len++; - if (len + 1 >= MAXPATHLEN) - goto out; + if (len + 1 >= MAXPATHLEN) { + error = ENAMETOOLONG; + goto err; + } bp = path + MAXPATHLEN - len; memmove(bp, path, len); *(--bp) = '/'; @@ -634,19 +639,19 @@ makepathbuf(struct lwp *l, const char *u GETCWD_CHECK_ACCESS, l); rw_exit(>cwdi_lock); - if (error) { - DPRINTF(("%s: getcwd_common path %s %d\n", __func__, path, - error)); - goto out; - } + if (error) + goto err; tlen = path + MAXPATHLEN - bp; memmove(path, bp, tlen); - path[tlen] = '\0'; + path[tlen - 1] = '\0'; *offs = tlen - len; out: *pbp = pathbuf_assimilate(path); return 0; +err: + PNBUF_PUT(path); + return error; } vaddr_t @@ -672,7 +677,7 @@ execve_loadvm(struct lwp *l, const char struct proc *p; char *dp; u_int modgen; - size_t offs = 0; // XXX: GCC + size_t offs; KASSERT(data != NULL); @@ -2088,6 +2093,7 @@ spawn_return(void *arg) /* handle posix_spawnattr */ if (spawn_data->sed_attrs != NULL) { struct sigaction sigact; + memset(, 0, sizeof(sigact)); sigact._sa_u._sa_handler = SIG_DFL; sigact.sa_flags = 0;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sun Aug 4 11:05:29 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: sys_ptrace_common.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1319): sys/kern/sys_ptrace_common.c: revision 1.57 Fix bug, don't release the reflock if we didn't take it in the first place. Looks like there are other locking issues in here. To generate a diff of this commit: cvs rdiff -u -r1.22.2.5 -r1.22.2.6 src/sys/kern/sys_ptrace_common.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sun Aug 4 11:05:29 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: sys_ptrace_common.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1319): sys/kern/sys_ptrace_common.c: revision 1.57 Fix bug, don't release the reflock if we didn't take it in the first place. Looks like there are other locking issues in here. To generate a diff of this commit: cvs rdiff -u -r1.22.2.5 -r1.22.2.6 src/sys/kern/sys_ptrace_common.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_ptrace_common.c diff -u src/sys/kern/sys_ptrace_common.c:1.22.2.5 src/sys/kern/sys_ptrace_common.c:1.22.2.6 --- src/sys/kern/sys_ptrace_common.c:1.22.2.5 Mon Jul 22 18:02:09 2019 +++ src/sys/kern/sys_ptrace_common.c Sun Aug 4 11:05:29 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_ptrace_common.c,v 1.22.2.5 2019/07/22 18:02:09 martin Exp $ */ +/* $NetBSD: sys_ptrace_common.c,v 1.22.2.6 2019/08/04 11:05:29 martin Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -118,7 +118,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.22.2.5 2019/07/22 18:02:09 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.22.2.6 2019/08/04 11:05:29 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_ptrace.h" @@ -365,8 +365,11 @@ ptrace_find(struct lwp *l, int req, pid_ } static int -ptrace_allowed(struct lwp *l, int req, struct proc *t, struct proc *p) +ptrace_allowed(struct lwp *l, int req, struct proc *t, struct proc *p, +bool *locked) { + *locked = false; + /* * Grab a reference on the process to prevent it from execing or * exiting. @@ -374,6 +377,8 @@ ptrace_allowed(struct lwp *l, int req, s if (!rw_tryenter(>p_reflock, RW_READER)) return EBUSY; + *locked = true; + /* Make sure we can operate on it. */ switch (req) { case PT_TRACE_ME: @@ -978,6 +983,7 @@ do_ptrace(struct ptrace_methods *ptm, st int error, write, tmp, pheld; int signo = 0; int resume_all; + bool locked; error = 0; /* @@ -993,7 +999,7 @@ do_ptrace(struct ptrace_methods *ptm, st } pheld = 1; - if ((error = ptrace_allowed(l, req, t, p)) != 0) + if ((error = ptrace_allowed(l, req, t, p, )) != 0) goto out; if ((error = kauth_authorize_process(l->l_cred, @@ -1318,7 +1324,8 @@ out: } if (lt != NULL) lwp_delref(lt); - rw_exit(>p_reflock); + if (locked) + rw_exit(>p_reflock); return error; }
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Jul 22 18:02:09 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: sys_ptrace_common.c Log Message: Pull up following revision(s) (requested by kamil in ticket #1302): sys/kern/sys_ptrace_common.c: revision 1.58 Enhance locking of ptrace_update_lwp Replace lwp_delref() + mutex_enter() with: mutex_enter() + lwp_delref2().= This avoids extra taking and exiting from a mutex. Add missing mutex_exit() for LW_SYSTEM. Do not switch lwp for PT_SET_SIGINFO. This operation is not needed and avoids panic for >2 LWPs as p_lock is attempted to be entered again in a critical section. To generate a diff of this commit: cvs rdiff -u -r1.22.2.4 -r1.22.2.5 src/sys/kern/sys_ptrace_common.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Jul 22 18:02:09 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: sys_ptrace_common.c Log Message: Pull up following revision(s) (requested by kamil in ticket #1302): sys/kern/sys_ptrace_common.c: revision 1.58 Enhance locking of ptrace_update_lwp Replace lwp_delref() + mutex_enter() with: mutex_enter() + lwp_delref2().= This avoids extra taking and exiting from a mutex. Add missing mutex_exit() for LW_SYSTEM. Do not switch lwp for PT_SET_SIGINFO. This operation is not needed and avoids panic for >2 LWPs as p_lock is attempted to be entered again in a critical section. To generate a diff of this commit: cvs rdiff -u -r1.22.2.4 -r1.22.2.5 src/sys/kern/sys_ptrace_common.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_ptrace_common.c diff -u src/sys/kern/sys_ptrace_common.c:1.22.2.4 src/sys/kern/sys_ptrace_common.c:1.22.2.5 --- src/sys/kern/sys_ptrace_common.c:1.22.2.4 Thu Nov 29 14:58:25 2018 +++ src/sys/kern/sys_ptrace_common.c Mon Jul 22 18:02:09 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_ptrace_common.c,v 1.22.2.4 2018/11/29 14:58:25 martin Exp $ */ +/* $NetBSD: sys_ptrace_common.c,v 1.22.2.5 2019/07/22 18:02:09 martin Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -118,7 +118,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.22.2.4 2018/11/29 14:58:25 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.22.2.5 2019/07/22 18:02:09 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_ptrace.h" @@ -527,9 +527,9 @@ ptrace_update_lwp(struct proc *t, struct if (lid == 0 || lid == (*lt)->l_lid || t->p_nlwps == 1) return 0; - lwp_delref(*lt); - mutex_enter(t->p_lock); + lwp_delref2(*lt); + *lt = lwp_find(t, lid); if (*lt == NULL) { mutex_exit(t->p_lock); @@ -537,6 +537,7 @@ ptrace_update_lwp(struct proc *t, struct } if ((*lt)->l_flag & LW_SYSTEM) { + mutex_exit(t->p_lock); *lt = NULL; return EINVAL; } @@ -574,9 +575,6 @@ ptrace_set_siginfo(struct proc *t, struc if (psi.psi_siginfo.si_signo < 0 || psi.psi_siginfo.si_signo >= NSIG) return EINVAL; - if ((error = ptrace_update_lwp(t, lt, psi.psi_lwpid)) != 0) - return error; - t->p_sigctx.ps_faked = true; t->p_sigctx.ps_info = psi.psi_siginfo._info; t->p_sigctx.ps_lwp = psi.psi_lwpid;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Wed May 1 14:51:17 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: sys_pipe.c Log Message: Pull up following revision(s) (requested by mlelstv in ticket #1253): sys/kern/sys_pipe.c: revision 1.147 sys/kern/sys_pipe.c: revision 1.148 Clean up pipe structure before recycling it. Handle half-closed pipes in FIONWRITE and FIONSPACE. To generate a diff of this commit: cvs rdiff -u -r1.140 -r1.140.12.1 src/sys/kern/sys_pipe.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_pipe.c diff -u src/sys/kern/sys_pipe.c:1.140 src/sys/kern/sys_pipe.c:1.140.12.1 --- src/sys/kern/sys_pipe.c:1.140 Fri Sep 5 09:20:59 2014 +++ src/sys/kern/sys_pipe.c Wed May 1 14:51:17 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_pipe.c,v 1.140 2014/09/05 09:20:59 matt Exp $ */ +/* $NetBSD: sys_pipe.c,v 1.140.12.1 2019/05/01 14:51:17 martin Exp $ */ /*- * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.140 2014/09/05 09:20:59 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.140.12.1 2019/05/01 14:51:17 martin Exp $"); #include #include @@ -1107,10 +1107,12 @@ pipe_ioctl(file_t *fp, u_long cmd, void case FIONWRITE: /* Look at other side */ - pipe = pipe->pipe_peer; mutex_enter(lock); + pipe = pipe->pipe_peer; + if (pipe == NULL) + *(int *)data = 0; #ifndef PIPE_NODIRECT - if (pipe->pipe_state & PIPE_DIRECTW) + else if (pipe->pipe_state & PIPE_DIRECTW) *(int *)data = pipe->pipe_map.cnt; else #endif @@ -1120,8 +1122,11 @@ pipe_ioctl(file_t *fp, u_long cmd, void case FIONSPACE: /* Look at other side */ - pipe = pipe->pipe_peer; mutex_enter(lock); + pipe = pipe->pipe_peer; + if (pipe == NULL) + *(int *)data = 0; + else #ifndef PIPE_NODIRECT /* * If we're in direct-mode, we don't really have a @@ -1346,6 +1351,8 @@ pipeclose(struct pipe *pipe) free_resources: pipe->pipe_pgid = 0; pipe->pipe_state = PIPE_SIGNALR; + pipe->pipe_peer = NULL; + pipe->pipe_lock = NULL; pipe_free_kmem(pipe); if (pipe->pipe_kmem != 0) { pool_cache_put(pipe_rd_cache, pipe);
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Wed May 1 14:51:17 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: sys_pipe.c Log Message: Pull up following revision(s) (requested by mlelstv in ticket #1253): sys/kern/sys_pipe.c: revision 1.147 sys/kern/sys_pipe.c: revision 1.148 Clean up pipe structure before recycling it. Handle half-closed pipes in FIONWRITE and FIONSPACE. To generate a diff of this commit: cvs rdiff -u -r1.140 -r1.140.12.1 src/sys/kern/sys_pipe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: msaitoh Date: Tue Apr 16 03:47:14 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: sys_mqueue.c Log Message: Pull up following revision(s) (requested by martin in ticket #1230): sys/kern/sys_mqueue.c: revision 1.44 mq_send1: fix argument validation and reject too large lengths early. Discovered by Andy Nguyen. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.39.10.1 src/sys/kern/sys_mqueue.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: msaitoh Date: Tue Apr 16 03:47:14 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: sys_mqueue.c Log Message: Pull up following revision(s) (requested by martin in ticket #1230): sys/kern/sys_mqueue.c: revision 1.44 mq_send1: fix argument validation and reject too large lengths early. Discovered by Andy Nguyen. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.39.10.1 src/sys/kern/sys_mqueue.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_mqueue.c diff -u src/sys/kern/sys_mqueue.c:1.39 src/sys/kern/sys_mqueue.c:1.39.10.1 --- src/sys/kern/sys_mqueue.c:1.39 Mon Jun 29 15:44:45 2015 +++ src/sys/kern/sys_mqueue.c Tue Apr 16 03:47:14 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_mqueue.c,v 1.39 2015/06/29 15:44:45 christos Exp $ */ +/* $NetBSD: sys_mqueue.c,v 1.39.10.1 2019/04/16 03:47:14 msaitoh Exp $ */ /* * Copyright (c) 2007-2011 Mindaugas Rasiukevicius @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.39 2015/06/29 15:44:45 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.39.10.1 2019/04/16 03:47:14 msaitoh Exp $"); #include #include @@ -811,6 +811,8 @@ mq_send1(mqd_t mqdes, const char *msg_pt return EINVAL; /* Allocate a new message */ + if (msg_len > mq_max_msgsize) + return EMSGSIZE; size = sizeof(struct mq_msg) + msg_len; if (size > mq_max_msgsize) return EMSGSIZE;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sun Feb 24 10:49:53 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: kern_time.c Log Message: Pull up following revision(s) (requested by mlelstv in ticket #1196): sys/kern/kern_time.c: revision 1.196 The callout is used by any nonvirtual timer including CLOCK_MONOTONIC and needs to be initialized. Detected by [syzkaller]. To generate a diff of this commit: cvs rdiff -u -r1.189.8.4 -r1.189.8.5 src/sys/kern/kern_time.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_time.c diff -u src/sys/kern/kern_time.c:1.189.8.4 src/sys/kern/kern_time.c:1.189.8.5 --- src/sys/kern/kern_time.c:1.189.8.4 Fri Feb 1 11:21:30 2019 +++ src/sys/kern/kern_time.c Sun Feb 24 10:49:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_time.c,v 1.189.8.4 2019/02/01 11:21:30 martin Exp $ */ +/* $NetBSD: kern_time.c,v 1.189.8.5 2019/02/24 10:49:53 martin Exp $ */ /*- * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.189.8.4 2019/02/01 11:21:30 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.189.8.5 2019/02/24 10:49:53 martin Exp $"); #include #include @@ -1179,7 +1179,7 @@ dosetitimer(struct proc *p, int which, s pt->pt_type = which; pt->pt_entry = which; pt->pt_queued = false; - if (pt->pt_type == CLOCK_REALTIME) + if (!CLOCK_VIRTUAL_P(which)) callout_init(>pt_ch, CALLOUT_MPSAFE); else pt->pt_active = 0;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sun Feb 24 10:49:53 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: kern_time.c Log Message: Pull up following revision(s) (requested by mlelstv in ticket #1196): sys/kern/kern_time.c: revision 1.196 The callout is used by any nonvirtual timer including CLOCK_MONOTONIC and needs to be initialized. Detected by [syzkaller]. To generate a diff of this commit: cvs rdiff -u -r1.189.8.4 -r1.189.8.5 src/sys/kern/kern_time.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Fri Feb 1 11:21:30 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: kern_time.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1180): sys/kern/kern_time.c: revision 1.190 sys/kern/kern_time.c: revision 1.194 Fix stack info leak. There are 4 bytes of padding in struct timeval. Looks like there are other leaks related to timeval in this file. [ 133.414352] kleak: Possible leak in copyout: [len=16, leaked=4] [ 133.414352] #0 0x80224d0a in kleak_note [ 133.424360] #1 0x80224d8a in kleak_copyout [ 133.434361] #2 0x80b5fd79 in sys___gettimeofday50 [ 133.434361] #3 0x8025a89c in sy_call [ 133.444351] #4 0x8025aace in sy_invoke [ 133.454365] #5 0x8025ab54 in syscall - Fix kernel info leaks. To generate a diff of this commit: cvs rdiff -u -r1.189.8.3 -r1.189.8.4 src/sys/kern/kern_time.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_time.c diff -u src/sys/kern/kern_time.c:1.189.8.3 src/sys/kern/kern_time.c:1.189.8.4 --- src/sys/kern/kern_time.c:1.189.8.3 Thu Dec 27 12:19:45 2018 +++ src/sys/kern/kern_time.c Fri Feb 1 11:21:30 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_time.c,v 1.189.8.3 2018/12/27 12:19:45 martin Exp $ */ +/* $NetBSD: kern_time.c,v 1.189.8.4 2019/02/01 11:21:30 martin Exp $ */ /*- * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.189.8.3 2018/12/27 12:19:45 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.189.8.4 2019/02/01 11:21:30 martin Exp $"); #include #include @@ -424,6 +424,7 @@ sys___gettimeofday50(struct lwp *l, cons struct timezone tzfake; if (SCARG(uap, tp)) { + memset(, 0, sizeof(atv)); microtime(); error = copyout(, SCARG(uap, tp), sizeof(atv)); if (error) @@ -523,6 +524,7 @@ adjtime1(const struct timeval *delta, st extern int64_t time_adjtime; /* in kern_ntptime.c */ if (olddelta) { + memset(olddelta, 0, sizeof(*olddelta)); mutex_spin_enter(_lock); olddelta->tv_sec = time_adjtime / 100; olddelta->tv_usec = time_adjtime % 100;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Fri Feb 1 11:21:30 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: kern_time.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1180): sys/kern/kern_time.c: revision 1.190 sys/kern/kern_time.c: revision 1.194 Fix stack info leak. There are 4 bytes of padding in struct timeval. Looks like there are other leaks related to timeval in this file. [ 133.414352] kleak: Possible leak in copyout: [len=16, leaked=4] [ 133.414352] #0 0x80224d0a in kleak_note [ 133.424360] #1 0x80224d8a in kleak_copyout [ 133.434361] #2 0x80b5fd79 in sys___gettimeofday50 [ 133.434361] #3 0x8025a89c in sy_call [ 133.444351] #4 0x8025aace in sy_invoke [ 133.454365] #5 0x8025ab54 in syscall - Fix kernel info leaks. To generate a diff of this commit: cvs rdiff -u -r1.189.8.3 -r1.189.8.4 src/sys/kern/kern_time.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Thu Jan 24 15:35:14 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: kern_ntptime.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1168): sys/kern/kern_ntptime.c: revision 1.60 Zero out the ntptimeval structure to prevent a 4 byte kernel stack disclosure. Reported by Thomas Barabosch. To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.57.10.1 src/sys/kern/kern_ntptime.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_ntptime.c diff -u src/sys/kern/kern_ntptime.c:1.57 src/sys/kern/kern_ntptime.c:1.57.10.1 --- src/sys/kern/kern_ntptime.c:1.57 Mon Nov 23 23:45:44 2015 +++ src/sys/kern/kern_ntptime.c Thu Jan 24 15:35:14 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_ntptime.c,v 1.57 2015/11/23 23:45:44 joerg Exp $ */ +/* $NetBSD: kern_ntptime.c,v 1.57.10.1 2019/01/24 15:35:14 martin Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ #include /* __FBSDID("$FreeBSD: src/sys/kern/kern_ntptime.c,v 1.59 2005/05/28 14:34:41 rwatson Exp $"); */ -__KERNEL_RCSID(0, "$NetBSD: kern_ntptime.c,v 1.57 2015/11/23 23:45:44 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_ntptime.c,v 1.57.10.1 2019/01/24 15:35:14 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_ntp.h" @@ -239,6 +239,7 @@ static void hardupdate(long offset); void ntp_gettime(struct ntptimeval *ntv) { + memset(ntv, 0, sizeof(*ntv)); mutex_spin_enter(_lock); nanotime(>time);
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Thu Jan 24 15:35:14 UTC 2019 Modified Files: src/sys/kern [netbsd-8]: kern_ntptime.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1168): sys/kern/kern_ntptime.c: revision 1.60 Zero out the ntptimeval structure to prevent a 4 byte kernel stack disclosure. Reported by Thomas Barabosch. To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.57.10.1 src/sys/kern/kern_ntptime.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Thu Dec 27 12:19:45 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_time.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1147): sys/kern/kern_time.c: revision 1.191 Fix kernel info leak. There are 2x4 bytes of padding in struct itimerval. [ 738.451860] kleak: Possible leak in copyout: [len=32, leaked=8] [ 738.481840] #0 0x80b7c42a in kleak_note [ 738.491821] #1 0x80b7c4aa in kleak_copyout [ 738.501806] #2 0x80b6154e in sys___getitimer50 [ 738.511778] #3 0x80b61e39 in sys___setitimer50 [ 738.521781] #4 0x8025ab3c in sy_call [ 738.521781] #5 0x8025ad6e in sy_invoke [ 738.531808] #6 0x8025adf4 in syscall To generate a diff of this commit: cvs rdiff -u -r1.189.8.2 -r1.189.8.3 src/sys/kern/kern_time.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_time.c diff -u src/sys/kern/kern_time.c:1.189.8.2 src/sys/kern/kern_time.c:1.189.8.3 --- src/sys/kern/kern_time.c:1.189.8.2 Fri Nov 30 10:28:46 2018 +++ src/sys/kern/kern_time.c Thu Dec 27 12:19:45 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_time.c,v 1.189.8.2 2018/11/30 10:28:46 martin Exp $ */ +/* $NetBSD: kern_time.c,v 1.189.8.3 2018/12/27 12:19:45 martin Exp $ */ /*- * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.189.8.2 2018/11/30 10:28:46 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.189.8.3 2018/12/27 12:19:45 martin Exp $"); #include #include @@ -1068,6 +1068,7 @@ sys___getitimer50(struct lwp *l, const s struct itimerval aitv; int error; + memset(, 0, sizeof(aitv)); error = dogetitimer(p, SCARG(uap, which), ); if (error) return error;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Thu Dec 27 12:19:45 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_time.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1147): sys/kern/kern_time.c: revision 1.191 Fix kernel info leak. There are 2x4 bytes of padding in struct itimerval. [ 738.451860] kleak: Possible leak in copyout: [len=32, leaked=8] [ 738.481840] #0 0x80b7c42a in kleak_note [ 738.491821] #1 0x80b7c4aa in kleak_copyout [ 738.501806] #2 0x80b6154e in sys___getitimer50 [ 738.511778] #3 0x80b61e39 in sys___setitimer50 [ 738.521781] #4 0x8025ab3c in sy_call [ 738.521781] #5 0x8025ad6e in sy_invoke [ 738.531808] #6 0x8025adf4 in syscall To generate a diff of this commit: cvs rdiff -u -r1.189.8.2 -r1.189.8.3 src/sys/kern/kern_time.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Wed Dec 12 11:33:29 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: sys_sig.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1134): sys/kern/sys_sig.c: revision 1.47 Fix kernel info leak, 4 bytes of padding in struct _ksiginfo. Maybe we should just set _pad to zero on LP64? + Possible info leak: [len=40, leaked=4] | #0 0x80baf397 in kleak_copyout | #1 0x80bda817 in sigtimedwait1 | #2 0x80bdab95 in sys_sigtimedwait50 | #3 0x80259c42 in syscall To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.46.8.1 src/sys/kern/sys_sig.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_sig.c diff -u src/sys/kern/sys_sig.c:1.46 src/sys/kern/sys_sig.c:1.46.8.1 --- src/sys/kern/sys_sig.c:1.46 Thu Aug 4 06:43:43 2016 +++ src/sys/kern/sys_sig.c Wed Dec 12 11:33:29 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_sig.c,v 1.46 2016/08/04 06:43:43 christos Exp $ */ +/* $NetBSD: sys_sig.c,v 1.46.8.1 2018/12/12 11:33:29 martin Exp $ */ /*- * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v 1.46 2016/08/04 06:43:43 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v 1.46.8.1 2018/12/12 11:33:29 martin Exp $"); #include "opt_dtrace.h" @@ -766,6 +766,8 @@ sigtimedwait1(struct lwp *l, const struc */ sigminusset(, >l_sigwaitset); + memset(_info, 0, sizeof(ksi.ksi_info)); + mutex_enter(p->p_lock); /* Check for pending signals in the process, if no - then in LWP. */
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Wed Dec 12 11:33:29 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: sys_sig.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1134): sys/kern/sys_sig.c: revision 1.47 Fix kernel info leak, 4 bytes of padding in struct _ksiginfo. Maybe we should just set _pad to zero on LP64? + Possible info leak: [len=40, leaked=4] | #0 0x80baf397 in kleak_copyout | #1 0x80bda817 in sigtimedwait1 | #2 0x80bdab95 in sys_sigtimedwait50 | #3 0x80259c42 in syscall To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.46.8.1 src/sys/kern/sys_sig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Fri Nov 30 10:32:22 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_exit.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1114): sys/kern/kern_exit.c: revision 1.273 Fix info leak. There is one branch where 'status' is not initialized at all. + Possible info leak: [len=4, leaked=4] | #0 0x80baf397 in kleak_copyout | #1 0x80b56d0c in sys_wait6 | #2 0x80259c42 in syscall To generate a diff of this commit: cvs rdiff -u -r1.268.8.1 -r1.268.8.2 src/sys/kern/kern_exit.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_exit.c diff -u src/sys/kern/kern_exit.c:1.268.8.1 src/sys/kern/kern_exit.c:1.268.8.2 --- src/sys/kern/kern_exit.c:1.268.8.1 Thu Apr 12 13:42:48 2018 +++ src/sys/kern/kern_exit.c Fri Nov 30 10:32:22 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exit.c,v 1.268.8.1 2018/04/12 13:42:48 martin Exp $ */ +/* $NetBSD: kern_exit.c,v 1.268.8.2 2018/11/30 10:32:22 martin Exp $ */ /*- * Copyright (c) 1998, 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.268.8.1 2018/04/12 13:42:48 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.268.8.2 2018/11/30 10:32:22 martin Exp $"); #include "opt_ktrace.h" #include "opt_dtrace.h" @@ -661,6 +661,7 @@ do_sys_waitid(idtype_t idtype, id_t id, if (child == NULL) { mutex_exit(proc_lock); *pid = 0; + *status = 0; return error; } *pid = child->p_pid;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Fri Nov 30 10:32:22 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_exit.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1114): sys/kern/kern_exit.c: revision 1.273 Fix info leak. There is one branch where 'status' is not initialized at all. + Possible info leak: [len=4, leaked=4] | #0 0x80baf397 in kleak_copyout | #1 0x80b56d0c in sys_wait6 | #2 0x80259c42 in syscall To generate a diff of this commit: cvs rdiff -u -r1.268.8.1 -r1.268.8.2 src/sys/kern/kern_exit.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Thu Nov 29 14:59:56 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_sig.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1113): sys/kern/kern_sig.c: revision 1.350 Fix kernel info leak, 4 bytes of padding at the end of struct sigaction. + Possible info leak: [len=32, leaked=4] | #0 0x80baf327 in kleak_copyout | #1 0x80bd9ca8 in sys___sigaction_sigtramp | #2 0x80259c42 in syscall To generate a diff of this commit: cvs rdiff -u -r1.336.4.2 -r1.336.4.3 src/sys/kern/kern_sig.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_sig.c diff -u src/sys/kern/kern_sig.c:1.336.4.2 src/sys/kern/kern_sig.c:1.336.4.3 --- src/sys/kern/kern_sig.c:1.336.4.2 Thu Apr 12 13:42:48 2018 +++ src/sys/kern/kern_sig.c Thu Nov 29 14:59:56 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sig.c,v 1.336.4.2 2018/04/12 13:42:48 martin Exp $ */ +/* $NetBSD: kern_sig.c,v 1.336.4.3 2018/11/29 14:59:56 martin Exp $ */ /*- * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.336.4.2 2018/04/12 13:42:48 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.336.4.3 2018/11/29 14:59:56 martin Exp $"); #include "opt_ptrace.h" #include "opt_dtrace.h" @@ -189,6 +189,13 @@ signal_listener_cb(kauth_cred_t cred, ka return result; } +static int +sigacts_ctor(void *arg __unused, void *obj, int flags __unused) +{ + memset(obj, 0, sizeof(struct sigacts)); + return 0; +} + /* * signal_init: * @@ -202,7 +209,7 @@ signal_init(void) sigacts_cache = pool_cache_init(sizeof(struct sigacts), 0, 0, 0, "sigacts", sizeof(struct sigacts) > PAGE_SIZE ? - _allocator : NULL, IPL_NONE, NULL, NULL, NULL); + _allocator : NULL, IPL_NONE, sigacts_ctor, NULL, NULL); ksiginfo_cache = pool_cache_init(sizeof(ksiginfo_t), 0, 0, 0, "ksiginfo", NULL, IPL_VM, NULL, NULL, NULL);
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Thu Nov 29 14:59:56 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_sig.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1113): sys/kern/kern_sig.c: revision 1.350 Fix kernel info leak, 4 bytes of padding at the end of struct sigaction. + Possible info leak: [len=32, leaked=4] | #0 0x80baf327 in kleak_copyout | #1 0x80bd9ca8 in sys___sigaction_sigtramp | #2 0x80259c42 in syscall To generate a diff of this commit: cvs rdiff -u -r1.336.4.2 -r1.336.4.3 src/sys/kern/kern_sig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Thu Nov 29 14:58:25 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: sys_ptrace_common.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1112): sys/kern/sys_ptrace_common.c: revision 1.46 Fix stack info leak. + Possible info leak: [len=136, leaked=92] | #0 0x80baf397 in kleak_copyout | #1 0x80bd4155 in ptrace_copyout_siginfo | #2 0x80bd5348 in do_ptrace | #3 0x80bd40fe in sys_ptrace | #4 0x80259c42 in syscall To generate a diff of this commit: cvs rdiff -u -r1.22.2.3 -r1.22.2.4 src/sys/kern/sys_ptrace_common.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_ptrace_common.c diff -u src/sys/kern/sys_ptrace_common.c:1.22.2.3 src/sys/kern/sys_ptrace_common.c:1.22.2.4 --- src/sys/kern/sys_ptrace_common.c:1.22.2.3 Sat May 5 19:13:21 2018 +++ src/sys/kern/sys_ptrace_common.c Thu Nov 29 14:58:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_ptrace_common.c,v 1.22.2.3 2018/05/05 19:13:21 martin Exp $ */ +/* $NetBSD: sys_ptrace_common.c,v 1.22.2.4 2018/11/29 14:58:25 martin Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -118,7 +118,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.22.2.3 2018/05/05 19:13:21 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.22.2.4 2018/11/29 14:58:25 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_ptrace.h" @@ -553,6 +553,7 @@ ptrace_get_siginfo(struct proc *t, struc { struct ptrace_siginfo psi; + memset(, 0, sizeof(psi)); psi.psi_siginfo._info = t->p_sigctx.ps_info; psi.psi_lwpid = t->p_sigctx.ps_lwp;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Thu Nov 29 14:58:25 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: sys_ptrace_common.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1112): sys/kern/sys_ptrace_common.c: revision 1.46 Fix stack info leak. + Possible info leak: [len=136, leaked=92] | #0 0x80baf397 in kleak_copyout | #1 0x80bd4155 in ptrace_copyout_siginfo | #2 0x80bd5348 in do_ptrace | #3 0x80bd40fe in sys_ptrace | #4 0x80259c42 in syscall To generate a diff of this commit: cvs rdiff -u -r1.22.2.3 -r1.22.2.4 src/sys/kern/sys_ptrace_common.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Thu Nov 29 08:48:38 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_time.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1110): sys/kern/kern_time.c: revision 1.192 Fix kernel info leak. + Possible info leak: [len=32, leaked=16] | #0 0x80baf3a7 in kleak_copyout | #1 0x80b940f8 in sys___timer_settime50 | #2 0x80259c42 in syscall To generate a diff of this commit: cvs rdiff -u -r1.189 -r1.189.8.1 src/sys/kern/kern_time.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_time.c diff -u src/sys/kern/kern_time.c:1.189 src/sys/kern/kern_time.c:1.189.8.1 --- src/sys/kern/kern_time.c:1.189 Fri Nov 11 15:29:36 2016 +++ src/sys/kern/kern_time.c Thu Nov 29 08:48:38 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_time.c,v 1.189 2016/11/11 15:29:36 njoly Exp $ */ +/* $NetBSD: kern_time.c,v 1.189.8.1 2018/11/29 08:48:38 martin Exp $ */ /*- * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.189 2016/11/11 15:29:36 njoly Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.189.8.1 2018/11/29 08:48:38 martin Exp $"); #include #include @@ -602,6 +602,7 @@ timer_create1(timer_t *tid, clockid_t id pts = timers_alloc(p); pt = pool_get(_pool, PR_WAITOK); + memset(pt, 0, sizeof(*pt)); if (evp != NULL) { if (((error = (*fetch_event)(evp, >pt_ev, sizeof(pt->pt_ev))) != 0) ||
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Thu Nov 29 08:48:38 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_time.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1110): sys/kern/kern_time.c: revision 1.192 Fix kernel info leak. + Possible info leak: [len=32, leaked=16] | #0 0x80baf3a7 in kleak_copyout | #1 0x80b940f8 in sys___timer_settime50 | #2 0x80259c42 in syscall To generate a diff of this commit: cvs rdiff -u -r1.189 -r1.189.8.1 src/sys/kern/kern_time.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: snj Date: Mon Nov 26 17:19:46 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: subr_evcnt.c Log Message: Apply patch (requested by maxv in ticket #1106): Fix kernel information leak. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.12.22.1 src/sys/kern/subr_evcnt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: snj Date: Mon Nov 26 17:19:46 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: subr_evcnt.c Log Message: Apply patch (requested by maxv in ticket #1106): Fix kernel information leak. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.12.22.1 src/sys/kern/subr_evcnt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_evcnt.c diff -u src/sys/kern/subr_evcnt.c:1.12 src/sys/kern/subr_evcnt.c:1.12.22.1 --- src/sys/kern/subr_evcnt.c:1.12 Tue Feb 25 18:30:11 2014 +++ src/sys/kern/subr_evcnt.c Mon Nov 26 17:19:46 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_evcnt.c,v 1.12 2014/02/25 18:30:11 pooka Exp $ */ +/* $NetBSD: subr_evcnt.c,v 1.12.22.1 2018/11/26 17:19:46 snj Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_evcnt.c,v 1.12 2014/02/25 18:30:11 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_evcnt.c,v 1.12.22.1 2018/11/26 17:19:46 snj Exp $"); #include #include @@ -257,7 +257,7 @@ sysctl_doevcnt(SYSCTLFN_ARGS) sysctl_unlock(); if (oldp != NULL && xevs0 == NULL) - xevs0 = kmem_alloc(sizeof(*xevs0), KM_SLEEP); + xevs0 = kmem_zalloc(sizeof(*xevs0), KM_SLEEP); retries = 100; retry:
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Wed Nov 21 12:05:10 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_event.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1102): sys/kern/kern_event.c: revision 1.104 Fix kernel info leak. There are 4 bytes of padding in struct kevent. [ 287.537676] kleak: Possible leak in copyout: [len=40, leaked=4] [ 287.537676] #0 0x80b7c41a in kleak_note [ 287.547673] #1 0x80b7c49a in kleak_copyout [ 287.557677] #2 0x80b1d32d in kqueue_scan.isra.1.constprop.2 [ 287.557677] #3 0x80b1dc6a in kevent1 [ 287.567683] #4 0x80b1dcb0 in sys___kevent50 [ 287.567683] #5 0x8025ab3c in sy_call [ 287.577688] #6 0x8025ad6e in sy_invoke [ 287.587693] #7 0x8025adf4 in syscall To generate a diff of this commit: cvs rdiff -u -r1.91.2.2 -r1.91.2.3 src/sys/kern/kern_event.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_event.c diff -u src/sys/kern/kern_event.c:1.91.2.2 src/sys/kern/kern_event.c:1.91.2.3 --- src/sys/kern/kern_event.c:1.91.2.2 Tue Jan 16 13:26:12 2018 +++ src/sys/kern/kern_event.c Wed Nov 21 12:05:09 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_event.c,v 1.91.2.2 2018/01/16 13:26:12 martin Exp $ */ +/* $NetBSD: kern_event.c,v 1.91.2.3 2018/11/21 12:05:09 martin Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.91.2.2 2018/01/16 13:26:12 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.91.2.3 2018/11/21 12:05:09 martin Exp $"); #include #include @@ -584,6 +584,7 @@ filt_proc(struct knote *kn, long hint) * event with the parent's pid. Register knote with new * process. */ + memset(, 0, sizeof(kev)); kev.ident = hint & NOTE_PDATAMASK; /* pid */ kev.filter = kn->kn_filter; kev.flags = kn->kn_flags | EV_ADD | EV_ENABLE | EV_FLAG1;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Wed Nov 21 12:05:10 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_event.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1102): sys/kern/kern_event.c: revision 1.104 Fix kernel info leak. There are 4 bytes of padding in struct kevent. [ 287.537676] kleak: Possible leak in copyout: [len=40, leaked=4] [ 287.537676] #0 0x80b7c41a in kleak_note [ 287.547673] #1 0x80b7c49a in kleak_copyout [ 287.557677] #2 0x80b1d32d in kqueue_scan.isra.1.constprop.2 [ 287.557677] #3 0x80b1dc6a in kevent1 [ 287.567683] #4 0x80b1dcb0 in sys___kevent50 [ 287.567683] #5 0x8025ab3c in sy_call [ 287.577688] #6 0x8025ad6e in sy_invoke [ 287.587693] #7 0x8025adf4 in syscall To generate a diff of this commit: cvs rdiff -u -r1.91.2.2 -r1.91.2.3 src/sys/kern/kern_event.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Wed Nov 21 11:58:32 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_exec.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1100): sys/kern/kern_exec.c: revision 1.462 Fix stack info leak. There are 2x4 bytes of padding in struct ps_strings. [ 223.896199] kleak: Possible leak in copyout: [len=32, leaked=8] [ 223.906430] #0 0x80224d0a in kleak_note [ 223.906430] #1 0x80224d8a in kleak_copyout [ 223.918363] #2 0x80b1e26c in copyoutpsstrs [ 223.926560] #3 0x80b1e331 in copyoutargs [ 223.936216] #4 0x80b21768 in execve_runproc [ 223.946225] #5 0x80b21cc9 in execve1 [ 223.946225] #6 0x8025a89c in sy_call [ 223.956225] #7 0x8025aace in sy_invoke [ 223.966232] #8 0x8025ab54 in syscall To generate a diff of this commit: cvs rdiff -u -r1.442.4.3 -r1.442.4.4 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.442.4.3 src/sys/kern/kern_exec.c:1.442.4.4 --- src/sys/kern/kern_exec.c:1.442.4.3 Sat Mar 17 11:19:27 2018 +++ src/sys/kern/kern_exec.c Wed Nov 21 11:58:32 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.442.4.3 2018/03/17 11:19:27 martin Exp $ */ +/* $NetBSD: kern_exec.c,v 1.442.4.4 2018/11/21 11:58:32 martin Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.442.4.3 2018/03/17 11:19:27 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.442.4.4 2018/11/21 11:58:32 martin Exp $"); #include "opt_exec.h" #include "opt_execfmt.h" @@ -1447,6 +1447,8 @@ copyoutargs(struct execve_data * restric struct proc *p = l->l_proc; int error; + memset(>ed_arginfo, 0, sizeof(data->ed_arginfo)); + /* remember information about the process */ data->ed_arginfo.ps_nargvstr = data->ed_argc; data->ed_arginfo.ps_nenvstr = data->ed_envc;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Wed Nov 21 11:58:32 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_exec.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1100): sys/kern/kern_exec.c: revision 1.462 Fix stack info leak. There are 2x4 bytes of padding in struct ps_strings. [ 223.896199] kleak: Possible leak in copyout: [len=32, leaked=8] [ 223.906430] #0 0x80224d0a in kleak_note [ 223.906430] #1 0x80224d8a in kleak_copyout [ 223.918363] #2 0x80b1e26c in copyoutpsstrs [ 223.926560] #3 0x80b1e331 in copyoutargs [ 223.936216] #4 0x80b21768 in execve_runproc [ 223.946225] #5 0x80b21cc9 in execve1 [ 223.946225] #6 0x8025a89c in sy_call [ 223.956225] #7 0x8025aace in sy_invoke [ 223.966232] #8 0x8025ab54 in syscall To generate a diff of this commit: cvs rdiff -u -r1.442.4.3 -r1.442.4.4 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: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Nov 12 08:56:15 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_proc.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1088): sys/kern/kern_proc.c: revision 1.219 (via patch) Fix buffer overflow, which can lead to severe information leak. Detected by kASan. To generate a diff of this commit: cvs rdiff -u -r1.206.6.4 -r1.206.6.5 src/sys/kern/kern_proc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_proc.c diff -u src/sys/kern/kern_proc.c:1.206.6.4 src/sys/kern/kern_proc.c:1.206.6.5 --- src/sys/kern/kern_proc.c:1.206.6.4 Mon Apr 16 13:31:33 2018 +++ src/sys/kern/kern_proc.c Mon Nov 12 08:56:15 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_proc.c,v 1.206.6.4 2018/04/16 13:31:33 martin Exp $ */ +/* $NetBSD: kern_proc.c,v 1.206.6.5 2018/11/12 08:56:15 martin Exp $ */ /*- * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.206.6.4 2018/04/16 13:31:33 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.206.6.5 2018/11/12 08:56:15 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_kstack.h" @@ -2461,7 +2461,8 @@ fill_pathname(struct lwp *l, pid_t pid, len = strlen(path) + 1; if (oldp != NULL) { - error = sysctl_copyout(l, path, oldp, *oldlenp); + size_t copylen = min(len, *oldlenp); + error = sysctl_copyout(l, path, oldp, copylen); if (error == 0 && *oldlenp < len) error = ENOSPC; }
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Mon Nov 12 08:56:15 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_proc.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1088): sys/kern/kern_proc.c: revision 1.219 (via patch) Fix buffer overflow, which can lead to severe information leak. Detected by kASan. To generate a diff of this commit: cvs rdiff -u -r1.206.6.4 -r1.206.6.5 src/sys/kern/kern_proc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sat Oct 13 17:14:13 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_subr.c Log Message: Pull up following revision(s) (requested by mlelstv in ticket #1056): sys/kern/kern_subr.c: revision 1.220 Set rootdev for wedges. To generate a diff of this commit: cvs rdiff -u -r1.217 -r1.217.10.1 src/sys/kern/kern_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sat Oct 13 17:14:13 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_subr.c Log Message: Pull up following revision(s) (requested by mlelstv in ticket #1056): sys/kern/kern_subr.c: revision 1.220 Set rootdev for wedges. To generate a diff of this commit: cvs rdiff -u -r1.217 -r1.217.10.1 src/sys/kern/kern_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_subr.c diff -u src/sys/kern/kern_subr.c:1.217 src/sys/kern/kern_subr.c:1.217.10.1 --- src/sys/kern/kern_subr.c:1.217 Thu May 12 02:24:16 2016 +++ src/sys/kern/kern_subr.c Sat Oct 13 17:14:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_subr.c,v 1.217 2016/05/12 02:24:16 ozaki-r Exp $ */ +/* $NetBSD: kern_subr.c,v 1.217.10.1 2018/10/13 17:14:13 martin Exp $ */ /*- * Copyright (c) 1997, 1998, 1999, 2002, 2007, 2008 The NetBSD Foundation, Inc. @@ -79,7 +79,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.217 2016/05/12 02:24:16 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.217.10.1 2018/10/13 17:14:13 martin Exp $"); #include "opt_ddb.h" #include "opt_md.h" @@ -430,11 +430,13 @@ setroot(device_t bootdv, int bootpartiti goto haveroot; } - if (rootdev == NODEV && - dv != NULL && device_class(dv) == DV_DISK && - device_is_a(dv, "dk") && - (majdev = devsw_name2blk(device_xname(dv), NULL, 0)) >= 0) + if (dv != NULL && device_class(dv) == DV_DISK && + !DEV_USES_PARTITIONS(dv) && + (majdev = devsw_name2blk(device_xname(dv), NULL, 0)) >= 0) { + rootdv = dv; rootdev = makedev(majdev, device_unit(dv)); + goto haveroot; + } rootdevname = devsw_blk2name(major(rootdev)); if (rootdevname == NULL) {
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sun Sep 23 17:46:16 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_synch.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1031): sys/kern/kern_synch.c: revision 1.317 In mi_switch(), also call pserialize_switchpoint() if we're not switching to another lwp, as proposed on http://mail-index.netbsd.org/tech-kern/2018/07/20/msg023709.html Without it, on a SMP machine with few processes running (e.g while running sysinst), pserialize could hang for a long time until all CPUs got a LWP to run (or, eventually, forever). Tested on Xen domUs with 4 CPUs, and on a 64-threads AMD machine. To generate a diff of this commit: cvs rdiff -u -r1.311.10.1 -r1.311.10.2 src/sys/kern/kern_synch.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_synch.c diff -u src/sys/kern/kern_synch.c:1.311.10.1 src/sys/kern/kern_synch.c:1.311.10.2 --- src/sys/kern/kern_synch.c:1.311.10.1 Mon Feb 26 00:43:23 2018 +++ src/sys/kern/kern_synch.c Sun Sep 23 17:46:16 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_synch.c,v 1.311.10.1 2018/02/26 00:43:23 snj Exp $ */ +/* $NetBSD: kern_synch.c,v 1.311.10.2 2018/09/23 17:46:16 martin Exp $ */ /*- * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009 @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.311.10.1 2018/02/26 00:43:23 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.311.10.2 2018/09/23 17:46:16 martin Exp $"); #include "opt_kstack.h" #include "opt_perfctrs.h" @@ -759,6 +759,7 @@ mi_switch(lwp_t *l) retval = 1; } else { /* Nothing to do - just unlock and return. */ + pserialize_switchpoint(); mutex_spin_exit(spc->spc_mutex); lwp_unlock(l); retval = 0;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sun Sep 23 17:46:16 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: kern_synch.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1031): sys/kern/kern_synch.c: revision 1.317 In mi_switch(), also call pserialize_switchpoint() if we're not switching to another lwp, as proposed on http://mail-index.netbsd.org/tech-kern/2018/07/20/msg023709.html Without it, on a SMP machine with few processes running (e.g while running sysinst), pserialize could hang for a long time until all CPUs got a LWP to run (or, eventually, forever). Tested on Xen domUs with 4 CPUs, and on a 64-threads AMD machine. To generate a diff of this commit: cvs rdiff -u -r1.311.10.1 -r1.311.10.2 src/sys/kern/kern_synch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sat Sep 1 06:04:16 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: vfs_bio.c Log Message: Pull up following revision(s) (requested by hannken in ticket #1000): sys/kern/vfs_bio.c: revision 1.277 Make sure getnewbuf() runs bawrite() inside fstrans. Use fstrans_start_nowait() to skip buffers that would block. To generate a diff of this commit: cvs rdiff -u -r1.273.2.1 -r1.273.2.2 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: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Sat Sep 1 06:04:16 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: vfs_bio.c Log Message: Pull up following revision(s) (requested by hannken in ticket #1000): sys/kern/vfs_bio.c: revision 1.277 Make sure getnewbuf() runs bawrite() inside fstrans. Use fstrans_start_nowait() to skip buffers that would block. To generate a diff of this commit: cvs rdiff -u -r1.273.2.1 -r1.273.2.2 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.273.2.1 src/sys/kern/vfs_bio.c:1.273.2.2 --- src/sys/kern/vfs_bio.c:1.273.2.1 Thu Nov 2 21:29:52 2017 +++ src/sys/kern/vfs_bio.c Sat Sep 1 06:04:16 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_bio.c,v 1.273.2.1 2017/11/02 21:29:52 snj Exp $ */ +/* $NetBSD: vfs_bio.c,v 1.273.2.2 2018/09/01 06:04:16 martin Exp $ */ /*- * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -123,7 +123,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.273.2.1 2017/11/02 21:29:52 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.273.2.2 2018/09/01 06:04:16 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_bufcache.h" @@ -1347,11 +1347,12 @@ allocbuf(buf_t *bp, int size, int preser * Called with the buffer queues locked. * Return buffer locked. */ -buf_t * +static buf_t * getnewbuf(int slpflag, int slptimeo, int from_bufq) { buf_t *bp; struct vnode *vp; + struct mount *transmp = NULL; start: KASSERT(mutex_owned(_lock)); @@ -1376,8 +1377,21 @@ getnewbuf(int slpflag, int slptimeo, int } KASSERT(mutex_owned(_lock)); - if ((bp = TAILQ_FIRST([BQ_AGE].bq_queue)) != NULL || - (bp = TAILQ_FIRST([BQ_LRU].bq_queue)) != NULL) { + if ((bp = TAILQ_FIRST([BQ_AGE].bq_queue)) != NULL) { + KASSERT(!ISSET(bp->b_oflags, BO_DELWRI)); + } else { + TAILQ_FOREACH(bp, [BQ_LRU].bq_queue, b_freelist) { + if (ISSET(bp->b_cflags, BC_VFLUSH) || + !ISSET(bp->b_oflags, BO_DELWRI)) +break; + if (fstrans_start_nowait(bp->b_vp->v_mount) == 0) { +KASSERT(transmp == NULL); +transmp = bp->b_vp->v_mount; +break; + } + } + } + if (bp != NULL) { KASSERT(!ISSET(bp->b_cflags, BC_BUSY) || ISSET(bp->b_cflags, BC_VFLUSH)); bremfree(bp); @@ -1431,10 +1445,14 @@ getnewbuf(int slpflag, int slptimeo, int SET(bp->b_cflags, BC_AGE); mutex_exit(_lock); bawrite(bp); + KASSERT(transmp != NULL); + fstrans_done(transmp); mutex_enter(_lock); return (NULL); } + KASSERT(transmp == NULL); + vp = bp->b_vp; /* clear out various other fields */
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Thu Jun 14 19:59:18 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: subr_workqueue.c Log Message: Pull up following revision(s) (requested by ozaki-r in ticket #879): sys/kern/subr_workqueue.c: revision 1.37 Don't wait on workqueue_wait if called from worker itself Otherwise workqueue_wait never return in such a case. This treatment is the same as callout_halt. To generate a diff of this commit: cvs rdiff -u -r1.33.30.2 -r1.33.30.3 src/sys/kern/subr_workqueue.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_workqueue.c diff -u src/sys/kern/subr_workqueue.c:1.33.30.2 src/sys/kern/subr_workqueue.c:1.33.30.3 --- src/sys/kern/subr_workqueue.c:1.33.30.2 Mon Feb 5 14:55:16 2018 +++ src/sys/kern/subr_workqueue.c Thu Jun 14 19:59:18 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_workqueue.c,v 1.33.30.2 2018/02/05 14:55:16 martin Exp $ */ +/* $NetBSD: subr_workqueue.c,v 1.33.30.3 2018/06/14 19:59:18 martin Exp $ */ /*- * Copyright (c)2002, 2005, 2006, 2007 YAMAMOTO Takashi, @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_workqueue.c,v 1.33.30.2 2018/02/05 14:55:16 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_workqueue.c,v 1.33.30.3 2018/06/14 19:59:18 martin Exp $"); #include #include @@ -286,6 +286,8 @@ workqueue_q_wait(struct workqueue_queue bool found = false; mutex_enter(>q_mutex); + if (q->q_worker == curlwp) + goto out; again: SIMPLEQ_FOREACH(wk, >q_queue_pending, wk_entry) { if (wk == wk_target) @@ -305,6 +307,7 @@ workqueue_q_wait(struct workqueue_queue } if (q->q_waiter != NULL) q->q_waiter = NULL; +out: mutex_exit(>q_mutex); return found;
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Thu Jun 14 19:59:18 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: subr_workqueue.c Log Message: Pull up following revision(s) (requested by ozaki-r in ticket #879): sys/kern/subr_workqueue.c: revision 1.37 Don't wait on workqueue_wait if called from worker itself Otherwise workqueue_wait never return in such a case. This treatment is the same as callout_halt. To generate a diff of this commit: cvs rdiff -u -r1.33.30.2 -r1.33.30.3 src/sys/kern/subr_workqueue.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/kern
Module Name:src Committed By: martin Date: Tue May 22 17:50:27 UTC 2018 Modified Files: src/sys/kern [netbsd-8]: uipc_mbuf.c Log Message: Pull up following revision(s) (requested by maxv in ticket #833): sys/kern/uipc_mbuf.c: revision 1.214 Revert my rev1.190, remove the M_READONLY check. The initial code was correct: what is read-only is the mbuf storage, not the mbuf itself. The storage contains the packet payload, and never has anything related to mbufs. So it is fine to remove M_PKTHDR on mbufs that have a read-only storage. In fact it was kind of obvious, since several places already manually remove M_PKTHDR without taking care of the external storage. To generate a diff of this commit: cvs rdiff -u -r1.172.6.4 -r1.172.6.5 src/sys/kern/uipc_mbuf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/uipc_mbuf.c diff -u src/sys/kern/uipc_mbuf.c:1.172.6.4 src/sys/kern/uipc_mbuf.c:1.172.6.5 --- src/sys/kern/uipc_mbuf.c:1.172.6.4 Sun May 6 09:20:43 2018 +++ src/sys/kern/uipc_mbuf.c Tue May 22 17:50:27 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_mbuf.c,v 1.172.6.4 2018/05/06 09:20:43 martin Exp $ */ +/* $NetBSD: uipc_mbuf.c,v 1.172.6.5 2018/05/22 17:50:27 martin Exp $ */ /*- * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.172.6.4 2018/05/06 09:20:43 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.172.6.5 2018/05/22 17:50:27 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_mbuftrace.h" @@ -460,11 +460,6 @@ m_pkthdr_remove(struct mbuf *m) { KASSERT(m->m_flags & M_PKTHDR); - if (M_READONLY(m)) { - /* Nothing we can do. */ - return; - } - m_tag_delete_chain(m, NULL); m->m_flags &= ~M_PKTHDR; memset(>m_pkthdr, 0, sizeof(m->m_pkthdr));