CVS commit: src/sys/dev/usb

2022-04-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Apr 19 01:35:28 UTC 2022

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

Log Message:
umcs(4): Avoid using uninitialized data if register read fails.

Reported-by: syzbot+511b32f415150b469...@syzkaller.appspotmail.com


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

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

Modified files:

Index: src/sys/dev/usb/umcs.c
diff -u src/sys/dev/usb/umcs.c:1.18 src/sys/dev/usb/umcs.c:1.19
--- src/sys/dev/usb/umcs.c:1.18	Wed Feb  9 07:32:33 2022
+++ src/sys/dev/usb/umcs.c	Tue Apr 19 01:35:28 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: umcs.c,v 1.18 2022/02/09 07:32:33 mrg Exp $ */
+/* $NetBSD: umcs.c,v 1.19 2022/04/19 01:35:28 riastradh Exp $ */
 /* $FreeBSD: head/sys/dev/usb/serial/umcs.c 260559 2014-01-12 11:44:28Z hselasky $ */
 
 /*-
@@ -41,7 +41,7 @@
  *
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umcs.c,v 1.18 2022/02/09 07:32:33 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umcs.c,v 1.19 2022/04/19 01:35:28 riastradh Exp $");
 
 #include 
 #include 
@@ -226,8 +226,8 @@ umcs7840_attach(device_t parent, device_
 	 *
 	 * Also, see notes in header file for these constants.
 	 */
