CVS commit: src

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 19:45:14 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: expr_fold.c msg_141.c
platform_ilp32_int.c platform_ilp32_long.c platform_lp64.c
src/usr.bin/xlint/lint1: err.c tree.c

Log Message:
lint: add details to the message about integer overflow

Having only the operator was too unspecific to be actionable, so add the
actual numbers and the data type.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/usr.bin/xlint/lint1/expr_fold.c
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/xlint/lint1/msg_141.c
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/platform_ilp32_int.c
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/platform_ilp32_long.c
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/xlint/lint1/platform_lp64.c
cvs rdiff -u -r1.231 -r1.232 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.622 -r1.623 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/expr_fold.c
diff -u src/tests/usr.bin/xlint/lint1/expr_fold.c:1.14 src/tests/usr.bin/xlint/lint1/expr_fold.c:1.15
--- src/tests/usr.bin/xlint/lint1/expr_fold.c:1.14	Sun Mar 10 14:32:30 2024
+++ src/tests/usr.bin/xlint/lint1/expr_fold.c	Sun Mar 10 19:45:14 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: expr_fold.c,v 1.14 2024/03/10 14:32:30 rillig Exp $	*/
+/*	$NetBSD: expr_fold.c,v 1.15 2024/03/10 19:45:14 rillig Exp $	*/
 # 3 "expr_fold.c"
 
 /*
@@ -59,9 +59,9 @@ fold_uminus(void)
 	/* The '-' is an operator, it is not part of the integer constant. */
 	take_int(-2147483648);
 
-	/* expect+1: warning: operator '+' produces integer overflow [141] */
+	/* expect+1: warning: '2147483647 + 1' overflows 'int' [141] */
 	take_int(-(2147483647 + 1));
-	/* expect+1: warning: operator '-' produces integer overflow [141] */
+	/* expect+1: warning: '-(-2147483648)' overflows 'int' [141] */
 	take_int(-(-2147483647 - 1));
 	/* expect+1: warning: conversion of 'long' to 'int' is out of range, arg #1 [295] */
 	take_int(-(4294967295));
@@ -99,14 +99,14 @@ void
 fold_mult(void)
 {
 	take_int(32767 * 65536);
-	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	/* expect+1: warning: '32768 * 65536' overflows 'int' [141] */
 	take_int(32768 * 65536);
-	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	/* expect+1: warning: '65536 * 65536' overflows 'int' [141] */
 	take_int(65536 * 65536);
 
 	take_uint(32767 * 65536U);
 	take_uint(32768 * 65536U);
-	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	/* expect+1: warning: '65536 * 65536' overflows 'unsigned int' [141] */
 	take_uint(65536 * 65536U);
 }
 
@@ -138,13 +138,13 @@ fold_mod(void)
 void
 fold_plus(void)
 {
-	/* expect+1: warning: operator '+' produces integer overflow [141] */
+	/* expect+1: warning: '2147483647 + 1' overflows 'int' [141] */
 	take_int(2147483647 + 1);
 
 	/* Assume two's complement, so no overflow. */
 	take_int(-2147483647 + -1);
 
-	/* expect+1: warning: operator '+' produces integer overflow [141] */
+	/* expect+1: warning: '-2147483647 + -2' overflows 'int' [141] */
 	take_int(-2147483647 + -2);
 
 	/*
@@ -161,25 +161,25 @@ fold_plus(void)
 void
 fold_minus(void)
 {
-	/* expect+1: warning: operator '-' produces integer overflow [141] */
+	/* expect+1: warning: '2147483647 - -1' overflows 'int' [141] */
 	take_int(2147483647 - -1);
 	/* Assume two's complement. */
 	take_int(-2147483647 - 1);
-	/* expect+1: warning: operator '-' produces integer overflow [141] */
+	/* expect+1: warning: '-2147483647 - 2' overflows 'int' [141] */
 	take_int(-2147483647 - 2);
 
 	take_int(0 - 2147483648);
-	/* expect+1: warning: operator '-' produces integer overflow [141] */
+	/* expect+1: warning: '0 - 2147483648' overflows 'unsigned int' [141] */
 	take_uint(0 - 2147483648U);
 }
 
 void
 fold_shl(void)
 {
-	/* expect+1: warning: operator '<<' produces integer overflow [141] */
+	/* expect+1: warning: '16777216 << 24' overflows 'int' [141] */
 	take_int(1 << 24 << 24);
 
-	/* expect+1: warning: operator '<<' produces integer overflow [141] */
+	/* expect+1: warning: '16777216 << 24' overflows 'unsigned int' [141] */
 	take_uint(1U << 24 << 24);
 
 	/* expect+1: warning: shift amount 104 is greater than bit-size 32 of 'unsigned int' [122] */

Index: src/tests/usr.bin/xlint/lint1/msg_141.c
diff -u src/tests/usr.bin/xlint/lint1/msg_141.c:1.15 src/tests/usr.bin/xlint/lint1/msg_141.c:1.16
--- src/tests/usr.bin/xlint/lint1/msg_141.c:1.15	Sun Mar 10 15:49:12 2024
+++ src/tests/usr.bin/xlint/lint1/msg_141.c	Sun Mar 10 19:45:14 2024
@@ -1,7 +1,7 @@
-/*	$NetBSD: msg_141.c,v 1.15 2024/03/10 15:49:12 rillig Exp $	*/
+/*	$NetBSD: msg_141.c,v 1.16 2024/03/10 19:45:14 rillig Exp $	*/
 # 3 "msg_141.c"
 
-// Test for message: operator '%s' produces integer overflow [141]
+// Test for message: '%s' 

CVS commit: src

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 19:45:14 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: expr_fold.c msg_141.c
platform_ilp32_int.c platform_ilp32_long.c platform_lp64.c
src/usr.bin/xlint/lint1: err.c tree.c

Log Message:
lint: add details to the message about integer overflow

Having only the operator was too unspecific to be actionable, so add the
actual numbers and the data type.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/usr.bin/xlint/lint1/expr_fold.c
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/xlint/lint1/msg_141.c
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/platform_ilp32_int.c
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/platform_ilp32_long.c
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/xlint/lint1/platform_lp64.c
cvs rdiff -u -r1.231 -r1.232 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.622 -r1.623 src/usr.bin/xlint/lint1/tree.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/doc

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:22:56 UTC 2024

Modified Files:
src/doc [netbsd-8]: CHANGES-8.3

Log Message:
Tickets #1939, #1941 - #1944


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.221 -r1.1.2.222 src/doc/CHANGES-8.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-8.3
diff -u src/doc/CHANGES-8.3:1.1.2.221 src/doc/CHANGES-8.3:1.1.2.222
--- src/doc/CHANGES-8.3:1.1.2.221	Thu Feb 29 10:47:52 2024
+++ src/doc/CHANGES-8.3	Sun Mar 10 19:22:56 2024
@@ -1,4 +1,4 @@
-$NetBSD: CHANGES-8.3,v 1.1.2.221 2024/02/29 10:47:52 martin Exp $
+$NetBSD: CHANGES-8.3,v 1.1.2.222 2024/03/10 19:22:56 martin Exp $
 
 A complete list of changes from the NetBSD 8.2 release to the NetBSD 8.3
 release:
@@ -4292,3 +4292,34 @@ sys/dev/pci/if_wmreg.h			1.131
 	- Fix comment.
 	[msaitoh, ticket #1938]
 
+lib/libc/net/getnameinfo.c			1.60
+
+	getnameinfo(3): PR 57609: fix socket address length checks.
+	[riastradh, ticket #1939]
+
+lib/libc/net/getnameinfo.3			1.43
+
+	getnameinfo(3): PR 57832_ document NI_NUMERICSCOPE.
+	[riastradh, ticket #1941]
+
+sys/dev/usb/if_urtwn.c1.109 (patch)
+
+	urtwn(4): PR 57965: avoid deadlock on command ring overflow.
+	[riastradh, ticket #1942]
+
+usr.bin/getconf/getconf.1			1.14
+usr.bin/getconf/getconf.c			1.37
+
+	getconf(1): PR 57875: accept variable names with or without
+	leading underscore. This matches FreeBSD and makes it more
+	portable to GNU getconf(1), which currently _requires_ a leading
+	underscore while ours currently _refuses_ a leading underscore.
+	[riastradh, ticket #1943]
+
+sys/netinet6/in6.c1.292
+
+	netinet6: PR 53922: avoid NPD on certain inet6 addr configs.
+	This can be provoked by anyone on the local network by issuing
+	a router advertisement processed by dhcpcd.
+	[riastradh, ticket #1944]
+



CVS commit: [netbsd-8] src/doc

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:22:56 UTC 2024

Modified Files:
src/doc [netbsd-8]: CHANGES-8.3

Log Message:
Tickets #1939, #1941 - #1944


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.221 -r1.1.2.222 src/doc/CHANGES-8.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

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:22:09 UTC 2024

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

Log Message:
Tickets #1806, #1808 - #1812


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.137 -r1.1.2.138 src/doc/CHANGES-9.4

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.4
diff -u src/doc/CHANGES-9.4:1.1.2.137 src/doc/CHANGES-9.4:1.1.2.138
--- src/doc/CHANGES-9.4:1.1.2.137	Sun Mar  3 07:13:06 2024
+++ src/doc/CHANGES-9.4	Sun Mar 10 19:22:08 2024
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.4,v 1.1.2.137 2024/03/03 07:13:06 martin Exp $
+# $NetBSD: CHANGES-9.4,v 1.1.2.138 2024/03/10 19:22:08 martin Exp $
 
 A complete list of changes from the NetBSD 9.3 release to the NetBSD 9.4
 release:
@@ -13400,3 +13400,41 @@ doc/3RDPARTY	(manually edited)
 	Import libuv 1.44.2.
 	Adjust nsd, unbound and bind to the netbsd-9 branch.
 	[christos, ticket #1805]
+
+lib/libc/net/getnameinfo.c			1.60
+
+	getnameinfo(3): PR 57609: fix socket address length checks.
+	[riastradh, ticket #1806]
+
+lib/libc/net/getnameinfo.3			1.43
+
+	getnameinfo(3): PR 57832_ document NI_NUMERICSCOPE.
+	[riastradh, ticket #1808]
+
+sys/netinet6/icmp6.c1.256 (patch)
+sys/netinet6/raw_ip6.c1.184 (patch)
+
+	PR 57955: deliver timestamps also to raw sockets.
+	[riastradh, ticket #1809]
+
+sys/dev/usb/if_urtwn.c1.109 (patch)
+
+	urtwn(4): PR 57965: avoid deadlock on command ring overflow.
+	[riastradh, ticket #1810]
+
+usr.bin/getconf/getconf.1			1.14
+usr.bin/getconf/getconf.c			1.37
+
+	getconf(1): PR 57875: accept variable names with or without
+	leading underscore. This matches FreeBSD and makes it more
+	portable to GNU getconf(1), which currently _requires_ a leading
+	underscore while ours currently _refuses_ a leading underscore.
+	[riastradh, ticket #1811]
+
+sys/netinet6/in6.c1.292
+
+	netinet6: PR 53922: avoid NPD on certain inet6 addr configs.
+	This can be provoked by anyone on the local network by issuing
+	a router advertisement processed by dhcpcd.
+	[riastradh, ticket #1812]
+



CVS commit: [netbsd-9] src/doc

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:22:09 UTC 2024

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

Log Message:
Tickets #1806, #1808 - #1812


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.137 -r1.1.2.138 src/doc/CHANGES-9.4

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



CVS commit: [netbsd-10] src/doc

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:21:05 UTC 2024

Modified Files:
src/doc [netbsd-10]: CHANGES-10.0

Log Message:
Tickets #612 - #619


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.208 -r1.1.2.209 src/doc/CHANGES-10.0

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



CVS commit: [netbsd-10] src/doc

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:21:05 UTC 2024

Modified Files:
src/doc [netbsd-10]: CHANGES-10.0

Log Message:
Tickets #612 - #619


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.208 -r1.1.2.209 src/doc/CHANGES-10.0

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-10.0
diff -u src/doc/CHANGES-10.0:1.1.2.208 src/doc/CHANGES-10.0:1.1.2.209
--- src/doc/CHANGES-10.0:1.1.2.208	Sat Mar  9 18:26:59 2024
+++ src/doc/CHANGES-10.0	Sun Mar 10 19:21:05 2024
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-10.0,v 1.1.2.208 2024/03/09 18:26:59 bouyer Exp $
+# $NetBSD: CHANGES-10.0,v 1.1.2.209 2024/03/10 19:21:05 martin Exp $
 
 A complete list of changes from the initial NetBSD 10.0 branch on 2022-12-16
 until the 10.0 release:
@@ -21264,3 +21264,52 @@ external/bsd/tcpdump/dist/print-ppp.c		p
 	fixes PR 57586
 	[martin, ticket #623]
 
+lib/libc/net/getnameinfo.c			1.60
+
+	getnameinfo(3): PR 57609: fix socket address length checks.
+	[riastradh, ticket #612]
+
+sys/dev/usb/usbdi.c1.248,1.249
+
+	usbdi(9): PR 57783: avoid locking against self when racing with
+	the host controller softint to enter ddb.
+	[riastradh, ticket #613]
+
+lib/libc/net/getnameinfo.3			1.43
+
+	getnameinfo(3): PR 57832_ document NI_NUMERICSCOPE.
+	[riastradh, ticket #614]
+
+sys/netinet6/icmp6.c1.256
+sys/netinet6/raw_ip6.c1.184
+
+	PR 57955: deliver timestamps also to raw sockets.
+	[riastradh, ticket #615]
+
+sys/dev/usb/if_urtwn.c1.109
+
+	urtwn(4): PR 57965: avoid deadlock on command ring overflow.
+	[riastradh, ticket #616]
+
+usr.bin/getconf/getconf.1			1.14
+usr.bin/getconf/getconf.c			1.37
+
+	getconf(1): PR 57875: accept variable names with or without
+	leading underscore. This matches FreeBSD and makes it more
+	portable to GNU getconf(1), which currently _requires_ a leading
+	underscore while ours currently _refuses_ a leading underscore.
+	[riastradh, ticket #617]
+
+sys/netinet/if_arp.c1.312
+
+	netinet: PR 57959: attribute arp debug message that
+	is printed to the console.
+	[riastradh, ticket #618]
+
+sys/netinet6/in6.c1.292
+
+	netinet6: PR 53922: avoid NPD on certain inet6 addr configs.
+	This can be provoked by anyone on the local network by issuing
+	a router advertisement processed by dhcpcd.
+	[riastradh, ticket #619]
+



CVS commit: [netbsd-8] src/sys/netinet6

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:13:09 UTC 2024

Modified Files:
src/sys/netinet6 [netbsd-8]: in6.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1944):

sys/netinet6/in6.c: revision 1.292

netinet6: Avoid NPD on `ifconfig ifN inet6 ... pltime 0 vltime 0'.
PR kern/53922


To generate a diff of this commit:
cvs rdiff -u -r1.245.2.14 -r1.245.2.15 src/sys/netinet6/in6.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/netinet6/in6.c
diff -u src/sys/netinet6/in6.c:1.245.2.14 src/sys/netinet6/in6.c:1.245.2.15
--- src/sys/netinet6/in6.c:1.245.2.14	Fri Aug  4 14:38:09 2023
+++ src/sys/netinet6/in6.c	Sun Mar 10 19:13:09 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6.c,v 1.245.2.14 2023/08/04 14:38:09 martin Exp $	*/
+/*	$NetBSD: in6.c,v 1.245.2.15 2024/03/10 19:13:09 martin Exp $	*/
 /*	$KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.245.2.14 2023/08/04 14:38:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.245.2.15 2024/03/10 19:13:09 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -708,7 +708,14 @@ in6_control1(struct socket *so, u_long c
 		int s = splsoftnet();
 		error = in6_update_ifa1(ifp, ifra, , , 0);
 		splx(s);
-		if (error)
+		/*
+		 * in6_update_ifa1 doesn't create the address if its
+		 * valid lifetime (vltime) is zero, since we would just
+		 * delete the address immediately in that case anyway.
+		 * So it may succeed but return null ia.  In that case,
+		 * nothing left to do.
+		 */
+		if (error || ia == NULL)
 			break;
 		pfil_run_addrhooks(if_pfil, cmd, >ia_ifa);
 		break;



CVS commit: [netbsd-8] src/sys/netinet6

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:13:09 UTC 2024

Modified Files:
src/sys/netinet6 [netbsd-8]: in6.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1944):

sys/netinet6/in6.c: revision 1.292

netinet6: Avoid NPD on `ifconfig ifN inet6 ... pltime 0 vltime 0'.
PR kern/53922


To generate a diff of this commit:
cvs rdiff -u -r1.245.2.14 -r1.245.2.15 src/sys/netinet6/in6.c

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



CVS commit: [netbsd-9] src/sys/netinet6

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:12:05 UTC 2024

Modified Files:
src/sys/netinet6 [netbsd-9]: in6.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1812):

sys/netinet6/in6.c: revision 1.292

netinet6: Avoid NPD on `ifconfig ifN inet6 ... pltime 0 vltime 0'.
PR kern/53922


To generate a diff of this commit:
cvs rdiff -u -r1.275.2.2 -r1.275.2.3 src/sys/netinet6/in6.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/netinet6/in6.c
diff -u src/sys/netinet6/in6.c:1.275.2.2 src/sys/netinet6/in6.c:1.275.2.3
--- src/sys/netinet6/in6.c:1.275.2.2	Fri Aug  4 14:29:44 2023
+++ src/sys/netinet6/in6.c	Sun Mar 10 19:12:05 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6.c,v 1.275.2.2 2023/08/04 14:29:44 martin Exp $	*/
+/*	$NetBSD: in6.c,v 1.275.2.3 2024/03/10 19:12:05 martin Exp $	*/
 /*	$KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.275.2.2 2023/08/04 14:29:44 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.275.2.3 2024/03/10 19:12:05 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -707,7 +707,14 @@ in6_control1(struct socket *so, u_long c
 		int s = splsoftnet();
 		error = in6_update_ifa1(ifp, ifra, , , 0);
 		splx(s);
-		if (error)
+		/*
+		 * in6_update_ifa1 doesn't create the address if its
+		 * valid lifetime (vltime) is zero, since we would just
+		 * delete the address immediately in that case anyway.
+		 * So it may succeed but return null ia.  In that case,
+		 * nothing left to do.
+		 */
+		if (error || ia == NULL)
 			break;
 		pfil_run_addrhooks(if_pfil, cmd, >ia_ifa);
 		break;



CVS commit: [netbsd-9] src/sys/netinet6

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:12:05 UTC 2024

Modified Files:
src/sys/netinet6 [netbsd-9]: in6.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1812):

sys/netinet6/in6.c: revision 1.292

netinet6: Avoid NPD on `ifconfig ifN inet6 ... pltime 0 vltime 0'.
PR kern/53922


To generate a diff of this commit:
cvs rdiff -u -r1.275.2.2 -r1.275.2.3 src/sys/netinet6/in6.c

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



CVS commit: [netbsd-10] src/sys/netinet6

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:11:07 UTC 2024

Modified Files:
src/sys/netinet6 [netbsd-10]: in6.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #619):

sys/netinet6/in6.c: revision 1.292

netinet6: Avoid NPD on `ifconfig ifN inet6 ... pltime 0 vltime 0'.
PR kern/53922


To generate a diff of this commit:
cvs rdiff -u -r1.288.2.2 -r1.288.2.3 src/sys/netinet6/in6.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/netinet6/in6.c
diff -u src/sys/netinet6/in6.c:1.288.2.2 src/sys/netinet6/in6.c:1.288.2.3
--- src/sys/netinet6/in6.c:1.288.2.2	Sun Dec 10 13:06:16 2023
+++ src/sys/netinet6/in6.c	Sun Mar 10 19:11:07 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6.c,v 1.288.2.2 2023/12/10 13:06:16 martin Exp $	*/
+/*	$NetBSD: in6.c,v 1.288.2.3 2024/03/10 19:11:07 martin Exp $	*/
 /*	$KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.288.2.2 2023/12/10 13:06:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.288.2.3 2024/03/10 19:11:07 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -726,7 +726,14 @@ in6_control1(struct socket *so, u_long c
 		int s = splsoftnet();
 		error = in6_update_ifa1(ifp, ifra, , , 0);
 		splx(s);
-		if (error)
+		/*
+		 * in6_update_ifa1 doesn't create the address if its
+		 * valid lifetime (vltime) is zero, since we would just
+		 * delete the address immediately in that case anyway.
+		 * So it may succeed but return null ia.  In that case,
+		 * nothing left to do.
+		 */
+		if (error || ia == NULL)
 			break;
 		pfil_run_addrhooks(if_pfil, cmd, >ia_ifa);
 		break;



CVS commit: [netbsd-10] src/sys/netinet6

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:11:07 UTC 2024

Modified Files:
src/sys/netinet6 [netbsd-10]: in6.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #619):

sys/netinet6/in6.c: revision 1.292

netinet6: Avoid NPD on `ifconfig ifN inet6 ... pltime 0 vltime 0'.
PR kern/53922


To generate a diff of this commit:
cvs rdiff -u -r1.288.2.2 -r1.288.2.3 src/sys/netinet6/in6.c

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



CVS commit: [netbsd-10] src/sys/netinet

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:07:42 UTC 2024

Modified Files:
src/sys/netinet [netbsd-10]: if_arp.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #618):

sys/netinet/if_arp.c: revision 1.312

Attribute debug message.
Fixes PR 57959


To generate a diff of this commit:
cvs rdiff -u -r1.311 -r1.311.2.1 src/sys/netinet/if_arp.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/netinet/if_arp.c
diff -u src/sys/netinet/if_arp.c:1.311 src/sys/netinet/if_arp.c:1.311.2.1
--- src/sys/netinet/if_arp.c:1.311	Tue Nov 15 10:47:39 2022
+++ src/sys/netinet/if_arp.c	Sun Mar 10 19:07:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arp.c,v 1.311 2022/11/15 10:47:39 roy Exp $	*/
+/*	$NetBSD: if_arp.c,v 1.311.2.1 2024/03/10 19:07:41 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.311 2022/11/15 10:47:39 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.311.2.1 2024/03/10 19:07:41 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1355,8 +1355,8 @@ arp_llinfo_output(struct ifnet *ifp, __u
 		if (sip.s_addr == INADDR_ANY) {
 			char ipbuf[INET_ADDRSTRLEN];
 
-			log(LOG_DEBUG, "source can't be "
-			"determined: dst=%s\n",
+			log(LOG_DEBUG, "%s: source can't be "
+			"determined: dst=%s\n", __func__,
 			IN_PRINT(ipbuf, ));
 			return;
 		}



CVS commit: [netbsd-10] src/sys/netinet

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:07:42 UTC 2024

Modified Files:
src/sys/netinet [netbsd-10]: if_arp.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #618):

sys/netinet/if_arp.c: revision 1.312

Attribute debug message.
Fixes PR 57959


To generate a diff of this commit:
cvs rdiff -u -r1.311 -r1.311.2.1 src/sys/netinet/if_arp.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/usr.bin/getconf

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:05:46 UTC 2024

Modified Files:
src/usr.bin/getconf [netbsd-8]: getconf.1 getconf.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1943):

usr.bin/getconf/getconf.c: revision 1.37
usr.bin/getconf/getconf.1: revision 1.14

PR/57875: Jason Bacon: Try again without an _ for portability.
getconf.1: Note that leading underscores in configuration
variable names are ignored by getconf(1).

While here, add a section with examples, and make the synopsis
more concise.

PR bin/57875


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.13.16.1 src/usr.bin/getconf/getconf.1
cvs rdiff -u -r1.35 -r1.35.18.1 src/usr.bin/getconf/getconf.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/usr.bin/getconf

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:05:46 UTC 2024

Modified Files:
src/usr.bin/getconf [netbsd-8]: getconf.1 getconf.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1943):

usr.bin/getconf/getconf.c: revision 1.37
usr.bin/getconf/getconf.1: revision 1.14

PR/57875: Jason Bacon: Try again without an _ for portability.
getconf.1: Note that leading underscores in configuration
variable names are ignored by getconf(1).

While here, add a section with examples, and make the synopsis
more concise.

PR bin/57875


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.13.16.1 src/usr.bin/getconf/getconf.1
cvs rdiff -u -r1.35 -r1.35.18.1 src/usr.bin/getconf/getconf.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/getconf/getconf.1
diff -u src/usr.bin/getconf/getconf.1:1.13 src/usr.bin/getconf/getconf.1:1.13.16.1
--- src/usr.bin/getconf/getconf.1:1.13	Sun Apr 13 01:45:34 2014
+++ src/usr.bin/getconf/getconf.1	Sun Mar 10 19:05:46 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: getconf.1,v 1.13 2014/04/13 01:45:34 snj Exp $
+.\"	$NetBSD: getconf.1,v 1.13.16.1 2024/03/10 19:05:46 martin Exp $
 .\"
 .\" Copyright (c) 1996 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd August 9, 2011
+.Dd February 18, 2024
 .Dt GETCONF 1
 .Os
 .Sh NAME
@@ -37,13 +37,10 @@
 .Nm
 .Ar system_var
 .Nm
-.Fl a
-.Nm
 .Ar path_var
 .Ar pathname
 .Nm
-.Fl a
-.Ar pathname
+.Fl a Op Ar pathname
 .Sh DESCRIPTION
 The
 .Nm
@@ -80,8 +77,28 @@ standard output, in the format
 =
 .Va value
 .Dc .
+.Pp
+For compatibility with other operating systems,
+.Nm
+will ignore leading underscores in the names specified in the
+.Ar system_var
+and
+.Ar path_var
+arguments.
 .Sh EXIT STATUS
 .Ex -std
+.Sh EXAMPLES
+To retrieve the number of configured processors, use:
+.Bd -literal -offset indent
+$ getconf NPROCESSORS_CONF
+.Ed
+.Pp
+To retrieve the maximum number of bytes (excluding the trailing
+.Dv NUL )
+for a filename in the current directory, use:
+.Bd -literal -offset indent
+$ getconf NAME_MAX .
+.Ed
 .Sh SEE ALSO
 .Xr pathconf 2 ,
 .Xr confstr 3 ,

Index: src/usr.bin/getconf/getconf.c
diff -u src/usr.bin/getconf/getconf.c:1.35 src/usr.bin/getconf/getconf.c:1.35.18.1
--- src/usr.bin/getconf/getconf.c:1.35	Thu Dec 19 19:11:50 2013
+++ src/usr.bin/getconf/getconf.c	Sun Mar 10 19:05:46 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: getconf.c,v 1.35 2013/12/19 19:11:50 rmind Exp $	*/
+/*	$NetBSD: getconf.c,v 1.35.18.1 2024/03/10 19:05:46 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: getconf.c,v 1.35 2013/12/19 19:11:50 rmind Exp $");
+__RCSID("$NetBSD: getconf.c,v 1.35.18.1 2024/03/10 19:05:46 martin Exp $");
 #endif /* not lint */
 
 #include 
@@ -193,7 +193,7 @@ main(int argc, char **argv)
 {
 	int ch;
 	const struct conf_variable *cp;
-	const char *varname, *pathname;
+	const char *varname, *pathname, *vn;
 	int found;
 
 	setprogname(argv[0]);
@@ -226,8 +226,10 @@ main(int argc, char **argv)
 	pathname = argv[0];	/* may be NULL */
 
 	found = 0;
+	vn = varname;
+again:
 	for (cp = conf_table; cp->name != NULL; cp++) {
-		if (a_flag || strcmp(varname, cp->name) == 0) {
+		if (a_flag || strcmp(vn, cp->name) == 0) {
 			/*LINTED weird expression*/
 			if ((cp->type == PATHCONF) == (pathname != NULL)) {
 printvar(cp, pathname);
@@ -238,8 +240,11 @@ main(int argc, char **argv)
 		}
 	}
 
-	if (!a_flag && !found)
+	if (!a_flag && !found) {
+		if (*vn++ == '_')
+			goto again;
 		errx(EXIT_FAILURE, "%s: unknown variable", varname);
+	}
 
 	(void)fflush(stdout);
 	return ferror(stdout) ? EXIT_FAILURE : EXIT_SUCCESS;



CVS commit: [netbsd-9] src/usr.bin/getconf

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:04:39 UTC 2024

Modified Files:
src/usr.bin/getconf [netbsd-9]: getconf.1 getconf.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1811):

usr.bin/getconf/getconf.c: revision 1.37
usr.bin/getconf/getconf.1: revision 1.14

PR/57875: Jason Bacon: Try again without an _ for portability.
getconf.1: Note that leading underscores in configuration
variable names are ignored by getconf(1).

While here, add a section with examples, and make the synopsis
more concise.

PR bin/57875


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.13.26.1 src/usr.bin/getconf/getconf.1
cvs rdiff -u -r1.35 -r1.35.28.1 src/usr.bin/getconf/getconf.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/getconf/getconf.1
diff -u src/usr.bin/getconf/getconf.1:1.13 src/usr.bin/getconf/getconf.1:1.13.26.1
--- src/usr.bin/getconf/getconf.1:1.13	Sun Apr 13 01:45:34 2014
+++ src/usr.bin/getconf/getconf.1	Sun Mar 10 19:04:39 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: getconf.1,v 1.13 2014/04/13 01:45:34 snj Exp $
+.\"	$NetBSD: getconf.1,v 1.13.26.1 2024/03/10 19:04:39 martin Exp $
 .\"
 .\" Copyright (c) 1996 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd August 9, 2011
+.Dd February 18, 2024
 .Dt GETCONF 1
 .Os
 .Sh NAME
@@ -37,13 +37,10 @@
 .Nm
 .Ar system_var
 .Nm
-.Fl a
-.Nm
 .Ar path_var
 .Ar pathname
 .Nm
-.Fl a
-.Ar pathname
+.Fl a Op Ar pathname
 .Sh DESCRIPTION
 The
 .Nm
@@ -80,8 +77,28 @@ standard output, in the format
 =
 .Va value
 .Dc .
+.Pp
+For compatibility with other operating systems,
+.Nm
+will ignore leading underscores in the names specified in the
+.Ar system_var
+and
+.Ar path_var
+arguments.
 .Sh EXIT STATUS
 .Ex -std
+.Sh EXAMPLES
+To retrieve the number of configured processors, use:
+.Bd -literal -offset indent
+$ getconf NPROCESSORS_CONF
+.Ed
+.Pp
+To retrieve the maximum number of bytes (excluding the trailing
+.Dv NUL )
+for a filename in the current directory, use:
+.Bd -literal -offset indent
+$ getconf NAME_MAX .
+.Ed
 .Sh SEE ALSO
 .Xr pathconf 2 ,
 .Xr confstr 3 ,

Index: src/usr.bin/getconf/getconf.c
diff -u src/usr.bin/getconf/getconf.c:1.35 src/usr.bin/getconf/getconf.c:1.35.28.1
--- src/usr.bin/getconf/getconf.c:1.35	Thu Dec 19 19:11:50 2013
+++ src/usr.bin/getconf/getconf.c	Sun Mar 10 19:04:39 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: getconf.c,v 1.35 2013/12/19 19:11:50 rmind Exp $	*/
+/*	$NetBSD: getconf.c,v 1.35.28.1 2024/03/10 19:04:39 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: getconf.c,v 1.35 2013/12/19 19:11:50 rmind Exp $");
+__RCSID("$NetBSD: getconf.c,v 1.35.28.1 2024/03/10 19:04:39 martin Exp $");
 #endif /* not lint */
 
 #include 
@@ -193,7 +193,7 @@ main(int argc, char **argv)
 {
 	int ch;
 	const struct conf_variable *cp;
-	const char *varname, *pathname;
+	const char *varname, *pathname, *vn;
 	int found;
 
 	setprogname(argv[0]);
@@ -226,8 +226,10 @@ main(int argc, char **argv)
 	pathname = argv[0];	/* may be NULL */
 
 	found = 0;
+	vn = varname;
+again:
 	for (cp = conf_table; cp->name != NULL; cp++) {
-		if (a_flag || strcmp(varname, cp->name) == 0) {
+		if (a_flag || strcmp(vn, cp->name) == 0) {
 			/*LINTED weird expression*/
 			if ((cp->type == PATHCONF) == (pathname != NULL)) {
 printvar(cp, pathname);
@@ -238,8 +240,11 @@ main(int argc, char **argv)
 		}
 	}
 
-	if (!a_flag && !found)
+	if (!a_flag && !found) {
+		if (*vn++ == '_')
+			goto again;
 		errx(EXIT_FAILURE, "%s: unknown variable", varname);
+	}
 
 	(void)fflush(stdout);
 	return ferror(stdout) ? EXIT_FAILURE : EXIT_SUCCESS;



CVS commit: [netbsd-9] src/usr.bin/getconf

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:04:39 UTC 2024

Modified Files:
src/usr.bin/getconf [netbsd-9]: getconf.1 getconf.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1811):

usr.bin/getconf/getconf.c: revision 1.37
usr.bin/getconf/getconf.1: revision 1.14

PR/57875: Jason Bacon: Try again without an _ for portability.
getconf.1: Note that leading underscores in configuration
variable names are ignored by getconf(1).

While here, add a section with examples, and make the synopsis
more concise.

PR bin/57875


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.13.26.1 src/usr.bin/getconf/getconf.1
cvs rdiff -u -r1.35 -r1.35.28.1 src/usr.bin/getconf/getconf.c

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



CVS commit: [netbsd-10] src/usr.bin/getconf

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:03:30 UTC 2024

Modified Files:
src/usr.bin/getconf [netbsd-10]: getconf.1 getconf.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #617):

usr.bin/getconf/getconf.c: revision 1.37
usr.bin/getconf/getconf.1: revision 1.14

PR/57875: Jason Bacon: Try again without an _ for portability.
getconf.1: Note that leading underscores in configuration
variable names are ignored by getconf(1).

While here, add a section with examples, and make the synopsis
more concise.

PR bin/57875


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.13.34.1 src/usr.bin/getconf/getconf.1
cvs rdiff -u -r1.35 -r1.35.36.1 src/usr.bin/getconf/getconf.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/getconf/getconf.1
diff -u src/usr.bin/getconf/getconf.1:1.13 src/usr.bin/getconf/getconf.1:1.13.34.1
--- src/usr.bin/getconf/getconf.1:1.13	Sun Apr 13 01:45:34 2014
+++ src/usr.bin/getconf/getconf.1	Sun Mar 10 19:03:30 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: getconf.1,v 1.13 2014/04/13 01:45:34 snj Exp $
+.\"	$NetBSD: getconf.1,v 1.13.34.1 2024/03/10 19:03:30 martin Exp $
 .\"
 .\" Copyright (c) 1996 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd August 9, 2011
+.Dd February 18, 2024
 .Dt GETCONF 1
 .Os
 .Sh NAME
@@ -37,13 +37,10 @@
 .Nm
 .Ar system_var
 .Nm
-.Fl a
-.Nm
 .Ar path_var
 .Ar pathname
 .Nm
-.Fl a
-.Ar pathname
+.Fl a Op Ar pathname
 .Sh DESCRIPTION
 The
 .Nm
@@ -80,8 +77,28 @@ standard output, in the format
 =
 .Va value
 .Dc .
+.Pp
+For compatibility with other operating systems,
+.Nm
+will ignore leading underscores in the names specified in the
+.Ar system_var
+and
+.Ar path_var
+arguments.
 .Sh EXIT STATUS
 .Ex -std
+.Sh EXAMPLES
+To retrieve the number of configured processors, use:
+.Bd -literal -offset indent
+$ getconf NPROCESSORS_CONF
+.Ed
+.Pp
+To retrieve the maximum number of bytes (excluding the trailing
+.Dv NUL )
+for a filename in the current directory, use:
+.Bd -literal -offset indent
+$ getconf NAME_MAX .
+.Ed
 .Sh SEE ALSO
 .Xr pathconf 2 ,
 .Xr confstr 3 ,

Index: src/usr.bin/getconf/getconf.c
diff -u src/usr.bin/getconf/getconf.c:1.35 src/usr.bin/getconf/getconf.c:1.35.36.1
--- src/usr.bin/getconf/getconf.c:1.35	Thu Dec 19 19:11:50 2013
+++ src/usr.bin/getconf/getconf.c	Sun Mar 10 19:03:30 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: getconf.c,v 1.35 2013/12/19 19:11:50 rmind Exp $	*/
+/*	$NetBSD: getconf.c,v 1.35.36.1 2024/03/10 19:03:30 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: getconf.c,v 1.35 2013/12/19 19:11:50 rmind Exp $");
+__RCSID("$NetBSD: getconf.c,v 1.35.36.1 2024/03/10 19:03:30 martin Exp $");
 #endif /* not lint */
 
 #include 
@@ -193,7 +193,7 @@ main(int argc, char **argv)
 {
 	int ch;
 	const struct conf_variable *cp;
-	const char *varname, *pathname;
+	const char *varname, *pathname, *vn;
 	int found;
 
 	setprogname(argv[0]);
@@ -226,8 +226,10 @@ main(int argc, char **argv)
 	pathname = argv[0];	/* may be NULL */
 
 	found = 0;
+	vn = varname;
+again:
 	for (cp = conf_table; cp->name != NULL; cp++) {
-		if (a_flag || strcmp(varname, cp->name) == 0) {
+		if (a_flag || strcmp(vn, cp->name) == 0) {
 			/*LINTED weird expression*/
 			if ((cp->type == PATHCONF) == (pathname != NULL)) {
 printvar(cp, pathname);
@@ -238,8 +240,11 @@ main(int argc, char **argv)
 		}
 	}
 
-	if (!a_flag && !found)
+	if (!a_flag && !found) {
+		if (*vn++ == '_')
+			goto again;
 		errx(EXIT_FAILURE, "%s: unknown variable", varname);
+	}
 
 	(void)fflush(stdout);
 	return ferror(stdout) ? EXIT_FAILURE : EXIT_SUCCESS;



CVS commit: [netbsd-10] src/usr.bin/getconf

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:03:30 UTC 2024

Modified Files:
src/usr.bin/getconf [netbsd-10]: getconf.1 getconf.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #617):

usr.bin/getconf/getconf.c: revision 1.37
usr.bin/getconf/getconf.1: revision 1.14

PR/57875: Jason Bacon: Try again without an _ for portability.
getconf.1: Note that leading underscores in configuration
variable names are ignored by getconf(1).

While here, add a section with examples, and make the synopsis
more concise.

PR bin/57875


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.13.34.1 src/usr.bin/getconf/getconf.1
cvs rdiff -u -r1.35 -r1.35.36.1 src/usr.bin/getconf/getconf.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/dev/usb

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:00:27 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-8]: if_urtwn.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1942):

sys/dev/usb/if_urtwn.c: revision 1.109 (patch)

urtwn(4): Ditch old queued commands on overflow.
Don't increment ring->queued past what the task will decrement.

This is a stop-gap measure; really, we should just have one task for
each operation that is deferred to the task thread.

PR kern/57965


To generate a diff of this commit:
cvs rdiff -u -r1.53.2.6 -r1.53.2.7 src/sys/dev/usb/if_urtwn.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/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.53.2.6 src/sys/dev/usb/if_urtwn.c:1.53.2.7
--- src/sys/dev/usb/if_urtwn.c:1.53.2.6	Sat Dec 14 12:33:47 2019
+++ src/sys/dev/usb/if_urtwn.c	Sun Mar 10 19:00:27 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.53.2.6 2019/12/14 12:33:47 martin Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.53.2.7 2024/03/10 19:00:27 martin Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.53.2.6 2019/12/14 12:33:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.53.2.7 2024/03/10 19:00:27 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -808,6 +808,24 @@ urtwn_free_tx_list(struct urtwn_softc *s
 }
 
 static void
+urtwn_cmdq_invariants(struct urtwn_softc *sc)
+{
+	struct urtwn_host_cmd_ring *const ring __diagused = >cmdq;
+
+	KASSERT(mutex_owned(>sc_task_mtx));
+	KASSERTMSG((ring->cur >= 0 && ring->cur < URTWN_HOST_CMD_RING_COUNT),
+	"%s: cur=%d next=%d queued=%d",
+	device_xname(sc->sc_dev), ring->cur, ring->next, ring->queued);
+	KASSERTMSG((ring->next >= 0 && ring->next < URTWN_HOST_CMD_RING_COUNT),
+	"%s: cur=%d next=%d queued=%d",
+	device_xname(sc->sc_dev), ring->cur, ring->next, ring->queued);
+	KASSERTMSG((ring->queued >= 0 &&
+		ring->queued <= URTWN_HOST_CMD_RING_COUNT),
+	"%s: %d commands queued",
+	device_xname(sc->sc_dev), ring->queued);
+}
+
+static void
 urtwn_task(void *arg)
 {
 	struct urtwn_softc *sc = arg;
@@ -820,7 +838,11 @@ urtwn_task(void *arg)
 	/* Process host commands. */
 	s = splusb();
 	mutex_spin_enter(>sc_task_mtx);
+	urtwn_cmdq_invariants(sc);
 	while (ring->next != ring->cur) {
+		KASSERTMSG(ring->queued > 0, "%s: cur=%d next=%d queued=%d",
+		device_xname(sc->sc_dev),
+		ring->cur, ring->next, ring->queued);
 		cmd = >cmd[ring->next];
 		mutex_spin_exit(>sc_task_mtx);
 		splx(s);
@@ -828,6 +850,10 @@ urtwn_task(void *arg)
 		cmd->cb(sc, cmd->data);
 		s = splusb();
 		mutex_spin_enter(>sc_task_mtx);
+		urtwn_cmdq_invariants(sc);
+		KASSERTMSG(ring->queued > 0, "%s: cur=%d next=%d queued=%d",
+		device_xname(sc->sc_dev),
+		ring->cur, ring->next, ring->queued);
 		ring->queued--;
 		ring->next = (ring->next + 1) % URTWN_HOST_CMD_RING_COUNT;
 	}
@@ -842,6 +868,7 @@ urtwn_do_async(struct urtwn_softc *sc, v
 {
 	struct urtwn_host_cmd_ring *ring = >cmdq;
 	struct urtwn_host_cmd *cmd;
+	bool schedtask = false;
 	int s;
 
 	DPRINTFN(DBG_FN, ("%s: %s: cb=%p, arg=%p, len=%d\n",
@@ -849,19 +876,27 @@ urtwn_do_async(struct urtwn_softc *sc, v
 
 	s = splusb();
 	mutex_spin_enter(>sc_task_mtx);
+	urtwn_cmdq_invariants(sc);
 	cmd = >cmd[ring->cur];
 	cmd->cb = cb;
 	KASSERT(len <= sizeof(cmd->data));
 	memcpy(cmd->data, arg, len);
 	ring->cur = (ring->cur + 1) % URTWN_HOST_CMD_RING_COUNT;
 
-	/* If there is no pending command already, schedule a task. */
-	if (!sc->sc_dying && ++ring->queued == 1) {
-		mutex_spin_exit(>sc_task_mtx);
-		usb_add_task(sc->sc_udev, >sc_task, USB_TASKQ_DRIVER);
-	} else
-		mutex_spin_exit(>sc_task_mtx);
+	/*
+	 * Schedule a task to process the command if need be.
+	 */
+	if (!sc->sc_dying) {
+		if (ring->queued == URTWN_HOST_CMD_RING_COUNT)
+			device_printf(sc->sc_dev, "command queue overflow\n");
+		else if (ring->queued++ == 0)
+			schedtask = true;
+	}
+	mutex_spin_exit(>sc_task_mtx);
 	splx(s);
+
+	if (schedtask)
+		usb_add_task(sc->sc_udev, >sc_task, USB_TASKQ_DRIVER);
 }
 
 static void



CVS commit: [netbsd-8] src/sys/dev/usb

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 19:00:27 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-8]: if_urtwn.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1942):

sys/dev/usb/if_urtwn.c: revision 1.109 (patch)

urtwn(4): Ditch old queued commands on overflow.
Don't increment ring->queued past what the task will decrement.

This is a stop-gap measure; really, we should just have one task for
each operation that is deferred to the task thread.

PR kern/57965


To generate a diff of this commit:
cvs rdiff -u -r1.53.2.6 -r1.53.2.7 src/sys/dev/usb/if_urtwn.c

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



CVS commit: [netbsd-9] src/sys/dev/usb

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 18:59:19 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-9]: if_urtwn.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1810):

sys/dev/usb/if_urtwn.c: revision 1.109 (patch)

urtwn(4): Ditch old queued commands on overflow.
Don't increment ring->queued past what the task will decrement.

This is a stop-gap measure; really, we should just have one task for
each operation that is deferred to the task thread.

PR kern/57965


To generate a diff of this commit:
cvs rdiff -u -r1.71.2.6 -r1.71.2.7 src/sys/dev/usb/if_urtwn.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/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.71.2.6 src/sys/dev/usb/if_urtwn.c:1.71.2.7
--- src/sys/dev/usb/if_urtwn.c:1.71.2.6	Sat Oct 23 11:21:54 2021
+++ src/sys/dev/usb/if_urtwn.c	Sun Mar 10 18:59:19 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.71.2.6 2021/10/23 11:21:54 martin Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.71.2.7 2024/03/10 18:59:19 martin Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.71.2.6 2021/10/23 11:21:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.71.2.7 2024/03/10 18:59:19 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -833,6 +833,24 @@ urtwn_tx_beacon(struct urtwn_softc *sc, 
 }
 
 static void
+urtwn_cmdq_invariants(struct urtwn_softc *sc)
+{
+	struct urtwn_host_cmd_ring *const ring __diagused = >cmdq;
+
+	KASSERT(mutex_owned(>sc_task_mtx));
+	KASSERTMSG((ring->cur >= 0 && ring->cur < URTWN_HOST_CMD_RING_COUNT),
+	"%s: cur=%d next=%d queued=%d",
+	device_xname(sc->sc_dev), ring->cur, ring->next, ring->queued);
+	KASSERTMSG((ring->next >= 0 && ring->next < URTWN_HOST_CMD_RING_COUNT),
+	"%s: cur=%d next=%d queued=%d",
+	device_xname(sc->sc_dev), ring->cur, ring->next, ring->queued);
+	KASSERTMSG((ring->queued >= 0 &&
+		ring->queued <= URTWN_HOST_CMD_RING_COUNT),
+	"%s: %d commands queued",
+	device_xname(sc->sc_dev), ring->queued);
+}
+
+static void
 urtwn_task(void *arg)
 {
 	struct urtwn_softc *sc = arg;
@@ -865,7 +883,11 @@ urtwn_task(void *arg)
 	/* Process host commands. */
 	s = splusb();
 	mutex_spin_enter(>sc_task_mtx);
+	urtwn_cmdq_invariants(sc);
 	while (ring->next != ring->cur) {
+		KASSERTMSG(ring->queued > 0, "%s: cur=%d next=%d queued=%d",
+		device_xname(sc->sc_dev),
+		ring->cur, ring->next, ring->queued);
 		cmd = >cmd[ring->next];
 		mutex_spin_exit(>sc_task_mtx);
 		splx(s);
@@ -873,6 +895,10 @@ urtwn_task(void *arg)
 		cmd->cb(sc, cmd->data);
 		s = splusb();
 		mutex_spin_enter(>sc_task_mtx);
+		urtwn_cmdq_invariants(sc);
+		KASSERTMSG(ring->queued > 0, "%s: cur=%d next=%d queued=%d",
+		device_xname(sc->sc_dev),
+		ring->cur, ring->next, ring->queued);
 		ring->queued--;
 		ring->next = (ring->next + 1) % URTWN_HOST_CMD_RING_COUNT;
 	}
@@ -887,6 +913,7 @@ urtwn_do_async(struct urtwn_softc *sc, v
 {
 	struct urtwn_host_cmd_ring *ring = >cmdq;
 	struct urtwn_host_cmd *cmd;
+	bool schedtask = false;
 	int s;
 
 	DPRINTFN(DBG_FN, ("%s: %s: cb=%p, arg=%p, len=%d\n",
@@ -894,19 +921,27 @@ urtwn_do_async(struct urtwn_softc *sc, v
 
 	s = splusb();
 	mutex_spin_enter(>sc_task_mtx);
+	urtwn_cmdq_invariants(sc);
 	cmd = >cmd[ring->cur];
 	cmd->cb = cb;
 	KASSERT(len <= sizeof(cmd->data));
 	memcpy(cmd->data, arg, len);
 	ring->cur = (ring->cur + 1) % URTWN_HOST_CMD_RING_COUNT;
 
-	/* If there is no pending command already, schedule a task. */
-	if (!sc->sc_dying && ++ring->queued == 1) {
-		mutex_spin_exit(>sc_task_mtx);
-		usb_add_task(sc->sc_udev, >sc_task, USB_TASKQ_DRIVER);
-	} else
-		mutex_spin_exit(>sc_task_mtx);
+	/*
+	 * Schedule a task to process the command if need be.
+	 */
+	if (!sc->sc_dying) {
+		if (ring->queued == URTWN_HOST_CMD_RING_COUNT)
+			device_printf(sc->sc_dev, "command queue overflow\n");
+		else if (ring->queued++ == 0)
+			schedtask = true;
+	}
+	mutex_spin_exit(>sc_task_mtx);
 	splx(s);
+
+	if (schedtask)
+		usb_add_task(sc->sc_udev, >sc_task, USB_TASKQ_DRIVER);
 }
 
 static void



CVS commit: [netbsd-9] src/sys/dev/usb

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 18:59:19 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-9]: if_urtwn.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1810):

sys/dev/usb/if_urtwn.c: revision 1.109 (patch)

urtwn(4): Ditch old queued commands on overflow.
Don't increment ring->queued past what the task will decrement.

This is a stop-gap measure; really, we should just have one task for
each operation that is deferred to the task thread.

PR kern/57965


To generate a diff of this commit:
cvs rdiff -u -r1.71.2.6 -r1.71.2.7 src/sys/dev/usb/if_urtwn.c

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



CVS commit: [netbsd-10] src/sys/dev/usb

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 18:57:11 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: if_urtwn.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #616):

sys/dev/usb/if_urtwn.c: revision 1.109

urtwn(4): Ditch old queued commands on overflow.
Don't increment ring->queued past what the task will decrement.

This is a stop-gap measure; really, we should just have one task for
each operation that is deferred to the task thread.

PR kern/57965


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.105.4.1 src/sys/dev/usb/if_urtwn.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/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.105 src/sys/dev/usb/if_urtwn.c:1.105.4.1
--- src/sys/dev/usb/if_urtwn.c:1.105	Sun Jul 31 12:59:26 2022
+++ src/sys/dev/usb/if_urtwn.c	Sun Mar 10 18:57:11 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.105 2022/07/31 12:59:26 mlelstv Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.105.4.1 2024/03/10 18:57:11 martin Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.105 2022/07/31 12:59:26 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.105.4.1 2024/03/10 18:57:11 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -864,6 +864,24 @@ urtwn_tx_beacon(struct urtwn_softc *sc, 
 }
 
 static void
+urtwn_cmdq_invariants(struct urtwn_softc *sc)
+{
+	struct urtwn_host_cmd_ring *const ring = >cmdq;
+
+	KASSERT(mutex_owned(>sc_task_mtx));
+	KASSERTMSG((ring->cur >= 0 && ring->cur < URTWN_HOST_CMD_RING_COUNT),
+	"%s: cur=%d next=%d queued=%d",
+	device_xname(sc->sc_dev), ring->cur, ring->next, ring->queued);
+	KASSERTMSG((ring->next >= 0 && ring->next < URTWN_HOST_CMD_RING_COUNT),
+	"%s: cur=%d next=%d queued=%d",
+	device_xname(sc->sc_dev), ring->cur, ring->next, ring->queued);
+	KASSERTMSG((ring->queued >= 0 &&
+		ring->queued <= URTWN_HOST_CMD_RING_COUNT),
+	"%s: %d commands queued",
+	device_xname(sc->sc_dev), ring->queued);
+}
+
+static void
 urtwn_task(void *arg)
 {
 	struct urtwn_softc *sc = arg;
@@ -895,7 +913,11 @@ urtwn_task(void *arg)
 	/* Process host commands. */
 	s = splusb();
 	mutex_spin_enter(>sc_task_mtx);
+	urtwn_cmdq_invariants(sc);
 	while (ring->next != ring->cur) {
+		KASSERTMSG(ring->queued > 0, "%s: cur=%d next=%d queued=%d",
+		device_xname(sc->sc_dev),
+		ring->cur, ring->next, ring->queued);
 		cmd = >cmd[ring->next];
 		mutex_spin_exit(>sc_task_mtx);
 		splx(s);
@@ -903,6 +925,10 @@ urtwn_task(void *arg)
 		cmd->cb(sc, cmd->data);
 		s = splusb();
 		mutex_spin_enter(>sc_task_mtx);
+		urtwn_cmdq_invariants(sc);
+		KASSERTMSG(ring->queued > 0, "%s: cur=%d next=%d queued=%d",
+		device_xname(sc->sc_dev),
+		ring->cur, ring->next, ring->queued);
 		ring->queued--;
 		ring->next = (ring->next + 1) % URTWN_HOST_CMD_RING_COUNT;
 	}
@@ -917,6 +943,7 @@ urtwn_do_async(struct urtwn_softc *sc, v
 {
 	struct urtwn_host_cmd_ring *ring = >cmdq;
 	struct urtwn_host_cmd *cmd;
+	bool schedtask = false;
 	int s;
 
 	URTWNHIST_FUNC();
@@ -925,19 +952,27 @@ urtwn_do_async(struct urtwn_softc *sc, v
 
 	s = splusb();
 	mutex_spin_enter(>sc_task_mtx);
+	urtwn_cmdq_invariants(sc);
 	cmd = >cmd[ring->cur];
 	cmd->cb = cb;
 	KASSERT(len <= sizeof(cmd->data));
 	memcpy(cmd->data, arg, len);
 	ring->cur = (ring->cur + 1) % URTWN_HOST_CMD_RING_COUNT;
 
-	/* If there is no pending command already, schedule a task. */
-	if (!sc->sc_dying && ++ring->queued == 1) {
-		mutex_spin_exit(>sc_task_mtx);
-		usb_add_task(sc->sc_udev, >sc_task, USB_TASKQ_DRIVER);
-	} else
-		mutex_spin_exit(>sc_task_mtx);
+	/*
+	 * Schedule a task to process the command if need be.
+	 */
+	if (!sc->sc_dying) {
+		if (ring->queued == URTWN_HOST_CMD_RING_COUNT)
+			device_printf(sc->sc_dev, "command queue overflow\n");
+		else if (ring->queued++ == 0)
+			schedtask = true;
+	}
+	mutex_spin_exit(>sc_task_mtx);
 	splx(s);
+
+	if (schedtask)
+		usb_add_task(sc->sc_udev, >sc_task, USB_TASKQ_DRIVER);
 }
 
 static void



CVS commit: [netbsd-10] src/sys/dev/usb

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 18:57:11 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: if_urtwn.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #616):

sys/dev/usb/if_urtwn.c: revision 1.109

urtwn(4): Ditch old queued commands on overflow.
Don't increment ring->queued past what the task will decrement.

This is a stop-gap measure; really, we should just have one task for
each operation that is deferred to the task thread.

PR kern/57965


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.105.4.1 src/sys/dev/usb/if_urtwn.c

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



CVS commit: [netbsd-9] src/sys/netinet6

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 18:54:41 UTC 2024

Modified Files:
src/sys/netinet6 [netbsd-9]: icmp6.c raw_ip6.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1809):

sys/netinet6/raw_ip6.c: revision 1.184 (patch)
sys/netinet6/icmp6.c: revision 1.256 (patch)

Deliver timestamps also to raw sockets.
Fixes PR 57955


To generate a diff of this commit:
cvs rdiff -u -r1.242 -r1.242.4.1 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.175.4.1 -r1.175.4.2 src/sys/netinet6/raw_ip6.c

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



CVS commit: [netbsd-9] src/sys/netinet6

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 18:54:41 UTC 2024

Modified Files:
src/sys/netinet6 [netbsd-9]: icmp6.c raw_ip6.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1809):

sys/netinet6/raw_ip6.c: revision 1.184 (patch)
sys/netinet6/icmp6.c: revision 1.256 (patch)

Deliver timestamps also to raw sockets.
Fixes PR 57955


To generate a diff of this commit:
cvs rdiff -u -r1.242 -r1.242.4.1 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.175.4.1 -r1.175.4.2 src/sys/netinet6/raw_ip6.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/netinet6/icmp6.c
diff -u src/sys/netinet6/icmp6.c:1.242 src/sys/netinet6/icmp6.c:1.242.4.1
--- src/sys/netinet6/icmp6.c:1.242	Sat Dec 22 14:07:54 2018
+++ src/sys/netinet6/icmp6.c	Sun Mar 10 18:54:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: icmp6.c,v 1.242 2018/12/22 14:07:54 maxv Exp $	*/
+/*	$NetBSD: icmp6.c,v 1.242.4.1 2024/03/10 18:54:41 martin Exp $	*/
 /*	$KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.242 2018/12/22 14:07:54 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.242.4.1 2024/03/10 18:54:41 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1965,7 +1965,8 @@ icmp6_rip6_input(struct mbuf **mp, int o
 		}
 #endif
 		else if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) {
-			if (last->in6p_flags & IN6P_CONTROLOPTS)
+			if (last->in6p_flags & IN6P_CONTROLOPTS ||
+			SOOPT_TIMESTAMP(last->in6p_socket->so_options))
 ip6_savecontrol(last, , ip6, n);
 			/* strip intermediate headers */
 			m_adj(n, off);
@@ -1992,7 +1993,8 @@ icmp6_rip6_input(struct mbuf **mp, int o
 	} else
 #endif
 	if (last) {
-		if (last->in6p_flags & IN6P_CONTROLOPTS)
+		if (last->in6p_flags & IN6P_CONTROLOPTS ||
+		SOOPT_TIMESTAMP(last->in6p_socket->so_options))
 			ip6_savecontrol(last, , ip6, m);
 		/* strip intermediate headers */
 		m_adj(m, off);

Index: src/sys/netinet6/raw_ip6.c
diff -u src/sys/netinet6/raw_ip6.c:1.175.4.1 src/sys/netinet6/raw_ip6.c:1.175.4.2
--- src/sys/netinet6/raw_ip6.c:1.175.4.1	Thu Mar 23 12:06:49 2023
+++ src/sys/netinet6/raw_ip6.c	Sun Mar 10 18:54:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip6.c,v 1.175.4.1 2023/03/23 12:06:49 martin Exp $	*/
+/*	$NetBSD: raw_ip6.c,v 1.175.4.2 2024/03/10 18:54:41 martin Exp $	*/
 /*	$KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.175.4.1 2023/03/23 12:06:49 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.175.4.2 2024/03/10 18:54:41 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -140,7 +140,8 @@ rip6_sbappendaddr(struct in6pcb *last, s
 {
 	struct mbuf *opts = NULL;
 
-	if (last->in6p_flags & IN6P_CONTROLOPTS)
+	if (last->in6p_flags & IN6P_CONTROLOPTS ||
+	SOOPT_TIMESTAMP(last->in6p_socket->so_options))
 		ip6_savecontrol(last, , ip6, n);
 
 	m_adj(n, hlen);



CVS commit: src/usr.bin/kdump

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 18:54:41 UTC 2024

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

Log Message:
kdump: keep the comment with its corresponding code

No binary change.


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

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

Modified files:

Index: src/usr.bin/kdump/kdump.c
diff -u src/usr.bin/kdump/kdump.c:1.143 src/usr.bin/kdump/kdump.c:1.144
--- src/usr.bin/kdump/kdump.c:1.143	Sun Mar 10 17:08:31 2024
+++ src/usr.bin/kdump/kdump.c	Sun Mar 10 18:54:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: kdump.c,v 1.143 2024/03/10 17:08:31 christos Exp $	*/
+/*	$NetBSD: kdump.c,v 1.144 2024/03/10 18:54:41 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)kdump.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: kdump.c,v 1.143 2024/03/10 17:08:31 christos Exp $");
+__RCSID("$NetBSD: kdump.c,v 1.144 2024/03/10 18:54:41 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -892,11 +892,6 @@ ktrsyscall(struct ktr_syscall *ktr)
 			argcount--;
 			c = ',';
 
-			/*
-			 * Linux name is "futex".
-			 * Native name is "__futex".
-			 * Both have the same op argument.
-			 */
 		} else if ((strcmp(sys_name, "setsockopt") == 0 ||
 		strcmp(sys_name, "getsockopt") == 0 ||
 		strcmp(sys_name, "getsockopt2") == 0) && argcount >= 3) {
@@ -940,9 +935,15 @@ ktrsyscall(struct ktr_syscall *ktr)
 			ap++;
 			argcount--;
 			c = ',';
+
 		} else if ((strcmp(sys_name, "futex") == 0 ||
 			strcmp(sys_name, "__futex") == 0) &&
 			   argcount > 2) {
+			/*
+			 * Linux name is "futex".
+			 * Native name is "__futex".
+			 * Both have the same op argument.
+			 */
 			(void)putchar('(');
 			output_long((long)*ap, 1);
 			(void)putchar(',');



CVS commit: src/usr.bin/kdump

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 18:54:41 UTC 2024

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

Log Message:
kdump: keep the comment with its corresponding code

No binary change.


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

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



CVS commit: [netbsd-10] src/sys/netinet6

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 18:51:54 UTC 2024

Modified Files:
src/sys/netinet6 [netbsd-10]: icmp6.c raw_ip6.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #615):

sys/netinet6/raw_ip6.c: revision 1.184
sys/netinet6/icmp6.c: revision 1.256

Deliver timestamps also to raw sockets.
Fixes PR 57955


To generate a diff of this commit:
cvs rdiff -u -r1.254.2.1 -r1.254.2.2 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.182.2.1 -r1.182.2.2 src/sys/netinet6/raw_ip6.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/netinet6/icmp6.c
diff -u src/sys/netinet6/icmp6.c:1.254.2.1 src/sys/netinet6/icmp6.c:1.254.2.2
--- src/sys/netinet6/icmp6.c:1.254.2.1	Sun Dec 10 13:06:16 2023
+++ src/sys/netinet6/icmp6.c	Sun Mar 10 18:51:54 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: icmp6.c,v 1.254.2.1 2023/12/10 13:06:16 martin Exp $	*/
+/*	$NetBSD: icmp6.c,v 1.254.2.2 2024/03/10 18:51:54 martin Exp $	*/
 /*	$KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.254.2.1 2023/12/10 13:06:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.254.2.2 2024/03/10 18:51:54 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1987,7 +1987,8 @@ icmp6_rip6_input(struct mbuf **mp, int o
 		}
 #endif
 		else if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) {
-			if (last->inp_flags & IN6P_CONTROLOPTS)
+			if (last->inp_flags & IN6P_CONTROLOPTS ||
+			SOOPT_TIMESTAMP(last->inp_socket->so_options))
 ip6_savecontrol(last, , ip6, n);
 			/* strip intermediate headers */
 			m_adj(n, off);
@@ -2014,7 +2015,8 @@ icmp6_rip6_input(struct mbuf **mp, int o
 	} else
 #endif
 	if (last) {
-		if (last->inp_flags & IN6P_CONTROLOPTS)
+		if (last->inp_flags & IN6P_CONTROLOPTS ||
+		SOOPT_TIMESTAMP(last->inp_socket->so_options))
 			ip6_savecontrol(last, , ip6, m);
 		/* strip intermediate headers */
 		m_adj(m, off);

Index: src/sys/netinet6/raw_ip6.c
diff -u src/sys/netinet6/raw_ip6.c:1.182.2.1 src/sys/netinet6/raw_ip6.c:1.182.2.2
--- src/sys/netinet6/raw_ip6.c:1.182.2.1	Thu Mar 23 12:03:04 2023
+++ src/sys/netinet6/raw_ip6.c	Sun Mar 10 18:51:54 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip6.c,v 1.182.2.1 2023/03/23 12:03:04 martin Exp $	*/
+/*	$NetBSD: raw_ip6.c,v 1.182.2.2 2024/03/10 18:51:54 martin Exp $	*/
 /*	$KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.182.2.1 2023/03/23 12:03:04 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.182.2.2 2024/03/10 18:51:54 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -140,7 +140,8 @@ rip6_sbappendaddr(struct inpcb *last, st
 {
 	struct mbuf *opts = NULL;
 
-	if (last->inp_flags & IN6P_CONTROLOPTS)
+	if (last->inp_flags & IN6P_CONTROLOPTS ||
+	SOOPT_TIMESTAMP(last->inp_socket->so_options))
 		ip6_savecontrol(last, , ip6, n);
 
 	m_adj(n, hlen);



CVS commit: [netbsd-10] src/sys/netinet6

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 18:51:54 UTC 2024

Modified Files:
src/sys/netinet6 [netbsd-10]: icmp6.c raw_ip6.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #615):

sys/netinet6/raw_ip6.c: revision 1.184
sys/netinet6/icmp6.c: revision 1.256

Deliver timestamps also to raw sockets.
Fixes PR 57955


To generate a diff of this commit:
cvs rdiff -u -r1.254.2.1 -r1.254.2.2 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.182.2.1 -r1.182.2.2 src/sys/netinet6/raw_ip6.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/lib/libc/net

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 18:48:57 UTC 2024

Modified Files:
src/lib/libc/net [netbsd-8]: getnameinfo.3

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1941):

lib/libc/net/getnameinfo.3: revision 1.43

Document the NI_NUMERICSCOPE flag.
PR lib/57832


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.41.18.1 src/lib/libc/net/getnameinfo.3

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

Modified files:

Index: src/lib/libc/net/getnameinfo.3
diff -u src/lib/libc/net/getnameinfo.3:1.41 src/lib/libc/net/getnameinfo.3:1.41.18.1
--- src/lib/libc/net/getnameinfo.3:1.41	Sun Aug 18 10:40:06 2013
+++ src/lib/libc/net/getnameinfo.3	Sun Mar 10 18:48:57 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: getnameinfo.3,v 1.41 2013/08/18 10:40:06 wiz Exp $
+.\"	$NetBSD: getnameinfo.3,v 1.41.18.1 2024/03/10 18:48:57 martin Exp $
 .\"	$KAME: getnameinfo.3,v 1.37 2005/01/05 03:23:05 itojun Exp $
 .\"	$OpenBSD: getnameinfo.3,v 1.36 2004/12/21 09:48:20 jmc Exp $
 .\"
@@ -17,7 +17,7 @@
 .\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 .\" PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd August 18, 2013
+.Dd February 15, 2024
 .Dt GETNAMEINFO 3
 .Os
 .Sh NAME
@@ -106,6 +106,10 @@ If the host name cannot be found in DNS 
 a non-zero error code is returned.
 If the host name is not found and the flag is not set, the
 address is returned in numeric form.
+.It NI_NUMERICSCOPE
+For IPv6 addresses the numeric form of the IPv6 scope identifier is
+returned.
+This flag is ignored for non-IPv6 addresses.
 .It NI_NUMERICSERV
 The service name is returned as a digit string representing the port number.
 .It NI_DGRAM



CVS commit: [netbsd-8] src/lib/libc/net

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 18:48:57 UTC 2024

Modified Files:
src/lib/libc/net [netbsd-8]: getnameinfo.3

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1941):

lib/libc/net/getnameinfo.3: revision 1.43

Document the NI_NUMERICSCOPE flag.
PR lib/57832


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.41.18.1 src/lib/libc/net/getnameinfo.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/lib/libc/net

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 18:44:37 UTC 2024

Modified Files:
src/lib/libc/net [netbsd-9]: getnameinfo.3

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1808):

lib/libc/net/getnameinfo.3: revision 1.43

Document the NI_NUMERICSCOPE flag.
PR lib/57832


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.42.8.1 src/lib/libc/net/getnameinfo.3

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

Modified files:

Index: src/lib/libc/net/getnameinfo.3
diff -u src/lib/libc/net/getnameinfo.3:1.42 src/lib/libc/net/getnameinfo.3:1.42.8.1
--- src/lib/libc/net/getnameinfo.3:1.42	Mon Jul  3 21:32:49 2017
+++ src/lib/libc/net/getnameinfo.3	Sun Mar 10 18:44:37 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: getnameinfo.3,v 1.42 2017/07/03 21:32:49 wiz Exp $
+.\"	$NetBSD: getnameinfo.3,v 1.42.8.1 2024/03/10 18:44:37 martin Exp $
 .\"	$KAME: getnameinfo.3,v 1.37 2005/01/05 03:23:05 itojun Exp $
 .\"	$OpenBSD: getnameinfo.3,v 1.36 2004/12/21 09:48:20 jmc Exp $
 .\"
@@ -17,7 +17,7 @@
 .\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 .\" PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd August 18, 2013
+.Dd February 15, 2024
 .Dt GETNAMEINFO 3
 .Os
 .Sh NAME
@@ -106,6 +106,10 @@ If the host name cannot be found in DNS 
 a non-zero error code is returned.
 If the host name is not found and the flag is not set, the
 address is returned in numeric form.
+.It NI_NUMERICSCOPE
+For IPv6 addresses the numeric form of the IPv6 scope identifier is
+returned.
+This flag is ignored for non-IPv6 addresses.
 .It NI_NUMERICSERV
 The service name is returned as a digit string representing the port number.
 .It NI_DGRAM



CVS commit: [netbsd-9] src/lib/libc/net

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 18:44:37 UTC 2024

Modified Files:
src/lib/libc/net [netbsd-9]: getnameinfo.3

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1808):

lib/libc/net/getnameinfo.3: revision 1.43

Document the NI_NUMERICSCOPE flag.
PR lib/57832


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.42.8.1 src/lib/libc/net/getnameinfo.3

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



CVS commit: [netbsd-10] src/lib/libc/net

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 18:42:42 UTC 2024

Modified Files:
src/lib/libc/net [netbsd-10]: getnameinfo.3

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #614):

lib/libc/net/getnameinfo.3: revision 1.43

Document the NI_NUMERICSCOPE flag.
PR lib/57832


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.42.16.1 src/lib/libc/net/getnameinfo.3

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

Modified files:

Index: src/lib/libc/net/getnameinfo.3
diff -u src/lib/libc/net/getnameinfo.3:1.42 src/lib/libc/net/getnameinfo.3:1.42.16.1
--- src/lib/libc/net/getnameinfo.3:1.42	Mon Jul  3 21:32:49 2017
+++ src/lib/libc/net/getnameinfo.3	Sun Mar 10 18:42:42 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: getnameinfo.3,v 1.42 2017/07/03 21:32:49 wiz Exp $
+.\"	$NetBSD: getnameinfo.3,v 1.42.16.1 2024/03/10 18:42:42 martin Exp $
 .\"	$KAME: getnameinfo.3,v 1.37 2005/01/05 03:23:05 itojun Exp $
 .\"	$OpenBSD: getnameinfo.3,v 1.36 2004/12/21 09:48:20 jmc Exp $
 .\"
@@ -17,7 +17,7 @@
 .\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 .\" PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd August 18, 2013
+.Dd February 15, 2024
 .Dt GETNAMEINFO 3
 .Os
 .Sh NAME
@@ -106,6 +106,10 @@ If the host name cannot be found in DNS 
 a non-zero error code is returned.
 If the host name is not found and the flag is not set, the
 address is returned in numeric form.
+.It NI_NUMERICSCOPE
+For IPv6 addresses the numeric form of the IPv6 scope identifier is
+returned.
+This flag is ignored for non-IPv6 addresses.
 .It NI_NUMERICSERV
 The service name is returned as a digit string representing the port number.
 .It NI_DGRAM



CVS commit: [netbsd-10] src/lib/libc/net

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 18:42:42 UTC 2024

Modified Files:
src/lib/libc/net [netbsd-10]: getnameinfo.3

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #614):

lib/libc/net/getnameinfo.3: revision 1.43

Document the NI_NUMERICSCOPE flag.
PR lib/57832


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.42.16.1 src/lib/libc/net/getnameinfo.3

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



CVS commit: [netbsd-10] src/sys/dev/usb

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 18:36:12 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: usbdi.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #613):

sys/dev/usb/usbdi.c: revision 1.248
sys/dev/usb/usbdi.c: revision 1.249

usbdi(9): Avoid calling ubm_softint with lock held and polling on.
usbdi(9): Avoid taking locks in usbd_transfer while polling.

PR kern/57783


To generate a diff of this commit:
cvs rdiff -u -r1.247 -r1.247.4.1 src/sys/dev/usb/usbdi.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/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.247 src/sys/dev/usb/usbdi.c:1.247.4.1
--- src/sys/dev/usb/usbdi.c:1.247	Tue Sep 13 10:32:58 2022
+++ src/sys/dev/usb/usbdi.c	Sun Mar 10 18:36:12 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdi.c,v 1.247 2022/09/13 10:32:58 riastradh Exp $	*/
+/*	$NetBSD: usbdi.c,v 1.247.4.1 2024/03/10 18:36:12 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.247 2022/09/13 10:32:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.247.4.1 2024/03/10 18:36:12 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -410,14 +410,18 @@ usbd_transfer(struct usbd_xfer *xfer)
 		}
 	}
 
-	usbd_lock_pipe(pipe);
+	if (pipe->up_dev->ud_bus->ub_usepolling == 0)
+		usbd_lock_pipe(pipe);
 	if (pipe->up_aborting) {
 		/*
 		 * XXX For synchronous transfers this is fine.  What to
 		 * do for asynchronous transfers?  The callback is
 		 * never run, not even with status USBD_CANCELLED.
+		 *
+		 * XXX Does it make sense to abort while polling?
 		 */
-		usbd_unlock_pipe(pipe);
+		if (pipe->up_dev->ud_bus->ub_usepolling == 0)
+			usbd_unlock_pipe(pipe);
 		USBHIST_LOG(usbdebug, "<- done xfer %#jx, aborting",
 		(uintptr_t)xfer, 0, 0, 0);
 		SDT_PROBE2(usb, device, xfer, done,  xfer, USBD_CANCELLED);
@@ -443,7 +447,8 @@ usbd_transfer(struct usbd_xfer *xfer)
 	} while (0);
 	SDT_PROBE3(usb, device, pipe, transfer__done,  pipe, xfer, err);
 
-	usbd_unlock_pipe(pipe);
+	if (pipe->up_dev->ud_bus->ub_usepolling == 0)
+		usbd_unlock_pipe(pipe);
 
 	if (err != USBD_IN_PROGRESS && err) {
 		/*
@@ -453,7 +458,8 @@ usbd_transfer(struct usbd_xfer *xfer)
 		 */
 		USBHIST_LOG(usbdebug, "xfer failed: %jd, reinserting",
 		err, 0, 0, 0);
-		usbd_lock_pipe(pipe);
+		if (pipe->up_dev->ud_bus->ub_usepolling == 0)
+			usbd_lock_pipe(pipe);
 		SDT_PROBE1(usb, device, xfer, preabort,  xfer);
 #ifdef DIAGNOSTIC
 		xfer->ux_state = XFER_BUSY;
@@ -461,7 +467,8 @@ usbd_transfer(struct usbd_xfer *xfer)
 		SIMPLEQ_REMOVE_HEAD(>up_queue, ux_next);
 		if (pipe->up_serialise)
 			usbd_start_next(pipe);
-		usbd_unlock_pipe(pipe);
+		if (pipe->up_dev->ud_bus->ub_usepolling == 0)
+			usbd_unlock_pipe(pipe);
 	}
 
 	if (!(flags & USBD_SYNCHRONOUS)) {
@@ -480,7 +487,8 @@ usbd_transfer(struct usbd_xfer *xfer)
 	}
 
 	/* Sync transfer, wait for completion. */
-	usbd_lock_pipe(pipe);
+	if (pipe->up_dev->ud_bus->ub_usepolling == 0)
+		usbd_lock_pipe(pipe);
 	while (!xfer->ux_done) {
 		if (pipe->up_dev->ud_bus->ub_usepolling)
 			panic("usbd_transfer: not done");
@@ -503,7 +511,8 @@ usbd_transfer(struct usbd_xfer *xfer)
 	}
 	err = xfer->ux_status;
 	SDT_PROBE2(usb, device, xfer, done,  xfer, err);
-	usbd_unlock_pipe(pipe);
+	if (pipe->up_dev->ud_bus->ub_usepolling == 0)
+		usbd_unlock_pipe(pipe);
 	return err;
 }
 
@@ -1362,14 +1371,34 @@ usbd_dopoll(struct usbd_interface *iface
 void
 usbd_set_polling(struct usbd_device *dev, int on)
 {
-	if (on)
-		dev->ud_bus->ub_usepolling++;
-	else
-		dev->ud_bus->ub_usepolling--;
 
-	/* Kick the host controller when switching modes */
 	mutex_enter(dev->ud_bus->ub_lock);
-	dev->ud_bus->ub_methods->ubm_softint(dev->ud_bus);
+	if (on) {
+		/*
+		 * Enabling polling.  If we're enabling for the first
+		 * time, call the softint routine on transition while
+		 * we hold the lock and polling is still disabled, and
+		 * then enable polling -- once polling is enabled, we
+		 * must not hold the lock when we call the softint
+		 * routine.
+		 */
+		KASSERT(dev->ud_bus->ub_usepolling < __type_max(char));
+		if (dev->ud_bus->ub_usepolling == 0)
+			dev->ud_bus->ub_methods->ubm_softint(dev->ud_bus);
+		dev->ud_bus->ub_usepolling++;
+	} else {
+		/*
+		 * Disabling polling.  If we're disabling polling for
+		 * the last time, disable polling first and then call
+		 * the softint routine while we hold the lock -- until
+		 * polling is disabled, we must not hold the lock when
+		 * we call the softint routine.
+		 */
+		KASSERT(dev->ud_bus->ub_usepolling > 0);
+		dev->ud_bus->ub_usepolling--;
+		if (dev->ud_bus->ub_usepolling == 0)
+			dev->ud_bus->ub_methods->ubm_softint(dev->ud_bus);
+	}
 	mutex_exit(dev->ud_bus->ub_lock);
 }
 



CVS commit: [netbsd-10] src/sys/dev/usb

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 18:36:12 UTC 2024

Modified Files:
src/sys/dev/usb [netbsd-10]: usbdi.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #613):

sys/dev/usb/usbdi.c: revision 1.248
sys/dev/usb/usbdi.c: revision 1.249

usbdi(9): Avoid calling ubm_softint with lock held and polling on.
usbdi(9): Avoid taking locks in usbd_transfer while polling.

PR kern/57783


To generate a diff of this commit:
cvs rdiff -u -r1.247 -r1.247.4.1 src/sys/dev/usb/usbdi.c

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



CVS commit: src/usr.sbin/postinstall

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 18:23:18 UTC 2024

Modified Files:
src/usr.sbin/postinstall: postinstall.in

Log Message:
postinstall: fix parameter order in usage message


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/usr.sbin/postinstall/postinstall.in

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

Modified files:

Index: src/usr.sbin/postinstall/postinstall.in
diff -u src/usr.sbin/postinstall/postinstall.in:1.61 src/usr.sbin/postinstall/postinstall.in:1.62
--- src/usr.sbin/postinstall/postinstall.in:1.61	Sat Mar  9 06:51:40 2024
+++ src/usr.sbin/postinstall/postinstall.in	Sun Mar 10 18:23:18 2024
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall.in,v 1.61 2024/03/09 06:51:40 rillig Exp $
+# $NetBSD: postinstall.in,v 1.62 2024/03/10 18:23:18 rillig Exp $
 #
 # Copyright (c) 2002-2022 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -235,7 +235,7 @@ check_dir()
 #
 check_ids()
 {
-	[ $# -ge 6 ] || err 3 "USAGE: checks_ids op type file start srcfile id ..."
+	[ $# -ge 6 ] || err 3 "USAGE: checks_ids op type file srcfile start id ..."
 	local op="$1"
 	local type="$2"
 	local file="$3"



CVS commit: src/usr.sbin/postinstall

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 18:23:18 UTC 2024

Modified Files:
src/usr.sbin/postinstall: postinstall.in

Log Message:
postinstall: fix parameter order in usage message


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/usr.sbin/postinstall/postinstall.in

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



CVS commit: src/lib/libc/compiler_rt

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 18:00:13 UTC 2024

Modified Files:
src/lib/libc/compiler_rt: Makefile.inc

Log Message:
compiler_rt: allow signed bit shifts for __negv

Standard C defines '1 << 31' as undefined behavior, but
https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html allows
it for GCC.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/lib/libc/compiler_rt/Makefile.inc

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

Modified files:

Index: src/lib/libc/compiler_rt/Makefile.inc
diff -u src/lib/libc/compiler_rt/Makefile.inc:1.46 src/lib/libc/compiler_rt/Makefile.inc:1.47
--- src/lib/libc/compiler_rt/Makefile.inc:1.46	Tue Jan 23 15:32:18 2024
+++ src/lib/libc/compiler_rt/Makefile.inc	Sun Mar 10 18:00:13 2024
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.46 2024/01/23 15:32:18 christos Exp $
+# $NetBSD: Makefile.inc,v 1.47 2024/03/10 18:00:13 rillig Exp $
 
 COMPILER_RT_DIR=	${NETBSDSRCDIR}/sys/external/bsd/compiler_rt
 COMPILER_RT_SRCDIR=	${COMPILER_RT_DIR}/dist
@@ -396,9 +396,9 @@ LINTFLAGS.mulvti3.c += -X 117,351
 LINTFLAGS.negdf2.c += -X 309,351
 LINTFLAGS.negsf2.c += -X 132,351
 LINTFLAGS.negti2.c += -X 351
-LINTFLAGS.negvdi2.c += -X 351
-LINTFLAGS.negvsi2.c += -X 351
-LINTFLAGS.negvti2.c += -X 351
+LINTFLAGS.negvdi2.c += -X 141,351
+LINTFLAGS.negvsi2.c += -X 141,351
+LINTFLAGS.negvti2.c += -X 141,351
 LINTFLAGS.parityti2.c += -X 351
 LINTFLAGS.popcountdi2.c += -X 351
 LINTFLAGS.popcountsi2.c += -X 351



CVS commit: src/lib/libc/compiler_rt

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 18:00:13 UTC 2024

Modified Files:
src/lib/libc/compiler_rt: Makefile.inc

Log Message:
compiler_rt: allow signed bit shifts for __negv

Standard C defines '1 << 31' as undefined behavior, but
https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html allows
it for GCC.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/lib/libc/compiler_rt/Makefile.inc

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



CVS commit: src/sys/ufs/ext2fs

2024-03-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 10 17:36:33 UTC 2024

Modified Files:
src/sys/ufs/ext2fs: ext2fs_dir.h

Log Message:
PR/58018: Damir Holovati: ext2fs readdir (d_type conversion error)


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/ext2fs/ext2fs_dir.h

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



CVS commit: src/sys/ufs/ext2fs

2024-03-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 10 17:36:33 UTC 2024

Modified Files:
src/sys/ufs/ext2fs: ext2fs_dir.h

Log Message:
PR/58018: Damir Holovati: ext2fs readdir (d_type conversion error)


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/ext2fs/ext2fs_dir.h

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

Modified files:

Index: src/sys/ufs/ext2fs/ext2fs_dir.h
diff -u src/sys/ufs/ext2fs/ext2fs_dir.h:1.22 src/sys/ufs/ext2fs/ext2fs_dir.h:1.23
--- src/sys/ufs/ext2fs/ext2fs_dir.h:1.22	Sat Aug  6 21:47:11 2016
+++ src/sys/ufs/ext2fs/ext2fs_dir.h	Sun Mar 10 13:36:33 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_dir.h,v 1.22 2016/08/07 01:47:11 kre Exp $	*/
+/*	$NetBSD: ext2fs_dir.h,v 1.23 2024/03/10 17:36:33 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -174,7 +174,7 @@ ext2dt2dt(uint8_t type)
 {
 	switch (type) {
 	case EXT2_FT_REG_FILE:
-		return DT_FIFO;
+		return DT_REG;
 	case EXT2_FT_DIR:
 		return DT_DIR;
 	case EXT2_FT_CHRDEV:



CVS commit: src/sys/arch

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 17:34:47 UTC 2024

Modified Files:
src/sys/arch/sparc/include: ctlreg.h
src/sys/arch/sparc64/include: ctlreg.h

Log Message:
sparc: fix snprintb formats for SFSR_BITS


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/sparc/include/ctlreg.h
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/sparc64/include/ctlreg.h

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

Modified files:

Index: src/sys/arch/sparc/include/ctlreg.h
diff -u src/sys/arch/sparc/include/ctlreg.h:1.31 src/sys/arch/sparc/include/ctlreg.h:1.32
--- src/sys/arch/sparc/include/ctlreg.h:1.31	Mon Sep  6 21:56:03 2021
+++ src/sys/arch/sparc/include/ctlreg.h	Sun Mar 10 17:34:46 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ctlreg.h,v 1.31 2021/09/06 21:56:03 andvar Exp $ */
+/*	$NetBSD: ctlreg.h,v 1.32 2024/03/10 17:34:46 rillig Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -376,7 +376,7 @@
 #define	SFSR_BITS	"\177\020"		\
 	"b\21EM\0b\20CS\0b\17SB\0f\15\2PERR\0"	\
 	"b\14UC\0b\13TO\0b\12BE\0f\10\2LVL\0"	\
-	"f\05\3AT\0f\02\3FT\0b\01FAV\0b\01OW\0"
+	"f\05\3AT\0f\02\3FT\0b\01FAV\0b\00OW\0"
 
 /* [4m] Synchronous Fault Types */
 #define SFSR_FT_NONE		(0 << 2) 	/* no fault */

Index: src/sys/arch/sparc64/include/ctlreg.h
diff -u src/sys/arch/sparc64/include/ctlreg.h:1.70 src/sys/arch/sparc64/include/ctlreg.h:1.71
--- src/sys/arch/sparc64/include/ctlreg.h:1.70	Fri Feb  2 22:33:42 2024
+++ src/sys/arch/sparc64/include/ctlreg.h	Sun Mar 10 17:34:47 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ctlreg.h,v 1.70 2024/02/02 22:33:42 andvar Exp $ */
+/*	$NetBSD: ctlreg.h,v 1.71 2024/03/10 17:34:47 rillig Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath
@@ -306,9 +306,10 @@
 		SFSR_ILL_ASI|SFSR_FT_IO_ATOMIC|SFSR_FT_ILL_NF|SFSR_FT_PRIV)
 
 #define	SFSR_BITS "\177\20" \
-	"f\20\30ASI\0" "b\16VAT\0" "b\15VAD\0" "b\14NFO\0" "b\13ASI\0" "b\12A\0" \
-	"b\11NF\0" "b\10PRIV\0" "b\7E\0" "b\6NUCLEUS\0" "b\5SECONDCTX\0" "b\4PRIV\0" \
-	"b\3W\0" "b\2OW\0" "b\1FV\0"
+	"f\20\30ASI\0"			"b\15VAT\0"	"b\14VAD\0" \
+	"b\13NFO\0"	"b\12ASI\0"	"b\11A\0"	"b\10NF\0" \
+	"b\07PRIV\0"	"b\06E\0"	"b\05NUCLEUS\0"	"b\04SECONDCTX\0" \
+	"b\03PRIV\0"	"b\02W\0"	"b\01OW\0"	"b\00FV\0"
 
 /* ASFR bits */
 #define	ASFR_ME			0x1LL



CVS commit: src/sys/arch

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 17:34:47 UTC 2024

Modified Files:
src/sys/arch/sparc/include: ctlreg.h
src/sys/arch/sparc64/include: ctlreg.h

Log Message:
sparc: fix snprintb formats for SFSR_BITS


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/sparc/include/ctlreg.h
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/sparc64/include/ctlreg.h

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



CVS commit: src/sys/dev/ic

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 17:16:26 UTC 2024

Modified Files:
src/sys/dev/ic: lsi64854reg.h

Log Message:
lsi64854reg: fix snprintb formats DDMACSR_BITS and PDMACSR_BITS


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/lsi64854reg.h

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

Modified files:

Index: src/sys/dev/ic/lsi64854reg.h
diff -u src/sys/dev/ic/lsi64854reg.h:1.6 src/sys/dev/ic/lsi64854reg.h:1.7
--- src/sys/dev/ic/lsi64854reg.h:1.6	Mon Apr 28 20:23:50 2008
+++ src/sys/dev/ic/lsi64854reg.h	Sun Mar 10 17:16:26 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: lsi64854reg.h,v 1.6 2008/04/28 20:23:50 martin Exp $ */
+/*	$NetBSD: lsi64854reg.h,v 1.7 2024/03/10 17:16:26 rillig Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
 #define DDMACSR_BITS	"\177\020"\
 	"b\00INT\0b\01ERR\0f\02\02DRAINING\0b\04IEN\0"		\
 	"b\06SLVERR\0b\07RST\0b\10WRITE\0b\11ENDMA\0"		\
-	"b\15ENCNT\0b\16TC\0\b\20DSBL_CSR_DRN\0"		\
+	"b\15ENCNT\0b\16TC\0b\20DSBL_CSR_DRN\0"			\
 	"b\21DSBL_SCSI_DRN\0f\22\2BURST\0b\25TWOCYCLE\0"	\
 	"b\26FASTER\0b\27TCIDIS\0b\30ENNXT\0b\031DMAON\0"	\
 	"b\32ALOADED\0b\33NALOADED\0"
@@ -192,5 +192,5 @@
 #define PDMACSR_BITS	"\177\020"\
 	"b\00INT\0b\01ERR\0f\02\02DRAINING\0b\04IEN\0"		\
 	"b\06SLVERR\0b\07RST\0b\10WRITE\0b\11ENDMA\0"		\
-	"b\15ENCNT\0b\16TC\0\b\24DIAG\0b\27TCIDIS\0"		\
+	"b\15ENCNT\0b\16TC\0b\24DIAG\0b\27TCIDIS\0"		\
 	"b\30ENNXT\0b\031DMAON\0b\32ALOADED\0b\33NALOADED\0"



CVS commit: src/sys/dev/ic

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 17:16:26 UTC 2024

Modified Files:
src/sys/dev/ic: lsi64854reg.h

Log Message:
lsi64854reg: fix snprintb formats DDMACSR_BITS and PDMACSR_BITS


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/lsi64854reg.h

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



CVS commit: src/usr.bin/kdump

2024-03-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 10 17:08:31 UTC 2024

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

Log Message:
decode some {g,s}etsockopt*.


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

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

Modified files:

Index: src/usr.bin/kdump/kdump.c
diff -u src/usr.bin/kdump/kdump.c:1.142 src/usr.bin/kdump/kdump.c:1.143
--- src/usr.bin/kdump/kdump.c:1.142	Sat Feb 10 20:08:57 2024
+++ src/usr.bin/kdump/kdump.c	Sun Mar 10 13:08:31 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: kdump.c,v 1.142 2024/02/11 01:08:57 kre Exp $	*/
+/*	$NetBSD: kdump.c,v 1.143 2024/03/10 17:08:31 christos Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)kdump.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: kdump.c,v 1.142 2024/02/11 01:08:57 kre Exp $");
+__RCSID("$NetBSD: kdump.c,v 1.143 2024/03/10 17:08:31 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -69,11 +69,16 @@ __RCSID("$NetBSD: kdump.c,v 1.142 2024/0
 #include 
 #include 
 
+#include 
+#include 
+
 #include "ktrace.h"
 #include "setemul.h"
 
 #include 
 
+#define	CASERETURN(a)	case a:	return # a
+
 #define TIMESTAMP_NONE		0x0
 #define TIMESTAMP_ABSOLUTE	0x1
 #define TIMESTAMP_ELAPSED	0x2
@@ -552,23 +557,152 @@ output_long(u_long it, int as_x)
 static const char *
 fcntlname(u_long cmd)
 {
-#define	FCNTLCASE(a)	case a:	return # a
 	switch (cmd) {
-	FCNTLCASE(F_DUPFD);
-	FCNTLCASE(F_GETFD);
-	FCNTLCASE(F_SETFD);
-	FCNTLCASE(F_GETFL);
-	FCNTLCASE(F_SETFL);
-	FCNTLCASE(F_GETOWN);
-	FCNTLCASE(F_SETOWN);
-	FCNTLCASE(F_GETLK);
-	FCNTLCASE(F_SETLK);
-	FCNTLCASE(F_SETLKW);
-	FCNTLCASE(F_CLOSEM);
-	FCNTLCASE(F_MAXFD);
-	FCNTLCASE(F_DUPFD_CLOEXEC);
-	FCNTLCASE(F_GETNOSIGPIPE);
-	FCNTLCASE(F_SETNOSIGPIPE);
+	CASERETURN(F_DUPFD);
+	CASERETURN(F_GETFD);
+	CASERETURN(F_SETFD);
+	CASERETURN(F_GETFL);
+	CASERETURN(F_SETFL);
+	CASERETURN(F_GETOWN);
+	CASERETURN(F_SETOWN);
+	CASERETURN(F_GETLK);
+	CASERETURN(F_SETLK);
+	CASERETURN(F_SETLKW);
+	CASERETURN(F_CLOSEM);
+	CASERETURN(F_MAXFD);
+	CASERETURN(F_DUPFD_CLOEXEC);
+	CASERETURN(F_GETNOSIGPIPE);
+	CASERETURN(F_SETNOSIGPIPE);
+	default:
+		return NULL;
+	}
+}
+
+static const char *
+sockproto(register_t proto)
+{
+	switch (proto) {
+	CASERETURN(IPPROTO_IP);
+	CASERETURN(IPPROTO_ICMP);
+	CASERETURN(IPPROTO_IGMP);
+	CASERETURN(IPPROTO_GGP);
+//	CASERETURN(IPPROTO_IPV4);
+	CASERETURN(IPPROTO_IPIP);
+	CASERETURN(IPPROTO_TCP);
+	CASERETURN(IPPROTO_EGP);
+	CASERETURN(IPPROTO_PUP);
+	CASERETURN(IPPROTO_UDP);
+	CASERETURN(IPPROTO_IDP);
+	CASERETURN(IPPROTO_TP);
+	CASERETURN(IPPROTO_DCCP);
+	CASERETURN(IPPROTO_IPV6);
+	CASERETURN(IPPROTO_ROUTING);
+	CASERETURN(IPPROTO_FRAGMENT);
+	CASERETURN(IPPROTO_RSVP);
+	CASERETURN(IPPROTO_GRE);
+	CASERETURN(IPPROTO_ESP);
+	CASERETURN(IPPROTO_AH);
+	CASERETURN(IPPROTO_MOBILE);
+//	CASERETURN(IPPROTO_IPV6_ICMP);
+	CASERETURN(IPPROTO_ICMPV6);
+	CASERETURN(IPPROTO_NONE);
+	CASERETURN(IPPROTO_DSTOPTS);
+	CASERETURN(IPPROTO_EON);
+	CASERETURN(IPPROTO_ETHERIP);
+	CASERETURN(IPPROTO_ENCAP);
+	CASERETURN(IPPROTO_PIM);
+	CASERETURN(IPPROTO_IPCOMP);
+	CASERETURN(IPPROTO_VRRP);
+//	CASERETURN(IPPROTO_CARP);
+	CASERETURN(IPPROTO_L2TP);
+	CASERETURN(IPPROTO_SCTP);
+	CASERETURN(IPPROTO_PFSYNC);
+	CASERETURN(IPPROTO_RAW);
+	CASERETURN(IPPROTO_MAX);
+	CASERETURN(IPPROTO_DONE);
+	CASERETURN(SOL_SOCKET);
+	default:
+		return NULL;
+	}
+}
+
+static const char *
+sockoptname(register_t optname)
+{
+	switch (optname) {
+	CASERETURN(SO_ACCEPTCONN);
+	CASERETURN(SO_ACCEPTFILTER);
+	CASERETURN(SO_BROADCAST);
+	CASERETURN(SO_DEBUG);
+	CASERETURN(SO_DONTROUTE);
+	CASERETURN(SO_ERROR);
+	CASERETURN(SO_KEEPALIVE);
+	CASERETURN(SO_LINGER);
+	CASERETURN(SO_NOHEADER);
+	CASERETURN(SO_NOSIGPIPE);
+	CASERETURN(SO_OOBINLINE);
+	CASERETURN(SO_OVERFLOWED);
+	CASERETURN(SO_RCVBUF);
+	CASERETURN(SO_RCVLOWAT);
+	CASERETURN(SO_RCVTIMEO);
+	CASERETURN(SO_RERROR);
+	CASERETURN(SO_REUSEADDR);
+	CASERETURN(SO_REUSEPORT);
+	CASERETURN(SO_SNDBUF);
+	CASERETURN(SO_SNDLOWAT);
+	CASERETURN(SO_SNDTIMEO);
+	CASERETURN(SO_TIMESTAMP);
+	CASERETURN(SO_TYPE);
+	CASERETURN(SO_USELOOPBACK);
+	default:
+		return NULL;
+	}
+}
+
+static const char *
+tcpoptname(register_t optname)
+{
+	switch (optname) {
+	CASERETURN(TCP_NODELAY);
+	CASERETURN(TCP_MAXSEG);
+	CASERETURN(TCP_MD5SIG);
+	CASERETURN(TCP_KEEPIDLE);
+	CASERETURN(TCP_KEEPINTVL);
+	CASERETURN(TCP_KEEPCNT);
+	CASERETURN(TCP_KEEPINIT);
+	CASERETURN(TCP_INFO);
+	default:
+		return NULL;
+	}
+}
+
+static const char *
+ipoptname(register_t optname)
+{
+	switch (optname) {
+	CASERETURN(IP_OPTIONS);
+	CASERETURN(IP_HDRINCL);
+	CASERETURN(IP_TOS);
+	CASERETURN(IP_TTL);
+	CASERETURN(IP_RECVOPTS);
+	CASERETURN(IP_RECVRETOPTS);
+	CASERETURN(IP_RECVDSTADDR);
+	CASERETURN(IP_RETOPTS);
+	CASERETURN(IP_MULTICAST_IF);
+	CASERETURN(IP_MULTICAST_TTL);
+	

CVS commit: src/usr.bin/kdump

2024-03-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 10 17:08:31 UTC 2024

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

Log Message:
decode some {g,s}etsockopt*.


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

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



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

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 17:07:31 UTC 2024

Modified Files:
src/sys/arch/powerpc/include/oea: hid.h

Log Message:
powerpc/hid: fix snprintb format for HID0_970_BITMASK_U


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/powerpc/include/oea/hid.h

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

Modified files:

Index: src/sys/arch/powerpc/include/oea/hid.h
diff -u src/sys/arch/powerpc/include/oea/hid.h:1.14 src/sys/arch/powerpc/include/oea/hid.h:1.15
--- src/sys/arch/powerpc/include/oea/hid.h:1.14	Sat Jan 20 09:47:35 2024
+++ src/sys/arch/powerpc/include/oea/hid.h	Sun Mar 10 17:07:31 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: hid.h,v 1.14 2024/01/20 09:47:35 jmcneill Exp $	*/
+/*	$NetBSD: hid.h,v 1.15 2024/03/10 17:07:31 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -112,7 +112,7 @@
 "\040EMCP"
 
 #define HID0_970_BITMASK_U "\020" \
-"\040ONEPPC\036DOSNGL\036ISYNCSC\035SERGP\034res\033res\032res\031DEEPNAP" \
+"\040ONEPPC\037DOSNGL\036ISYNCSC\035SERGP\034res\033res\032res\031DEEPNAP" \
 "\030DOZE\027NAP\026res\025DPM\024res\023TG\022HNGDIS\021NHR" \
 "\020INORDER\017res\016TBCTRL\015EXTBEN\014res\013res\012CIABREN\011HDICEEN" \
 "\001ENATTN"



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

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 17:07:31 UTC 2024

Modified Files:
src/sys/arch/powerpc/include/oea: hid.h

Log Message:
powerpc/hid: fix snprintb format for HID0_970_BITMASK_U


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/powerpc/include/oea/hid.h

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



CVS commit: src/sys/arch/sparc/dev

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 17:02:24 UTC 2024

Modified Files:
src/sys/arch/sparc/dev: sbusreg.h

Log Message:
sparc/sbusreg: fix snprintb format for SBUS_AFSR_BITS


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc/dev/sbusreg.h

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

Modified files:

Index: src/sys/arch/sparc/dev/sbusreg.h
diff -u src/sys/arch/sparc/dev/sbusreg.h:1.6 src/sys/arch/sparc/dev/sbusreg.h:1.7
--- src/sys/arch/sparc/dev/sbusreg.h:1.6	Wed Nov 16 00:49:03 2005
+++ src/sys/arch/sparc/dev/sbusreg.h	Sun Mar 10 17:02:24 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sbusreg.h,v 1.6 2005/11/16 00:49:03 uwe Exp $ */
+/*	$NetBSD: sbusreg.h,v 1.7 2024/03/10 17:02:24 rillig Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -94,7 +94,7 @@ struct sbusreg {
 #define SBUS_AFSR_ERR	0x8000	/* Summary bit: one of LE,TO,BERR */
 #define SBUS_AFSR_BITS	"\177\020"	\
 			"f\0\4PAH\0b\10WM\0f\11\3SSIZ\0f\14\5SA\0"	\
-			"b\11FAV\0b\12RD\0b\13ME\0f\14\4MID\0b\30S\0"	\
+			"b\21FAV\0b\22RD\0b\23ME\0f\24\4MID\0b\30S\0"	\
 			"f\31\3SIZ\0b\34BERR\0b\35TO\0b\36LE\0b\37ERR\0"
 
 /* Arbiter Enable register */



CVS commit: src/sys/arch/sparc/dev

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 17:02:24 UTC 2024

Modified Files:
src/sys/arch/sparc/dev: sbusreg.h

Log Message:
sparc/sbusreg: fix snprintb format for SBUS_AFSR_BITS


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc/dev/sbusreg.h

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



CVS commit: src/sys/arch/sparc/dev

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 16:58:08 UTC 2024

Modified Files:
src/sys/arch/sparc/dev: vmereg.h

Log Message:
sparc/vmereg: fix snprintb format VMEBUS_AFSR_BITS


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sparc/dev/vmereg.h

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

Modified files:

Index: src/sys/arch/sparc/dev/vmereg.h
diff -u src/sys/arch/sparc/dev/vmereg.h:1.7 src/sys/arch/sparc/dev/vmereg.h:1.8
--- src/sys/arch/sparc/dev/vmereg.h:1.7	Mon Apr 28 20:23:36 2008
+++ src/sys/arch/sparc/dev/vmereg.h	Sun Mar 10 16:58:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmereg.h,v 1.7 2008/04/28 20:23:36 martin Exp $ */
+/*	$NetBSD: vmereg.h,v 1.8 2024/03/10 16:58:08 rillig Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@ struct vmebusreg {
 #define VMEBUS_AFSR_ME	0x0080	/* Multiple error */
 #define VMEBUS_AFSR_RSVD 0x007f	/* reserved */
 #define VMEBUS_AFSR_BITS "\177\020"	\
-			 "b\27ME\0b\30S\0b\31ERR\0b\32WB\0\33TO\0f\34\3SZ\0"
+	"b\27ME\0b\30S\0b\31ERR\0b\32WB\0b\33BERR\0b\34TO\0f\35\3SZ\0"
 
 struct vmebusvec {
 	volatile uint8_t	vmebusvec[16];



CVS commit: src/sys/arch/sparc/dev

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 16:58:08 UTC 2024

Modified Files:
src/sys/arch/sparc/dev: vmereg.h

Log Message:
sparc/vmereg: fix snprintb format VMEBUS_AFSR_BITS


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sparc/dev/vmereg.h

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



CVS commit: src/usr.bin/xlint/lint1

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 16:27:16 UTC 2024

Modified Files:
src/usr.bin/xlint/lint1: cksnprintb.c

Log Message:
lint: clean up tree matcher for snprintb calls


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/xlint/lint1/cksnprintb.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/xlint/lint1/cksnprintb.c
diff -u src/usr.bin/xlint/lint1/cksnprintb.c:1.9 src/usr.bin/xlint/lint1/cksnprintb.c:1.10
--- src/usr.bin/xlint/lint1/cksnprintb.c:1.9	Sat Mar  9 13:54:47 2024
+++ src/usr.bin/xlint/lint1/cksnprintb.c	Sun Mar 10 16:27:16 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: cksnprintb.c,v 1.9 2024/03/09 13:54:47 rillig Exp $	*/
+/*	$NetBSD: cksnprintb.c,v 1.10 2024/03/10 16:27:16 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2024 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: cksnprintb.c,v 1.9 2024/03/09 13:54:47 rillig Exp $");
+__RCSID("$NetBSD: cksnprintb.c,v 1.10 2024/03/10 16:27:16 rillig Exp $");
 #endif
 
 #include 
@@ -67,24 +67,17 @@ match_string_literal(const tnode_t *tn, 
 
 static bool
 match_snprintb_call(const function_call *call,
-const buffer **out_fmt, const tnode_t **out_val)
+const buffer **fmt, const tnode_t **val)
 {
 	const char *func;
-	const tnode_t *val;
-	const buffer *str;
 
-	if (call->func->tn_op == ADDR
+	return call->func->tn_op == ADDR
 	&& call->func->u.ops.left->tn_op == NAME
 	&& (func = call->func->u.ops.left->u.sym->s_name, true)
 	&& ((strcmp(func, "snprintb") == 0 && call->args_len == 4)
 		|| (strcmp(func, "snprintb_m") == 0 && call->args_len == 5))
-	&& match_string_literal(call->args[2], )
-	&& (val = call->args[3], true)) {
-		*out_fmt = str;
-		*out_val = val;
-		return true;
-	}
-	return false;
+	&& match_string_literal(call->args[2], fmt)
+	&& (*val = call->args[3], true);
 }
 
 static int



CVS commit: src/usr.bin/xlint/lint1

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 16:27:16 UTC 2024

Modified Files:
src/usr.bin/xlint/lint1: cksnprintb.c

Log Message:
lint: clean up tree matcher for snprintb calls


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/xlint/lint1/cksnprintb.c

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



CVS commit: src

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 16:06:13 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: platform_ilp32_int.c
platform_ilp32_long.c platform_lp64.c
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: saturate signed integer overflow

In array address calculations, this prevents a 'array subscript cannot
be negative' for large array subscripts.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/platform_ilp32_int.c
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/platform_ilp32_long.c
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/xlint/lint1/platform_lp64.c
cvs rdiff -u -r1.621 -r1.622 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/platform_ilp32_int.c
diff -u src/tests/usr.bin/xlint/lint1/platform_ilp32_int.c:1.4 src/tests/usr.bin/xlint/lint1/platform_ilp32_int.c:1.5
--- src/tests/usr.bin/xlint/lint1/platform_ilp32_int.c:1.4	Sat Mar  9 17:34:01 2024
+++ src/tests/usr.bin/xlint/lint1/platform_ilp32_int.c	Sun Mar 10 16:06:13 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: platform_ilp32_int.c,v 1.4 2024/03/09 17:34:01 rillig Exp $	*/
+/*	$NetBSD: platform_ilp32_int.c,v 1.5 2024/03/10 16:06:13 rillig Exp $	*/
 # 3 "platform_ilp32_int.c"
 
 /*
@@ -65,19 +65,22 @@ array_index(void)
 	/* expect+1: warning: array subscript cannot be > 19: 16777215 [168] */
 	u64 += u64_buf[0x00ff];
 	/* expect+2: warning: operator '*' produces integer overflow [141] */
-	/* expect+1: warning: array subscript cannot be negative: -1 [167] */
+	/* expect+1: warning: array subscript cannot be > 19: 268435455 [168] */
 	u64 += u64_buf[0x7fff];
-	/* expect+2: warning: conversion of 'long long' to 'int' is out of range [119] */
-	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	/* expect+3: warning: conversion of 'long long' to 'int' is out of range [119] */
+	/* expect+2: warning: operator '*' produces integer overflow [141] */
+	/* expect+1: warning: array subscript cannot be negative: -268435456 [167] */
 	u64 += u64_buf[2147483648];
-	/* expect+2: warning: conversion of 'unsigned int' to 'int' is out of range [119] */
-	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	/* expect+3: warning: conversion of 'unsigned int' to 'int' is out of range [119] */
+	/* expect+2: warning: operator '*' produces integer overflow [141] */
+	/* expect+1: warning: array subscript cannot be negative: -268435456 [167] */
 	u64 += u64_buf[0x8000];
 	/* expect+2: warning: conversion of 'unsigned int' to 'int' is out of range [119] */
 	/* expect+1: warning: array subscript cannot be negative: -1 [167] */
 	u64 += u64_buf[0x];
-	/* expect+2: warning: conversion of 'unsigned int' to 'int' is out of range [119] */
-	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	/* expect+3: warning: conversion of 'unsigned int' to 'int' is out of range [119] */
+	/* expect+2: warning: operator '*' produces integer overflow [141] */
+	/* expect+1: warning: array subscript cannot be negative: -268435456 [167] */
 	u64 += u64_buf[0x8000];
 	/* expect+2: warning: conversion of 'unsigned int' to 'int' is out of range [119] */
 	/* expect+1: warning: array subscript cannot be negative: -1 [167] */

Index: src/tests/usr.bin/xlint/lint1/platform_ilp32_long.c
diff -u src/tests/usr.bin/xlint/lint1/platform_ilp32_long.c:1.6 src/tests/usr.bin/xlint/lint1/platform_ilp32_long.c:1.7
--- src/tests/usr.bin/xlint/lint1/platform_ilp32_long.c:1.6	Sat Mar  9 17:34:01 2024
+++ src/tests/usr.bin/xlint/lint1/platform_ilp32_long.c	Sun Mar 10 16:06:13 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: platform_ilp32_long.c,v 1.6 2024/03/09 17:34:01 rillig Exp $	*/
+/*	$NetBSD: platform_ilp32_long.c,v 1.7 2024/03/10 16:06:13 rillig Exp $	*/
 # 3 "platform_ilp32_long.c"
 
 /*
@@ -74,19 +74,22 @@ array_index(void)
 	/* expect+1: warning: array subscript cannot be > 19: 16777215 [168] */
 	u64 += u64_buf[0x00ff];
 	/* expect+2: warning: operator '*' produces integer overflow [141] */
-	/* expect+1: warning: array subscript cannot be negative: -1 [167] */
+	/* expect+1: warning: array subscript cannot be > 19: 268435455 [168] */
 	u64 += u64_buf[0x7fff];
-	/* expect+2: warning: conversion of 'long long' to 'long' is out of range [119] */
-	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	/* expect+3: warning: conversion of 'long long' to 'long' is out of range [119] */
+	/* expect+2: warning: operator '*' produces integer overflow [141] */
+	/* expect+1: warning: array subscript cannot be negative: -268435456 [167] */
 	u64 += u64_buf[2147483648];
-	/* expect+2: warning: conversion of 'unsigned int' to 'long' is out of range [119] */
-	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	/* expect+3: warning: conversion of 

CVS commit: src

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 16:06:13 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: platform_ilp32_int.c
platform_ilp32_long.c platform_lp64.c
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: saturate signed integer overflow

In array address calculations, this prevents a 'array subscript cannot
be negative' for large array subscripts.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/platform_ilp32_int.c
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/platform_ilp32_long.c
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/xlint/lint1/platform_lp64.c
cvs rdiff -u -r1.621 -r1.622 src/usr.bin/xlint/lint1/tree.c

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



CVS commit: src

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 15:49:12 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_141.c
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: fix integer overflow detection

Previously, an unsigned operation that had a negative result went
undetected in a few cases. Now, all results that are not representable
by their type are considered overflows.

The implementation of signed shift-right had been wrong for a few
commits.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/usr.bin/xlint/lint1/msg_141.c
cvs rdiff -u -r1.620 -r1.621 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_141.c
diff -u src/tests/usr.bin/xlint/lint1/msg_141.c:1.14 src/tests/usr.bin/xlint/lint1/msg_141.c:1.15
--- src/tests/usr.bin/xlint/lint1/msg_141.c:1.14	Sun Mar 10 14:32:30 2024
+++ src/tests/usr.bin/xlint/lint1/msg_141.c	Sun Mar 10 15:49:12 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_141.c,v 1.14 2024/03/10 14:32:30 rillig Exp $	*/
+/*	$NetBSD: msg_141.c,v 1.15 2024/03/10 15:49:12 rillig Exp $	*/
 # 3 "msg_141.c"
 
 // Test for message: operator '%s' produces integer overflow [141]
@@ -412,7 +412,7 @@ minus_u64(void)
 void
 shl_s32(void)
 {
-	/* TODO: expect+1: warning: operator '<<' produces integer overflow [141] */
+	/* expect+1: warning: operator '<<' produces integer overflow [141] */
 	s32 = 0x0100 << 23;
 	/* expect+1: warning: operator '<<' produces integer overflow [141] */
 	s32 = 0x0100 << 24;
@@ -457,6 +457,15 @@ shr_s32(void)
 	s32 = +9 >> 1;
 	s32 = +10 >> 1;
 	s32 = 0x7fff >> 1;
+
+	/* expect+1: error: negative array dimension (-16) [20] */
+	typedef int minus_32_shr_1[-32 >> 1];
+	/* expect+1: error: negative array dimension (-16) [20] */
+	typedef int minus_31_shr_1[-31 >> 1];
+	/* expect+1: error: negative array dimension (-15) [20] */
+	typedef int minus_30_shr_1[-30 >> 1];
+	/* expect+1: error: negative array dimension (-1) [20] */
+	typedef int minus_1_shr_1[-1 >> 31];
 }
 
 void
@@ -472,6 +481,15 @@ void
 shr_s64(void)
 {
 	// TODO
+
+	/* expect+1: error: negative array dimension (-16) [20] */
+	typedef int shr_minus_1_shr_0[-16LL >> 0];
+	/* expect+1: error: negative array dimension (-8) [20] */
+	typedef int shr_minus_1_shr_1[-16LL >> 1];
+	/* expect+1: error: negative array dimension (-1) [20] */
+	typedef int shr_minus_1_shr_16[-16LL >> 16];
+	/* expect+1: error: negative array dimension (-1) [20] */
+	typedef int shr_minus_1_shr_40[-16LL >> 40];
 }
 
 void

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.620 src/usr.bin/xlint/lint1/tree.c:1.621
--- src/usr.bin/xlint/lint1/tree.c:1.620	Sun Mar 10 14:42:04 2024
+++ src/usr.bin/xlint/lint1/tree.c	Sun Mar 10 15:49:12 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.620 2024/03/10 14:42:04 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.621 2024/03/10 15:49:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.620 2024/03/10 14:42:04 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.621 2024/03/10 15:49:12 rillig Exp $");
 #endif
 
 #include 
@@ -793,11 +793,11 @@ fold_unsigned_integer(op_t op, uint64_t 
 {
 	switch (op) {
 	case COMPL:
-		return ~l;
+		return ~l & max_value;
 	case UPLUS:
 		return +l;
 	case UMINUS:
-		return -l;
+		return -l & max_value;
 	case MULT:
 		*overflow = r > 0 && l > max_value / r;
 		return l * r;
@@ -920,12 +920,11 @@ fold_signed_integer(op_t op, int64_t l, 
 		/* TODO: warn about out-of-bounds 'sr'. */
 		/* TODO: warn about overflow. */
 		return l << (r & 63);
-	case SHR:;
+	case SHR:
 		/* TODO: warn about out-of-bounds 'sr'. */
-		uint64_t shr_result = (uint64_t)l >> (r & 63);
-		if (shr_result & min_value)
-			shr_result |= min_value;
-		return (int64_t)shr_result;
+		if (l < 0)
+			return (int64_t)~(~(uint64_t)l >> (r & 63));
+		return (int64_t)((uint64_t)l >> (r & 63));
 	case LT:
 		return l < r ? 1 : 0;
 	case LE:
@@ -950,45 +949,40 @@ fold_signed_integer(op_t op, int64_t l, 
 	}
 }
 
-/*
- * XXX
- * Note: There appear to be a number of bugs in detecting overflow in
- * this function. An audit and a set of proper regression tests are needed.
- * --Perry Metzger, Nov. 16, 2001
- */
 static tnode_t *
 fold_constant_integer(tnode_t *tn)
 {
 
 	lint_assert(has_operands(tn));
 	tspec_t t = tn->u.ops.left->tn_type->t_tspec;
-	bool utyp = !is_integer(t) || is_uinteger(t);
-	int64_t sl = tn->u.ops.left->u.value.u.integer, sr = 0;
-	uint64_t ul = sl, ur = 0;
-	if (is_binary(tn))
-		ur = sr = tn->u.ops.right->u.value.u.integer;
-
+	int64_t l = tn->u.ops.left->u.value.u.integer;
+	int64_t r = is_binary(tn) ? tn->u.ops.right->u.value.u.integer : 0;
 	uint64_t mask = value_bits(size_in_bits(t));
-	int64_t max_value = (int64_t)(mask >> 1);
-	int64_t min_value = -max_value - 1;

CVS commit: src

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 15:49:12 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_141.c
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: fix integer overflow detection

Previously, an unsigned operation that had a negative result went
undetected in a few cases. Now, all results that are not representable
by their type are considered overflows.

The implementation of signed shift-right had been wrong for a few
commits.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/usr.bin/xlint/lint1/msg_141.c
cvs rdiff -u -r1.620 -r1.621 src/usr.bin/xlint/lint1/tree.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/xlint/lint1

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 14:42:04 UTC 2024

Modified Files:
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: clean up check for overflow in integer constants


To generate a diff of this commit:
cvs rdiff -u -r1.619 -r1.620 src/usr.bin/xlint/lint1/tree.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/xlint/lint1

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 14:42:04 UTC 2024

Modified Files:
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: clean up check for overflow in integer constants


To generate a diff of this commit:
cvs rdiff -u -r1.619 -r1.620 src/usr.bin/xlint/lint1/tree.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/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.619 src/usr.bin/xlint/lint1/tree.c:1.620
--- src/usr.bin/xlint/lint1/tree.c:1.619	Sun Mar 10 14:32:30 2024
+++ src/usr.bin/xlint/lint1/tree.c	Sun Mar 10 14:42:04 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.619 2024/03/10 14:32:30 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.620 2024/03/10 14:42:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.619 2024/03/10 14:32:30 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.620 2024/03/10 14:42:04 rillig Exp $");
 #endif
 
 #include 
@@ -795,30 +795,26 @@ fold_unsigned_integer(op_t op, uint64_t 
 	case COMPL:
 		return ~l;
 	case UPLUS:
-		return l;
+		return +l;
 	case UMINUS:
 		return -l;
-	case MULT:;
-		uint64_t mult_result = l * r;
-		if (mult_result != (mult_result & max_value))
-			*overflow = true;
-		else if (l != 0 && mult_result / l != r)
-			*overflow = true;
-		return mult_result;
+	case MULT:
+		*overflow = r > 0 && l > max_value / r;
+		return l * r;
 	case DIV:
 		if (r == 0) {
 			/* division by 0 */
 			error(139);
 			return max_value;
-		} else
-			return l / r;
+		}
+		return l / r;
 	case MOD:
 		if (r == 0) {
 			/* modulus by 0 */
 			error(140);
 			return 0;
-		} else
-			return l % r;
+		}
+		return l % r;
 	case PLUS:
 		*overflow = l > max_value - r;
 		return l + r;
@@ -827,6 +823,7 @@ fold_unsigned_integer(op_t op, uint64_t 
 		return l - r;
 	case SHL:
 		/* TODO: warn about out-of-bounds 'sr'. */
+		/* TODO: warn about overflow. */
 		return l << (r & 63);
 	case SHR:
 		/* TODO: warn about out-of-bounds 'sr'. */
@@ -851,8 +848,8 @@ fold_unsigned_integer(op_t op, uint64_t 
 		return l | r;
 	default:
 		lint_assert(/*CONSTCOND*/false);
+		/* NOTREACHED */
 	}
-	/* NOTREACHED */
 }
 
 static int64_t
@@ -863,7 +860,7 @@ fold_signed_integer(op_t op, int64_t l, 
 	case COMPL:
 		return ~l;
 	case UPLUS:
-		return l;
+		return +l;
 	case UMINUS:
 		*overflow = l == min_value;
 		return *overflow ? l : -l;
@@ -876,12 +873,7 @@ fold_signed_integer(op_t op, int64_t l, 
 			*overflow = true;
 			return (int64_t)(al * ar);
 		}
-		uint64_t mult_result = l * r;
-		uint64_t hi = (uint64_t)max_value + 1;
-		// FIXME: Overflow can also happen in other bits.
-		if ((mult_result & hi) != ((l & hi) ^ (r & hi)))
-			*overflow = true;
-		return (int64_t)mult_result;
+		return l * r;
 	case DIV:
 		if (r == 0) {
 			/* division by 0 */
@@ -926,9 +918,10 @@ fold_signed_integer(op_t op, int64_t l, 
 		return l - r;
 	case SHL:
 		/* TODO: warn about out-of-bounds 'sr'. */
-		/* TODO: warn about overflow in signed '<<'. */
+		/* TODO: warn about overflow. */
 		return l << (r & 63);
 	case SHR:;
+		/* TODO: warn about out-of-bounds 'sr'. */
 		uint64_t shr_result = (uint64_t)l >> (r & 63);
 		if (shr_result & min_value)
 			shr_result |= min_value;
@@ -953,8 +946,8 @@ fold_signed_integer(op_t op, int64_t l, 
 		return l | r;
 	default:
 		lint_assert(/*CONSTCOND*/false);
+		/* NOTREACHED */
 	}
-	/* NOTREACHED */
 }
 
 /*



CVS commit: src

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 14:32:30 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: expr_fold.c msg_141.c
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: detect more cases of integer overflow in constant expressions

For unsigned integers, detect when 'a + b' wraps around.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/usr.bin/xlint/lint1/expr_fold.c \
src/tests/usr.bin/xlint/lint1/msg_141.c
cvs rdiff -u -r1.618 -r1.619 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/expr_fold.c
diff -u src/tests/usr.bin/xlint/lint1/expr_fold.c:1.13 src/tests/usr.bin/xlint/lint1/expr_fold.c:1.14
--- src/tests/usr.bin/xlint/lint1/expr_fold.c:1.13	Sun Mar 10 10:31:29 2024
+++ src/tests/usr.bin/xlint/lint1/expr_fold.c	Sun Mar 10 14:32:30 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: expr_fold.c,v 1.13 2024/03/10 10:31:29 rillig Exp $	*/
+/*	$NetBSD: expr_fold.c,v 1.14 2024/03/10 14:32:30 rillig Exp $	*/
 # 3 "expr_fold.c"
 
 /*
@@ -59,8 +59,7 @@ fold_uminus(void)
 	/* The '-' is an operator, it is not part of the integer constant. */
 	take_int(-2147483648);
 
-	/* expect+2: warning: operator '+' produces integer overflow [141] */
-	/* expect+1: warning: operator '-' produces integer overflow [141] */
+	/* expect+1: warning: operator '+' produces integer overflow [141] */
 	take_int(-(2147483647 + 1));
 	/* expect+1: warning: operator '-' produces integer overflow [141] */
 	take_int(-(-2147483647 - 1));
Index: src/tests/usr.bin/xlint/lint1/msg_141.c
diff -u src/tests/usr.bin/xlint/lint1/msg_141.c:1.13 src/tests/usr.bin/xlint/lint1/msg_141.c:1.14
--- src/tests/usr.bin/xlint/lint1/msg_141.c:1.13	Sun Mar 10 10:31:29 2024
+++ src/tests/usr.bin/xlint/lint1/msg_141.c	Sun Mar 10 14:32:30 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_141.c,v 1.13 2024/03/10 10:31:29 rillig Exp $	*/
+/*	$NetBSD: msg_141.c,v 1.14 2024/03/10 14:32:30 rillig Exp $	*/
 # 3 "msg_141.c"
 
 // Test for message: operator '%s' produces integer overflow [141]
@@ -347,11 +347,11 @@ plus_u64(void)
 	u64 = 0xULL + 0xULL;
 	u64 = 0xULL + 0xULL;
 	u64 = 0xfffeULL + 0x0001ULL;
-	/* TODO: expect+1: warning: operator '+' produces integer overflow [141] */
+	/* expect+1: warning: operator '+' produces integer overflow [141] */
 	u64 = 0xULL + 0x0001ULL;
-	/* TODO: expect+1: warning: operator '+' produces integer overflow [141] */
+	/* expect+1: warning: operator '+' produces integer overflow [141] */
 	u64 = 0x0001ULL + 0xULL;
-	/* TODO: expect+1: warning: operator '+' produces integer overflow [141] */
+	/* expect+1: warning: operator '+' produces integer overflow [141] */
 	u64 = 0xULL + 0xULL;
 }
 
@@ -374,12 +374,12 @@ void
 minus_u32(void)
 {
 	u32 = 0xU - 0xU;
-	/* TODO: expect+1: warning: operator '-' produces integer overflow [141] */
+	/* expect+1: warning: operator '-' produces integer overflow [141] */
 	u32 = 0xU - 0x0001U;
 	/* expect+1: warning: operator '-' produces integer overflow [141] */
 	u32 = 0xU - 0x8000U;
 	u32 = 0x8000U - 0x0001U;
-	/* TODO: expect+1: warning: operator '-' produces integer overflow [141] */
+	/* expect+1: warning: operator '-' produces integer overflow [141] */
 	u32 = 0xU - 0xU;
 	u32 = 0xU - 0xU;
 	u32 = 0xU - 0xU;

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.618 src/usr.bin/xlint/lint1/tree.c:1.619
--- src/usr.bin/xlint/lint1/tree.c:1.618	Sun Mar 10 12:50:45 2024
+++ src/usr.bin/xlint/lint1/tree.c	Sun Mar 10 14:32:30 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.618 2024/03/10 12:50:45 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.619 2024/03/10 14:32:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.618 2024/03/10 12:50:45 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.619 2024/03/10 14:32:30 rillig Exp $");
 #endif
 
 #include 
@@ -819,18 +819,12 @@ fold_unsigned_integer(op_t op, uint64_t 
 			return 0;
 		} else
 			return l % r;
-	case PLUS:;
-		uint64_t plus_result = l + r;
-		uint64_t hi = max_value ^ (max_value >> 1);
-		if (l & hi && r & hi && !(plus_result & hi))
-			*overflow = true;
-		return plus_result;
-	case MINUS:;
-		uint64_t minus_result = l - r;
-		hi = max_value ^ (max_value >> 1);
-		if (!(l & hi) && r & hi && minus_result & hi)
-			*overflow = true;
-		return minus_result;
+	case PLUS:
+		*overflow = l > max_value - r;
+		return l + r;
+	case MINUS:
+		*overflow = l < r;
+		return l - r;
 	case SHL:
 		/* TODO: warn about out-of-bounds 'sr'. */
 		return l << (r & 63);
@@ -910,23 

CVS commit: src

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 14:32:30 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: expr_fold.c msg_141.c
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: detect more cases of integer overflow in constant expressions

For unsigned integers, detect when 'a + b' wraps around.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/usr.bin/xlint/lint1/expr_fold.c \
src/tests/usr.bin/xlint/lint1/msg_141.c
cvs rdiff -u -r1.618 -r1.619 src/usr.bin/xlint/lint1/tree.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/lib/libc/net

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 13:47:32 UTC 2024

Modified Files:
src/lib/libc/net [netbsd-8]: getnameinfo.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1939):

lib/libc/net/getnameinfo.c: revision 1.60

PR/57609: Carl Engvall: Add salen checks but accept larger sizes
(upto sockaddr_storage)


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.59.8.1 src/lib/libc/net/getnameinfo.c

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

Modified files:

Index: src/lib/libc/net/getnameinfo.c
diff -u src/lib/libc/net/getnameinfo.c:1.59 src/lib/libc/net/getnameinfo.c:1.59.8.1
--- src/lib/libc/net/getnameinfo.c:1.59	Tue Sep 22 16:15:08 2015
+++ src/lib/libc/net/getnameinfo.c	Sun Mar 10 13:47:32 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: getnameinfo.c,v 1.59 2015/09/22 16:15:08 christos Exp $	*/
+/*	$NetBSD: getnameinfo.c,v 1.59.8.1 2024/03/10 13:47:32 martin Exp $	*/
 /*	$KAME: getnameinfo.c,v 1.45 2000/09/25 22:43:56 itojun Exp $	*/
 
 /*
@@ -47,7 +47,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getnameinfo.c,v 1.59 2015/09/22 16:15:08 christos Exp $");
+__RCSID("$NetBSD: getnameinfo.c,v 1.59.8.1 2024/03/10 13:47:32 martin Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #ifndef RUMP_ACTION
@@ -128,6 +128,13 @@ getnameinfo(const struct sockaddr *sa, s
 	int flags)
 {
 
+	/*  
+	 * getnameinfo() accepts an salen of sizeof(struct sockaddr_storage)
+	 * at maximum as shown in RFC 4038 Sec.6.2.3.
+	 */ 
+	if (salen > sizeof(struct sockaddr_storage))
+		return EAI_FAMILY;
+
 	switch (sa->sa_family) {
 	case AF_APPLETALK:
 		return getnameinfo_atalk(sa, salen, host, hostlen,
@@ -220,6 +227,9 @@ getnameinfo_local(const struct sockaddr 
 	const struct sockaddr_un *sun =
 	(const struct sockaddr_un *)(const void *)sa;
 
+if (salen <= sizeof(*sun) - sizeof(sun->sun_path))
+		return EAI_FAMILY;
+
 	if (serv != NULL && servlen > 0)
 		serv[0] = '\0';
 
@@ -266,8 +276,8 @@ getnameinfo_inet(const struct sockaddr *
 	return EAI_FAMILY;
 
  found:
-	if (salen != afd->a_socklen)
-		return EAI_FAIL;
+	if (salen < afd->a_socklen)
+		return EAI_FAMILY;
 
 	/* network byte order */
 	port = ((const struct sockinet *)(const void *)sa)->si_port;
@@ -544,6 +554,9 @@ getnameinfo_link(const struct sockaddr *
 	const struct ieee1394_hwaddr *iha;
 	int n;
 
+if (salen <= sizeof(*sdl) - sizeof(sdl->sdl_data))
+		return EAI_FAMILY;
+
 	if (serv != NULL && servlen > 0)
 		*serv = '\0';
 



CVS commit: [netbsd-8] src/lib/libc/net

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 13:47:32 UTC 2024

Modified Files:
src/lib/libc/net [netbsd-8]: getnameinfo.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1939):

lib/libc/net/getnameinfo.c: revision 1.60

PR/57609: Carl Engvall: Add salen checks but accept larger sizes
(upto sockaddr_storage)


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.59.8.1 src/lib/libc/net/getnameinfo.c

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



CVS commit: [netbsd-9] src/lib/libc/net

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 13:46:04 UTC 2024

Modified Files:
src/lib/libc/net [netbsd-9]: getnameinfo.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1806):

lib/libc/net/getnameinfo.c: revision 1.60

PR/57609: Carl Engvall: Add salen checks but accept larger sizes
(upto sockaddr_storage)


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.59.18.1 src/lib/libc/net/getnameinfo.c

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



CVS commit: [netbsd-9] src/lib/libc/net

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 13:46:04 UTC 2024

Modified Files:
src/lib/libc/net [netbsd-9]: getnameinfo.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1806):

lib/libc/net/getnameinfo.c: revision 1.60

PR/57609: Carl Engvall: Add salen checks but accept larger sizes
(upto sockaddr_storage)


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.59.18.1 src/lib/libc/net/getnameinfo.c

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

Modified files:

Index: src/lib/libc/net/getnameinfo.c
diff -u src/lib/libc/net/getnameinfo.c:1.59 src/lib/libc/net/getnameinfo.c:1.59.18.1
--- src/lib/libc/net/getnameinfo.c:1.59	Tue Sep 22 16:15:08 2015
+++ src/lib/libc/net/getnameinfo.c	Sun Mar 10 13:46:04 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: getnameinfo.c,v 1.59 2015/09/22 16:15:08 christos Exp $	*/
+/*	$NetBSD: getnameinfo.c,v 1.59.18.1 2024/03/10 13:46:04 martin Exp $	*/
 /*	$KAME: getnameinfo.c,v 1.45 2000/09/25 22:43:56 itojun Exp $	*/
 
 /*
@@ -47,7 +47,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getnameinfo.c,v 1.59 2015/09/22 16:15:08 christos Exp $");
+__RCSID("$NetBSD: getnameinfo.c,v 1.59.18.1 2024/03/10 13:46:04 martin Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #ifndef RUMP_ACTION
@@ -128,6 +128,13 @@ getnameinfo(const struct sockaddr *sa, s
 	int flags)
 {
 
+	/*  
+	 * getnameinfo() accepts an salen of sizeof(struct sockaddr_storage)
+	 * at maximum as shown in RFC 4038 Sec.6.2.3.
+	 */ 
+	if (salen > sizeof(struct sockaddr_storage))
+		return EAI_FAMILY;
+
 	switch (sa->sa_family) {
 	case AF_APPLETALK:
 		return getnameinfo_atalk(sa, salen, host, hostlen,
@@ -220,6 +227,9 @@ getnameinfo_local(const struct sockaddr 
 	const struct sockaddr_un *sun =
 	(const struct sockaddr_un *)(const void *)sa;
 
+if (salen <= sizeof(*sun) - sizeof(sun->sun_path))
+		return EAI_FAMILY;
+
 	if (serv != NULL && servlen > 0)
 		serv[0] = '\0';
 
@@ -266,8 +276,8 @@ getnameinfo_inet(const struct sockaddr *
 	return EAI_FAMILY;
 
  found:
-	if (salen != afd->a_socklen)
-		return EAI_FAIL;
+	if (salen < afd->a_socklen)
+		return EAI_FAMILY;
 
 	/* network byte order */
 	port = ((const struct sockinet *)(const void *)sa)->si_port;
@@ -544,6 +554,9 @@ getnameinfo_link(const struct sockaddr *
 	const struct ieee1394_hwaddr *iha;
 	int n;
 
+if (salen <= sizeof(*sdl) - sizeof(sdl->sdl_data))
+		return EAI_FAMILY;
+
 	if (serv != NULL && servlen > 0)
 		*serv = '\0';
 



CVS commit: [netbsd-10] src/lib/libc/net

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 13:44:35 UTC 2024

Modified Files:
src/lib/libc/net [netbsd-10]: getnameinfo.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #612):

lib/libc/net/getnameinfo.c: revision 1.60

PR/57609: Carl Engvall: Add salen checks but accept larger sizes
(upto sockaddr_storage)


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.59.26.1 src/lib/libc/net/getnameinfo.c

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



CVS commit: [netbsd-10] src/lib/libc/net

2024-03-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 10 13:44:35 UTC 2024

Modified Files:
src/lib/libc/net [netbsd-10]: getnameinfo.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #612):

lib/libc/net/getnameinfo.c: revision 1.60

PR/57609: Carl Engvall: Add salen checks but accept larger sizes
(upto sockaddr_storage)


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.59.26.1 src/lib/libc/net/getnameinfo.c

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

Modified files:

Index: src/lib/libc/net/getnameinfo.c
diff -u src/lib/libc/net/getnameinfo.c:1.59 src/lib/libc/net/getnameinfo.c:1.59.26.1
--- src/lib/libc/net/getnameinfo.c:1.59	Tue Sep 22 16:15:08 2015
+++ src/lib/libc/net/getnameinfo.c	Sun Mar 10 13:44:34 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: getnameinfo.c,v 1.59 2015/09/22 16:15:08 christos Exp $	*/
+/*	$NetBSD: getnameinfo.c,v 1.59.26.1 2024/03/10 13:44:34 martin Exp $	*/
 /*	$KAME: getnameinfo.c,v 1.45 2000/09/25 22:43:56 itojun Exp $	*/
 
 /*
@@ -47,7 +47,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getnameinfo.c,v 1.59 2015/09/22 16:15:08 christos Exp $");
+__RCSID("$NetBSD: getnameinfo.c,v 1.59.26.1 2024/03/10 13:44:34 martin Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #ifndef RUMP_ACTION
@@ -128,6 +128,13 @@ getnameinfo(const struct sockaddr *sa, s
 	int flags)
 {
 
+	/*  
+	 * getnameinfo() accepts an salen of sizeof(struct sockaddr_storage)
+	 * at maximum as shown in RFC 4038 Sec.6.2.3.
+	 */ 
+	if (salen > sizeof(struct sockaddr_storage))
+		return EAI_FAMILY;
+
 	switch (sa->sa_family) {
 	case AF_APPLETALK:
 		return getnameinfo_atalk(sa, salen, host, hostlen,
@@ -220,6 +227,9 @@ getnameinfo_local(const struct sockaddr 
 	const struct sockaddr_un *sun =
 	(const struct sockaddr_un *)(const void *)sa;
 
+if (salen <= sizeof(*sun) - sizeof(sun->sun_path))
+		return EAI_FAMILY;
+
 	if (serv != NULL && servlen > 0)
 		serv[0] = '\0';
 
@@ -266,8 +276,8 @@ getnameinfo_inet(const struct sockaddr *
 	return EAI_FAMILY;
 
  found:
-	if (salen != afd->a_socklen)
-		return EAI_FAIL;
+	if (salen < afd->a_socklen)
+		return EAI_FAMILY;
 
 	/* network byte order */
 	port = ((const struct sockinet *)(const void *)sa)->si_port;
@@ -544,6 +554,9 @@ getnameinfo_link(const struct sockaddr *
 	const struct ieee1394_hwaddr *iha;
 	int n;
 
+if (salen <= sizeof(*sdl) - sizeof(sdl->sdl_data))
+		return EAI_FAMILY;
+
 	if (serv != NULL && servlen > 0)
 		*serv = '\0';
 



CVS commit: src/usr.bin/xlint/lint1

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 12:50:46 UTC 2024

Modified Files:
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: split integer overflow check into separate functions

The checks for unsigned and signed integers differ for each operator, so
there's no point having both parts in the same function.


To generate a diff of this commit:
cvs rdiff -u -r1.617 -r1.618 src/usr.bin/xlint/lint1/tree.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/xlint/lint1

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 12:50:46 UTC 2024

Modified Files:
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: split integer overflow check into separate functions

The checks for unsigned and signed integers differ for each operator, so
there's no point having both parts in the same function.


To generate a diff of this commit:
cvs rdiff -u -r1.617 -r1.618 src/usr.bin/xlint/lint1/tree.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/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.617 src/usr.bin/xlint/lint1/tree.c:1.618
--- src/usr.bin/xlint/lint1/tree.c:1.617	Sun Mar 10 10:31:29 2024
+++ src/usr.bin/xlint/lint1/tree.c	Sun Mar 10 12:50:45 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.617 2024/03/10 10:31:29 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.618 2024/03/10 12:50:45 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.617 2024/03/10 10:31:29 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.618 2024/03/10 12:50:45 rillig Exp $");
 #endif
 
 #include 
@@ -787,147 +787,206 @@ build_address(bool sys, tnode_t *tn, boo
 	tn, NULL);
 }
 
-/*
- * XXX
- * Note: There appear to be a number of bugs in detecting overflow in
- * this function. An audit and a set of proper regression tests are needed.
- * --Perry Metzger, Nov. 16, 2001
- */
-static tnode_t *
-fold_constant_integer(tnode_t *tn)
+static uint64_t
+fold_unsigned_integer(op_t op, uint64_t l, uint64_t r,
+		  uint64_t max_value, bool *overflow)
 {
-
-	lint_assert(has_operands(tn));
-	tspec_t t = tn->u.ops.left->tn_type->t_tspec;
-	bool utyp = !is_integer(t) || is_uinteger(t);
-	int64_t sl = tn->u.ops.left->u.value.u.integer, sr = 0;
-	uint64_t ul = sl, ur = 0;
-	if (is_binary(tn))
-		ur = sr = tn->u.ops.right->u.value.u.integer;
-
-	uint64_t mask = value_bits(size_in_bits(t));
-	int64_t max_value = (int64_t)(mask >> 1);
-	int64_t min_value = -max_value - 1;
-	bool ovfl = false;
-
-	int64_t si;
-	switch (tn->tn_op) {
+	switch (op) {
 	case COMPL:
-		si = ~sl;
-		break;
+		return ~l;
 	case UPLUS:
-		si = sl;
-		break;
+		return l;
 	case UMINUS:
-		if (utyp)
-			si = (int64_t)-ul;
-		else {
-			ovfl = sl == min_value;
-			si = ovfl ? sl : -sl;
-		}
-		break;
-	case MULT:
-		if (utyp) {
-			si = (int64_t)(ul * ur);
-			if (si != (si & (int64_t)mask))
-ovfl = true;
-			else if (ul != 0 && si / ul != ur)
-ovfl = true;
-		} else {
-			uint64_t al = sl >= 0 ? ul : -ul;
-			uint64_t ar = sr >= 0 ? ur : -ur;
-			bool neg = (sl >= 0) != (sr >= 0);
-			uint64_t max_prod = (uint64_t)max_value
-			+ (neg ? 1 : 0);
-			if (al > 0 && ar > max_prod / al) {
-si = (int64_t)(al * ar);
-ovfl = true;
-			} else
-si = sl * sr;
-			if (msb(si, t) != (msb(sl, t) ^ msb(sr, t)))
-ovfl = true;
-		}
-		break;
+		return -l;
+	case MULT:;
+		uint64_t mult_result = l * r;
+		if (mult_result != (mult_result & max_value))
+			*overflow = true;
+		else if (l != 0 && mult_result / l != r)
+			*overflow = true;
+		return mult_result;
 	case DIV:
-		if (sr == 0) {
+		if (r == 0) {
 			/* division by 0 */
 			error(139);
-			si = utyp ? -1 : max_value;
-		} else if (!utyp && sl == min_value && sr == -1) {
-			ovfl = true;
-			si = sl;
+			return max_value;
 		} else
-			si = utyp ? (int64_t)(ul / ur) : sl / sr;
-		break;
+			return l / r;
 	case MOD:
-		if (sr == 0) {
+		if (r == 0) {
 			/* modulus by 0 */
 			error(140);
-			si = 0;
-		} else if (!utyp && sl == min_value && sr == -1) {
-			ovfl = true;
-			si = 0;
+			return 0;
 		} else
-			si = utyp ? (int64_t)(ul % ur) : sl % sr;
-		break;
-	case PLUS:
-		si = (int64_t)(ul + ur);
-		if (msb(sl, t) && msb(sr, t) && !msb(si, t))
-			ovfl = true;
-		if (!utyp && !msb(sl, t) && !msb(sr, t) && msb(si, t))
-			ovfl = true;
-		break;
-	case MINUS:
-		si = (int64_t)(ul - ur);
-		if (!utyp && msb(sl, t) && !msb(sr, t) && !msb(si, t))
-			ovfl = true;
-		if (!msb(sl, t) && msb(sr, t) && msb(si, t))
-			ovfl = true;
-		break;
+			return l % r;
+	case PLUS:;
+		uint64_t plus_result = l + r;
+		uint64_t hi = max_value ^ (max_value >> 1);
+		if (l & hi && r & hi && !(plus_result & hi))
+			*overflow = true;
+		return plus_result;
+	case MINUS:;
+		uint64_t minus_result = l - r;
+		hi = max_value ^ (max_value >> 1);
+		if (!(l & hi) && r & hi && minus_result & hi)
+			*overflow = true;
+		return minus_result;
 	case SHL:
 		/* TODO: warn about out-of-bounds 'sr'. */
-		/* TODO: warn about overflow in signed '<<'. */
-		si = utyp ? (int64_t)(ul << (sr & 63)) : sl << (sr & 63);
-		break;
+		return l << (r & 63);
 	case SHR:
-		/*
-		 * The sign must be explicitly extended because shifts of
-		 * signed values are implementation dependent.
-		 */
 		/* TODO: warn about out-of-bounds 'sr'. */
-		si = (int64_t)(ul >> (sr & 63));
-		si = convert_integer(si, t, 

CVS commit: src/tests/usr.bin/xlint/lint1

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 10:39:19 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: platform_lp64.c

Log Message:
tests/lint: enable test for integer overflow in array index


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/platform_lp64.c

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



CVS commit: src/tests/usr.bin/xlint/lint1

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 10:39:19 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: platform_lp64.c

Log Message:
tests/lint: enable test for integer overflow in array index


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/platform_lp64.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/platform_lp64.c
diff -u src/tests/usr.bin/xlint/lint1/platform_lp64.c:1.9 src/tests/usr.bin/xlint/lint1/platform_lp64.c:1.10
--- src/tests/usr.bin/xlint/lint1/platform_lp64.c:1.9	Sat Mar  9 17:34:01 2024
+++ src/tests/usr.bin/xlint/lint1/platform_lp64.c	Sun Mar 10 10:39:19 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: platform_lp64.c,v 1.9 2024/03/09 17:34:01 rillig Exp $	*/
+/*	$NetBSD: platform_lp64.c,v 1.10 2024/03/10 10:39:19 rillig Exp $	*/
 # 3 "platform_lp64.c"
 
 /*
@@ -91,12 +91,15 @@ array_index(void)
 	u64 += u64_buf[0x00ff];
 	/* expect+1: warning: array subscript cannot be > 19: 1152921504606846975 [168] */
 	u64 += u64_buf[0x0fff];
-	// FIXME: integer overflow
-	//u64 += u64_buf[0x1fff];
-	// FIXME: integer overflow
-	//u64 += u64_buf[0x3fff];
-	// FIXME: integer overflow
-	//u64 += u64_buf[0x7fff];
+	/* expect+2: warning: operator '*' produces integer overflow [141] */
+	/* expect+1: warning: array subscript cannot be negative: -1 [167] */
+	u64 += u64_buf[0x1fff];
+	/* expect+2: warning: operator '*' produces integer overflow [141] */
+	/* expect+1: warning: array subscript cannot be negative: -1 [167] */
+	u64 += u64_buf[0x3fff];
+	/* expect+2: warning: operator '*' produces integer overflow [141] */
+	/* expect+1: warning: array subscript cannot be negative: -1 [167] */
+	u64 += u64_buf[0x7fff];
 	/* expect+1: warning: array subscript cannot be negative: -1 [167] */
 	u64 += u64_buf[0x];
 }



CVS commit: src

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 10:31:29 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: expr_fold.c msg_141.c
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: remove wrong warning about overflow in unary '-' for unsigned


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/xlint/lint1/expr_fold.c \
src/tests/usr.bin/xlint/lint1/msg_141.c
cvs rdiff -u -r1.616 -r1.617 src/usr.bin/xlint/lint1/tree.c

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



CVS commit: src

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 10:31:29 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: expr_fold.c msg_141.c
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: remove wrong warning about overflow in unary '-' for unsigned


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/xlint/lint1/expr_fold.c \
src/tests/usr.bin/xlint/lint1/msg_141.c
cvs rdiff -u -r1.616 -r1.617 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/expr_fold.c
diff -u src/tests/usr.bin/xlint/lint1/expr_fold.c:1.12 src/tests/usr.bin/xlint/lint1/expr_fold.c:1.13
--- src/tests/usr.bin/xlint/lint1/expr_fold.c:1.12	Sat Mar  9 23:55:11 2024
+++ src/tests/usr.bin/xlint/lint1/expr_fold.c	Sun Mar 10 10:31:29 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: expr_fold.c,v 1.12 2024/03/09 23:55:11 rillig Exp $	*/
+/*	$NetBSD: expr_fold.c,v 1.13 2024/03/10 10:31:29 rillig Exp $	*/
 # 3 "expr_fold.c"
 
 /*
@@ -292,7 +292,6 @@ struct ctassert5_struct {
 void
 unary_minus_overflow(unsigned long long val)
 {
-	/* expect+1: warning: operator '-' produces integer overflow [141] */
 	if (val > -(unsigned long long)(-0x7fffL - 1))
 		return;
 }
Index: src/tests/usr.bin/xlint/lint1/msg_141.c
diff -u src/tests/usr.bin/xlint/lint1/msg_141.c:1.12 src/tests/usr.bin/xlint/lint1/msg_141.c:1.13
--- src/tests/usr.bin/xlint/lint1/msg_141.c:1.12	Sun Mar 10 10:15:52 2024
+++ src/tests/usr.bin/xlint/lint1/msg_141.c	Sun Mar 10 10:31:29 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_141.c,v 1.12 2024/03/10 10:15:52 rillig Exp $	*/
+/*	$NetBSD: msg_141.c,v 1.13 2024/03/10 10:31:29 rillig Exp $	*/
 # 3 "msg_141.c"
 
 // Test for message: operator '%s' produces integer overflow [141]
@@ -101,7 +101,6 @@ uminus_u32(void)
 {
 	u32 = -0xU;
 	u32 = -0x7fffU;
-	/* expect+1: warning: operator '-' produces integer overflow [141] */
 	u32 = -0x8000U;
 	u32 = -0xU;
 }
@@ -121,7 +120,6 @@ uminus_u64(void)
 {
 	u64 = -0xULL;
 	u64 = -0x7fffULL;
-	/* expect+1: warning: operator '-' produces integer overflow [141] */
 	u64 = -0x8000ULL;
 	u64 = -0xULL;
 }

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.616 src/usr.bin/xlint/lint1/tree.c:1.617
--- src/usr.bin/xlint/lint1/tree.c:1.616	Sun Mar 10 10:15:51 2024
+++ src/usr.bin/xlint/lint1/tree.c	Sun Mar 10 10:31:29 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.616 2024/03/10 10:15:51 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.617 2024/03/10 10:31:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.616 2024/03/10 10:15:51 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.617 2024/03/10 10:31:29 rillig Exp $");
 #endif
 
 #include 
@@ -797,9 +797,6 @@ static tnode_t *
 fold_constant_integer(tnode_t *tn)
 {
 
-	val_t *v = xcalloc(1, sizeof(*v));
-	v->v_tspec = tn->tn_type->t_tspec;
-
 	lint_assert(has_operands(tn));
 	tspec_t t = tn->u.ops.left->tn_type->t_tspec;
 	bool utyp = !is_integer(t) || is_uinteger(t);
@@ -822,9 +819,12 @@ fold_constant_integer(tnode_t *tn)
 		si = sl;
 		break;
 	case UMINUS:
-		si = sl == INT64_MIN ? sl : -sl;
-		if (sl != 0 && msb(si, t) == msb(sl, t))
-			ovfl = true;
+		if (utyp)
+			si = (int64_t)-ul;
+		else {
+			ovfl = sl == min_value;
+			si = ovfl ? sl : -sl;
+		}
 		break;
 	case MULT:
 		if (utyp) {
@@ -937,6 +937,8 @@ fold_constant_integer(tnode_t *tn)
 			warning(141, op_name(tn->tn_op));
 	}
 
+	val_t *v = xcalloc(1, sizeof(*v));
+	v->v_tspec = tn->tn_type->t_tspec;
 	v->u.integer = convert_integer(si, t, 0);
 
 	tnode_t *cn = build_constant(tn->tn_type, v);



CVS commit: src

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 10:15:52 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_141.c
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: fix integer overflow in integer overflow check


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/xlint/lint1/msg_141.c
cvs rdiff -u -r1.615 -r1.616 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_141.c
diff -u src/tests/usr.bin/xlint/lint1/msg_141.c:1.11 src/tests/usr.bin/xlint/lint1/msg_141.c:1.12
--- src/tests/usr.bin/xlint/lint1/msg_141.c:1.11	Sun Mar 10 09:58:30 2024
+++ src/tests/usr.bin/xlint/lint1/msg_141.c	Sun Mar 10 10:15:52 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_141.c,v 1.11 2024/03/10 09:58:30 rillig Exp $	*/
+/*	$NetBSD: msg_141.c,v 1.12 2024/03/10 10:15:52 rillig Exp $	*/
 # 3 "msg_141.c"
 
 // Test for message: operator '%s' produces integer overflow [141]
@@ -162,26 +162,26 @@ mult_u32(void)
 void
 mult_s64(void)
 {
-	/* TODO: expect+1: warning: operator '*' produces integer overflow [141] */
-	//s64 = -0x1LL * 0x1LL;	// -0x01
-	/* TODO: expect+1: warning: operator '*' produces integer overflow [141] */
-	//s64 = -3LL * 0x2aabLL;	// -0x8001
-	/* TODO: expect+1: warning: operator '*' produces integer overflow [141] */
-	//s64 = 0x2aabLL * -3LL;	// -0x8001
+	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	s64 = -0x1LL * 0x1LL;	// -0x01
+	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	s64 = -3LL * 0x2aabLL;	// -0x8001
+	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	s64 = 0x2aabLL * -3LL;	// -0x8001
 	s64 = -8LL * +0x1000LL;	// -0x8000
 	s64 = +0x1000LL * -8LL;	// -0x8000
 	s64 = +2LL * +0x3fffLL;	// +0x7ffe
 	s64 = +0x3fffLL * +2LL;	// +0x7ffe
 	s64 = +0x7fffLL * +1LL;	// +0x7fff
 	s64 = +1LL * +0x7fffLL;	// +0x7fff
-	/* TODO: expect+1: warning: operator '*' produces integer overflow [141] */
-	//s64 = +2LL * +0x4000LL;	// +0x8000
-	/* TODO: expect+1: warning: operator '*' produces integer overflow [141] */
-	//s64 = +0x4000LL * +2LL;	// +0x8000
-	/* TODO: expect+1: warning: operator '*' produces integer overflow [141] */
-	//s64 = +0xLL * +0x10001LL;	// +0x
-	/* TODO: expect+1: warning: operator '*' produces integer overflow [141] */
-	//s64 = +0x1LL * +0x1LL;	// +0x01
+	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	s64 = +2LL * +0x4000LL;	// +0x8000
+	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	s64 = +0x4000LL * +2LL;	// +0x8000
+	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	s64 = +0xLL * +0x10001LL;	// +0x
+	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	s64 = +0x1LL * +0x1LL;	// +0x01
 }
 
 void
@@ -249,6 +249,7 @@ mod_s32(void)
 {
 	s32 = -1 % (-0x7fff - 1);
 	s32 = -1 % 0x7fff;
+	/* expect+1: warning: operator '%' produces integer overflow [141] */
 	s32 = (-0x7fff - 1) % -1;
 	s32 = 0x7fff % -1;
 }
@@ -269,9 +270,8 @@ mod_s64(void)
 {
 	s64 = -1LL % (-0x7fffLL - 1LL);
 	s64 = -1LL % 0x7fffLL;
-	// FIXME: endless loop on x86_64 in idivq instruction,
-	//  probably due to SIGFPE handling.
-	//s64 = (-0x7fffLL - 1LL) % -1LL;
+	/* expect+1: warning: operator '%' produces integer overflow [141] */
+	s64 = (-0x7fffLL - 1LL) % -1LL;
 	s64 = 0x7fffLL % -1LL;
 }
 
@@ -334,12 +334,12 @@ plus_u32(void)
 void
 plus_s64(void)
 {
-	/* TODO: expect+1: warning: operator '+' produces integer overflow [141] */
-	// FIXME: s64 = -0x7fffLL + -2LL;
+	/* expect+1: warning: operator '+' produces integer overflow [141] */
+	s64 = -0x7fffLL + -2LL;
 	s64 = -0x7fffLL + -1LL;
 	s64 = 0x7ffeLL + 1LL;
-	/* TODO: expect+1: warning: operator '+' produces integer overflow [141] */
-	// FIXME: s64 = 0x7fffLL + 1LL;
+	/* expect+1: warning: operator '+' produces integer overflow [141] */
+	s64 = 0x7fffLL + 1LL;
 }
 
 void
@@ -390,19 +390,19 @@ minus_u32(void)
 void
 minus_s64(void)
 {
-	/* TODO: expect+1: warning: operator '-' produces integer overflow [141] */
-	// FIXME: s64 = -0x7fffLL - 0x7fffLL;
-	/* TODO: expect+1: warning: operator '-' produces integer overflow [141] 

CVS commit: src

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 10:15:52 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_141.c
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: fix integer overflow in integer overflow check


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/xlint/lint1/msg_141.c
cvs rdiff -u -r1.615 -r1.616 src/usr.bin/xlint/lint1/tree.c

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



CVS commit: src/tests/usr.bin/xlint/lint1

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 09:58:30 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_141.c

Log Message:
tests/lint: test integer overflow when folding constants

The test is still incomplete, yet it has discovered several bugs that
are worth fixing.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/xlint/lint1/msg_141.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_141.c
diff -u src/tests/usr.bin/xlint/lint1/msg_141.c:1.10 src/tests/usr.bin/xlint/lint1/msg_141.c:1.11
--- src/tests/usr.bin/xlint/lint1/msg_141.c:1.10	Thu Jan 11 20:25:04 2024
+++ src/tests/usr.bin/xlint/lint1/msg_141.c	Sun Mar 10 09:58:30 2024
@@ -1,213 +1,583 @@
-/*	$NetBSD: msg_141.c,v 1.10 2024/01/11 20:25:04 rillig Exp $	*/
+/*	$NetBSD: msg_141.c,v 1.11 2024/03/10 09:58:30 rillig Exp $	*/
 # 3 "msg_141.c"
 
 // Test for message: operator '%s' produces integer overflow [141]
 
 /* lint1-extra-flags: -h -X 351 */
 
-/*
- * Before tree.c 1.347 from 2021-08-23, lint wrongly warned about integer
- * overflow in '-'.
- */
-int signed_int_max = (1U << 31) - 1;
+// Integer overflow occurs when the arbitrary-precision result of an
+// arithmetic operation cannot be represented by the type of the expression.
 
-/*
- * Before tree.c 1.347 from 2021-08-23, lint wrongly warned about integer
- * overflow in '-'.
- */
-unsigned int unsigned_int_max = (1U << 31) - 1;
-
-/* expect+1: warning: operator '+' produces integer overflow [141] */
-int int_overflow = (1 << 30) + (1 << 30);
-
-/* expect+2: warning: operator '+' produces integer overflow [141] */
-/* expect+1: warning: initialization of unsigned with negative constant [221] */
-unsigned int intermediate_overflow = (1 << 30) + (1 << 30);
-
-unsigned int no_overflow = (1U << 30) + (1 << 30);
-
-/* expect+1: warning: operator '-' produces integer overflow [141] */
-unsigned int unsigned_int_min = 0U - (1U << 31);
-
-/* expect+1: warning: operator '-' produces integer overflow [141] */
-unsigned int unsigned_int_min_unary = -(1U << 31);
-
-enum {
-	INT_MAX = 2147483647,
-	INT_MIN = -INT_MAX - 1,
-};
-
-unsigned long long overflow_unsigned[] = {
-
-	// unary '+'
-
-	+0U,
-	+~0U,
-	+~0ULL,
-
-	// unary '-'
-
-	-0U,
-	-~0U,
+signed int s32;
+unsigned int u32;
+signed long long s64;
+unsigned long long u64;
+
+void
+compl_s32(void)
+{
+	s32 = ~(-0x7fff - 1);
+	s32 = ~-1;
+	s32 = ~0;
+	s32 = ~1;
+	s32 = ~0x7fff;
+}
+
+void
+compl_u32(void)
+{
+	u32 = ~0xU;
+	u32 = ~0x7fffU;
+	u32 = ~0x8000U;
+	u32 = ~0xU;
+}
+
+void
+compl_s64(void)
+{
+	s64 = ~(-0x7fffLL - 1LL);
+	s64 = ~-1LL;
+	s64 = ~0LL;
+	s64 = ~0x7fffLL;
+}
+
+void
+compl_u64(void)
+{
+	u64 = ~0ULL;
+	u64 = ~0x7fffULL;
+	u64 = ~0x8000ULL;
+	u64 = ~0xULL;
+}
+
+void
+uplus_s32(void)
+{
+	s32 = +(-0x7fff - 1);
+	s32 = +-1;
+	s32 = +0;
+	s32 = +0x7fff;
+}
+
+void
+uplus_u32(void)
+{
+	u32 = +0xU;
+	u32 = +0x7fffU;
+	u32 = +0x8000U;
+	u32 = +0xU;
+}
+
+void
+uplus_s64(void)
+{
+	s64 = +(-0x7fffLL - 1LL);
+	s64 = +-1LL;
+	s64 = +0LL;
+	s64 = +0x7fffLL;
+}
+
+void
+uplus_u64(void)
+{
+	u64 = +0xULL;
+	u64 = +0x7fffULL;
+	u64 = +0x8000ULL;
+	u64 = +0xULL;
+}
+
+void
+uminus_s32(void)
+{
 	/* expect+1: warning: operator '-' produces integer overflow [141] */
-	-(1ULL << 63),
+	s32 = -(-0x7fff - 1);
+	s32 = - -1;
+	s32 = -0;
+	s32 = -0x7fff;
+}
+
+void
+uminus_u32(void)
+{
+	u32 = -0xU;
+	u32 = -0x7fffU;
 	/* expect+1: warning: operator '-' produces integer overflow [141] */
-	-(1U << 31),
-
-	// '~'
+	u32 = -0x8000U;
+	u32 = -0xU;
+}
+
+void
+uminus_s64(void)
+{
+	/* expect+1: warning: operator '-' produces integer overflow [141] */
+	s64 = -(-0x7fffLL - 1LL);
+	s64 = - -1LL;
+	s64 = -0LL;
+	s64 = -0x7fffLL;
+}
+
+void
+uminus_u64(void)
+{
+	u64 = -0xULL;
+	u64 = -0x7fffULL;
+	/* expect+1: warning: operator '-' produces integer overflow [141] */
+	u64 = -0x8000ULL;
+	u64 = -0xULL;
+}
+
+void
+mult_s32(void)
+{
+	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	s32 = -0x0001 * +0x0001;	// -0x01
+	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	s32 = -0x0003 * +0x2aab;	// -0x8001
+	/* expect+1: warning: operator '*' produces integer overflow [141] */
+	s32 = +0x2aab * -0x0003;	// -0x8001
+	s32 = -0x0008 * +0x1000;	// -0x8000
+	s32 = +0x1000 * -0x0008;	// -0x8000
+	s32 = +0x0002 * +0x3fff;	// +0x7ffe
+	s32 = +0x3fff * +0x0002;	// +0x7ffe
+	s32 = +0x7fff * +0x0001;	// +0x7fff
+	s32 = 

CVS commit: src/tests/usr.bin/xlint/lint1

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 09:58:30 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_141.c

Log Message:
tests/lint: test integer overflow when folding constants

The test is still incomplete, yet it has discovered several bugs that
are worth fixing.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/xlint/lint1/msg_141.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/xlint/lint1

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 09:24:54 UTC 2024

Modified Files:
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: in check for integer overflow, sort operators


To generate a diff of this commit:
cvs rdiff -u -r1.614 -r1.615 src/usr.bin/xlint/lint1/tree.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/xlint/lint1

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 09:24:54 UTC 2024

Modified Files:
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: in check for integer overflow, sort operators


To generate a diff of this commit:
cvs rdiff -u -r1.614 -r1.615 src/usr.bin/xlint/lint1/tree.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/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.614 src/usr.bin/xlint/lint1/tree.c:1.615
--- src/usr.bin/xlint/lint1/tree.c:1.614	Sat Mar  9 23:55:11 2024
+++ src/usr.bin/xlint/lint1/tree.c	Sun Mar 10 09:24:54 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.614 2024/03/09 23:55:11 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.615 2024/03/10 09:24:54 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.614 2024/03/09 23:55:11 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.615 2024/03/10 09:24:54 rillig Exp $");
 #endif
 
 #include 
@@ -815,6 +815,9 @@ fold_constant_integer(tnode_t *tn)
 
 	int64_t si;
 	switch (tn->tn_op) {
+	case COMPL:
+		si = ~sl;
+		break;
 	case UPLUS:
 		si = sl;
 		break;
@@ -823,9 +826,6 @@ fold_constant_integer(tnode_t *tn)
 		if (sl != 0 && msb(si, t) == msb(sl, t))
 			ovfl = true;
 		break;
-	case COMPL:
-		si = ~sl;
-		break;
 	case MULT:
 		if (utyp) {
 			si = (int64_t)(ul * ur);
@@ -892,12 +892,12 @@ fold_constant_integer(tnode_t *tn)
 	case LE:
 		si = (utyp ? ul <= ur : sl <= sr) ? 1 : 0;
 		break;
-	case GE:
-		si = (utyp ? ul >= ur : sl >= sr) ? 1 : 0;
-		break;
 	case GT:
 		si = (utyp ? ul > ur : sl > sr) ? 1 : 0;
 		break;
+	case GE:
+		si = (utyp ? ul >= ur : sl >= sr) ? 1 : 0;
+		break;
 	case EQ:
 		si = (utyp ? ul == ur : sl == sr) ? 1 : 0;
 		break;