-	umcs7840_get_reg(sc, MCS7840_DEV_REG_GPIO, );
-	if (data & MCS7840_DEV_GPIO_4PORTS) {
+	error = umcs7840_get_reg(sc, MCS7840_DEV_REG_GPIO, );
+	if (error == 0 && (data & MCS7840_DEV_GPIO_4PORTS) != 0) {
 		sc->sc_numports = 4;
 		/* physical port no are : 0, 1, 2, 3 */
 	} else {



CVS commit: src/sys/dev/usb

2022-04-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Apr 19 01:35:28 UTC 2022

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

Log Message:
umcs(4): Avoid using uninitialized data if register read fails.

Reported-by: syzbot+511b32f415150b469...@syzkaller.appspotmail.com


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

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



CVS commit: src/sys/uvm

2022-04-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Apr 19 01:34:52 UTC 2022

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

Log Message:
mmap(2): If we fail with a hint, try again without it.

`Hint' here means nonzero addr, but no MAP_FIXED or MAP_TRYFIXED.

This is suboptimal -- we could teach uvm_mmap to do a fancier search
using the address as a hint.  But this should do for now.

Candidate fix for PR kern/55533.

ok chs@


To generate a diff of this commit:
cvs rdiff -u -r1.177 -r1.178 src/sys/uvm/uvm_mmap.c

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



CVS commit: src/sys/uvm

2022-04-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Apr 19 01:34:52 UTC 2022

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

Log Message:
mmap(2): If we fail with a hint, try again without it.

`Hint' here means nonzero addr, but no MAP_FIXED or MAP_TRYFIXED.

This is suboptimal -- we could teach uvm_mmap to do a fancier search
using the address as a hint.  But this should do for now.

Candidate fix for PR kern/55533.

ok chs@


To generate a diff of this commit:
cvs rdiff -u -r1.177 -r1.178 src/sys/uvm/uvm_mmap.c

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

Modified files:

Index: src/sys/uvm/uvm_mmap.c
diff -u src/sys/uvm/uvm_mmap.c:1.177 src/sys/uvm/uvm_mmap.c:1.178
--- src/sys/uvm/uvm_mmap.c:1.177	Sun Mar 27 20:18:05 2022
+++ src/sys/uvm/uvm_mmap.c	Tue Apr 19 01:34:52 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_mmap.c,v 1.177 2022/03/27 20:18:05 hannken Exp $	*/
+/*	$NetBSD: uvm_mmap.c,v 1.178 2022/04/19 01:34:52 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -46,7 +46,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_mmap.c,v 1.177 2022/03/27 20:18:05 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_mmap.c,v 1.178 2022/04/19 01:34:52 riastradh Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_pax.h"
@@ -277,7 +277,8 @@ sys_mmap(struct lwp *l, const struct sys
 	vsize_t size, pageoff, newsize;
 	vm_prot_t prot, maxprot, extraprot;
 	int flags, fd, advice;
-	vaddr_t defaddr;
+	vaddr_t defaddr = 0;	/* XXXGCC */
+	bool addrhint = false;
 	struct file *fp = NULL;
 	struct uvm_object *uobj;
 	int error;
@@ -349,6 +350,12 @@ sys_mmap(struct lwp *l, const struct sys
 			addr = MAX(addr, defaddr);
 		else
 			addr = MIN(addr, defaddr);
+
+		/*
+		 * If addr is nonzero and not the default, then the
+		 * address is a hint.
+		 */
+		addrhint = (addr != 0 && addr != defaddr);
 	}
 
 	/*
@@ -401,10 +408,21 @@ sys_mmap(struct lwp *l, const struct sys
 	/*
 	 * now let kernel internal function uvm_mmap do the work.
 	 */
-
 	error = uvm_mmap(>p_vmspace->vm_map, , size, prot, maxprot,
 	flags, advice, uobj, pos, p->p_rlimit[RLIMIT_MEMLOCK].rlim_cur);
 
+	/*
+	 * If the user provided a hint, and we couldn't satisfy that
+	 * hint, try again with the default address.
+	 */
+	if (error && addrhint) {
+		addr = defaddr;
+		pax_aslr_mmap(l, , orig_addr, flags);
+		error = uvm_mmap(>p_vmspace->vm_map, , size, prot,
+		maxprot, flags, advice, uobj, pos,
+		p->p_rlimit[RLIMIT_MEMLOCK].rlim_cur);
+	}
+
 	/* remember to add offset */
 	*retval = (register_t)(addr + pageoff);
 



CVS commit: src/tools

2022-04-18 Thread Joseph Koshy
Module Name:src
Committed By:   jkoshy
Date:   Mon Apr 18 19:46:35 UTC 2022

Modified Files:
src/tools: Makefile

Log Message:
Disconnect 'tools/lib{elf,dwarf}' from the build.

These libraries are now built by 'tools/elftoolchain/lib{elf,dwarf}'
respectively.


To generate a diff of this commit:
cvs rdiff -u -r1.213 -r1.214 src/tools/Makefile

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



CVS commit: src/tools

2022-04-18 Thread Joseph Koshy
Module Name:src
Committed By:   jkoshy
Date:   Mon Apr 18 19:46:35 UTC 2022

Modified Files:
src/tools: Makefile

Log Message:
Disconnect 'tools/lib{elf,dwarf}' from the build.

These libraries are now built by 'tools/elftoolchain/lib{elf,dwarf}'
respectively.


To generate a diff of this commit:
cvs rdiff -u -r1.213 -r1.214 src/tools/Makefile

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

Modified files:

Index: src/tools/Makefile
diff -u src/tools/Makefile:1.213 src/tools/Makefile:1.214
--- src/tools/Makefile:1.213	Wed Apr 13 17:52:56 2022
+++ src/tools/Makefile	Mon Apr 18 19:46:35 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.213 2022/04/13 17:52:56 jkoshy Exp $
+#	$NetBSD: Makefile,v 1.214 2022/04/18 19:46:35 jkoshy Exp $
 
 .include 
 .include 
@@ -59,8 +59,6 @@ TOOLCHAIN_BITS+= dbsym mdsetimage
 DTRACE_BITS=
 .if ${MKDTRACE} != "no" || ${MKCTF} != "no"
 DTRACE_BITS+= .WAIT elftoolchain
-DTRACE_BITS+= .WAIT libelf
-DTRACE_BITS+= .WAIT libdwarf
 DTRACE_BITS+= .WAIT libctf
 .endif
 .if ${MKCTF} != "no"



CVS commit: src/tools

2022-04-18 Thread Joseph Koshy
Module Name:src
Committed By:   jkoshy
Date:   Mon Apr 18 19:40:07 UTC 2022

Modified Files:
src/tools/ctfconvert: Makefile
src/tools/ctfmerge: Makefile

Log Message:
Update 'tools/ctf{merge,convert}' to use the new build locations for
'libelf' and 'libdwarf'.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tools/ctfconvert/Makefile
cvs rdiff -u -r1.10 -r1.11 src/tools/ctfmerge/Makefile

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

Modified files:

Index: src/tools/ctfconvert/Makefile
diff -u src/tools/ctfconvert/Makefile:1.9 src/tools/ctfconvert/Makefile:1.10
--- src/tools/ctfconvert/Makefile:1.9	Tue May  1 19:59:46 2018
+++ src/tools/ctfconvert/Makefile	Mon Apr 18 19:40:06 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.9 2018/05/01 19:59:46 christos Exp $
+#	$NetBSD: Makefile,v 1.10 2022/04/18 19:40:06 jkoshy Exp $
 
 .include 
 
@@ -45,8 +45,8 @@ OSNETDIR=	${.CURDIR}/../../external/cddl
 OPENSOLARIS_DISTDIR= ${OSNETDIR}/dist
 
 CTFOBJ!=	cd ${.CURDIR}/../libctf && ${PRINTOBJDIR}
-DWARFOBJ!=	cd ${.CURDIR}/../libdwarf && ${PRINTOBJDIR}
-ELFOBJ!=	cd ${.CURDIR}/../libelf && ${PRINTOBJDIR}
+DWARFOBJ!=	cd ${.CURDIR}/../elftoolchain/libdwarf && ${PRINTOBJDIR}
+ELFOBJ!=	cd ${.CURDIR}/../elftoolchain/libelf && ${PRINTOBJDIR}
 LDADD+=		-L${CTFOBJ} -lctf
 DPADD+=		${CTFOBJ}/libctf.a
 LDADD+=		-L${DWARFOBJ} -ldwarf

Index: src/tools/ctfmerge/Makefile
diff -u src/tools/ctfmerge/Makefile:1.10 src/tools/ctfmerge/Makefile:1.11
--- src/tools/ctfmerge/Makefile:1.10	Tue May  1 19:59:46 2018
+++ src/tools/ctfmerge/Makefile	Mon Apr 18 19:40:06 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.10 2018/05/01 19:59:46 christos Exp $
+#	$NetBSD: Makefile,v 1.11 2022/04/18 19:40:06 jkoshy Exp $
 
 .include 
 
@@ -25,8 +25,8 @@ OSNETDIR=	${.CURDIR}/../../external/cddl
 OPENSOLARIS_DISTDIR= ${OSNETDIR}/dist
 
 CTFOBJ!=	cd ${.CURDIR}/../libctf && ${PRINTOBJDIR}
-DWARFOBJ!=	cd ${.CURDIR}/../libdwarf && ${PRINTOBJDIR}
-ELFOBJ!=	cd ${.CURDIR}/../libelf && ${PRINTOBJDIR}
+DWARFOBJ!=	cd ${.CURDIR}/../elftoolchain/libdwarf && ${PRINTOBJDIR}
+ELFOBJ!=	cd ${.CURDIR}/../elftoolchain/libelf && ${PRINTOBJDIR}
 LDADD+=		-L${CTFOBJ} -lctf
 LDADD+=		-L${DWARFOBJ} -ldwarf
 LDADD+=		-L${ELFOBJ} -lelf



CVS commit: src/tools

2022-04-18 Thread Joseph Koshy
Module Name:src
Committed By:   jkoshy
Date:   Mon Apr 18 19:40:07 UTC 2022

Modified Files:
src/tools/ctfconvert: Makefile
src/tools/ctfmerge: Makefile

Log Message:
Update 'tools/ctf{merge,convert}' to use the new build locations for
'libelf' and 'libdwarf'.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tools/ctfconvert/Makefile
cvs rdiff -u -r1.10 -r1.11 src/tools/ctfmerge/Makefile

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



CVS commit: src/usr.bin/make

2022-04-18 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Mon Apr 18 16:09:05 UTC 2022

Modified Files:
src/usr.bin/make: parse.c

Log Message:
Comment on interaction of posix.mk with[out] -r


To generate a diff of this commit:
cvs rdiff -u -r1.669 -r1.670 src/usr.bin/make/parse.c

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



CVS commit: src/usr.bin/make

2022-04-18 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Mon Apr 18 16:09:05 UTC 2022

Modified Files:
src/usr.bin/make: parse.c

Log Message:
Comment on interaction of posix.mk with[out] -r


To generate a diff of this commit:
cvs rdiff -u -r1.669 -r1.670 src/usr.bin/make/parse.c

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

Modified files:

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.669 src/usr.bin/make/parse.c:1.670
--- src/usr.bin/make/parse.c:1.669	Mon Apr 18 15:06:27 2022
+++ src/usr.bin/make/parse.c	Mon Apr 18 16:09:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.669 2022/04/18 15:06:27 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.670 2022/04/18 16:09:05 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.669 2022/04/18 15:06:27 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.670 2022/04/18 16:09:05 sjg Exp $");
 
 /*
  * A file being read.
@@ -1254,6 +1254,11 @@ HandleDependencySourcesEmpty(ParseSpecia
 #ifdef POSIX
 	case SP_POSIX:
 		if (posix_state == PS_NOW_OR_NEVER) {
+			/*
+			 * With '-r', 'posix.mk' (if it exists)
+			 * can effectively substitute for 'sys.mk',
+			 * otherwise it is an extension.
+			 */
 			Global_Set("%POSIX", "1003.2");
 			IncludeFile("posix.mk", true, false, true);
 		}



CVS commit: src/usr.bin/make/unit-tests

2022-04-18 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Mon Apr 18 15:59:39 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: deptgt-posix.mk

Log Message:
Never 'rm -rf ${TMPDIR}' when you cannot be sure what it is

Use a safer variable for a subdir of ${TMPDIR} that we know
we can remove safely.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/deptgt-posix.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/deptgt-posix.mk
diff -u src/usr.bin/make/unit-tests/deptgt-posix.mk:1.1 src/usr.bin/make/unit-tests/deptgt-posix.mk:1.2
--- src/usr.bin/make/unit-tests/deptgt-posix.mk:1.1	Mon Apr 18 15:06:28 2022
+++ src/usr.bin/make/unit-tests/deptgt-posix.mk	Mon Apr 18 15:59:39 2022
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt-posix.mk,v 1.1 2022/04/18 15:06:28 rillig Exp $
+# $NetBSD: deptgt-posix.mk,v 1.2 2022/04/18 15:59:39 sjg Exp $
 #
 # Tests for the special target '.POSIX', which enables POSIX mode.
 #
@@ -15,10 +15,10 @@
 # See also:
 #	https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html
 
-TMPDIR?=	/tmp/make.test.deptgt-posix
-SYSDIR=		${TMPDIR}/sysdir
-MAIN_MK=	${TMPDIR}/main.mk
-INCLUDED_MK=	${TMPDIR}/included.mk
+TESTTMP=	${TMPDIR:U/tmp}/make.test.deptgt-posix
+SYSDIR=		${TESTTMP}/sysdir
+MAIN_MK=	${TESTTMP}/main.mk
+INCLUDED_MK=	${TESTTMP}/included.mk
 
 all: .PHONY
 .SILENT:
@@ -58,9 +58,9 @@ check-not-seen-sys-mk: .USE
 	'.endif'
 
 run: .USE
-	(cd "${TMPDIR}" && MAKEFLAGS=${MAKEFLAGS.${.TARGET}:Q} ${MAKE} \
+	(cd "${TESTTMP}" && MAKEFLAGS=${MAKEFLAGS.${.TARGET}:Q} ${MAKE} \
 	-m "${SYSDIR}" -f ${MAIN_MK:T})
-	rm -rf ${TMPDIR}
+	rm -rf ${TESTTMP}
 
 # If the main makefile has a '.for' loop as its first non-comment line, a
 # strict reading of POSIX 2018 makes the makefile non-conforming.



CVS commit: src/usr.bin/make/unit-tests

2022-04-18 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Mon Apr 18 15:59:39 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: deptgt-posix.mk

Log Message:
Never 'rm -rf ${TMPDIR}' when you cannot be sure what it is

Use a safer variable for a subdir of ${TMPDIR} that we know
we can remove safely.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/deptgt-posix.mk

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



CVS commit: src

2022-04-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr 18 15:06:28 UTC 2022

Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make: main.c make.1 make.h parse.c
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: deptgt-posix.exp deptgt-posix.mk

Log Message:
make: only switch to POSIX mode if '.POSIX:' is the first line

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html
says that in order to make a makefile POSIX-conforming, its first
non-comment line must be the special dependency line '.POSIX:' without
any source dependencies.

Previously, make switched to POSIX mode even if such a line occurred
anywhere else, which was allowed by POSIX but was deep in the
"unspecified behavior" area.  For NetBSD make, there is no big
difference since it doesn't ship any  file, this change mainly
affects the bmake distribution.

Previously, makefiles that contain '.POSIX:' somewhere in the middle
could fail due to  resetting .SUFFIXES, among other things.

Suggested by Simon J. Gerraty, who also reviewed an earlier version of
this change.


To generate a diff of this commit:
cvs rdiff -u -r1.1192 -r1.1193 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.579 -r1.580 src/usr.bin/make/main.c
cvs rdiff -u -r1.307 -r1.308 src/usr.bin/make/make.1
cvs rdiff -u -r1.299 -r1.300 src/usr.bin/make/make.h
cvs rdiff -u -r1.668 -r1.669 src/usr.bin/make/parse.c
cvs rdiff -u -r1.311 -r1.312 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/deptgt-posix.exp \
src/usr.bin/make/unit-tests/deptgt-posix.mk

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



CVS commit: src

2022-04-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr 18 15:06:28 UTC 2022

Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make: main.c make.1 make.h parse.c
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: deptgt-posix.exp deptgt-posix.mk

Log Message:
make: only switch to POSIX mode if '.POSIX:' is the first line

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html
says that in order to make a makefile POSIX-conforming, its first
non-comment line must be the special dependency line '.POSIX:' without
any source dependencies.

Previously, make switched to POSIX mode even if such a line occurred
anywhere else, which was allowed by POSIX but was deep in the
"unspecified behavior" area.  For NetBSD make, there is no big
difference since it doesn't ship any  file, this change mainly
affects the bmake distribution.

Previously, makefiles that contain '.POSIX:' somewhere in the middle
could fail due to  resetting .SUFFIXES, among other things.

Suggested by Simon J. Gerraty, who also reviewed an earlier version of
this change.


To generate a diff of this commit:
cvs rdiff -u -r1.1192 -r1.1193 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.579 -r1.580 src/usr.bin/make/main.c
cvs rdiff -u -r1.307 -r1.308 src/usr.bin/make/make.1
cvs rdiff -u -r1.299 -r1.300 src/usr.bin/make/make.h
cvs rdiff -u -r1.668 -r1.669 src/usr.bin/make/parse.c
cvs rdiff -u -r1.311 -r1.312 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/deptgt-posix.exp \
src/usr.bin/make/unit-tests/deptgt-posix.mk

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1192 src/distrib/sets/lists/tests/mi:1.1193
--- src/distrib/sets/lists/tests/mi:1.1192	Fri Apr  8 23:35:52 2022
+++ src/distrib/sets/lists/tests/mi	Mon Apr 18 15:06:27 2022
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1192 2022/04/08 23:35:52 riastradh Exp $
+# $NetBSD: mi,v 1.1193 2022/04/18 15:06:27 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5565,6 +5565,8 @@
 ./usr/tests/usr.bin/make/unit-tests/deptgt-path.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/deptgt-phony.exptests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/deptgt-phony.mktests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/deptgt-posix.exptests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/deptgt-posix.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/deptgt-precious.exptests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/deptgt-precious.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/deptgt-shell.exptests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.579 src/usr.bin/make/main.c:1.580
--- src/usr.bin/make/main.c:1.579	Tue Mar 22 23:37:09 2022
+++ src/usr.bin/make/main.c	Mon Apr 18 15:06:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.579 2022/03/22 23:37:09 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.580 2022/04/18 15:06:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.579 2022/03/22 23:37:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.580 2022/04/18 15:06:27 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -1480,6 +1480,7 @@ main_ReadFiles(void)
 	if (!opts.noBuiltins)
 		ReadBuiltinRules();
 
+	posix_state = PS_MAYBE_NEXT_LINE;
 	if (!Lst_IsEmpty())
 		ReadAllMakefiles();
 	else

Index: src/usr.bin/make/make.1
diff -u src/usr.bin/make/make.1:1.307 src/usr.bin/make/make.1:1.308
--- src/usr.bin/make/make.1:1.307	Sat Mar 26 15:39:58 2022
+++ src/usr.bin/make/make.1	Mon Apr 18 15:06:27 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.307 2022/03/26 15:39:58 sjg Exp $
+.\"	$NetBSD: make.1,v 1.308 2022/04/18 15:06:27 rillig Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
 .\"
-.Dd March 24, 2022
+.Dd April 18, 2022
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -2290,17 +2290,15 @@ Apply the
 .Ic .PHONY
 attribute to any specified sources.
 .It Ic .POSIX
-This should be the first non-comment line in a Makefile.
-It results in the variable
+If this is the first non-comment line in the main makefile,
+the variable
 .Va %POSIX
-being defined with the value
-.Ql 1003.2 .
-The first time
-.Ic .POSIX
-is encountered, the makefile
-.Ql posix.mk
-will be 

CVS commit: src/usr.bin/make/unit-tests

2022-04-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr 18 14:41:42 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: depsrc-usebefore.mk

Log Message:
tests/make: refine documentation of test for .USEBEFORE


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/depsrc-usebefore.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/depsrc-usebefore.mk
diff -u src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.8 src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.9
--- src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.8	Mon Apr 18 14:38:24 2022
+++ src/usr.bin/make/unit-tests/depsrc-usebefore.mk	Mon Apr 18 14:41:42 2022
@@ -1,11 +1,13 @@
-# $NetBSD: depsrc-usebefore.mk,v 1.8 2022/04/18 14:38:24 rillig Exp $
+# $NetBSD: depsrc-usebefore.mk,v 1.9 2022/04/18 14:41:42 rillig Exp $
 #
 # Tests for the special source .USEBEFORE in dependency declarations,
 # which allows to prepend common commands to other targets.
 #
-# If a target depends on several .USE or .USEBEFORE targets, the commands get
-# appended in declaration order.  For .USE targets, this is the expected
-# order, for .USEBEFORE targets the order is somewhat reversed.
+# If a target depends on several .USE or .USEBEFORE nodes, the commands get
+# appended or prepended in declaration order.  For .USE nodes, this is the
+# expected order, for .USEBEFORE nodes the order is somewhat reversed, and for
+# .USE or .USEBEFORE nodes that depend on other .USE or .USEBEFORE nodes, it
+# gets even more complicated.
 #
 # See also:
 #	.USE



CVS commit: src/usr.bin/make/unit-tests

2022-04-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr 18 14:41:42 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: depsrc-usebefore.mk

Log Message:
tests/make: refine documentation of test for .USEBEFORE


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/depsrc-usebefore.mk

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



CVS commit: src/usr.bin/make/unit-tests

2022-04-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr 18 14:38:24 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: depsrc-use.exp depsrc-use.mk
depsrc-usebefore.exp depsrc-usebefore.mk

Log Message:
tests/make: extend tests for .USE and .USEBEFORE


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/depsrc-use.exp \
src/usr.bin/make/unit-tests/depsrc-usebefore.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/depsrc-use.mk
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/depsrc-usebefore.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/depsrc-use.exp
diff -u src/usr.bin/make/unit-tests/depsrc-use.exp:1.3 src/usr.bin/make/unit-tests/depsrc-use.exp:1.4
--- src/usr.bin/make/unit-tests/depsrc-use.exp:1.3	Sat Aug 22 12:30:57 2020
+++ src/usr.bin/make/unit-tests/depsrc-use.exp	Mon Apr 18 14:38:24 2022
@@ -2,5 +2,9 @@ first 1
 first 2
 second 1
 second 2
+first-first 1
+first-first 2
+first-second 1
+first-second 2
 directly
 exit status 0
Index: src/usr.bin/make/unit-tests/depsrc-usebefore.exp
diff -u src/usr.bin/make/unit-tests/depsrc-usebefore.exp:1.3 src/usr.bin/make/unit-tests/depsrc-usebefore.exp:1.4
--- src/usr.bin/make/unit-tests/depsrc-usebefore.exp:1.3	Sat Aug 22 11:53:18 2020
+++ src/usr.bin/make/unit-tests/depsrc-usebefore.exp	Mon Apr 18 14:38:24 2022
@@ -1,6 +1,42 @@
-first 1
-first 2
-second 1
-second 2
-directly
+after-2-before-2 1
+after-2-before-2 2
+after-2-before-1 1
+after-2-before-1 2
+after-1-before-2 1
+after-1-before-2 2
+after-1-before-1 1
+after-1-before-1 2
+before-2-before-2 1
+before-2-before-2 2
+before-2-before-1 1
+before-2-before-1 2
+before-1-before-2 1
+before-1-before-2 2
+before-1-before-1 1
+before-1-before-1 2
+before-2 1
+before-2 2
+before-1 1
+before-1 2
+after-1 1
+after-1 2
+after-2 1
+after-2 2
+before-1-after-1 1
+before-1-after-1 2
+before-1-after-2 1
+before-1-after-2 2
+before-2-after-1 1
+before-2-after-1 2
+before-2-after-2 1
+before-2-after-2 2
+after-1-after-1 1
+after-1-after-1 2
+after-1-after-2 1
+after-1-after-2 2
+after-2-after-1 1
+after-2-after-1 2
+after-2-after-2 1
+after-2-after-2 2
+`directly' is up to date.
 exit status 0

Index: src/usr.bin/make/unit-tests/depsrc-use.mk
diff -u src/usr.bin/make/unit-tests/depsrc-use.mk:1.5 src/usr.bin/make/unit-tests/depsrc-use.mk:1.6
--- src/usr.bin/make/unit-tests/depsrc-use.mk:1.5	Tue Dec 28 14:22:51 2021
+++ src/usr.bin/make/unit-tests/depsrc-use.mk	Mon Apr 18 14:38:24 2022
@@ -1,7 +1,11 @@
-# $NetBSD: depsrc-use.mk,v 1.5 2021/12/28 14:22:51 rillig Exp $
+# $NetBSD: depsrc-use.mk,v 1.6 2022/04/18 14:38:24 rillig Exp $
 #
 # Tests for the special source .USE in dependency declarations,
 # which allows to append common commands to other targets.
+#
+# See also:
+#	.USEBEFORE
+#	depsrc-usebefore.mk
 
 # Before make.h 1.280 from 2021-12-28, a .USEBEFORE target was accidentally
 # regarded as a candidate for the main target.  On the other hand, a .USE
@@ -10,9 +14,15 @@ not-a-main-candidate: .USE
 
 all: action directly
 
-first: .USE
+first: .USE first-first first-second
 	@echo first 1		# Using ${.TARGET} here would expand to "action"
 	@echo first 2
+first-first: .USE
+	@echo first-first 1
+	@echo first-first 2
+first-second: .USE
+	@echo first-second 1
+	@echo first-second 2
 
 second: .USE
 	@echo second 1
@@ -22,7 +32,7 @@ second: .USE
 # This may happen as the result of expanding a .for loop.
 empty: .USE
 
-# It's possible but uncommon to directly make a .USEBEFORE target.
+# It's possible but uncommon to directly make a .USE target.
 directly: .USE
 	@echo directly
 

Index: src/usr.bin/make/unit-tests/depsrc-usebefore.mk
diff -u src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.7 src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.8
--- src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.7	Tue Dec 28 14:22:51 2021
+++ src/usr.bin/make/unit-tests/depsrc-usebefore.mk	Mon Apr 18 14:38:24 2022
@@ -1,8 +1,12 @@
-# $NetBSD: depsrc-usebefore.mk,v 1.7 2021/12/28 14:22:51 rillig Exp $
+# $NetBSD: depsrc-usebefore.mk,v 1.8 2022/04/18 14:38:24 rillig Exp $
 #
 # Tests for the special source .USEBEFORE in dependency declarations,
 # which allows to prepend common commands to other targets.
 #
+# If a target depends on several .USE or .USEBEFORE targets, the commands get
+# appended in declaration order.  For .USE targets, this is the expected
+# order, for .USEBEFORE targets the order is somewhat reversed.
+#
 # See also:
 #	.USE
 #	depsrc-use.mk
@@ -12,22 +16,98 @@
 # target was not.
 not-a-main-candidate: .USEBEFORE
 
-all: action directly
-
-first: .USEBEFORE
-	@echo first 1		# Using ${.TARGET} here would expand to "action"
-	@echo first 2		# Using ${.TARGET} here would expand to "action"
-
-second: .USEBEFORE
-	@echo second 1
-	@echo second 2
+all:
+	@${MAKE} -r -f ${MAKEFILE} ordering
+	@${MAKE} -r -f 

CVS commit: src/usr.bin/make/unit-tests

2022-04-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr 18 14:38:24 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: depsrc-use.exp depsrc-use.mk
depsrc-usebefore.exp depsrc-usebefore.mk

Log Message:
tests/make: extend tests for .USE and .USEBEFORE


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/depsrc-use.exp \
src/usr.bin/make/unit-tests/depsrc-usebefore.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/depsrc-use.mk
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/depsrc-usebefore.mk

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



CVS commit: src/tools/elftoolchain

2022-04-18 Thread Joseph Koshy
Module Name:src
Committed By:   jkoshy
Date:   Mon Apr 18 14:11:44 UTC 2022

Modified Files:
src/tools/elftoolchain: Makefile
Added Files:
src/tools/elftoolchain/libdwarf: Makefile
src/tools/elftoolchain/libelf: Makefile

Log Message:
Build 'libelf' and 'libdwarf' under 'tools/elftoolchain', after
'tools/elftoolchain/common' has been built.

This change aligns the 'tools' build with the regular build.

Subsequent commits will change 'tools/libctf' and
'tools/cft{merge,convert}' to use the new build paths.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tools/elftoolchain/Makefile
cvs rdiff -u -r0 -r1.1 src/tools/elftoolchain/libdwarf/Makefile
cvs rdiff -u -r0 -r1.1 src/tools/elftoolchain/libelf/Makefile

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

Modified files:

Index: src/tools/elftoolchain/Makefile
diff -u src/tools/elftoolchain/Makefile:1.1 src/tools/elftoolchain/Makefile:1.2
--- src/tools/elftoolchain/Makefile:1.1	Wed Apr 13 17:52:56 2022
+++ src/tools/elftoolchain/Makefile	Mon Apr 18 14:11:43 2022
@@ -1,5 +1,7 @@
-# $NetBSD: Makefile,v 1.1 2022/04/13 17:52:56 jkoshy Exp $
+# $NetBSD: Makefile,v 1.2 2022/04/18 14:11:43 jkoshy Exp $
 
 SUBDIR= common
+SUBDIR+= .WAIT libelf
+SUBDIR+= .WAIT libdwarf
 
 .include 

Added files:

Index: src/tools/elftoolchain/libdwarf/Makefile
diff -u /dev/null src/tools/elftoolchain/libdwarf/Makefile:1.1
--- /dev/null	Mon Apr 18 14:11:44 2022
+++ src/tools/elftoolchain/libdwarf/Makefile	Mon Apr 18 14:11:43 2022
@@ -0,0 +1,96 @@
+#	$NetBSD: Makefile,v 1.1 2022/04/18 14:11:43 jkoshy Exp $
+
+HOSTLIB=dwarf
+
+.include 
+
+SRCS= \
+	dwarf_abbrev.c	\
+	dwarf_arange.c	\
+	dwarf_attr.c	\
+	dwarf_attrval.c	\
+	dwarf_cu.c	\
+	dwarf_dealloc.c	\
+	dwarf_die.c	\
+	dwarf_dump.c	\
+	dwarf_errmsg.c	\
+	dwarf_finish.c	\
+	dwarf_form.c	\
+	dwarf_frame.c	\
+	dwarf_init.c	\
+	dwarf_lineno.c	\
+	dwarf_loclist.c	\
+	dwarf_macinfo.c	\
+	dwarf_pro_arange.c	\
+	dwarf_pro_attr.c	\
+	dwarf_pro_die.c	\
+	dwarf_pro_expr.c	\
+	dwarf_pro_finish.c	\
+	dwarf_pro_frame.c	\
+	dwarf_pro_init.c	\
+	dwarf_pro_lineno.c	\
+	dwarf_pro_macinfo.c	\
+	dwarf_pro_reloc.c	\
+	dwarf_pro_sections.c	\
+	dwarf_ranges.c	\
+	dwarf_reloc.c	\
+	dwarf_seterror.c	\
+	dwarf_str.c	\
+	libdwarf.c	\
+	libdwarf_abbrev.c	\
+	libdwarf_arange.c	\
+	libdwarf_attr.c	\
+	libdwarf_die.c	\
+	libdwarf_elf_access.c	\
+	libdwarf_elf_init.c	\
+	libdwarf_error.c	\
+	libdwarf_frame.c	\
+	libdwarf_info.c	\
+	libdwarf_init.c	\
+	libdwarf_lineno.c	\
+	libdwarf_loc.c	\
+	libdwarf_loclist.c	\
+	libdwarf_macinfo.c	\
+	libdwarf_nametbl.c	\
+	libdwarf_ranges.c	\
+	libdwarf_reloc.c	\
+	libdwarf_rw.c	\
+	libdwarf_sections.c	\
+	libdwarf_str.c
+
+ELFTOOLCHAIN_DIR=${.CURDIR}/../../../external/bsd/elftoolchain/dist
+LIBDWARF_DIR=	${ELFTOOLCHAIN_DIR}/libdwarf
+LIBELF_DIR=	${ELFTOOLCHAIN_DIR}/libelf
+COMMON_DIR=	${ELFTOOLCHAIN_DIR}/common
+
+INCS=		dwarf.h libdwarf.h
+INCSDIR=	/usr/include
+
+.ifndef NOCOMPATLIB
+COMPATLIB_NO_LIB= yes # only the include files, not the library
+.-include	"${TOOLDIR}/share/compat/defs.mk"
+.endif
+
+CPPFLAGS+=	-I${.CURDIR}/../../compat
+CPPFLAGS+=	-I${.CURDIR}/../../common
+CPPFLAGS+=	-I${LIBDWARF_DIR} -I${LIBELF_DIR} -I${COMMON_DIR}
+CPPFLAGS+=	-I${TOOLDIR}/include -I${TOOLDIR}/include/nbinclude
+
+BUILD_OSTYPE!=  uname -s
+
+# Disable use of pre-compiled headers on Darwin.
+.if ${BUILD_OSTYPE} == "Darwin"
+CPPFLAGS+=	-no-cpp-precomp
+.endif
+
+# -D_FILE_OFFSET_BITS=64 produces a much more amenable `struct stat', and
+# other file ops, on many systems, without changing function names.
+
+CPPFLAGS+=	-DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64
+
+.PATH:		${LIBDWARF_DIR}
+
+HOST_CPPFLAGS:=	${CPPFLAGS} ${HOST_CPPFLAGS}
+CPPFLAGS:=	# empty
+
+.include 

Index: src/tools/elftoolchain/libelf/Makefile
diff -u /dev/null src/tools/elftoolchain/libelf/Makefile:1.1
--- /dev/null	Mon Apr 18 14:11:44 2022
+++ src/tools/elftoolchain/libelf/Makefile	Mon Apr 18 14:11:44 2022
@@ -0,0 +1,91 @@
+#	$NetBSD: Makefile,v 1.1 2022/04/18 14:11:44 jkoshy Exp $
+
+HOSTLIB=	elf
+
+.include 
+
+SRCS=		elf_begin.c		\
+		elf_cntl.c		\
+		elf_end.c elf_errmsg.c elf_errno.c			\
+		elf_data.c		\
+		elf_fill.c elf_flag.c	\
+		elf_getarhdr.c elf_getarsym.c elf_getbase.c		\
+		elf_getident.c	\
+		elf_hash.c		\
+		elf_kind.c		\
+		elf_memory.c		\
+		elf_next.c		\
+		elf_rand.c elf_rawfile.c\
+		elf_phnum.c		\
+		elf_shnum.c elf_shstrndx.c elf_scn.c elf_strptr.c	\
+		elf_update.c		\
+		elf_version.c		\
+		gelf_cap.c		\
+		gelf_checksum.c		\
+		gelf_dyn.c		\
+		gelf_ehdr.c		\
+		gelf_getclass.c		\
+		gelf_fsize.c		\
+		gelf_move.c		\
+		gelf_phdr.c		\
+		gelf_rel.c gelf_rela.c	\
+		gelf_shdr.c gelf_sym.c gelf_syminfo.c gelf_symshndx.c	\
+		gelf_xlate.c		\
+		elf.c			\
+		libelf_align.c libelf_allocate.c libelf_ar.c		\
+		libelf_ar_util.c	\
+	

CVS commit: src/tools/elftoolchain

2022-04-18 Thread Joseph Koshy
Module Name:src
Committed By:   jkoshy
Date:   Mon Apr 18 14:11:44 UTC 2022

Modified Files:
src/tools/elftoolchain: Makefile
Added Files:
src/tools/elftoolchain/libdwarf: Makefile
src/tools/elftoolchain/libelf: Makefile

Log Message:
Build 'libelf' and 'libdwarf' under 'tools/elftoolchain', after
'tools/elftoolchain/common' has been built.

This change aligns the 'tools' build with the regular build.

Subsequent commits will change 'tools/libctf' and
'tools/cft{merge,convert}' to use the new build paths.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tools/elftoolchain/Makefile
cvs rdiff -u -r0 -r1.1 src/tools/elftoolchain/libdwarf/Makefile
cvs rdiff -u -r0 -r1.1 src/tools/elftoolchain/libelf/Makefile

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



CVS commit: [netbsd-9] src/doc

2022-04-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr 18 10:57:05 UTC 2022

Modified Files:
src/doc [netbsd-9]: CHANGES-9.3

Log Message:
Ticket #1437


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.83 -r1.1.2.84 src/doc/CHANGES-9.3

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



CVS commit: [netbsd-9] src/doc

2022-04-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr 18 10:57:05 UTC 2022

Modified Files:
src/doc [netbsd-9]: CHANGES-9.3

Log Message:
Ticket #1437


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.83 -r1.1.2.84 src/doc/CHANGES-9.3

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

Modified files:

Index: src/doc/CHANGES-9.3
diff -u src/doc/CHANGES-9.3:1.1.2.83 src/doc/CHANGES-9.3:1.1.2.84
--- src/doc/CHANGES-9.3:1.1.2.83	Wed Apr 13 03:39:58 2022
+++ src/doc/CHANGES-9.3	Mon Apr 18 10:57:05 2022
@@ -1,4 +1,4 @@
-29~# $NetBSD: CHANGES-9.3,v 1.1.2.83 2022/04/13 03:39:58 snj Exp $
+# $NetBSD: CHANGES-9.3,v 1.1.2.84 2022/04/18 10:57:05 martin Exp $
 
 A complete list of changes from the NetBSD 9.2 release to the NetBSD 9.3
 release:
@@ -1535,3 +1535,8 @@ distrib/amd64/ramdisks/common/list.ramdi
 	Add missing EFI bootloaders to the install kernel ramdisk.
 	[martin, ticket #1436]
 
+sys/fs/udf/udf_allocation.c			1.46
+
+	Avoid a race introduced with ticket #1431.
+	[reinoud, ticket #1437]
+



CVS commit: [netbsd-9] src/sys/fs/udf

2022-04-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr 18 10:54:21 UTC 2022

Modified Files:
src/sys/fs/udf [netbsd-9]: udf_allocation.c

Log Message:
Pull up following revision(s) (requested by reinoud in ticket #1437):

sys/fs/udf/udf_allocation.c: revision 1.46

Revere modification of initializer; it can lead to race conditions where two
allocation would pick the `empty' space causing a panic later on.


To generate a diff of this commit:
cvs rdiff -u -r1.40.4.1 -r1.40.4.2 src/sys/fs/udf/udf_allocation.c

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

Modified files:

Index: src/sys/fs/udf/udf_allocation.c
diff -u src/sys/fs/udf/udf_allocation.c:1.40.4.1 src/sys/fs/udf/udf_allocation.c:1.40.4.2
--- src/sys/fs/udf/udf_allocation.c:1.40.4.1	Sun Mar 13 09:48:32 2022
+++ src/sys/fs/udf/udf_allocation.c	Mon Apr 18 10:54:21 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_allocation.c,v 1.40.4.1 2022/03/13 09:48:32 martin Exp $ */
+/* $NetBSD: udf_allocation.c,v 1.40.4.2 2022/04/18 10:54:21 martin Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_allocation.c,v 1.40.4.1 2022/03/13 09:48:32 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_allocation.c,v 1.40.4.2 2022/04/18 10:54:21 martin Exp $");
 #endif /* not lint */
 
 
@@ -863,8 +863,8 @@ udf_search_free_vatloc(struct udf_mount 
 		ump->vat_entries++;
 	}
 
-	/* mark entry with initialiser just in case */
-	lb_map = udf_rw32(0x);
+	/* mark entry with non free-space initialiser just in case */
+	lb_map = udf_rw32(0xfffe);
 	udf_vat_write(ump->vat_node, (uint8_t *) _map, 4,
 		ump->vat_offset + lb_num *4);
 	ump->vat_last_free_lb = lb_num;



CVS commit: [netbsd-9] src/sys/fs/udf

2022-04-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr 18 10:54:21 UTC 2022

Modified Files:
src/sys/fs/udf [netbsd-9]: udf_allocation.c

Log Message:
Pull up following revision(s) (requested by reinoud in ticket #1437):

sys/fs/udf/udf_allocation.c: revision 1.46

Revere modification of initializer; it can lead to race conditions where two
allocation would pick the `empty' space causing a panic later on.


To generate a diff of this commit:
cvs rdiff -u -r1.40.4.1 -r1.40.4.2 src/sys/fs/udf/udf_allocation.c

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



CVS commit: src/sys/dev/isa

2022-04-18 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Apr 18 10:09:07 UTC 2022

Modified Files:
src/sys/dev/isa: fdc_isa.c

Log Message:
Do not attach if the parent bus failed to provide an ISA chipset tag.


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

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

Modified files:

Index: src/sys/dev/isa/fdc_isa.c
diff -u src/sys/dev/isa/fdc_isa.c:1.20 src/sys/dev/isa/fdc_isa.c:1.21
--- src/sys/dev/isa/fdc_isa.c:1.20	Mon Apr 13 16:33:24 2015
+++ src/sys/dev/isa/fdc_isa.c	Mon Apr 18 10:09:07 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdc_isa.c,v 1.20 2015/04/13 16:33:24 riastradh Exp $	*/
+/*	$NetBSD: fdc_isa.c,v 1.21 2022/04/18 10:09:07 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdc_isa.c,v 1.20 2015/04/13 16:33:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdc_isa.c,v 1.21 2022/04/18 10:09:07 jmcneill Exp $");
 
 #include 
 #include 
@@ -131,6 +131,10 @@ fdc_isa_probe(device_t parent, cfdata_t 
 	if (ia->ia_drq[0].ir_drq == ISA_UNKNOWN_DRQ)
 		return (0);
 
+	/* ISA chipset tag is required for DMA support. */
+	if (ia->ia_ic == NULL)
+		return (0);
+
 	/* Map the I/O space. */
 	iobase = ia->ia_io[0].ir_addr;
 	if (bus_space_map(iot, iobase, 6 /* FDC_NPORT */, 0, _ioh))



CVS commit: src/sys/dev/isa

2022-04-18 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Apr 18 10:09:07 UTC 2022

Modified Files:
src/sys/dev/isa: fdc_isa.c

Log Message:
Do not attach if the parent bus failed to provide an ISA chipset tag.


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

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



CVS commit: src/bin/sh

2022-04-18 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Apr 18 06:02:27 UTC 2022

Modified Files:
src/bin/sh: jobs.c

Log Message:
Introduce a new macro JNUM to replace the idiom jp-jobtab+1
(the job number, given jp a pointer to a jobs table entry)
used open coded previously in many places (mostly in DEBUG mode
trace messages, so not included in most shells, but there are
a few others).

Make the type of JNUM() be int rather than the ptrdiff_t the
open coded version became ... which when used in some printf()
type function arg list was cast to some other arbitrary (but not
consistent) int type for which there is a standard %Xd type
format conversion.   Now we can (and do) just use %d for this.

If the number of jobs ever exceeds the range of an int, we would
have far more serious problems than the broken output this would
cause.

While here improve a comment or two, and use JOBRUNNING instead
of 0 where the intent is the former (JOBRUNNING is #defined as 0).

NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/bin/sh/jobs.c

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

Modified files:

Index: src/bin/sh/jobs.c
diff -u src/bin/sh/jobs.c:1.115 src/bin/sh/jobs.c:1.116
--- src/bin/sh/jobs.c:1.115	Sun Dec 19 21:15:27 2021
+++ src/bin/sh/jobs.c	Mon Apr 18 06:02:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: jobs.c,v 1.115 2021/12/19 21:15:27 andvar Exp $	*/
+/*	$NetBSD: jobs.c,v 1.116 2022/04/18 06:02:27 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)jobs.c	8.5 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: jobs.c,v 1.115 2021/12/19 21:15:27 andvar Exp $");
+__RCSID("$NetBSD: jobs.c,v 1.116 2022/04/18 06:02:27 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -116,6 +116,8 @@ STATIC void cmdlist(union node *, int);
 STATIC void cmdputs(const char *);
 inline static void cmdputi(int);
 
+#define	JNUM(j)	((int)((j) != NULL ? ((j) - jobtab) + 1 : 0))
+
 #ifdef SYSV
 STATIC int onsigchild(void);
 #endif
@@ -355,7 +357,7 @@ bgcmd(int argc, char **argv)
 		if (jp->jobctl == 0)
 			error("job not created under job control");
 		set_curjob(jp, 1);
-		out1fmt("[%ld] %s", (long)(jp - jobtab + 1), jp->ps[0].cmd);
+		out1fmt("[%d] %s", JNUM(jp), jp->ps[0].cmd);
 		for (i = 1; i < jp->nprocs; i++)
 			out1fmt(" | %s", jp->ps[i].cmd );
 		out1c('\n');
@@ -403,9 +405,9 @@ restartjob(struct job *jp)
 	for (ps = jp->ps, i = jp->nprocs ; --i >= 0 ; ps++) {
 		if (WIFSTOPPED(ps->status)) {
 			VTRACE(DBG_JOBS, (
-			   "restartjob: [%zu] pid %d status change"
+			   "restartjob: [%d] pid %d status change"
 			   " from %#x (stopped) to -1 (running)\n",
-			   (size_t)(jp-jobtab+1), ps->pid, ps->status));
+			   JNUM(jp), ps->pid, ps->status));
 			ps->status = -1;
 			jp->state = JOBRUNNING;
 		}
@@ -470,7 +472,7 @@ showjob(struct output *out, struct job *
 	if (mode & SHOW_SIGNALLED && !(mode & SHOW_ISSIG)) {
 		if (jp->state == JOBDONE && !(mode & SHOW_NO_FREE)) {
 			VTRACE(DBG_JOBS, ("showjob: freeing job %d\n",
-			jp - jobtab + 1));
+			JNUM(jp)));
 			freejob(jp);
 		}
 		return;
@@ -478,8 +480,8 @@ showjob(struct output *out, struct job *
 
 	for (ps = jp->ps; --procno >= 0; ps++) {	/* for each process */
 		if (ps == jp->ps)
-			fmtstr(s, 16, "[%ld] %c ",
-(long)(jp - jobtab + 1),
+			fmtstr(s, 16, "[%d] %c ",
+JNUM(jp),
 #if JOBS
 jp - jobtab == curjob ?
 	  '+' :
@@ -948,7 +950,7 @@ jobidcmd(int argc, char **argv)
 
 	jp = getjob(*argptr, 0);
 	if (job) {
-		out1fmt("%%%zu\n", (size_t)(jp - jobtab + 1));
+		out1fmt("%%%d\n", JNUM(jp));
 		return 0;
 	}
 	if (pg) {
@@ -1157,7 +1159,7 @@ makejob(union node *node, int nprocs)
 	}
 	INTON;
 	VTRACE(DBG_JOBS, ("makejob(%p, %d)%s returns %%%d\n", (void *)node,
-	nprocs, (jp->flags)?" PF":"", jp - jobtab + 1));
+	nprocs, (jp->flags & JPIPEFAIL) ? " PF" : "", JNUM(jp)));
 	return jp;
 }
 
@@ -1184,7 +1186,7 @@ forkshell(struct job *jp, union node *n,
 	int serrno;
 
 	CTRACE(DBG_JOBS, ("forkshell(%%%d, %p, %d) called\n",
-	jp - jobtab, n, mode));
+	JNUM(jp), n, mode));
 
 	switch ((pid = fork())) {
 	case -1:
@@ -1326,7 +1328,7 @@ waitforjob(struct job *jp)
 	int st;
 
 	INTOFF;
-	VTRACE(DBG_JOBS, ("waitforjob(%%%d) called\n", jp - jobtab + 1));
+	VTRACE(DBG_JOBS, ("waitforjob(%%%d) called\n", JNUM(jp)));
 	while (jp->state == JOBRUNNING) {
 		dowait(WBLOCK, jp, NULL);
 	}
@@ -1352,7 +1354,7 @@ waitforjob(struct job *jp)
 		st = WTERMSIG(status) + 128;
 
 	VTRACE(DBG_JOBS, ("waitforjob: job %d, nproc %d, status %d, st %x\n",
-		jp - jobtab + 1, jp->nprocs, status, st));
+		JNUM(jp), jp->nprocs, status, st));
 #if JOBS
 	if (jp->jobctl) {
 		/*
@@ -1402,7 +1404,7 @@ dowait(int flags, struct job *job, struc
 	int err;
 
 	VTRACE(DBG_JOBS|DBG_PROCS, ("dowait(%x) called for job %d%s\n",
-	flags, (job ? job-jobtab+1 : 0), changed ? " [report change]":""));
+	flags, JNUM(job), changed ? 

CVS commit: src/bin/sh

2022-04-18 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Apr 18 06:02:27 UTC 2022

Modified Files:
src/bin/sh: jobs.c

Log Message:
Introduce a new macro JNUM to replace the idiom jp-jobtab+1
(the job number, given jp a pointer to a jobs table entry)
used open coded previously in many places (mostly in DEBUG mode
trace messages, so not included in most shells, but there are
a few others).

Make the type of JNUM() be int rather than the ptrdiff_t the
open coded version became ... which when used in some printf()
type function arg list was cast to some other arbitrary (but not
consistent) int type for which there is a standard %Xd type
format conversion.   Now we can (and do) just use %d for this.

If the number of jobs ever exceeds the range of an int, we would
have far more serious problems than the broken output this would
cause.

While here improve a comment or two, and use JOBRUNNING instead
of 0 where the intent is the former (JOBRUNNING is #defined as 0).

NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/bin/sh/jobs.c

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