CVS commit: src

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 21:39:44 UTC 2022

Modified Files:
src/tests/usr.bin/compress: t_pr_19722.sh
src/usr.bin/compress: compress.c

Log Message:
uncompress: if the source is broken, don't delete the target

Fixes the second half of PR bin/19722, reported by Giorgos Keramidas.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/compress/t_pr_19722.sh
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/compress/compress.c

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



CVS commit: src

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 21:39:44 UTC 2022

Modified Files:
src/tests/usr.bin/compress: t_pr_19722.sh
src/usr.bin/compress: compress.c

Log Message:
uncompress: if the source is broken, don't delete the target

Fixes the second half of PR bin/19722, reported by Giorgos Keramidas.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/compress/t_pr_19722.sh
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/compress/compress.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/compress/t_pr_19722.sh
diff -u src/tests/usr.bin/compress/t_pr_19722.sh:1.3 src/tests/usr.bin/compress/t_pr_19722.sh:1.4
--- src/tests/usr.bin/compress/t_pr_19722.sh:1.3	Sun May 22 21:16:50 2022
+++ src/tests/usr.bin/compress/t_pr_19722.sh	Sun May 22 21:39:44 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: t_pr_19722.sh,v 1.3 2022/05/22 21:16:50 rillig Exp $
+#	$NetBSD: t_pr_19722.sh,v 1.4 2022/05/22 21:39:44 rillig Exp $
 #
 # Copyright (c) 2022 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -148,6 +148,10 @@ atf_test_case 'uncompress_broken_source_
 uncompress_broken_source_existing_target_body()
 {
 	# PR 19722: uncompressing a broken source removes existing target
+	#
+	# Before compress.c 1.29 from 2022-05-22, uncompress removed an
+	# existing target before checking that the source has the correct
+	# format.
 
 	echo 'broken' > file.Z
 	echo 'before' > file
@@ -158,8 +162,7 @@ uncompress_broken_source_existing_target
 	uncompress -f file.Z
 
 	atf_check -o 'inline:broken\n' cat file.Z
-	# FIXME: Must not be modified.
-	atf_check test ! -f file
+	atf_check -o 'inline:before\n' cat file
 }
 
 

Index: src/usr.bin/compress/compress.c
diff -u src/usr.bin/compress/compress.c:1.28 src/usr.bin/compress/compress.c:1.29
--- src/usr.bin/compress/compress.c:1.28	Sun May 22 21:16:50 2022
+++ src/usr.bin/compress/compress.c	Sun May 22 21:39:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: compress.c,v 1.28 2022/05/22 21:16:50 rillig Exp $	*/
+/*	$NetBSD: compress.c,v 1.29 2022/05/22 21:39:44 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 19
 #if 0
 static char sccsid[] = "@(#)compress.c	8.2 (Berkeley) 1/7/94";
 #else
-__RCSID("$NetBSD: compress.c,v 1.28 2022/05/22 21:16:50 rillig Exp $");
+__RCSID("$NetBSD: compress.c,v 1.29 2022/05/22 21:39:44 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -318,10 +318,6 @@ decompress(const char *in, const char *o
 		cwarn("%s", in);
 		goto err;
 	}
-	if ((ofp = fopen(out, "w")) == NULL) {
-		cwarn("%s", out);
-		goto err;
-	}
 	if (!isstdin) {
 		if (stat(in, &sb)) {
 			cwarn("%s", in);
@@ -333,6 +329,19 @@ decompress(const char *in, const char *o
 			isreg = 1;
 	} else
 		isreg = 0;
+	if ((nr = fread(buf, 1, sizeof(buf), ifp)) == 0) {
+		cwarn("%s", in);
+		goto err;
+	}
+
+	if ((ofp = fopen(out, "w")) == NULL) {
+		cwarn("%s", out);
+		goto err;
+	}
+	if (fwrite(buf, 1, nr, ofp) != nr) {
+		cwarn("%s", out);
+		goto err;
+	}
 
 	oreg <<= 1;
 	while ((nr = fread(buf, 1, sizeof(buf), ifp)) != 0)



CVS commit: src/sys/sys

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 21:31:48 UTC 2022

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

Log Message:
sys/param.h: Welcome to 9.99.97, courtesy of opencrypto cleanup.

crypto_dispatch, crypto_kdispatch, and crypto_freesession now return
void, as does the opencrypto driver's freesession callback.


To generate a diff of this commit:
cvs rdiff -u -r1.709 -r1.710 src/sys/sys/param.h

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

Modified files:

Index: src/sys/sys/param.h
diff -u src/sys/sys/param.h:1.709 src/sys/sys/param.h:1.710
--- src/sys/sys/param.h:1.709	Sun Mar 27 16:16:39 2022
+++ src/sys/sys/param.h	Sun May 22 21:31:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.709 2022/03/27 16:16:39 christos Exp $	*/
+/*	$NetBSD: param.h,v 1.710 2022/05/22 21:31:48 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	999009600	/* NetBSD 9.99.96 */
+#define	__NetBSD_Version__	999009700	/* NetBSD 9.99.97 */
 
 #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \
 (m) * 100) + (p) * 100) <= __NetBSD_Version__)



CVS commit: src/sys/sys

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 21:31:48 UTC 2022

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

Log Message:
sys/param.h: Welcome to 9.99.97, courtesy of opencrypto cleanup.

crypto_dispatch, crypto_kdispatch, and crypto_freesession now return
void, as does the opencrypto driver's freesession callback.


To generate a diff of this commit:
cvs rdiff -u -r1.709 -r1.710 src/sys/sys/param.h

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/display

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 21:18:12 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/display: intel_gmbus.c

Log Message:
i915: Fix sense of conditional for gmbus wait.

This enables i915 to again retrieve EDID data from displays over the
I2C DDC.

Embarrassing.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.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/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.c:1.6 src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.c:1.7
--- src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.c:1.6	Sun May 22 20:35:20 2022
+++ src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.c	Sun May 22 21:18:12 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel_gmbus.c,v 1.6 2022/05/22 20:35:20 riastradh Exp $	*/
+/*	$NetBSD: intel_gmbus.c,v 1.7 2022/05/22 21:18:12 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2006 Dave Airlie 
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intel_gmbus.c,v 1.6 2022/05/22 20:35:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_gmbus.c,v 1.7 2022/05/22 21:18:12 riastradh Exp $");
 
 #include 
 #include 
@@ -354,8 +354,8 @@ static int gmbus_wait(struct drm_i915_pr
 		unsigned timeout = 50*1000;
 
 		ret = 0;
-		while ((gmbus2 = intel_uncore_read_fw(&dev_priv->uncore,
-			GMBUS2)) & status) {
+		while (((gmbus2 = intel_uncore_read_fw(&dev_priv->uncore,
+GMBUS2)) & status) == 0) {
 			if (--timeout == 0) {
 ret = -ETIMEDOUT;
 break;
@@ -370,7 +370,7 @@ static int gmbus_wait(struct drm_i915_pr
 		(((gmbus2 = intel_uncore_read_fw(&dev_priv->uncore,
 GMBUS2))
 			& status)
-			== 0));
+			!= 0));
 		/*
 		 * After DRM_SPIN_TIMED_WAIT_NOINTR_UNTIL, ret<0 on
 		 * error (-ERESTARTSYS, interrupt), ret=0 on timeout,



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/display

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 21:18:12 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/display: intel_gmbus.c

Log Message:
i915: Fix sense of conditional for gmbus wait.

This enables i915 to again retrieve EDID data from displays over the
I2C DDC.

Embarrassing.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.c

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



CVS commit: src

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 21:16:50 UTC 2022

Modified Files:
src/tests/usr.bin/compress: t_pr_19722.sh
src/usr.bin/compress: compress.c

Log Message:
uncompress: if the source doesn't exist, don't touch the target

Fixes part of PR bin/19722, reported by Giorgos Keramidas.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/compress/t_pr_19722.sh
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/compress/compress.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/compress/t_pr_19722.sh
diff -u src/tests/usr.bin/compress/t_pr_19722.sh:1.2 src/tests/usr.bin/compress/t_pr_19722.sh:1.3
--- src/tests/usr.bin/compress/t_pr_19722.sh:1.2	Sun May 22 20:49:12 2022
+++ src/tests/usr.bin/compress/t_pr_19722.sh	Sun May 22 21:16:50 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: t_pr_19722.sh,v 1.2 2022/05/22 20:49:12 rillig Exp $
+#	$NetBSD: t_pr_19722.sh,v 1.3 2022/05/22 21:16:50 rillig Exp $
 #
 # Copyright (c) 2022 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -92,15 +92,17 @@ atf_test_case 'uncompress_no_source_no_t
 uncompress_no_source_no_target_body()
 {
 	# PR 19722: uncompressing a missing source creates empty target
+	#
+	# Before compress.c 1.28 from 2022-05-22, uncompress created an empty
+	# target file and didn't clean it up.
 
 	atf_check \
 	-s 'not-exit:0' \
 	-e 'inline:uncompress: file.Z: No such file or directory\n' \
 	uncompress -f file
 
-	# FIXME: The target file must not be created.
-	atf_check cat file
-	atf_check test ! -f nonexistent.Z
+	atf_check test ! -f file
+	atf_check test ! -f file.Z
 }
 
 
@@ -108,6 +110,9 @@ atf_test_case 'uncompress_no_source_exis
 uncompress_no_source_existing_target_body()
 {
 	# PR 19722: uncompressing a missing source truncates target
+	#
+	# Before compress.c 1.28 from 2022-05-22, uncompress truncated the
+	# target.
 
 	atf_check sh -c "echo 'hello' > file"
 
@@ -116,8 +121,7 @@ uncompress_no_source_existing_target_bod
 	-e 'inline:uncompress: file.Z: No such file or directory\n' \
 	uncompress -f file
 
-	# FIXME: The file must not be truncated.
-	atf_check cat file
+	atf_check -o 'inline:hello\n' cat file
 	atf_check test ! -f file.Z
 }
 

Index: src/usr.bin/compress/compress.c
diff -u src/usr.bin/compress/compress.c:1.27 src/usr.bin/compress/compress.c:1.28
--- src/usr.bin/compress/compress.c:1.27	Sun May 22 19:41:49 2022
+++ src/usr.bin/compress/compress.c	Sun May 22 21:16:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: compress.c,v 1.27 2022/05/22 19:41:49 rillig Exp $	*/
+/*	$NetBSD: compress.c,v 1.28 2022/05/22 21:16:50 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 19
 #if 0
 static char sccsid[] = "@(#)compress.c	8.2 (Berkeley) 1/7/94";
 #else
-__RCSID("$NetBSD: compress.c,v 1.27 2022/05/22 19:41:49 rillig Exp $");
+__RCSID("$NetBSD: compress.c,v 1.28 2022/05/22 21:16:50 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -313,15 +313,15 @@ decompress(const char *in, const char *o
 		oreg = 0;
 
 	ifp = ofp = NULL;
-	if ((ofp = fopen(out, "w")) == NULL) {
-		cwarn("%s", out);
-		return;
-	}
 
 	if ((ifp = zopen(in, "r", bits)) == NULL) {
 		cwarn("%s", in);
 		goto err;
 	}
+	if ((ofp = fopen(out, "w")) == NULL) {
+		cwarn("%s", out);
+		goto err;
+	}
 	if (!isstdin) {
 		if (stat(in, &sb)) {
 			cwarn("%s", in);



CVS commit: src

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 21:16:50 UTC 2022

Modified Files:
src/tests/usr.bin/compress: t_pr_19722.sh
src/usr.bin/compress: compress.c

Log Message:
uncompress: if the source doesn't exist, don't touch the target

Fixes part of PR bin/19722, reported by Giorgos Keramidas.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/compress/t_pr_19722.sh
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/compress/compress.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/compress

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 20:49:12 UTC 2022

Modified Files:
src/tests/usr.bin/compress: t_pr_19722.sh

Log Message:
tests/compress: extend tests for compressing and uncompressing

For PR bin/19722.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/compress/t_pr_19722.sh

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/compress

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 20:49:12 UTC 2022

Modified Files:
src/tests/usr.bin/compress: t_pr_19722.sh

Log Message:
tests/compress: extend tests for compressing and uncompressing

For PR bin/19722.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/compress/t_pr_19722.sh

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

Modified files:

Index: src/tests/usr.bin/compress/t_pr_19722.sh
diff -u src/tests/usr.bin/compress/t_pr_19722.sh:1.1 src/tests/usr.bin/compress/t_pr_19722.sh:1.2
--- src/tests/usr.bin/compress/t_pr_19722.sh:1.1	Sun May 22 17:55:08 2022
+++ src/tests/usr.bin/compress/t_pr_19722.sh	Sun May 22 20:49:12 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: t_pr_19722.sh,v 1.1 2022/05/22 17:55:08 rillig Exp $
+#	$NetBSD: t_pr_19722.sh,v 1.2 2022/05/22 20:49:12 rillig Exp $
 #
 # Copyright (c) 2022 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -25,65 +25,149 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 
-# https://gnats.netbsd.org/19722
-#
-# Before TODO:rev from TODO:date, trying to uncompress a nonexistent or
-# malformed source file resulted in a truncated target file.
+atf_test_case 'compress_small_file'
+compress_small_file_body()
+{
+	# If the compressed version of a file would be larger than the
+	# original file, the original file is kept.
+
+	echo 'hello' > file
+
+	atf_check compress file
+
+	atf_check -o 'inline:hello\n' cat file
+	atf_check test ! -f file.Z
+}
+
+
+atf_test_case 'compress_small_file_force'
+compress_small_file_force_body()
+{
+	# The option '-f' forces compression to happen, even if the resulting
+	# file becomes larger than the original.
+
+	echo 'hello' > file
+
+	atf_check compress -f file
+
+	atf_check test ! -f file
+	atf_check \
+	-o 'inline:000   1f  9d  90  68  ca  b0  61  f3  46  01\n00a\n' \
+	od -Ax -tx1 file.Z
+}
+
+
+atf_test_case 'roundtrip'
+roundtrip_body()
+{
+	# Compressing and decompressing a file must preserve every byte.
+
+	atf_check -e 'ignore' dd if=/dev/urandom of=file bs=4k count=10
+	atf_check cp file original
+
+	atf_check compress -f file
+	atf_check uncompress file.Z
 
+	atf_check cmp file original
+}
+
+
+atf_test_case 'uncompress_basename'
+uncompress_basename_body()
+{
+	# To uncompress a file, it suffices to specify the basename of the
+	# file, the filename extension '.Z' is optional.
+
+	atf_check sh -c "echo 'hello' > file"
+	atf_check compress -f file
 
-atf_test_case 'no_source_no_target'
-no_source_no_target_body()
+	atf_check uncompress file
+
+	atf_check -o 'inline:hello\n' cat file
+	atf_check test ! -f file.Z
+}
+
+
+atf_test_case 'uncompress_no_source_no_target'
+uncompress_no_source_no_target_body()
 {
+	# PR 19722: uncompressing a missing source creates empty target
 
 	atf_check \
 	-s 'not-exit:0' \
 	-e 'inline:uncompress: file.Z: No such file or directory\n' \
-	uncompress -f 'file'
+	uncompress -f file
 
 	# FIXME: The target file must not be created.
-	atf_check cat 'file'
-	atf_check test ! -f 'nonexistent.Z'
+	atf_check cat file
+	atf_check test ! -f nonexistent.Z
 }
 
 
-atf_test_case 'no_source_existing_target'
-no_source_existing_target_body()
+atf_test_case 'uncompress_no_source_existing_target'
+uncompress_no_source_existing_target_body()
 {
+	# PR 19722: uncompressing a missing source truncates target
 
-	echo 'before' > 'file'
+	atf_check sh -c "echo 'hello' > file"
 
 	atf_check \
 	-s 'not-exit:0' \
 	-e 'inline:uncompress: file.Z: No such file or directory\n' \
-	uncompress -f 'file'
+	uncompress -f file
+
+	# FIXME: The file must not be truncated.
+	atf_check cat file
+	atf_check test ! -f file.Z
+}
+
+
+atf_test_case 'uncompress_broken_source_no_target'
+uncompress_broken_source_no_target_body()
+{
+	# When trying to uncompress a broken source, the target is created
+	# temporarily but deleted again, as part of the cleanup.
+
+	echo 'broken' > file.Z
+
+	atf_check \
+	-s 'not-exit:0' \
+	-e 'inline:uncompress: file.Z: Inappropriate file type or format\n' \
+	uncompress -f file
 
-	# FIXME: The target file must not be truncated.
-	atf_check cat 'file'
+	atf_check test ! -f file
+	atf_check test -f file.Z
 }
 
 
-atf_test_case 'broken_source_existing_target'
-broken_source_existing_target_body()
+atf_test_case 'uncompress_broken_source_existing_target'
+uncompress_broken_source_existing_target_body()
 {
-	# If the source file is not compressed, preserve the target file.
+	# PR 19722: uncompressing a broken source removes existing target
 
-	echo 'broken' > 'file.Z'
-	echo 'before' > 'file'
+	echo 'broken' > file.Z
+	echo 'before' > file
 
 	atf_check \
 	-s 'not-exit:0' \
 	-e 'inline:uncompress: file.Z: Inappropriate file type or format\n' \
-	uncompress -f 'file.Z'
+	uncompress -f file.Z
 
-	# FIXME: Must not be removed, must not be truncated.
-	atf_check test ! -f 'file'
+	atf_c

CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/display

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 20:35:20 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/display: intel_gmbus.c

Log Message:
i915: Raise gmbus_wait timeout from 10ms to 50ms to match upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.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/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.c:1.5 src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.c:1.6
--- src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.c:1.5	Sun May 22 18:41:22 2022
+++ src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.c	Sun May 22 20:35:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel_gmbus.c,v 1.5 2022/05/22 18:41:22 riastradh Exp $	*/
+/*	$NetBSD: intel_gmbus.c,v 1.6 2022/05/22 20:35:20 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2006 Dave Airlie 
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intel_gmbus.c,v 1.5 2022/05/22 18:41:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_gmbus.c,v 1.6 2022/05/22 20:35:20 riastradh Exp $");
 
 #include 
 #include 
@@ -351,7 +351,7 @@ static int gmbus_wait(struct drm_i915_pr
 
 	status |= GMBUS_SATOER;
 	if (!irq_en) {
-		unsigned timeout = 10*1000;
+		unsigned timeout = 50*1000;
 
 		ret = 0;
 		while ((gmbus2 = intel_uncore_read_fw(&dev_priv->uncore,
@@ -366,7 +366,7 @@ static int gmbus_wait(struct drm_i915_pr
 		DRM_SPIN_TIMED_WAIT_NOINTR_UNTIL(ret,
 		&dev_priv->gmbus_wait_queue,
 		&dev_priv->gmbus_wait_lock,
-		msecs_to_jiffies_timeout(10),
+		msecs_to_jiffies_timeout(50),
 		(((gmbus2 = intel_uncore_read_fw(&dev_priv->uncore,
 GMBUS2))
 			& status)



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/display

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 20:35:20 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/display: intel_gmbus.c

Log Message:
i915: Raise gmbus_wait timeout from 10ms to 50ms to match upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.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/compress

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 19:41:50 UTC 2022

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

Log Message:
compress: normalize indentation and spacing

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/compress/compress.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/compress

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 19:41:50 UTC 2022

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

Log Message:
compress: normalize indentation and spacing

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/compress/compress.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/compress/compress.c
diff -u src/usr.bin/compress/compress.c:1.26 src/usr.bin/compress/compress.c:1.27
--- src/usr.bin/compress/compress.c:1.26	Tue Aug 30 23:08:05 2011
+++ src/usr.bin/compress/compress.c	Sun May 22 19:41:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: compress.c,v 1.26 2011/08/30 23:08:05 joerg Exp $	*/
+/*	$NetBSD: compress.c,v 1.27 2022/05/22 19:41:49 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 19
 #if 0
 static char sccsid[] = "@(#)compress.c	8.2 (Berkeley) 1/7/94";
 #else
-__RCSID("$NetBSD: compress.c,v 1.26 2011/08/30 23:08:05 joerg Exp $");
+__RCSID("$NetBSD: compress.c,v 1.27 2022/05/22 19:41:49 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -71,7 +71,7 @@ static int isstdout, isstdin;
 int
 main(int argc, char **argv)
 {
-enum {COMPRESS, DECOMPRESS} style = COMPRESS;
+	enum {COMPRESS, DECOMPRESS} style = COMPRESS;
 	size_t len;
 	int bits, cat, ch;
 	char *p, newname[MAXPATHLEN];
@@ -82,18 +82,17 @@ main(int argc, char **argv)
 		++p;
 	if (!strcmp(p, "uncompress"))
 		style = DECOMPRESS;
-else if (!strcmp(p, "compress"))
-style = COMPRESS;
-else if (!strcmp(p, "zcat")) {
-style = DECOMPRESS;
-cat = 1;
-}
-	else
+	else if (!strcmp(p, "compress"))
+		style = COMPRESS;
+	else if (!strcmp(p, "zcat")) {
+		style = DECOMPRESS;
+		cat = 1;
+	} else
 		errx(1, "unknown program name");
 
 	bits = cat = 0;
 	while ((ch = getopt(argc, argv, "b:cdfv")) != -1)
-		switch(ch) {
+		switch (ch) {
 		case 'b':
 			bits = strtol(optarg, &p, 10);
 			if (*p)
@@ -119,7 +118,7 @@ main(int argc, char **argv)
 	argv += optind;
 
 	if (argc == 0) {
-		switch(style) {
+		switch (style) {
 		case COMPRESS:
 			isstdout = 1;
 			isstdin = 1;
@@ -139,7 +138,7 @@ main(int argc, char **argv)
 
 	for (; *argv; ++argv) {
 		isstdout = 0;
-		switch(style) {
+		switch (style) {
 		case COMPRESS:
 			if (cat) {
 isstdout = 1;



CVS commit: src/distrib/amd64

2022-05-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun May 22 19:32:42 UTC 2022

Modified Files:
src/distrib/amd64/installimage: Makefile installimage.mk
src/distrib/amd64/installimage-bios: Makefile

Log Message:
Restore Makefile.installimage include after variables are set. Makes amd64
USB install images bootable again.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/distrib/amd64/installimage/Makefile
cvs rdiff -u -r1.1 -r1.2 src/distrib/amd64/installimage/installimage.mk
cvs rdiff -u -r1.6 -r1.7 src/distrib/amd64/installimage-bios/Makefile

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

Modified files:

Index: src/distrib/amd64/installimage/Makefile
diff -u src/distrib/amd64/installimage/Makefile:1.22 src/distrib/amd64/installimage/Makefile:1.23
--- src/distrib/amd64/installimage/Makefile:1.22	Sun May  8 08:12:45 2022
+++ src/distrib/amd64/installimage/Makefile	Sun May 22 19:32:41 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.22 2022/05/08 08:12:45 mrg Exp $
+#	$NetBSD: Makefile,v 1.23 2022/05/22 19:32:41 jmcneill Exp $
 
 .include 
 
@@ -14,3 +14,5 @@ EFIBOOT+=		${WORKDIR}/usr/mdec/bootia32.
 USE_MBR=		yes
 USE_GPT=		yes
 USE_GPTMBR=		yes
+
+.include "${NETBSDSRCDIR}/distrib/common/bootimage/Makefile.installimage"

Index: src/distrib/amd64/installimage/installimage.mk
diff -u src/distrib/amd64/installimage/installimage.mk:1.1 src/distrib/amd64/installimage/installimage.mk:1.2
--- src/distrib/amd64/installimage/installimage.mk:1.1	Sun May  8 08:12:45 2022
+++ src/distrib/amd64/installimage/installimage.mk	Sun May 22 19:32:41 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: installimage.mk,v 1.1 2022/05/08 08:12:45 mrg Exp $
+#	$NetBSD: installimage.mk,v 1.2 2022/05/22 19:32:41 jmcneill Exp $
 
 # common code between distrib/amd64/installimage/Makefile and
 # distrib/amd64/installimage-bios/Makefile.
@@ -29,5 +29,3 @@ IMGFILE_EXTRA=\
 	${.CURDIR}/etc.rc		etc/rc\
 	${.CURDIR}/install.sh		.\
 	${.OBJDIR}/boot.cfg		.
-
-.include "${NETBSDSRCDIR}/distrib/common/bootimage/Makefile.installimage"

Index: src/distrib/amd64/installimage-bios/Makefile
diff -u src/distrib/amd64/installimage-bios/Makefile:1.6 src/distrib/amd64/installimage-bios/Makefile:1.7
--- src/distrib/amd64/installimage-bios/Makefile:1.6	Sun May  8 08:12:45 2022
+++ src/distrib/amd64/installimage-bios/Makefile	Sun May 22 19:32:41 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.6 2022/05/08 08:12:45 mrg Exp $
+#	$NetBSD: Makefile,v 1.7 2022/05/22 19:32:41 jmcneill Exp $
 
 .include 
 
@@ -7,3 +7,5 @@ INSTIMGBASE=	NetBSD-${DISTRIBVER}-amd64-
 .include "../installimage/installimage.mk"
 
 USE_MBR=		yes
+
+.include "${NETBSDSRCDIR}/distrib/common/bootimage/Makefile.installimage"



CVS commit: src/distrib/amd64

2022-05-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun May 22 19:32:42 UTC 2022

Modified Files:
src/distrib/amd64/installimage: Makefile installimage.mk
src/distrib/amd64/installimage-bios: Makefile

Log Message:
Restore Makefile.installimage include after variables are set. Makes amd64
USB install images bootable again.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/distrib/amd64/installimage/Makefile
cvs rdiff -u -r1.1 -r1.2 src/distrib/amd64/installimage/installimage.mk
cvs rdiff -u -r1.6 -r1.7 src/distrib/amd64/installimage-bios/Makefile

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



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/display

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 18:41:22 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/display: intel_gmbus.c

Log Message:
i915: Fix bug in gmbus_wait: test status passed, not GMBUS_ACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.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/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.c:1.4 src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.c:1.5
--- src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.c:1.4	Sun Dec 19 12:40:31 2021
+++ src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.c	Sun May 22 18:41:22 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel_gmbus.c,v 1.4 2021/12/19 12:40:31 riastradh Exp $	*/
+/*	$NetBSD: intel_gmbus.c,v 1.5 2022/05/22 18:41:22 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2006 Dave Airlie 
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intel_gmbus.c,v 1.4 2021/12/19 12:40:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_gmbus.c,v 1.5 2022/05/22 18:41:22 riastradh Exp $");
 
 #include 
 #include 
@@ -355,7 +355,7 @@ static int gmbus_wait(struct drm_i915_pr
 
 		ret = 0;
 		while ((gmbus2 = intel_uncore_read_fw(&dev_priv->uncore,
-			GMBUS2)) & GMBUS_ACTIVE) {
+			GMBUS2)) & status) {
 			if (--timeout == 0) {
 ret = -ETIMEDOUT;
 break;
@@ -369,7 +369,7 @@ static int gmbus_wait(struct drm_i915_pr
 		msecs_to_jiffies_timeout(10),
 		(((gmbus2 = intel_uncore_read_fw(&dev_priv->uncore,
 GMBUS2))
-			& GMBUS_ACTIVE)
+			& status)
 			== 0));
 		/*
 		 * After DRM_SPIN_TIMED_WAIT_NOINTR_UNTIL, ret<0 on



CVS commit: src/sys/external/bsd/drm2/dist/drm/i915/display

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 18:41:22 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915/display: intel_gmbus.c

Log Message:
i915: Fix bug in gmbus_wait: test status passed, not GMBUS_ACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/i915/display/intel_gmbus.c

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



CVS commit: src/sys/external/bsd/drm2/linux

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 18:41:14 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/linux: linux_i2c.c

Log Message:
linux: Repeat i2c transfer if driver fails with EAGAIN.

The Intel GMBUS (graphics management bus, i2c controller) relies on
this now to fall back from interrupt-driven xfers to bit-banging.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/external/bsd/drm2/linux/linux_i2c.c

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



CVS commit: src/sys/external/bsd/drm2/linux

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 18:41:14 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/linux: linux_i2c.c

Log Message:
linux: Repeat i2c transfer if driver fails with EAGAIN.

The Intel GMBUS (graphics management bus, i2c controller) relies on
this now to fall back from interrupt-driven xfers to bit-banging.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/external/bsd/drm2/linux/linux_i2c.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/external/bsd/drm2/linux/linux_i2c.c
diff -u src/sys/external/bsd/drm2/linux/linux_i2c.c:1.6 src/sys/external/bsd/drm2/linux/linux_i2c.c:1.7
--- src/sys/external/bsd/drm2/linux/linux_i2c.c:1.6	Sun Dec 19 11:49:12 2021
+++ src/sys/external/bsd/drm2/linux/linux_i2c.c	Sun May 22 18:41:14 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_i2c.c,v 1.6 2021/12/19 11:49:12 riastradh Exp $	*/
+/*	$NetBSD: linux_i2c.c,v 1.7 2022/05/22 18:41:14 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_i2c.c,v 1.6 2021/12/19 11:49:12 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_i2c.c,v 1.7 2022/05/22 18:41:14 riastradh Exp $");
 
 #include 
 #include 
@@ -127,8 +127,18 @@ i2c_master_recv(const struct i2c_client 
 int
 __i2c_transfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int n)
 {
+	unsigned timeout = hz;	/* XXX adapter->timeout */
+	unsigned start = getticks();
+	int ret, nretries = 0;
+
+	do {
+		ret = (*adapter->algo->master_xfer)(adapter, msgs, n);
+		if (ret != -EAGAIN)
+			break;
+	} while (nretries++ < adapter->retries &&
+	getticks() - start < timeout);
 
-	return (*adapter->algo->master_xfer)(adapter, msgs, n);
+	return ret;
 }
 
 int



CVS commit: src

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 17:55:09 UTC 2022

Modified Files:
src/distrib/sets/lists/tests: mi
src/etc/mtree: NetBSD.dist.tests
src/tests/usr.bin: Makefile
Added Files:
src/tests/usr.bin/compress: Makefile t_pr_19722.sh

Log Message:
tests/compress: demonstrate truncation of target file

Reported by Giorgos Keramidas in PR#19722.


To generate a diff of this commit:
cvs rdiff -u -r1.1205 -r1.1206 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.191 -r1.192 src/etc/mtree/NetBSD.dist.tests
cvs rdiff -u -r1.35 -r1.36 src/tests/usr.bin/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/compress/Makefile \
src/tests/usr.bin/compress/t_pr_19722.sh

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1205 src/distrib/sets/lists/tests/mi:1.1206
--- src/distrib/sets/lists/tests/mi:1.1205	Thu May 12 20:49:21 2022
+++ src/distrib/sets/lists/tests/mi	Sun May 22 17:55:08 2022
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1205 2022/05/12 20:49:21 rillig Exp $
+# $NetBSD: mi,v 1.1206 2022/05/22 17:55:08 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4629,6 +4629,9 @@
 ./usr/tests/usr.bin/col/rlf2.in	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/col/rlf3.in	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/col/t_col	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/compresstests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/compress/Atffile			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/compress/t_pr_19722			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/configtests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/config/Atffile			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/config/Kyuafile			tests-usr.bin-tests	compattestfile,atf,kyua

Index: src/etc/mtree/NetBSD.dist.tests
diff -u src/etc/mtree/NetBSD.dist.tests:1.191 src/etc/mtree/NetBSD.dist.tests:1.192
--- src/etc/mtree/NetBSD.dist.tests:1.191	Fri Apr 29 22:17:50 2022
+++ src/etc/mtree/NetBSD.dist.tests	Sun May 22 17:55:08 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: NetBSD.dist.tests,v 1.191 2022/04/29 22:17:50 pgoyette Exp $
+#	$NetBSD: NetBSD.dist.tests,v 1.192 2022/05/22 17:55:08 rillig Exp $
 
 ./usr/libdata/debug/usr/tests
 ./usr/libdata/debug/usr/tests/atf
@@ -429,6 +429,7 @@
 ./usr/tests/usr.bin/config/support/arch/regress/conf
 ./usr/tests/usr.bin/config/support/conf
 ./usr/tests/usr.bin/cpio
+./usr/tests/usr.bin/compress
 ./usr/tests/usr.bin/cut
 ./usr/tests/usr.bin/diff
 ./usr/tests/usr.bin/dirname

Index: src/tests/usr.bin/Makefile
diff -u src/tests/usr.bin/Makefile:1.35 src/tests/usr.bin/Makefile:1.36
--- src/tests/usr.bin/Makefile:1.35	Tue Oct 12 17:24:36 2021
+++ src/tests/usr.bin/Makefile	Sun May 22 17:55:08 2022
@@ -1,11 +1,11 @@
-#	$NetBSD: Makefile,v 1.35 2021/10/12 17:24:36 nia Exp $
+#	$NetBSD: Makefile,v 1.36 2022/05/22 17:55:08 rillig Exp $
 #
 
 .include 
 
 TESTSDIR=   ${TESTSBASE}/usr.bin
 
-TESTS_SUBDIRS=	awk basename bzip2 cc cmp config cpio col cut \
+TESTS_SUBDIRS=	awk basename bzip2 cc cmp compress config cpio col cut \
 		diff dirname find fstat gdb grep gzip id indent \
 		infocmp jot ld locale m4 make mixerctl mkdep nbperf \
 		netpgpverify patch pkill pr printf pwhash rump_server \

Added files:

Index: src/tests/usr.bin/compress/Makefile
diff -u /dev/null src/tests/usr.bin/compress/Makefile:1.1
--- /dev/null	Sun May 22 17:55:09 2022
+++ src/tests/usr.bin/compress/Makefile	Sun May 22 17:55:08 2022
@@ -0,0 +1,7 @@
+#	$NetBSD: Makefile,v 1.1 2022/05/22 17:55:08 rillig Exp $
+
+TESTSDIR=	${TESTSBASE}/usr.bin/compress
+
+TESTS_SH=	t_pr_19722
+
+.include 
Index: src/tests/usr.bin/compress/t_pr_19722.sh
diff -u /dev/null src/tests/usr.bin/compress/t_pr_19722.sh:1.1
--- /dev/null	Sun May 22 17:55:09 2022
+++ src/tests/usr.bin/compress/t_pr_19722.sh	Sun May 22 17:55:08 2022
@@ -0,0 +1,89 @@
+#	$NetBSD: t_pr_19722.sh,v 1.1 2022/05/22 17:55:08 rillig Exp $
+#
+# Copyright (c) 2022 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#notice, this list of conditions and the following disclaimer in the
+#documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# P

CVS commit: src

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 17:55:09 UTC 2022

Modified Files:
src/distrib/sets/lists/tests: mi
src/etc/mtree: NetBSD.dist.tests
src/tests/usr.bin: Makefile
Added Files:
src/tests/usr.bin/compress: Makefile t_pr_19722.sh

Log Message:
tests/compress: demonstrate truncation of target file

Reported by Giorgos Keramidas in PR#19722.


To generate a diff of this commit:
cvs rdiff -u -r1.1205 -r1.1206 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.191 -r1.192 src/etc/mtree/NetBSD.dist.tests
cvs rdiff -u -r1.35 -r1.36 src/tests/usr.bin/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/compress/Makefile \
src/tests/usr.bin/compress/t_pr_19722.sh

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



CVS commit: src

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 13:58:59 UTC 2022

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_206.c msg_206.exp
src/usr.bin/xlint/lint1: func.c

Log Message:
lint: fix wrong warning about unhandled enum constants in switch


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_206.c \
src/tests/usr.bin/xlint/lint1/msg_206.exp
cvs rdiff -u -r1.136 -r1.137 src/usr.bin/xlint/lint1/func.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_206.c
diff -u src/tests/usr.bin/xlint/lint1/msg_206.c:1.5 src/tests/usr.bin/xlint/lint1/msg_206.c:1.6
--- src/tests/usr.bin/xlint/lint1/msg_206.c:1.5	Sun May 22 13:53:39 2022
+++ src/tests/usr.bin/xlint/lint1/msg_206.c	Sun May 22 13:58:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_206.c,v 1.5 2022/05/22 13:53:39 rillig Exp $	*/
+/*	$NetBSD: msg_206.c,v 1.6 2022/05/22 13:58:59 rillig Exp $	*/
 # 3 "msg_206.c"
 
 // Test for message: enumeration value(s) not handled in switch [206]
@@ -40,7 +40,11 @@ too_many(enum number num)
 	case 3:
 		return -1;
 	}
-	/* FIXME: There are _too many_ branches, not _too few_. */
-	/* expect-2: warning: enumeration value(s) not handled in switch [206] */
+	/*
+	 * Before func.c 1.137 from 2022-05-22, lint complained that there
+	 * were enum constants not handled in switch, even though all of them
+	 * are handled.  The code smell in this case is that there are _too
+	 * many_ branches that cover "impossible" values.
+	 */
 	return 3;
 }
Index: src/tests/usr.bin/xlint/lint1/msg_206.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_206.exp:1.5 src/tests/usr.bin/xlint/lint1/msg_206.exp:1.6
--- src/tests/usr.bin/xlint/lint1/msg_206.exp:1.5	Sun May 22 13:53:39 2022
+++ src/tests/usr.bin/xlint/lint1/msg_206.exp	Sun May 22 13:58:59 2022
@@ -1,2 +1 @@
 msg_206.c(19): warning: enumeration value(s) not handled in switch [206]
-msg_206.c(42): warning: enumeration value(s) not handled in switch [206]

Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.136 src/usr.bin/xlint/lint1/func.c:1.137
--- src/usr.bin/xlint/lint1/func.c:1.136	Fri May 20 21:18:55 2022
+++ src/usr.bin/xlint/lint1/func.c	Sun May 22 13:58:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: func.c,v 1.136 2022/05/20 21:18:55 rillig Exp $	*/
+/*	$NetBSD: func.c,v 1.137 2022/05/22 13:58:59 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: func.c,v 1.136 2022/05/20 21:18:55 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.137 2022/05/22 13:58:59 rillig Exp $");
 #endif
 
 #include 
@@ -760,7 +760,7 @@ switch2(void)
 		}
 		for (cl = cstmt->c_case_labels; cl != NULL; cl = cl->cl_next)
 			nclab++;
-		if (hflag && eflag && nenum != nclab && !cstmt->c_default) {
+		if (hflag && eflag && nclab < nenum && !cstmt->c_default) {
 			/* enumeration value(s) not handled in switch */
 			warning(206);
 		}



CVS commit: src

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 13:58:59 UTC 2022

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_206.c msg_206.exp
src/usr.bin/xlint/lint1: func.c

Log Message:
lint: fix wrong warning about unhandled enum constants in switch


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_206.c \
src/tests/usr.bin/xlint/lint1/msg_206.exp
cvs rdiff -u -r1.136 -r1.137 src/usr.bin/xlint/lint1/func.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

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 13:53:39 UTC 2022

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

Log Message:
tests/lint: demonstrate wrong warning for switch on enum


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_206.c \
src/tests/usr.bin/xlint/lint1/msg_206.exp

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_206.c
diff -u src/tests/usr.bin/xlint/lint1/msg_206.c:1.4 src/tests/usr.bin/xlint/lint1/msg_206.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_206.c:1.4	Thu Jul  8 18:53:57 2021
+++ src/tests/usr.bin/xlint/lint1/msg_206.c	Sun May 22 13:53:39 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_206.c,v 1.4 2021/07/08 18:53:57 rillig Exp $	*/
+/*	$NetBSD: msg_206.c,v 1.5 2022/05/22 13:53:39 rillig Exp $	*/
 # 3 "msg_206.c"
 
 // Test for message: enumeration value(s) not handled in switch [206]
@@ -26,3 +26,21 @@ test(enum number num)
 		break;
 	}
 }
+
+int
+too_many(enum number num)
+{
+	switch (num) {
+	case ONE:
+		return 1;
+	case TWO:
+		return 2;
+	case THREE:
+		return 3;
+	case 3:
+		return -1;
+	}
+	/* FIXME: There are _too many_ branches, not _too few_. */
+	/* expect-2: warning: enumeration value(s) not handled in switch [206] */
+	return 3;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_206.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_206.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_206.exp:1.5
--- src/tests/usr.bin/xlint/lint1/msg_206.exp:1.4	Thu Jul  8 18:53:57 2021
+++ src/tests/usr.bin/xlint/lint1/msg_206.exp	Sun May 22 13:53:39 2022
@@ -1 +1,2 @@
 msg_206.c(19): warning: enumeration value(s) not handled in switch [206]
+msg_206.c(42): warning: enumeration value(s) not handled in switch [206]



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

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 13:53:39 UTC 2022

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

Log Message:
tests/lint: demonstrate wrong warning for switch on enum


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_206.c \
src/tests/usr.bin/xlint/lint1/msg_206.exp

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



CVS commit: src/games/gomoku

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 13:38:08 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c

Log Message:
gomoku: add mouse support

NetBSD 10 provides the mouse handling functions from  but does
not actually implement the mouse handling.  For the benefit of other
platforms, add mouse support; when linked with ncurses instead of
curses, it works.

Depending on the input device, mouse clicks are either reported as
"button 1 clicked" (mouse) or "button 1 pressed/released" (touchpad);
support both.

Be strict about the X coordinate when clicking.  Since the coordinates
are integer numbers, getting the location between two spots is
ambiguous, as it could be just one pixel away or right in the middle of
the space between the spots.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/games/gomoku/bdisp.c

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

Modified files:

Index: src/games/gomoku/bdisp.c
diff -u src/games/gomoku/bdisp.c:1.45 src/games/gomoku/bdisp.c:1.46
--- src/games/gomoku/bdisp.c:1.45	Sun May 22 12:42:54 2022
+++ src/games/gomoku/bdisp.c	Sun May 22 13:38:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdisp.c,v 1.45 2022/05/22 12:42:54 rillig Exp $	*/
+/*	$NetBSD: bdisp.c,v 1.46 2022/05/22 13:38:08 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -34,7 +34,7 @@
 
 #include 
 /*	@(#)bdisp.c	8.2 (Berkeley) 5/3/95	*/
-__RCSID("$NetBSD: bdisp.c,v 1.45 2022/05/22 12:42:54 rillig Exp $");
+__RCSID("$NetBSD: bdisp.c,v 1.46 2022/05/22 13:38:08 rillig Exp $");
 
 #include 
 #include 
@@ -73,9 +73,7 @@ cursinit(void)
 	cbreak();
 	leaveok(stdscr, false);
 
-#if 0 /* no mouse support in netbsd curses yet */
 	mousemask(BUTTON1_CLICKED, NULL);
-#endif
 }
 
 /*
@@ -323,6 +321,23 @@ get_line(char *buf, int size, void (*on_
 	return c != EOF;
 }
 
+static bool
+get_coord_mouse(int *x, int *y)
+{
+	MEVENT ev;
+
+	if (getmouse(&ev) == OK &&
+	(ev.bstate & (BUTTON1_RELEASED | BUTTON1_CLICKED)) != 0 &&
+	ev.y >= scr_y(BSZ) && ev.y <= scr_y(1) &&
+	ev.x >= scr_x(1) && ev.x <= scr_x(BSZ) &&
+	(ev.x - scr_x(1)) % (scr_x(2) - scr_x(1)) == 0) {
+		*x = 1 + (ev.x - scr_x(1)) / (scr_x(2) - scr_x(1));
+		*y = 1 + (scr_y(1) - ev.y) / (scr_y(1) - scr_y(2));
+		return true;
+	}
+	return false;
+}
+
 /*
  * Ask the user for the coordinate of a move, or return RESIGN or SAVE.
  *
@@ -419,25 +434,11 @@ get_coord(void)
 			(void)clearok(stdscr, true);
 			(void)refresh();
 			break;
-#if 0 /* notyet */
 		case KEY_MOUSE:
-		{
-			MEVENT	myevent;
-
-			getmouse(&myevent);
-			/* XXX: 'y <= BSZ + 1' should probably be '<'. */
-			/* TODO: use scr_x and scr_y. */
-			if (myevent.y >= 1 && myevent.y <= BSZ + 1 &&
-			myevent.x >= 3 && myevent.x <= 2 * BSZ + 1) {
-curx0 = (myevent.x - 3) / 2;
-cury0 = BSZ - myevent.y;
-return PT(curx0,cury0);
-			} else {
-beep();
-			}
-		}
-		break;
-#endif
+			if (get_coord_mouse(&x, &y))
+return PT(x, y);
+			beep();
+			break;
 		case 'Q':
 		case 'q':
 			return RESIGN;



CVS commit: src/games/gomoku

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 13:38:08 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c

Log Message:
gomoku: add mouse support

NetBSD 10 provides the mouse handling functions from  but does
not actually implement the mouse handling.  For the benefit of other
platforms, add mouse support; when linked with ncurses instead of
curses, it works.

Depending on the input device, mouse clicks are either reported as
"button 1 clicked" (mouse) or "button 1 pressed/released" (touchpad);
support both.

Be strict about the X coordinate when clicking.  Since the coordinates
are integer numbers, getting the location between two spots is
ambiguous, as it could be just one pixel away or right in the middle of
the space between the spots.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/games/gomoku/bdisp.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/macppc/conf

2022-05-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun May 22 13:20:44 UTC 2022

Modified Files:
src/sys/arch/macppc/conf: POWERMAC_G5 POWERMAC_G5_11_2

Log Message:
Sync pseudo devs crypto and swcrypto with GENERIC


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/macppc/conf/POWERMAC_G5
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/macppc/conf/POWERMAC_G5_11_2

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/macppc/conf/POWERMAC_G5
diff -u src/sys/arch/macppc/conf/POWERMAC_G5:1.51 src/sys/arch/macppc/conf/POWERMAC_G5:1.52
--- src/sys/arch/macppc/conf/POWERMAC_G5:1.51	Tue Feb 22 17:03:48 2022
+++ src/sys/arch/macppc/conf/POWERMAC_G5	Sun May 22 13:20:44 2022
@@ -226,8 +226,8 @@ sd*	at atapibus? drive ? flags 0x	# 
 uk*	at atapibus? drive ? flags 0x	# ATAPI unknown
 
 
-#pseudo-device 	crypto			# opencrypto framework
-	# (disabled, requires generic softints)
+pseudo-device 	crypto			# /dev/crypto device
+pseudo-device	swcrypto		# software crypto implementation
 pseudo-device	vnd			# disk-like interface to files
 #pseudo-device	md			# memory disk device
 pseudo-device	loop			# network loopback

Index: src/sys/arch/macppc/conf/POWERMAC_G5_11_2
diff -u src/sys/arch/macppc/conf/POWERMAC_G5_11_2:1.20 src/sys/arch/macppc/conf/POWERMAC_G5_11_2:1.21
--- src/sys/arch/macppc/conf/POWERMAC_G5_11_2:1.20	Tue Jul  7 02:39:59 2020
+++ src/sys/arch/macppc/conf/POWERMAC_G5_11_2	Sun May 22 13:20:44 2022
@@ -182,8 +182,8 @@ cd*	at atapibus? drive ? flags 0x	# 
 sd*	at atapibus? drive ? flags 0x	# ATAPI disk drives
 uk*	at atapibus? drive ? flags 0x	# ATAPI unknown
 
-#pseudo-device 	crypto			# opencrypto framework
-	# (disabled, requires generic softints)
+pseudo-device 	crypto			# /dev/crypto device
+pseudo-device	swcrypto		# software crypto implementation
 pseudo-device	vnd		4	# disk-like interface to files
 pseudo-device	md			# memory disk device
 pseudo-device	loop			# network loopback



CVS commit: src/sys/arch/macppc/conf

2022-05-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun May 22 13:20:44 UTC 2022

Modified Files:
src/sys/arch/macppc/conf: POWERMAC_G5 POWERMAC_G5_11_2

Log Message:
Sync pseudo devs crypto and swcrypto with GENERIC


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/macppc/conf/POWERMAC_G5
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/macppc/conf/POWERMAC_G5_11_2

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



CVS commit: src/games/gomoku

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 12:42:54 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c

Log Message:
gomoku: clean up coordinate calculations in get_coord

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/games/gomoku/bdisp.c

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



CVS commit: src/games/gomoku

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 12:42:54 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c

Log Message:
gomoku: clean up coordinate calculations in get_coord

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/games/gomoku/bdisp.c

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

Modified files:

Index: src/games/gomoku/bdisp.c
diff -u src/games/gomoku/bdisp.c:1.44 src/games/gomoku/bdisp.c:1.45
--- src/games/gomoku/bdisp.c:1.44	Sun May 22 12:30:05 2022
+++ src/games/gomoku/bdisp.c	Sun May 22 12:42:54 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdisp.c,v 1.44 2022/05/22 12:30:05 rillig Exp $	*/
+/*	$NetBSD: bdisp.c,v 1.45 2022/05/22 12:42:54 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -34,7 +34,7 @@
 
 #include 
 /*	@(#)bdisp.c	8.2 (Berkeley) 5/3/95	*/
-__RCSID("$NetBSD: bdisp.c,v 1.44 2022/05/22 12:30:05 rillig Exp $");
+__RCSID("$NetBSD: bdisp.c,v 1.45 2022/05/22 12:42:54 rillig Exp $");
 
 #include 
 #include 
@@ -332,103 +332,90 @@ get_line(char *buf, int size, void (*on_
 int
 get_coord(void)
 {
-	static int curx = BSZ / 2;
-	static int cury = BSZ / 2;
-	int nx, ny, ch;
+	static int x = 1 + (BSZ - 1) / 2;
+	static int y = 1 + (BSZ - 1) / 2;
 
-	move(scr_y(cury), scr_x(curx));
+	move(scr_y(y), scr_x(x));
 	refresh();
-	nx = curx;
-	ny = cury;
 	for (;;) {
-		mvprintw(BSZ + 3, 6, "(%c %d) ", letters[curx], cury);
-		move(scr_y(cury), scr_x(curx));
+		mvprintw(BSZ + 3, 6, "(%c %d) ", letters[x], y);
+		move(scr_y(y), scr_x(x));
 
-		ch = getch();
+		int ch = getch();
 		switch (ch) {
 		case 'k':
 		case '8':
 		case KEY_UP:
-			nx = curx;
-			ny = cury + 1;
+			y++;
 			break;
 		case 'j':
 		case '2':
 		case KEY_DOWN:
-			nx = curx;
-			ny = cury + BSZ - 1;
+			y--;
 			break;
 		case 'h':
 		case '4':
 		case KEY_LEFT:
-			nx = curx + BSZ - 1;
-			ny = cury;
+			x--;
 			break;
 		case 'l':
 		case '6':
 		case KEY_RIGHT:
-			nx = curx + 1;
-			ny = cury;
+			x++;
 			break;
 		case 'y':
 		case '7':
 		case KEY_A1:
-			nx = curx + BSZ - 1;
-			ny = cury + 1;
+			x--;
+			y++;
 			break;
 		case 'b':
 		case '1':
 		case KEY_C1:
-			nx = curx + BSZ - 1;
-			ny = cury + BSZ - 1;
+			x--;
+			y--;
 			break;
 		case 'u':
 		case '9':
 		case KEY_A3:
-			nx = curx + 1;
-			ny = cury + 1;
+			x++;
+			y++;
 			break;
 		case 'n':
 		case '3':
 		case KEY_C3:
-			nx = curx + 1;
-			ny = cury + BSZ - 1;
+			x++;
+			y--;
 			break;
 		case 'K':
-			nx = curx;
-			ny = cury + 5;
+			y += 5;
 			break;
 		case 'J':
-			nx = curx;
-			ny = cury + BSZ - 5;
+			y -= 5;
 			break;
 		case 'H':
-			nx = curx + BSZ - 5;
-			ny = cury;
+			x -= 5;
 			break;
 		case 'L':
-			nx = curx + 5;
-			ny = cury;
+			x += 5;
 			break;
 		case 'Y':
-			nx = curx + BSZ - 5;
-			ny = cury + 5;
+			x -= 5;
+			y += 5;
 			break;
 		case 'B':
-			nx = curx + BSZ - 5;
-			ny = cury + BSZ - 5;
+			x -= 5;
+			y -= 5;
 			break;
 		case 'U':
-			nx = curx + 5;
-			ny = cury + 5;
+			x += 5;
+			y += 5;
 			break;
 		case 'N':
-			nx = curx + 5;
-			ny = cury + BSZ - 5;
+			x += 5;
+			y -= 5;
 			break;
 		case 0x0c:	/* ^L */
-			nx = curx;
-			ny = cury;
 			(void)clearok(stdscr, true);
 			(void)refresh();
 			break;
@@ -460,10 +447,10 @@ get_coord(void)
 		case ' ':
 		case '\r':
 			(void)mvhline(BSZ + 3, 6, ' ', 6);
-			return PT(curx, cury);
+			return PT(x, y);
 		}
 
-		curx = 1 + (nx - 1) % BSZ;
-		cury = 1 + (ny - 1) % BSZ;
+		x = 1 + (x + BSZ - 1) % BSZ;
+		y = 1 + (y + BSZ - 1) % BSZ;
 	}
 }



CVS commit: src/games/gomoku

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 12:30:05 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c

Log Message:
gomoku: make coordinates in get_coord 1-based

The rest of the game has 1-based coordinates as well.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/games/gomoku/bdisp.c

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



CVS commit: src/games/gomoku

2022-05-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 22 12:30:05 UTC 2022

Modified Files:
src/games/gomoku: bdisp.c

Log Message:
gomoku: make coordinates in get_coord 1-based

The rest of the game has 1-based coordinates as well.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/games/gomoku/bdisp.c

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

Modified files:

Index: src/games/gomoku/bdisp.c
diff -u src/games/gomoku/bdisp.c:1.43 src/games/gomoku/bdisp.c:1.44
--- src/games/gomoku/bdisp.c:1.43	Sun May 22 08:12:15 2022
+++ src/games/gomoku/bdisp.c	Sun May 22 12:30:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdisp.c,v 1.43 2022/05/22 08:12:15 rillig Exp $	*/
+/*	$NetBSD: bdisp.c,v 1.44 2022/05/22 12:30:05 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -34,7 +34,7 @@
 
 #include 
 /*	@(#)bdisp.c	8.2 (Berkeley) 5/3/95	*/
-__RCSID("$NetBSD: bdisp.c,v 1.43 2022/05/22 08:12:15 rillig Exp $");
+__RCSID("$NetBSD: bdisp.c,v 1.44 2022/05/22 12:30:05 rillig Exp $");
 
 #include 
 #include 
@@ -332,19 +332,17 @@ get_line(char *buf, int size, void (*on_
 int
 get_coord(void)
 {
-	/* XXX: These coordinates are 0-based, all others are 1-based. */
 	static int curx = BSZ / 2;
 	static int cury = BSZ / 2;
-	int ny, nx, ch;
+	int nx, ny, ch;
 
-	move(scr_y(cury + 1), scr_x(curx + 1));
+	move(scr_y(cury), scr_x(curx));
 	refresh();
 	nx = curx;
 	ny = cury;
 	for (;;) {
-		mvprintw(BSZ + 3, 6, "(%c %d) ",
-		letters[curx + 1], cury + 1);
-		move(scr_y(cury + 1), scr_x(curx + 1));
+		mvprintw(BSZ + 3, 6, "(%c %d) ", letters[curx], cury);
+		move(scr_y(cury), scr_x(curx));
 
 		ch = getch();
 		switch (ch) {
@@ -358,12 +356,12 @@ get_coord(void)
 		case '2':
 		case KEY_DOWN:
 			nx = curx;
-			ny = BSZ + cury - 1;
+			ny = cury + BSZ - 1;
 			break;
 		case 'h':
 		case '4':
 		case KEY_LEFT:
-			nx = BSZ + curx - 1;
+			nx = curx + BSZ - 1;
 			ny = cury;
 			break;
 		case 'l':
@@ -375,14 +373,14 @@ get_coord(void)
 		case 'y':
 		case '7':
 		case KEY_A1:
-			nx = BSZ + curx - 1;
+			nx = curx + BSZ - 1;
 			ny = cury + 1;
 			break;
 		case 'b':
 		case '1':
 		case KEY_C1:
-			nx = BSZ + curx - 1;
-			ny = BSZ + cury - 1;
+			nx = curx + BSZ - 1;
+			ny = cury + BSZ - 1;
 			break;
 		case 'u':
 		case '9':
@@ -394,7 +392,7 @@ get_coord(void)
 		case '3':
 		case KEY_C3:
 			nx = curx + 1;
-			ny = BSZ + cury - 1;
+			ny = cury + BSZ - 1;
 			break;
 		case 'K':
 			nx = curx;
@@ -402,10 +400,10 @@ get_coord(void)
 			break;
 		case 'J':
 			nx = curx;
-			ny = BSZ + cury - 5;
+			ny = cury + BSZ - 5;
 			break;
 		case 'H':
-			nx = BSZ + curx - 5;
+			nx = curx + BSZ - 5;
 			ny = cury;
 			break;
 		case 'L':
@@ -413,12 +411,12 @@ get_coord(void)
 			ny = cury;
 			break;
 		case 'Y':
-			nx = BSZ + curx - 5;
+			nx = curx + BSZ - 5;
 			ny = cury + 5;
 			break;
 		case 'B':
-			nx = BSZ + curx - 5;
-			ny = BSZ + cury - 5;
+			nx = curx + BSZ - 5;
+			ny = cury + BSZ - 5;
 			break;
 		case 'U':
 			nx = curx + 5;
@@ -426,9 +424,9 @@ get_coord(void)
 			break;
 		case 'N':
 			nx = curx + 5;
-			ny = BSZ + cury - 5;
+			ny = cury + BSZ - 5;
 			break;
-		case '\f':
+		case 0x0c:	/* ^L */
 			nx = curx;
 			ny = cury;
 			(void)clearok(stdscr, true);
@@ -440,17 +438,19 @@ get_coord(void)
 			MEVENT	myevent;
 
 			getmouse(&myevent);
+			/* XXX: 'y <= BSZ + 1' should probably be '<'. */
+			/* TODO: use scr_x and scr_y. */
 			if (myevent.y >= 1 && myevent.y <= BSZ + 1 &&
 			myevent.x >= 3 && myevent.x <= 2 * BSZ + 1) {
-curx = (myevent.x - 3) / 2;
-cury = BSZ - myevent.y;
-return PT(curx,cury);
+curx0 = (myevent.x - 3) / 2;
+cury0 = BSZ - myevent.y;
+return PT(curx0,cury0);
 			} else {
 beep();
 			}
 		}
 		break;
-#endif /* 0 */
+#endif
 		case 'Q':
 		case 'q':
 			return RESIGN;
@@ -459,11 +459,11 @@ get_coord(void)
 			return SAVE;
 		case ' ':
 		case '\r':
-			(void)mvaddstr(BSZ + 3, 6, "  ");
-			return PT(curx + 1, cury + 1);
+			(void)mvhline(BSZ + 3, 6, ' ', 6);
+			return PT(curx, cury);
 		}
 
-		curx = nx % BSZ;
-		cury = ny % BSZ;
+		curx = 1 + (nx - 1) % BSZ;
+		cury = 1 + (ny - 1) % BSZ;
 	}
 }



CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:40:54 UTC 2022

Modified Files:
src/sys/opencrypto: crypto.c

Log Message:
opencrypto: Assert session id is valid in crypto_freesession.

This gives us the opportunity to detect usage mistakes like
use-after-free.

Exception: Continue to silently ignore sid=0.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/opencrypto/crypto.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/opencrypto/crypto.c
diff -u src/sys/opencrypto/crypto.c:1.129 src/sys/opencrypto/crypto.c:1.130
--- src/sys/opencrypto/crypto.c:1.129	Sun May 22 11:40:29 2022
+++ src/sys/opencrypto/crypto.c	Sun May 22 11:40:54 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypto.c,v 1.129 2022/05/22 11:40:29 riastradh Exp $ */
+/*	$NetBSD: crypto.c,v 1.130 2022/05/22 11:40:54 riastradh Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $	*/
 /*	$OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $	*/
 
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.129 2022/05/22 11:40:29 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.130 2022/05/22 11:40:54 riastradh Exp $");
 
 #include 
 #include 
@@ -870,11 +870,10 @@ crypto_freesession(u_int64_t sid)
 
 	/* Determine two IDs. */
 	cap = crypto_checkdriver_lock(CRYPTO_SESID2HID(sid));
-	if (cap == NULL)	/* XXX should assert; need to audit callers */
-		return;
+	KASSERTMSG(cap != NULL, "sid=%"PRIx64, sid);
 
-	if (cap->cc_sessions)
-		(cap->cc_sessions)--;
+	KASSERT(cap->cc_sessions > 0);
+	cap->cc_sessions--;
 
 	/* Call the driver cleanup routine, if available. */
 	if (cap->cc_freesession)



CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:40:54 UTC 2022

Modified Files:
src/sys/opencrypto: crypto.c

Log Message:
opencrypto: Assert session id is valid in crypto_freesession.

This gives us the opportunity to detect usage mistakes like
use-after-free.

Exception: Continue to silently ignore sid=0.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/opencrypto/crypto.c

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



CVS commit: src/share/man/man9

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:40:46 UTC 2022

Modified Files:
src/share/man/man9: opencrypto.9

Log Message:
opencrypto: Touch up man page a little.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/share/man/man9/opencrypto.9

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

Modified files:

Index: src/share/man/man9/opencrypto.9
diff -u src/share/man/man9/opencrypto.9:1.22 src/share/man/man9/opencrypto.9:1.23
--- src/share/man/man9/opencrypto.9:1.22	Sun May 22 11:40:29 2022
+++ src/share/man/man9/opencrypto.9	Sun May 22 11:40:46 2022
@@ -1,5 +1,5 @@
 .\"	$OpenBSD: crypto.9,v 1.25 2003/07/11 13:47:41 jmc Exp $
-.\"	$NetBSD: opencrypto.9,v 1.22 2022/05/22 11:40:29 riastradh Exp $
+.\"	$NetBSD: opencrypto.9,v 1.23 2022/05/22 11:40:46 riastradh Exp $
 .\"
 .\" The author of this man page is Angelos D. Keromytis (ange...@cis.upenn.edu)
 .\"
@@ -276,15 +276,12 @@ buffer for the result (or for re-formatt
 .It Fa crp_callback
 This routine is invoked upon completion of the request, whether
 successful or not.
-It is invoked through the
+It is invoked by the driver through the
 .Fn crypto_done
 routine.
 If the request was not successful, an error code is set in the
 .Fa crp_etype
 field.
-It is the responsibility of the callback routine to set the appropriate
-.Xr spl 9
-level.
 .It Fa crp_etype
 Contains the error type, if any errors were encountered, or zero if
 the request was successfully processed.
@@ -710,13 +707,3 @@ supported.
 Note that 3DES is considered one algorithm (and not three
 instances of DES).
 Thus, 3DES and DES could be mixed in the same request.
-.Pp
-A queue for completed operations should be implemented and processed
-at some software
-.Xr spl 9
-level, to avoid overall system latency issues, and potential kernel
-stack exhaustion while processing a callback.
-.Pp
-When SMP time comes, we will support use of a second processor (or
-more) as a crypto device (this is actually AMP, but we need the same
-basic support).



CVS commit: src/share/man/man9

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:40:46 UTC 2022

Modified Files:
src/share/man/man9: opencrypto.9

Log Message:
opencrypto: Touch up man page a little.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/share/man/man9/opencrypto.9

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



CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:40:38 UTC 2022

Modified Files:
src/sys/opencrypto: cryptodev.c

Log Message:
opencrypto: Prune dead code now that crypto_dispatch never fails.


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/opencrypto/cryptodev.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/opencrypto/cryptodev.c
diff -u src/sys/opencrypto/cryptodev.c:1.123 src/sys/opencrypto/cryptodev.c:1.124
--- src/sys/opencrypto/cryptodev.c:1.123	Sun May 22 11:40:29 2022
+++ src/sys/opencrypto/cryptodev.c	Sun May 22 11:40:38 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: cryptodev.c,v 1.123 2022/05/22 11:40:29 riastradh Exp $ */
+/*	$NetBSD: cryptodev.c,v 1.124 2022/05/22 11:40:38 riastradh Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $	*/
 /*	$OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $	*/
 
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.123 2022/05/22 11:40:29 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.124 2022/05/22 11:40:38 riastradh Exp $");
 
 #include 
 #include 
@@ -1292,30 +1292,8 @@ cryptodev_mop(struct fcrypt *fcr, 
 		crp->crp_reqid = cnop[req].reqid;
 		crp->crp_usropaque = cnop[req].opaque;
 		cv_init(&crp->crp_cv, "crydev");
-#ifdef notyet
-eagain:
-#endif
 		crypto_dispatch(crp);
 		cnop[req].status = 0;
-		mutex_enter(&cryptodev_mtx);	/* XXX why mutex? */
-
-		switch (cnop[req].status) {
-#ifdef notyet	/* don't loop forever -- but EAGAIN not possible here yet */
-		case EAGAIN:
-			mutex_exit(&cryptodev_mtx);
-			goto eagain;
-			break;
-#endif
-		case 0:
-			break;
-		default:
-			DPRINTF("not waiting, error.\n");
-			mutex_exit(&cryptodev_mtx);
-			cv_destroy(&crp->crp_cv);
-			goto bail;
-		}
-
-		mutex_exit(&cryptodev_mtx);
 		cv_destroy(&crp->crp_cv);
 bail:
 		if (cnop[req].status) {



CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:40:38 UTC 2022

Modified Files:
src/sys/opencrypto: cryptodev.c

Log Message:
opencrypto: Prune dead code now that crypto_dispatch never fails.


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/opencrypto/cryptodev.c

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



CVS commit: src

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:40:29 UTC 2022

Modified Files:
src/share/man/man9: opencrypto.9
src/sys/netipsec: xform_ah.c xform_esp.c xform_ipcomp.c
src/sys/opencrypto: crypto.c cryptodev.c cryptodev.h

Log Message:
opencrypto: crypto_dispatch never fails now.  Make it return void.

Same with crypto_kdispatch.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/share/man/man9/opencrypto.9
cvs rdiff -u -r1.113 -r1.114 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.104 -r1.105 src/sys/netipsec/xform_esp.c
cvs rdiff -u -r1.73 -r1.74 src/sys/netipsec/xform_ipcomp.c
cvs rdiff -u -r1.128 -r1.129 src/sys/opencrypto/crypto.c
cvs rdiff -u -r1.122 -r1.123 src/sys/opencrypto/cryptodev.c
cvs rdiff -u -r1.49 -r1.50 src/sys/opencrypto/cryptodev.h

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

Modified files:

Index: src/share/man/man9/opencrypto.9
diff -u src/share/man/man9/opencrypto.9:1.21 src/share/man/man9/opencrypto.9:1.22
--- src/share/man/man9/opencrypto.9:1.21	Sun May 22 11:40:03 2022
+++ src/share/man/man9/opencrypto.9	Sun May 22 11:40:29 2022
@@ -1,5 +1,5 @@
 .\"	$OpenBSD: crypto.9,v 1.25 2003/07/11 13:47:41 jmc Exp $
-.\"	$NetBSD: opencrypto.9,v 1.21 2022/05/22 11:40:03 riastradh Exp $
+.\"	$NetBSD: opencrypto.9,v 1.22 2022/05/22 11:40:29 riastradh Exp $
 .\"
 .\" The author of this man page is Angelos D. Keromytis (ange...@cis.upenn.edu)
 .\"
@@ -57,9 +57,9 @@
 .Fn crypto_newsession "u_int64_t *" "struct cryptoini *" "int"
 .Ft void
 .Fn crypto_freesession "u_int64_t"
-.Ft int
+.Ft void
 .Fn crypto_dispatch "struct cryptop *"
-.Ft int
+.Ft void
 .Fn crypto_kdispatch "struct cryptkop *"
 .Ft struct cryptop *
 .Fn crypto_getreq "int"
@@ -650,14 +650,10 @@ structure and
 .Dv NULL
 on failure.
 .Fn crypto_dispatch
-returns
-.Er EINVAL
-if its argument or the callback function was
-.Dv NULL ,
-and 0 otherwise.
-The callback is provided with an error code in case of failure, in the
+arranges to invoke the callback with an error code
+in the
 .Fa crp_etype
-field.
+field, or zero on success.
 .Sh FILES
 .Bl -tag -width sys/opencrypto/crypto.c
 .It Pa sys/opencrypto/crypto.c

Index: src/sys/netipsec/xform_ah.c
diff -u src/sys/netipsec/xform_ah.c:1.113 src/sys/netipsec/xform_ah.c:1.114
--- src/sys/netipsec/xform_ah.c:1.113	Sun May 22 11:40:03 2022
+++ src/sys/netipsec/xform_ah.c	Sun May 22 11:40:29 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_ah.c,v 1.113 2022/05/22 11:40:03 riastradh Exp $	*/
+/*	$NetBSD: xform_ah.c,v 1.114 2022/05/22 11:40:29 riastradh Exp $	*/
 /*	$FreeBSD: xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */
 /*
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.113 2022/05/22 11:40:03 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.114 2022/05/22 11:40:29 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -691,7 +691,8 @@ ah_input(struct mbuf *m, struct secasvar
 	 crp->crp_ilen, tc->tc_skip,
 	 crda->crd_len, crda->crd_skip, crda->crd_inject);
 
-	return crypto_dispatch(crp);
+	crypto_dispatch(crp);
+	return 0;
 
 bad:
 	if (tc != NULL) {
@@ -1106,7 +1107,8 @@ ah_output(struct mbuf *m, const struct i
 	tc->tc_flags = flags;
 	tc->tc_sav = sav;
 
-	return crypto_dispatch(crp);
+	crypto_dispatch(crp);
+	return 0;
 
 bad_tc:
 	if (__predict_true(pool_used))

Index: src/sys/netipsec/xform_esp.c
diff -u src/sys/netipsec/xform_esp.c:1.104 src/sys/netipsec/xform_esp.c:1.105
--- src/sys/netipsec/xform_esp.c:1.104	Sun May 22 11:40:03 2022
+++ src/sys/netipsec/xform_esp.c	Sun May 22 11:40:29 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_esp.c,v 1.104 2022/05/22 11:40:03 riastradh Exp $	*/
+/*	$NetBSD: xform_esp.c,v 1.105 2022/05/22 11:40:29 riastradh Exp $	*/
 /*	$FreeBSD: xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.104 2022/05/22 11:40:03 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.105 2022/05/22 11:40:29 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -472,7 +472,8 @@ esp_input(struct mbuf *m, struct secasva
 	crde->crd_klen = _KEYBITS(sav->key_enc);
 	/* XXX Rounds ? */
 
-	return crypto_dispatch(crp);
+	crypto_dispatch(crp);
+	return 0;
 
 out2:
 	pool_cache_put(esp_tdb_crypto_pool_cache, tc);
@@ -924,7 +925,8 @@ esp_output(struct mbuf *m, const struct 
 		}
 	}
 
-	return crypto_dispatch(crp);
+	crypto_dispatch(crp);
+	return 0;
 
 bad:
 	if (m)

Index: src/sys/netipsec/xform_ipcomp.c
diff -u src/sys/netipsec/xform_ipcomp.c:1.73 src/sys/netipsec/xform_ipcomp.c:1.74
--- src/sys/netipsec/xform_ipcomp.c:1.73	Sun May 22 11:40:03 2022
+++ src/sys/netipsec/xform_ipcomp.c	Sun May 22 11:40:29 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xf

CVS commit: src

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:40:29 UTC 2022

Modified Files:
src/share/man/man9: opencrypto.9
src/sys/netipsec: xform_ah.c xform_esp.c xform_ipcomp.c
src/sys/opencrypto: crypto.c cryptodev.c cryptodev.h

Log Message:
opencrypto: crypto_dispatch never fails now.  Make it return void.

Same with crypto_kdispatch.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/share/man/man9/opencrypto.9
cvs rdiff -u -r1.113 -r1.114 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.104 -r1.105 src/sys/netipsec/xform_esp.c
cvs rdiff -u -r1.73 -r1.74 src/sys/netipsec/xform_ipcomp.c
cvs rdiff -u -r1.128 -r1.129 src/sys/opencrypto/crypto.c
cvs rdiff -u -r1.122 -r1.123 src/sys/opencrypto/cryptodev.c
cvs rdiff -u -r1.49 -r1.50 src/sys/opencrypto/cryptodev.h

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



CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:40:15 UTC 2022

Modified Files:
src/sys/opencrypto: crypto.c

Log Message:
opencrypto: Assert driver process routine returns 0 or ERESTART.

No other errors are allowed -- other errors must be transmitted by
crypto_done.  All drivers in tree (sun8i_crypto, glxsb, via_padlock,
mvcesa, mvxpsec, hifn, qat, ubsec, cryptosoft) have been audited for
this.


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/sys/opencrypto/crypto.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/opencrypto/crypto.c
diff -u src/sys/opencrypto/crypto.c:1.127 src/sys/opencrypto/crypto.c:1.128
--- src/sys/opencrypto/crypto.c:1.127	Sun May 22 11:40:03 2022
+++ src/sys/opencrypto/crypto.c	Sun May 22 11:40:15 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypto.c,v 1.127 2022/05/22 11:40:03 riastradh Exp $ */
+/*	$NetBSD: crypto.c,v 1.128 2022/05/22 11:40:15 riastradh Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $	*/
 /*	$OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $	*/
 
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.127 2022/05/22 11:40:03 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.128 2022/05/22 11:40:15 riastradh Exp $");
 
 #include 
 #include 
@@ -1318,7 +1318,6 @@ crypto_dispatch(struct cryptop *crp)
 			softint_schedule(crypto_q_si);
 			kpreempt_enable();
 		}
-
 		return 0;
 	}
 
@@ -1336,7 +1335,6 @@ crypto_dispatch(struct cryptop *crp)
 		 * to other drivers in cryptointr() later.
 		 */
 		TAILQ_INSERT_TAIL(crp_q, crp, crp_next);
-		result = 0;
 		goto out;
 	}
 
@@ -1347,7 +1345,6 @@ crypto_dispatch(struct cryptop *crp)
 		 * it unblocks and the swi thread gets kicked.
 		 */
 		TAILQ_INSERT_TAIL(crp_q, crp, crp_next);
-		result = 0;
 		goto out;
 	}
 
@@ -1358,6 +1355,7 @@ crypto_dispatch(struct cryptop *crp)
 	 */
 	crypto_driver_unlock(cap);
 	result = crypto_invoke(crp, 0);
+	KASSERTMSG(result == 0 || result == ERESTART, "result=%d", result);
 	if (result == ERESTART) {
 		/*
 		 * The driver ran out of resources, mark the
@@ -1369,18 +1367,11 @@ crypto_dispatch(struct cryptop *crp)
 		crypto_driver_unlock(cap);
 		TAILQ_INSERT_HEAD(crp_q, crp, crp_next);
 		cryptostats.cs_blocks++;
-
-		/*
-		 * The crp is enqueued to crp_q, that is,
-		 * no error occurs. So, this function should
-		 * not return error.
-		 */
-		result = 0;
 	}
 
 out:
 	crypto_put_crp_qs(&s);
-	return result;
+	return 0;
 }
 
 /*
@@ -1411,7 +1402,6 @@ crypto_kdispatch(struct cryptkop *krp)
 	 */
 	if (cap == NULL) {
 		TAILQ_INSERT_TAIL(crp_kq, krp, krp_next);
-		result = 0;
 		goto out;
 	}
 
@@ -1422,12 +1412,12 @@ crypto_kdispatch(struct cryptkop *krp)
 		 * it unblocks and the swi thread gets kicked.
 		 */
 		TAILQ_INSERT_TAIL(crp_kq, krp, krp_next);
-		result = 0;
 		goto out;
 	}
 
 	crypto_driver_unlock(cap);
 	result = crypto_kinvoke(krp, 0);
+	KASSERTMSG(result == 0 || result == ERESTART, "result=%d", result);
 	if (result == ERESTART) {
 		/*
 		 * The driver ran out of resources, mark the
@@ -1439,18 +1429,11 @@ crypto_kdispatch(struct cryptkop *krp)
 		crypto_driver_unlock(cap);
 		TAILQ_INSERT_HEAD(crp_kq, krp, krp_next);
 		cryptostats.cs_kblocks++;
-
-		/*
-		 * The krp is enqueued to crp_kq, that is,
-		 * no error occurs. So, this function should
-		 * not return error.
-		 */
-		result = 0;
 	}
 
 out:
 	crypto_put_crp_qs(&s);
-	return result;
+	return 0;
 }
 
 /*
@@ -1500,15 +1483,14 @@ crypto_kinvoke(struct cryptkop *krp, int
 		krp->reqcpu = curcpu();
 		crypto_driver_unlock(cap);
 		error = (*process)(arg, krp, hint);
+		KASSERTMSG(error == 0 || error == ERESTART, "error=%d",
+		error);
+		return error;
 	} else {
-		error = ENODEV;
-	}
-
-	if (error) {
-		krp->krp_status = error;
+		krp->krp_status = ENODEV;
 		crypto_kdone(krp);
+		return 0;
 	}
-	return 0;
 }
 
 #ifdef CRYPTO_TIMING
@@ -1542,6 +1524,7 @@ static int
 crypto_invoke(struct cryptop *crp, int hint)
 {
 	struct cryptocap *cap;
+	int error;
 
 	KASSERT(crp != NULL);
 	KASSERT(crp->crp_callback != NULL);
@@ -1567,7 +1550,10 @@ crypto_invoke(struct cryptop *crp, int h
 		 */
 		DPRINTF("calling process for %p\n", crp);
 		crypto_driver_unlock(cap);
-		return (*process)(arg, crp, hint);
+		error = (*process)(arg, crp, hint);
+		KASSERTMSG(error == 0 || error == ERESTART, "error=%d",
+		error);
+		return error;
 	} else {
 		if (cap != NULL) {
 			crypto_driver_unlock(cap);
@@ -1880,6 +1866,8 @@ cryptointr(void *arg __unused)
 		if (submit != NULL) {
 			TAILQ_REMOVE(crp_q, submit, crp_next);
 			result = crypto_invoke(submit, hint);
+			KASSERTMSG(result == 0 || result == ERESTART,
+			"result=%d", result);
 			/* we must take here as the TAILQ op or kinvoke
 			   may need this mutex below.  sigh. */
 			if (result == ERESTART) {
@@ -1924,6 +1912,8 @@ cryptointr(void *ar

CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:40:15 UTC 2022

Modified Files:
src/sys/opencrypto: crypto.c

Log Message:
opencrypto: Assert driver process routine returns 0 or ERESTART.

No other errors are allowed -- other errors must be transmitted by
crypto_done.  All drivers in tree (sun8i_crypto, glxsb, via_padlock,
mvcesa, mvxpsec, hifn, qat, ubsec, cryptosoft) have been audited for
this.


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/sys/opencrypto/crypto.c

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



CVS commit: src

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:40:04 UTC 2022

Modified Files:
src/share/man/man9: opencrypto.9
src/sys/netipsec: xform_ah.c xform_esp.c xform_ipcomp.c
src/sys/opencrypto: crypto.c cryptodev.c cryptodev.h

Log Message:
opencrypto: Rip out EAGAIN logic when unregistering crypto drivers.

I'm pretty sure this never worked reliably based on code inspection,
and it's unlikely to have ever been tested because it only applies
when unregistering a driver -- but we have no crypto drivers for
removable devices, so it would only apply if we went out of our way
to trigger detach with drvctl.

Instead, just make the operation fail with ENODEV, and remove all the
callback logic to resubmit the request on EAGAIN.  (Maybe this should
be ENXIO, but crypto_kdispatch already does ENODEV.)


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/share/man/man9/opencrypto.9
cvs rdiff -u -r1.112 -r1.113 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.103 -r1.104 src/sys/netipsec/xform_esp.c
cvs rdiff -u -r1.72 -r1.73 src/sys/netipsec/xform_ipcomp.c
cvs rdiff -u -r1.126 -r1.127 src/sys/opencrypto/crypto.c
cvs rdiff -u -r1.121 -r1.122 src/sys/opencrypto/cryptodev.c
cvs rdiff -u -r1.48 -r1.49 src/sys/opencrypto/cryptodev.h

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

Modified files:

Index: src/share/man/man9/opencrypto.9
diff -u src/share/man/man9/opencrypto.9:1.20 src/share/man/man9/opencrypto.9:1.21
--- src/share/man/man9/opencrypto.9:1.20	Sun May 22 11:39:37 2022
+++ src/share/man/man9/opencrypto.9	Sun May 22 11:40:03 2022
@@ -1,5 +1,5 @@
 .\"	$OpenBSD: crypto.9,v 1.25 2003/07/11 13:47:41 jmc Exp $
-.\"	$NetBSD: opencrypto.9,v 1.20 2022/05/22 11:39:37 riastradh Exp $
+.\"	$NetBSD: opencrypto.9,v 1.21 2022/05/22 11:40:03 riastradh Exp $
 .\"
 .\" The author of this man page is Angelos D. Keromytis (ange...@cis.upenn.edu)
 .\"
@@ -288,16 +288,6 @@ level.
 .It Fa crp_etype
 Contains the error type, if any errors were encountered, or zero if
 the request was successfully processed.
-If the
-.Er EAGAIN
-error code is returned, the SID has changed (and has been recorded in the
-.Fa crp_sid
-field).
-The consumer should record the new SID and use it in all subsequent requests.
-In this case, the request may be re-submitted immediately.
-This mechanism is used by the framework to perform
-session migration (move a session from one driver to another, because
-of availability, performance, or other considerations).
 .Pp
 Note that this field only makes sense when examined by
 the callback routine specified in

Index: src/sys/netipsec/xform_ah.c
diff -u src/sys/netipsec/xform_ah.c:1.112 src/sys/netipsec/xform_ah.c:1.113
--- src/sys/netipsec/xform_ah.c:1.112	Sun May 22 11:39:37 2022
+++ src/sys/netipsec/xform_ah.c	Sun May 22 11:40:03 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_ah.c,v 1.112 2022/05/22 11:39:37 riastradh Exp $	*/
+/*	$NetBSD: xform_ah.c,v 1.113 2022/05/22 11:40:03 riastradh Exp $	*/
 /*	$FreeBSD: xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */
 /*
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.112 2022/05/22 11:39:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.113 2022/05/22 11:40:03 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -772,12 +772,6 @@ ah_input_cb(struct cryptop *crp)
 		if (sav->tdb_cryptoid != 0)
 			sav->tdb_cryptoid = crp->crp_sid;
 
-		if (crp->crp_etype == EAGAIN) {
-			IPSEC_RELEASE_GLOBAL_LOCKS();
-			(void)crypto_dispatch(crp);
-			return;
-		}
-
 		AH_STATINC(AH_STAT_NOXFORM);
 		DPRINTF("crypto error %d\n", crp->crp_etype);
 		goto bad;
@@ -1162,12 +1156,6 @@ ah_output_cb(struct cryptop *crp)
 		if (sav->tdb_cryptoid != 0)
 			sav->tdb_cryptoid = crp->crp_sid;
 
-		if (crp->crp_etype == EAGAIN) {
-			IPSEC_RELEASE_GLOBAL_LOCKS();
-			(void)crypto_dispatch(crp);
-			return;
-		}
-
 		AH_STATINC(AH_STAT_NOXFORM);
 		DPRINTF("crypto error %d\n", crp->crp_etype);
 		goto bad;

Index: src/sys/netipsec/xform_esp.c
diff -u src/sys/netipsec/xform_esp.c:1.103 src/sys/netipsec/xform_esp.c:1.104
--- src/sys/netipsec/xform_esp.c:1.103	Sun May 22 11:39:08 2022
+++ src/sys/netipsec/xform_esp.c	Sun May 22 11:40:03 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_esp.c,v 1.103 2022/05/22 11:39:08 riastradh Exp $	*/
+/*	$NetBSD: xform_esp.c,v 1.104 2022/05/22 11:40:03 riastradh Exp $	*/
 /*	$FreeBSD: xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.103 2022/05/22 11:39:08 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.104 2022/05/22 11:40:03 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -538,13 +538,6 @@ esp_input_cb(struct cryptop *crp)
 		if 

CVS commit: src

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:40:04 UTC 2022

Modified Files:
src/share/man/man9: opencrypto.9
src/sys/netipsec: xform_ah.c xform_esp.c xform_ipcomp.c
src/sys/opencrypto: crypto.c cryptodev.c cryptodev.h

Log Message:
opencrypto: Rip out EAGAIN logic when unregistering crypto drivers.

I'm pretty sure this never worked reliably based on code inspection,
and it's unlikely to have ever been tested because it only applies
when unregistering a driver -- but we have no crypto drivers for
removable devices, so it would only apply if we went out of our way
to trigger detach with drvctl.

Instead, just make the operation fail with ENODEV, and remove all the
callback logic to resubmit the request on EAGAIN.  (Maybe this should
be ENXIO, but crypto_kdispatch already does ENODEV.)


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/share/man/man9/opencrypto.9
cvs rdiff -u -r1.112 -r1.113 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.103 -r1.104 src/sys/netipsec/xform_esp.c
cvs rdiff -u -r1.72 -r1.73 src/sys/netipsec/xform_ipcomp.c
cvs rdiff -u -r1.126 -r1.127 src/sys/opencrypto/crypto.c
cvs rdiff -u -r1.121 -r1.122 src/sys/opencrypto/cryptodev.c
cvs rdiff -u -r1.48 -r1.49 src/sys/opencrypto/cryptodev.h

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



CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:39:54 UTC 2022

Modified Files:
src/sys/opencrypto: crypto.c

Log Message:
opencrypto: Assert nonnull callback up front in crypto_dispatch.

Same with crypto_kdispatch.

Convert some dead branches downstream to assertions too.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sys/opencrypto/crypto.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/opencrypto/crypto.c
diff -u src/sys/opencrypto/crypto.c:1.125 src/sys/opencrypto/crypto.c:1.126
--- src/sys/opencrypto/crypto.c:1.125	Sun May 22 11:39:37 2022
+++ src/sys/opencrypto/crypto.c	Sun May 22 11:39:54 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypto.c,v 1.125 2022/05/22 11:39:37 riastradh Exp $ */
+/*	$NetBSD: crypto.c,v 1.126 2022/05/22 11:39:54 riastradh Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $	*/
 /*	$OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $	*/
 
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.125 2022/05/22 11:39:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.126 2022/05/22 11:39:54 riastradh Exp $");
 
 #include 
 #include 
@@ -1283,6 +1283,7 @@ crypto_dispatch(struct cryptop *crp)
 	struct crypto_crp_q *crp_q;
 
 	KASSERT(crp != NULL);
+	KASSERT(crp->crp_callback != NULL);
 	KASSERT(crp->crp_desc != NULL);
 	KASSERT(crp->crp_buf != NULL);
 	KASSERT(!cpu_intr_p());
@@ -1395,6 +1396,7 @@ crypto_kdispatch(struct cryptkop *krp)
 	struct crypto_crp_kq *crp_kq;
 
 	KASSERT(krp != NULL);
+	KASSERT(krp->krp_callback != NULL);
 	KASSERT(!cpu_intr_p());
 
 	cryptostats.cs_kops++;
@@ -1462,15 +1464,9 @@ crypto_kinvoke(struct cryptkop *krp, int
 	int error;
 
 	KASSERT(krp != NULL);
+	KASSERT(krp->krp_callback != NULL);
 	KASSERT(!cpu_intr_p());
 
-	/* Sanity checks. */
-	if (krp->krp_callback == NULL) {
-		cv_destroy(&krp->krp_cv);
-		crypto_kfreereq(krp);
-		return EINVAL;
-	}
-
 	mutex_enter(&crypto_drv_mtx);
 	for (hid = 0; hid < crypto_drivers_num; hid++) {
 		cap = crypto_checkdriver(hid);
@@ -1548,21 +1544,14 @@ crypto_invoke(struct cryptop *crp, int h
 	struct cryptocap *cap;
 
 	KASSERT(crp != NULL);
+	KASSERT(crp->crp_callback != NULL);
+	KASSERT(crp->crp_desc != NULL);
 	KASSERT(!cpu_intr_p());
 
 #ifdef CRYPTO_TIMING
 	if (crypto_timing)
 		crypto_tstat(&cryptostats.cs_invoke, &crp->crp_tstamp);
 #endif
-	/* Sanity checks. */
-	if (crp->crp_callback == NULL) {
-		return EINVAL;
-	}
-	if (crp->crp_desc == NULL) {
-		crp->crp_etype = EINVAL;
-		crypto_done(crp);
-		return 0;
-	}
 
 	cap = crypto_checkdriver_lock(CRYPTO_SESID2HID(crp->crp_sid));
 	if (cap != NULL && (cap->cc_flags & CRYPTOCAP_F_CLEANUP) == 0) {



CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:39:54 UTC 2022

Modified Files:
src/sys/opencrypto: crypto.c

Log Message:
opencrypto: Assert nonnull callback up front in crypto_dispatch.

Same with crypto_kdispatch.

Convert some dead branches downstream to assertions too.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sys/opencrypto/crypto.c

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



CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:39:46 UTC 2022

Modified Files:
src/sys/opencrypto: cryptodev.c

Log Message:
crypto(4): Nix dead code now that crypto_freesession never fails.


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/opencrypto/cryptodev.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/opencrypto/cryptodev.c
diff -u src/sys/opencrypto/cryptodev.c:1.120 src/sys/opencrypto/cryptodev.c:1.121
--- src/sys/opencrypto/cryptodev.c:1.120	Sun May 22 11:39:37 2022
+++ src/sys/opencrypto/cryptodev.c	Sun May 22 11:39:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: cryptodev.c,v 1.120 2022/05/22 11:39:37 riastradh Exp $ */
+/*	$NetBSD: cryptodev.c,v 1.121 2022/05/22 11:39:45 riastradh Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $	*/
 /*	$OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $	*/
 
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.120 2022/05/22 11:39:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.121 2022/05/22 11:39:45 riastradh Exp $");
 
 #include 
 #include 
@@ -182,11 +182,11 @@ static struct	csession *csecreate(struct
 u_int64_t, void *, u_int64_t, u_int32_t, u_int32_t, u_int32_t,
 const struct enc_xform *, const struct auth_hash *,
 const struct comp_algo *);
-static int	csefree(struct csession *);
+static void	csefree(struct csession *);
 
 static int	cryptodev_key(struct crypt_kop *);
 static int	cryptodev_mkey(struct fcrypt *, struct crypt_n_kop *, int);
-static int	cryptodev_msessionfin(struct fcrypt *, int, u_int32_t *);
+static void	cryptodev_msessionfin(struct fcrypt *, int, u_int32_t *);
 
 static void	cryptodev_cb(struct cryptop *);
 static void	cryptodevkey_cb(struct cryptkop *);
@@ -317,7 +317,7 @@ mbail:
 		}
 		csedelete(fcr, cse);
 		mutex_exit(&cryptodev_mtx);
-		error = csefree(cse);
+		csefree(cse);
 		break;
 	case CIOCNFSESSION:
 		mutex_enter(&cryptodev_mtx);
@@ -334,7 +334,7 @@ mbail:
 		error = copyin(sfop->sesid, sesid,
 		(sfop->count * sizeof(u_int32_t)));
 		if (!error) {
-			error = cryptodev_msessionfin(fcr, sfop->count, sesid);
+			cryptodev_msessionfin(fcr, sfop->count, sesid);
 		}
 		kmem_free(sesid, (sfop->count * sizeof(u_int32_t)));
 		break;
@@ -922,7 +922,7 @@ cryptof_close(struct file *fp)
 	while ((cse = TAILQ_FIRST(&fcr->csessions))) {
 		TAILQ_REMOVE(&fcr->csessions, cse, next);
 		mutex_exit(&cryptodev_mtx);
-		(void)csefree(cse);
+		csefree(cse);
 		mutex_enter(&cryptodev_mtx);
 	}
 	seldestroy(&fcr->sinfo);
@@ -950,7 +950,7 @@ csefind(struct fcrypt *fcr, u_int ses)
 	TAILQ_FOREACH_SAFE(cse, &fcr->csessions, next, cnext)
 		if (cse->ses == ses)
 			ret = cse;
-	
+
 	return ret;
 }
 
@@ -1014,19 +1014,16 @@ csecreate(struct fcrypt *fcr, u_int64_t 
 	}
 }
 
-static int
+static void
 csefree(struct csession *cse)
 {
-	int error;
 
 	crypto_freesession(cse->sid);
-	error = 0;
 	if (cse->key)
 		free(cse->key, M_XDATA);
 	if (cse->mackey)
 		free(cse->mackey, M_XDATA);
 	pool_put(&csepl, cse);
-	return error;
 }
 
 static int
@@ -1757,11 +1754,11 @@ cryptodev_msession(struct fcrypt *fcr, s
 	return 0;
 }
 
-static int
+static void
 cryptodev_msessionfin(struct fcrypt *fcr, int count, u_int32_t *sesid)
 {
 	struct csession *cse;
-	int req, error = 0;
+	int req;
 
 	mutex_enter(&cryptodev_mtx);
 	for(req = 0; req < count; req++) {
@@ -1770,11 +1767,10 @@ cryptodev_msessionfin(struct fcrypt *fcr
 			continue;
 		csedelete(fcr, cse);
 		mutex_exit(&cryptodev_mtx);
-		error = csefree(cse);
+		csefree(cse);
 		mutex_enter(&cryptodev_mtx);
 	}
 	mutex_exit(&cryptodev_mtx);
-	return error;
 }
 
 /*



CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:39:46 UTC 2022

Modified Files:
src/sys/opencrypto: cryptodev.c

Log Message:
crypto(4): Nix dead code now that crypto_freesession never fails.


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/opencrypto/cryptodev.c

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



CVS commit: src

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:39:37 UTC 2022

Modified Files:
src/share/man/man9: opencrypto.9
src/sys/netipsec: xform_ah.c xform_ipcomp.c
src/sys/opencrypto: crypto.c cryptodev.c cryptodev.h

Log Message:
opencrypto: Make crypto_freesession return void.

No callers use the return value.  It is not sensible to allow this to
fail.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/share/man/man9/opencrypto.9
cvs rdiff -u -r1.111 -r1.112 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.71 -r1.72 src/sys/netipsec/xform_ipcomp.c
cvs rdiff -u -r1.124 -r1.125 src/sys/opencrypto/crypto.c
cvs rdiff -u -r1.119 -r1.120 src/sys/opencrypto/cryptodev.c
cvs rdiff -u -r1.47 -r1.48 src/sys/opencrypto/cryptodev.h

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

Modified files:

Index: src/share/man/man9/opencrypto.9
diff -u src/share/man/man9/opencrypto.9:1.19 src/share/man/man9/opencrypto.9:1.20
--- src/share/man/man9/opencrypto.9:1.19	Sun May 22 11:39:26 2022
+++ src/share/man/man9/opencrypto.9	Sun May 22 11:39:37 2022
@@ -1,5 +1,5 @@
 .\"	$OpenBSD: crypto.9,v 1.25 2003/07/11 13:47:41 jmc Exp $
-.\"	$NetBSD: opencrypto.9,v 1.19 2022/05/22 11:39:26 riastradh Exp $
+.\"	$NetBSD: opencrypto.9,v 1.20 2022/05/22 11:39:37 riastradh Exp $
 .\"
 .\" The author of this man page is Angelos D. Keromytis (ange...@cis.upenn.edu)
 .\"
@@ -55,7 +55,7 @@
 .Fn crypto_kdone "struct cryptkop *"
 .Ft int
 .Fn crypto_newsession "u_int64_t *" "struct cryptoini *" "int"
-.Ft int
+.Ft void
 .Fn crypto_freesession "u_int64_t"
 .Ft int
 .Fn crypto_dispatch "struct cryptop *"
@@ -642,9 +642,8 @@ routine should invoke
 .Fn crypto_register ,
 .Fn crypto_kregister ,
 .Fn crypto_unregister ,
-.Fn crypto_newsession ,
 and
-.Fn crypto_freesession
+.Fn crypto_newsession
 return 0 on success, or an error code on failure.
 .Fn crypto_get_driverid
 returns a non-negative value on error, and \-1 on failure.

Index: src/sys/netipsec/xform_ah.c
diff -u src/sys/netipsec/xform_ah.c:1.111 src/sys/netipsec/xform_ah.c:1.112
--- src/sys/netipsec/xform_ah.c:1.111	Sun May 22 11:39:08 2022
+++ src/sys/netipsec/xform_ah.c	Sun May 22 11:39:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_ah.c,v 1.111 2022/05/22 11:39:08 riastradh Exp $	*/
+/*	$NetBSD: xform_ah.c,v 1.112 2022/05/22 11:39:37 riastradh Exp $	*/
 /*	$FreeBSD: xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */
 /*
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.111 2022/05/22 11:39:08 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.112 2022/05/22 11:39:37 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -273,7 +273,7 @@ ah_zeroize(struct secasvar *sav)
 		_KEYLEN(sav->key_auth));
 	}
 
-	(void)crypto_freesession(sav->tdb_cryptoid);
+	crypto_freesession(sav->tdb_cryptoid);
 	sav->tdb_cryptoid = 0;
 	sav->tdb_authalgxform = NULL;
 	sav->tdb_xform = NULL;

Index: src/sys/netipsec/xform_ipcomp.c
diff -u src/sys/netipsec/xform_ipcomp.c:1.71 src/sys/netipsec/xform_ipcomp.c:1.72
--- src/sys/netipsec/xform_ipcomp.c:1.71	Sun May 22 11:39:08 2022
+++ src/sys/netipsec/xform_ipcomp.c	Sun May 22 11:39:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_ipcomp.c,v 1.71 2022/05/22 11:39:08 riastradh Exp $	*/
+/*	$NetBSD: xform_ipcomp.c,v 1.72 2022/05/22 11:39:37 riastradh Exp $	*/
 /*	$FreeBSD: xform_ipcomp.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
 /* $OpenBSD: ip_ipcomp.c,v 1.1 2001/07/05 12:08:52 jjbg Exp $ */
 
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_ipcomp.c,v 1.71 2022/05/22 11:39:08 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ipcomp.c,v 1.72 2022/05/22 11:39:37 riastradh Exp $");
 
 /* IP payload compression protocol (IPComp), see RFC 2393 */
 #if defined(_KERNEL_OPT)
@@ -128,7 +128,7 @@ static void
 ipcomp_zeroize(struct secasvar *sav)
 {
 
-	(void)crypto_freesession(sav->tdb_cryptoid);
+	crypto_freesession(sav->tdb_cryptoid);
 	sav->tdb_cryptoid = 0;
 }
 

Index: src/sys/opencrypto/crypto.c
diff -u src/sys/opencrypto/crypto.c:1.124 src/sys/opencrypto/crypto.c:1.125
--- src/sys/opencrypto/crypto.c:1.124	Sun May 22 11:39:27 2022
+++ src/sys/opencrypto/crypto.c	Sun May 22 11:39:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypto.c,v 1.124 2022/05/22 11:39:27 riastradh Exp $ */
+/*	$NetBSD: crypto.c,v 1.125 2022/05/22 11:39:37 riastradh Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $	*/
 /*	$OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $	*/
 
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.124 2022/05/22 11:39:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.125 2022/05/22 11:39:37 riastradh Exp $");
 
 #include 
 #include 
@@ -852,11 +852,10 @@ crypto_newsession(u_int64_t *sid, struct
  * Delete an existing session (o

CVS commit: src

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:39:37 UTC 2022

Modified Files:
src/share/man/man9: opencrypto.9
src/sys/netipsec: xform_ah.c xform_ipcomp.c
src/sys/opencrypto: crypto.c cryptodev.c cryptodev.h

Log Message:
opencrypto: Make crypto_freesession return void.

No callers use the return value.  It is not sensible to allow this to
fail.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/share/man/man9/opencrypto.9
cvs rdiff -u -r1.111 -r1.112 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.71 -r1.72 src/sys/netipsec/xform_ipcomp.c
cvs rdiff -u -r1.124 -r1.125 src/sys/opencrypto/crypto.c
cvs rdiff -u -r1.119 -r1.120 src/sys/opencrypto/cryptodev.c
cvs rdiff -u -r1.47 -r1.48 src/sys/opencrypto/cryptodev.h

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



CVS commit: src

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:39:27 UTC 2022

Modified Files:
src/share/man/man9: opencrypto.9
src/sys/arch/arm/sunxi: sun8i_crypto.c
src/sys/arch/i386/pci: glxsb.c
src/sys/arch/x86/x86: via_padlock.c
src/sys/dev/marvell: mvcesa.c mvxpsecvar.h
src/sys/dev/pci: hifn7751.c ubsec.c
src/sys/dev/pci/qat: qat.c
src/sys/opencrypto: crypto.c cryptodev.h cryptosoft.c

Log Message:
opencrypto: Make freesession callback return void.

No functional change intended: all drivers already return zero
unconditionally.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/share/man/man9/opencrypto.9
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/arm/sunxi/sun8i_crypto.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/pci/glxsb.c
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/x86/x86/via_padlock.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/marvell/mvcesa.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/marvell/mvxpsecvar.h
cvs rdiff -u -r1.79 -r1.80 src/sys/dev/pci/hifn7751.c
cvs rdiff -u -r1.58 -r1.59 src/sys/dev/pci/ubsec.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/qat/qat.c
cvs rdiff -u -r1.123 -r1.124 src/sys/opencrypto/crypto.c
cvs rdiff -u -r1.46 -r1.47 src/sys/opencrypto/cryptodev.h
cvs rdiff -u -r1.63 -r1.64 src/sys/opencrypto/cryptosoft.c

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

Modified files:

Index: src/share/man/man9/opencrypto.9
diff -u src/share/man/man9/opencrypto.9:1.18 src/share/man/man9/opencrypto.9:1.19
--- src/share/man/man9/opencrypto.9:1.18	Sun May 22 11:34:17 2022
+++ src/share/man/man9/opencrypto.9	Sun May 22 11:39:26 2022
@@ -1,5 +1,5 @@
 .\"	$OpenBSD: crypto.9,v 1.25 2003/07/11 13:47:41 jmc Exp $
-.\"	$NetBSD: opencrypto.9,v 1.18 2022/05/22 11:34:17 riastradh Exp $
+.\"	$NetBSD: opencrypto.9,v 1.19 2022/05/22 11:39:26 riastradh Exp $
 .\"
 .\" The author of this man page is Angelos D. Keromytis (ange...@cis.upenn.edu)
 .\"
@@ -579,7 +579,7 @@ and migrate existing sessions to other d
 The calling convention for the three driver-supplied routines is:
 .Bd -literal
 int (*newsession) (void *, u_int32_t *, struct cryptoini *);
-int (*freesession) (void *, u_int64_t);
+void (*freesession) (void *, u_int64_t);
 int (*process) (void *, struct cryptop *, int);
 .Ed
 .Pp
@@ -595,7 +595,9 @@ The second argument is identical to that
 The
 .Fn freesession
 routine takes as argument the SID (which is the concatenation of the
-driver identifier and the driver-specific session identifier).
+driver identifier and the driver-specific session identifier returned
+by
+.Fn newsession ).
 It should clear any context associated with the session (clear hardware
 registers, memory, etc.).
 .Pp

Index: src/sys/arch/arm/sunxi/sun8i_crypto.c
diff -u src/sys/arch/arm/sunxi/sun8i_crypto.c:1.31 src/sys/arch/arm/sunxi/sun8i_crypto.c:1.32
--- src/sys/arch/arm/sunxi/sun8i_crypto.c:1.31	Sun May 15 16:58:28 2022
+++ src/sys/arch/arm/sunxi/sun8i_crypto.c	Sun May 22 11:39:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun8i_crypto.c,v 1.31 2022/05/15 16:58:28 riastradh Exp $	*/
+/*	$NetBSD: sun8i_crypto.c,v 1.32 2022/05/22 11:39:26 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.31 2022/05/15 16:58:28 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.32 2022/05/22 11:39:26 riastradh Exp $");
 
 #include 
 #include 
@@ -249,7 +249,7 @@ static void	sun8i_crypto_register(struct
 static void	sun8i_crypto_register1(struct sun8i_crypto_softc *, uint32_t);
 static int	sun8i_crypto_newsession(void *, uint32_t *,
 		struct cryptoini *);
-static int	sun8i_crypto_freesession(void *, uint64_t);
+static void	sun8i_crypto_freesession(void *, uint64_t);
 static u_int	sun8i_crypto_ivlen(const struct cryptodesc *);
 static int	sun8i_crypto_process(void *, struct cryptop *, int);
 static void	sun8i_crypto_callback(struct sun8i_crypto_softc *,
@@ -2050,14 +2050,11 @@ sun8i_crypto_newsession(void *cookie, ui
  *	Note: dsid is actually a 64-bit quantity containing both the
  *	driver id in the high half and the session id in the low half.
  */
-static int
+static void
 sun8i_crypto_freesession(void *cookie, uint64_t dsid)
 {
 
 	KASSERT((dsid & 0x) == 1);
-
-	/* Success! */
-	return 0;
 }
 
 /*

Index: src/sys/arch/i386/pci/glxsb.c
diff -u src/sys/arch/i386/pci/glxsb.c:1.18 src/sys/arch/i386/pci/glxsb.c:1.19
--- src/sys/arch/i386/pci/glxsb.c:1.18	Sun May 22 11:38:12 2022
+++ src/sys/arch/i386/pci/glxsb.c	Sun May 22 11:39:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: glxsb.c,v 1.18 2022/05/22 11:38:12 riastradh Exp $	*/
+/*	$NetBSD: glxsb.c,v 1.19 2022/05/22 11:39:26 riastradh Exp $	*/
 /* $OpenBSD: glxsb.c,v 1.7 2007/02/12 14:31:45 tom Exp $ */
 
 /*
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: glxsb.c,v 1.18 2022/05/22 11:38:12 riastradh Exp $");
+__KERNE

CVS commit: src

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:39:27 UTC 2022

Modified Files:
src/share/man/man9: opencrypto.9
src/sys/arch/arm/sunxi: sun8i_crypto.c
src/sys/arch/i386/pci: glxsb.c
src/sys/arch/x86/x86: via_padlock.c
src/sys/dev/marvell: mvcesa.c mvxpsecvar.h
src/sys/dev/pci: hifn7751.c ubsec.c
src/sys/dev/pci/qat: qat.c
src/sys/opencrypto: crypto.c cryptodev.h cryptosoft.c

Log Message:
opencrypto: Make freesession callback return void.

No functional change intended: all drivers already return zero
unconditionally.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/share/man/man9/opencrypto.9
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/arm/sunxi/sun8i_crypto.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/pci/glxsb.c
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/x86/x86/via_padlock.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/marvell/mvcesa.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/marvell/mvxpsecvar.h
cvs rdiff -u -r1.79 -r1.80 src/sys/dev/pci/hifn7751.c
cvs rdiff -u -r1.58 -r1.59 src/sys/dev/pci/ubsec.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/qat/qat.c
cvs rdiff -u -r1.123 -r1.124 src/sys/opencrypto/crypto.c
cvs rdiff -u -r1.46 -r1.47 src/sys/opencrypto/cryptodev.h
cvs rdiff -u -r1.63 -r1.64 src/sys/opencrypto/cryptosoft.c

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



CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:39:17 UTC 2022

Modified Files:
src/sys/opencrypto: cryptodev.c

Log Message:
crypto(4): crypto_freesession should never fail here.

It can only fail if we pass it an invalid sid, which the logic to
maintain the user sessions should not do.  So kassert error=0 here.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/opencrypto/cryptodev.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/opencrypto/cryptodev.c
diff -u src/sys/opencrypto/cryptodev.c:1.118 src/sys/opencrypto/cryptodev.c:1.119
--- src/sys/opencrypto/cryptodev.c:1.118	Sun May 22 11:34:29 2022
+++ src/sys/opencrypto/cryptodev.c	Sun May 22 11:39:17 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: cryptodev.c,v 1.118 2022/05/22 11:34:29 riastradh Exp $ */
+/*	$NetBSD: cryptodev.c,v 1.119 2022/05/22 11:39:17 riastradh Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $	*/
 /*	$OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $	*/
 
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.118 2022/05/22 11:34:29 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.119 2022/05/22 11:39:17 riastradh Exp $");
 
 #include 
 #include 
@@ -1020,6 +1020,7 @@ csefree(struct csession *cse)
 	int error;
 
 	error = crypto_freesession(cse->sid);
+	KASSERTMSG(error == 0, "error=%d", error);
 	if (cse->key)
 		free(cse->key, M_XDATA);
 	if (cse->mackey)



CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:39:17 UTC 2022

Modified Files:
src/sys/opencrypto: cryptodev.c

Log Message:
crypto(4): crypto_freesession should never fail here.

It can only fail if we pass it an invalid sid, which the logic to
maintain the user sessions should not do.  So kassert error=0 here.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/opencrypto/cryptodev.c

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



CVS commit: src/sys/netipsec

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:39:08 UTC 2022

Modified Files:
src/sys/netipsec: xform.h xform_ah.c xform_esp.c xform_ipcomp.c
xform_ipip.c xform_tcp.c

Log Message:
netipsec: Nothing uses xf_zeroize return value.  Nix it.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/netipsec/xform.h
cvs rdiff -u -r1.110 -r1.111 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.102 -r1.103 src/sys/netipsec/xform_esp.c
cvs rdiff -u -r1.70 -r1.71 src/sys/netipsec/xform_ipcomp.c
cvs rdiff -u -r1.77 -r1.78 src/sys/netipsec/xform_ipip.c
cvs rdiff -u -r1.24 -r1.25 src/sys/netipsec/xform_tcp.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/netipsec/xform.h
diff -u src/sys/netipsec/xform.h:1.21 src/sys/netipsec/xform.h:1.22
--- src/sys/netipsec/xform.h:1.21	Fri Nov  1 04:23:21 2019
+++ src/sys/netipsec/xform.h	Sun May 22 11:39:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform.h,v 1.21 2019/11/01 04:23:21 knakahara Exp $	*/
+/*	$NetBSD: xform.h,v 1.22 2022/05/22 11:39:08 riastradh Exp $	*/
 /*	$FreeBSD: xform.h,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ipsp.h,v 1.119 2002/03/14 01:27:11 millert Exp $	*/
 /*
@@ -77,7 +77,7 @@ struct xformsw {
 #define	XFT_COMP	0x1000
 	const char *xf_name;
 	int (*xf_init)(struct secasvar *, const struct xformsw *);
-	int (*xf_zeroize)(struct secasvar *);
+	void (*xf_zeroize)(struct secasvar *);
 	int (*xf_input)(struct mbuf *, struct secasvar *, int, int);
 	int (*xf_output)(struct mbuf *, const struct ipsecrequest *,
 	struct secasvar *, int, int, int);
@@ -95,7 +95,7 @@ int ipip_output(struct mbuf *, struct se
 
 /* XF_AH */
 int ah_init0(struct secasvar *, const struct xformsw *, struct cryptoini *);
-int ah_zeroize(struct secasvar *);
+void ah_zeroize(struct secasvar *);
 const struct auth_hash *ah_algorithm_lookup(int);
 size_t ah_authsiz(const struct secasvar *);
 size_t ah_hdrsiz(const struct secasvar *);

Index: src/sys/netipsec/xform_ah.c
diff -u src/sys/netipsec/xform_ah.c:1.110 src/sys/netipsec/xform_ah.c:1.111
--- src/sys/netipsec/xform_ah.c:1.110	Sun May 22 11:30:40 2022
+++ src/sys/netipsec/xform_ah.c	Sun May 22 11:39:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_ah.c,v 1.110 2022/05/22 11:30:40 riastradh Exp $	*/
+/*	$NetBSD: xform_ah.c,v 1.111 2022/05/22 11:39:08 riastradh Exp $	*/
 /*	$FreeBSD: xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */
 /*
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.110 2022/05/22 11:30:40 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.111 2022/05/22 11:39:08 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -264,21 +264,19 @@ ah_init(struct secasvar *sav, const stru
  *
  * NB: public for use by esp_zeroize (XXX).
  */
-int
+void
 ah_zeroize(struct secasvar *sav)
 {
-	int err;
 
 	if (sav->key_auth) {
 		explicit_memset(_KEYBUF(sav->key_auth), 0,
 		_KEYLEN(sav->key_auth));
 	}
 
-	err = crypto_freesession(sav->tdb_cryptoid);
+	(void)crypto_freesession(sav->tdb_cryptoid);
 	sav->tdb_cryptoid = 0;
 	sav->tdb_authalgxform = NULL;
 	sav->tdb_xform = NULL;
-	return err;
 }
 
 /*

Index: src/sys/netipsec/xform_esp.c
diff -u src/sys/netipsec/xform_esp.c:1.102 src/sys/netipsec/xform_esp.c:1.103
--- src/sys/netipsec/xform_esp.c:1.102	Sun May 22 11:30:40 2022
+++ src/sys/netipsec/xform_esp.c	Sun May 22 11:39:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_esp.c,v 1.102 2022/05/22 11:30:40 riastradh Exp $	*/
+/*	$NetBSD: xform_esp.c,v 1.103 2022/05/22 11:39:08 riastradh Exp $	*/
 /*	$FreeBSD: xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.102 2022/05/22 11:30:40 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.103 2022/05/22 11:39:08 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -280,11 +280,11 @@ esp_init(struct secasvar *sav, const str
 /*
  * Paranoia.
  */
-static int
+static void
 esp_zeroize(struct secasvar *sav)
 {
 	/* NB: ah_zerorize free's the crypto session state */
-	int error = ah_zeroize(sav);
+	ah_zeroize(sav);
 
 	if (sav->key_enc) {
 		explicit_memset(_KEYBUF(sav->key_enc), 0,
@@ -292,7 +292,6 @@ esp_zeroize(struct secasvar *sav)
 	}
 	sav->tdb_encalgxform = NULL;
 	sav->tdb_xform = NULL;
-	return error;
 }
 
 /*

Index: src/sys/netipsec/xform_ipcomp.c
diff -u src/sys/netipsec/xform_ipcomp.c:1.70 src/sys/netipsec/xform_ipcomp.c:1.71
--- src/sys/netipsec/xform_ipcomp.c:1.70	Sun May 22 11:30:40 2022
+++ src/sys/netipsec/xform_ipcomp.c	Sun May 22 11:39:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_ipcomp.c,v 1.70 2022/05/22 11:30:40 riastradh Exp $	*/
+/*	$NetBSD: xform_ipcomp.c,v 1.71 2022/05/22 11:39:08 riastradh Exp $	*/

CVS commit: src/sys/netipsec

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:39:08 UTC 2022

Modified Files:
src/sys/netipsec: xform.h xform_ah.c xform_esp.c xform_ipcomp.c
xform_ipip.c xform_tcp.c

Log Message:
netipsec: Nothing uses xf_zeroize return value.  Nix it.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/netipsec/xform.h
cvs rdiff -u -r1.110 -r1.111 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.102 -r1.103 src/sys/netipsec/xform_esp.c
cvs rdiff -u -r1.70 -r1.71 src/sys/netipsec/xform_ipcomp.c
cvs rdiff -u -r1.77 -r1.78 src/sys/netipsec/xform_ipip.c
cvs rdiff -u -r1.24 -r1.25 src/sys/netipsec/xform_tcp.c

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



CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:38:59 UTC 2022

Modified Files:
src/sys/opencrypto: cryptosoft.c

Log Message:
cryptosoft(4): Prune dead branches.  Assert session id validity.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/opencrypto/cryptosoft.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/opencrypto/cryptosoft.c
diff -u src/sys/opencrypto/cryptosoft.c:1.62 src/sys/opencrypto/cryptosoft.c:1.63
--- src/sys/opencrypto/cryptosoft.c:1.62	Sun May 22 11:29:25 2022
+++ src/sys/opencrypto/cryptosoft.c	Sun May 22 11:38:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: cryptosoft.c,v 1.62 2022/05/22 11:29:25 riastradh Exp $ */
+/*	$NetBSD: cryptosoft.c,v 1.63 2022/05/22 11:38:59 riastradh Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/cryptosoft.c,v 1.2.2.1 2002/11/21 23:34:23 sam Exp $	*/
 /*	$OpenBSD: cryptosoft.c,v 1.35 2002/04/26 08:43:50 deraadt Exp $	*/
 
@@ -24,7 +24,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.62 2022/05/22 11:29:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.63 2022/05/22 11:38:59 riastradh Exp $");
 
 #include 
 #include 
@@ -766,9 +766,6 @@ swcr_newsession(void *arg, u_int32_t *si
 	u_int32_t i;
 	int k, error;
 
-	if (sid == NULL || cri == NULL)
-		return EINVAL;
-
 	if (swcr_sessions) {
 		for (i = 1; i < swcr_sesnum; i++)
 			if (swcr_sessions[i] == NULL)
@@ -1128,9 +1125,9 @@ swcr_freesession(void *arg, u_int64_t ti
 	struct swcr_data *swd;
 	u_int32_t sid = ((u_int32_t) tid) & 0x;
 
-	if (sid > swcr_sesnum || swcr_sessions == NULL ||
-	swcr_sessions[sid] == NULL)
-		return EINVAL;
+	KASSERTMSG(sid < swcr_sesnum, "sid=%"PRIu32" swcr_sesnum=%"PRIu32,
+	sid, swcr_sesnum);
+	KASSERT(swcr_sessions[sid]);
 
 	swd = swcr_sessions[sid];
 	swcr_sessions[sid] = NULL;



CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:38:59 UTC 2022

Modified Files:
src/sys/opencrypto: cryptosoft.c

Log Message:
cryptosoft(4): Prune dead branches.  Assert session id validity.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/opencrypto/cryptosoft.c

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



CVS commit: src/sys/dev/marvell

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:38:51 UTC 2022

Modified Files:
src/sys/dev/marvell: mvxpsec.c

Log Message:
mvxpsec(4): Prune dead branches.  Assert session id validity.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/marvell/mvxpsec.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/marvell/mvxpsec.c
diff -u src/sys/dev/marvell/mvxpsec.c:1.14 src/sys/dev/marvell/mvxpsec.c:1.15
--- src/sys/dev/marvell/mvxpsec.c:1.14	Tue Apr 12 21:05:37 2022
+++ src/sys/dev/marvell/mvxpsec.c	Sun May 22 11:38:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: mvxpsec.c,v 1.14 2022/04/12 21:05:37 andvar Exp $	*/
+/*	$NetBSD: mvxpsec.c,v 1.15 2022/05/22 11:38:51 riastradh Exp $	*/
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
  * All rights reserved.
@@ -2029,21 +2029,13 @@ mvxpsec_freesession(void *arg, uint64_t 
 	uint32_t sid = ((uint32_t)tid) & 0x;
 
 	session = MVXPSEC_SESSION(sid);
-	if (session < 0 || session >= MVXPSEC_MAX_SESSIONS) {
-		log(LOG_ERR, "%s: invalid session (id:%u)\n",
-		__func__, session);
-		return EINVAL;
-	}
+	KASSERTMSG(session >= 0, "session=%d", session);
+	KASSERTMSG(session < MVXPSEC_MAX_SESSIONS, "session=%d max=%d",
+	session, MVXPSEC_MAX_SESSIONS);
 
 	mutex_enter(&sc->sc_session_mtx);
-	if ( (mv_s = sc->sc_sessions[session]) == NULL) {
-		mutex_exit(&sc->sc_session_mtx);
-#ifdef DEBUG
-		log(LOG_DEBUG, "%s: session %d already inactivated\n",
-		__func__, session);
-#endif
-		return ENOENT;
-	}
+	mv_s = sc->sc_sessions[session];
+	KASSERT(mv_s != NULL);
 	MVXPSEC_PRINTF(MVXPSEC_DEBUG_OPENCRYPTO,
 	"%s: inactivate session %d\n", __func__, session);
 



CVS commit: src/sys/dev/marvell

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:38:51 UTC 2022

Modified Files:
src/sys/dev/marvell: mvxpsec.c

Log Message:
mvxpsec(4): Prune dead branches.  Assert session id validity.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/marvell/mvxpsec.c

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



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:38:43 UTC 2022

Modified Files:
src/sys/dev/pci: ubsec.c

Log Message:
ubsec(4): Prune dead branches.  Assert session id validity.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/dev/pci/ubsec.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/pci/ubsec.c
diff -u src/sys/dev/pci/ubsec.c:1.57 src/sys/dev/pci/ubsec.c:1.58
--- src/sys/dev/pci/ubsec.c:1.57	Sun May 22 11:35:13 2022
+++ src/sys/dev/pci/ubsec.c	Sun May 22 11:38:43 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ubsec.c,v 1.57 2022/05/22 11:35:13 riastradh Exp $	*/
+/*	$NetBSD: ubsec.c,v 1.58 2022/05/22 11:38:43 riastradh Exp $	*/
 /* $FreeBSD: src/sys/dev/ubsec/ubsec.c,v 1.6.2.6 2003/01/23 21:06:43 sam Exp $ */
 /*	$OpenBSD: ubsec.c,v 1.143 2009/03/27 13:31:30 reyk Exp$	*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.57 2022/05/22 11:35:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.58 2022/05/22 11:38:43 riastradh Exp $");
 
 #undef UBSEC_DEBUG
 
@@ -955,18 +955,12 @@ static int
 ubsec_newsession(void *arg, u_int32_t *sidp, struct cryptoini *cri)
 {
 	struct cryptoini *c, *encini = NULL, *macini = NULL;
-	struct ubsec_softc *sc;
+	struct ubsec_softc *sc = arg;
 	struct ubsec_session *ses = NULL;
 	MD5_CTX md5ctx;
 	SHA1_CTX sha1ctx;
 	int i, sesn;
 
-	sc = arg;
-	KASSERT(sc != NULL /*, ("ubsec_newsession: null softc")*/);
-
-	if (sidp == NULL || cri == NULL || sc == NULL)
-		return (EINVAL);
-
 	for (c = cri; c != NULL; c = c->cri_next) {
 		if (c->cri_alg == CRYPTO_MD5_HMAC_96 ||
 		c->cri_alg == CRYPTO_SHA1_HMAC_96) {
@@ -1108,16 +1102,14 @@ ubsec_newsession(void *arg, u_int32_t *s
 static int
 ubsec_freesession(void *arg, u_int64_t tid)
 {
-	struct ubsec_softc *sc;
+	struct ubsec_softc *sc = arg;
 	int session;
 	u_int32_t sid = ((u_int32_t) tid) & 0x;
 
-	sc = arg;
-	KASSERT(sc != NULL /*, ("ubsec_freesession: null softc")*/);
-
 	session = UBSEC_SESSION(sid);
-	if (session >= sc->sc_nsessions)
-		return (EINVAL);
+	KASSERTMSG(session >= 0, "session=%d", session);
+	KASSERTMSG(session < sc->sc_nsessions, "session=%d nsessions=%d",
+	session, sc->sc_nsessions);
 
 	memset(&sc->sc_sessions[session], 0, sizeof(sc->sc_sessions[session]));
 	return (0);



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:38:43 UTC 2022

Modified Files:
src/sys/dev/pci: ubsec.c

Log Message:
ubsec(4): Prune dead branches.  Assert session id validity.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/dev/pci/ubsec.c

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



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:38:34 UTC 2022

Modified Files:
src/sys/dev/pci: hifn7751.c

Log Message:
hifn(4): Prune dead branches.  Assert session id validity.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/dev/pci/hifn7751.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/pci/hifn7751.c
diff -u src/sys/dev/pci/hifn7751.c:1.78 src/sys/dev/pci/hifn7751.c:1.79
--- src/sys/dev/pci/hifn7751.c:1.78	Sun May 22 11:34:57 2022
+++ src/sys/dev/pci/hifn7751.c	Sun May 22 11:38:34 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: hifn7751.c,v 1.78 2022/05/22 11:34:57 riastradh Exp $	*/
+/*	$NetBSD: hifn7751.c,v 1.79 2022/05/22 11:38:34 riastradh Exp $	*/
 /*	$OpenBSD: hifn7751.c,v 1.179 2020/01/11 21:34:03 cheloha Exp $	*/
 
 /*
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.78 2022/05/22 11:34:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.79 2022/05/22 11:38:34 riastradh Exp $");
 
 #include 
 #include 
@@ -2076,10 +2076,6 @@ hifn_newsession(void *arg, uint32_t *sid
 	struct hifn_softc *sc = arg;
 	int i, mac = 0, cry = 0, comp = 0, retval = EINVAL;
 
-	KASSERT(sc != NULL /*, ("hifn_newsession: null softc")*/);
-	if (sidp == NULL || cri == NULL || sc == NULL)
-		return retval;
-
 	mutex_spin_enter(&sc->sc_mtx);
 	for (i = 0; i < sc->sc_maxses; i++)
 		if (isclr(sc->sc_sessions, i))
@@ -2154,16 +2150,12 @@ hifn_freesession(void *arg, uint64_t tid
 	int session;
 	uint32_t sid = ((uint32_t) tid) & 0x;
 
-	KASSERT(sc != NULL /*, ("hifn_freesession: null softc")*/);
-	if (sc == NULL)
-		return (EINVAL);
-
 	mutex_spin_enter(&sc->sc_mtx);
 	session = HIFN_SESSION(sid);
-	if (session >= sc->sc_maxses) {
-		mutex_spin_exit(&sc->sc_mtx);
-		return (EINVAL);
-	}
+	KASSERTMSG(session >= 0, "session=%d", session);
+	KASSERTMSG(session < sc->sc_maxses, "session=%d maxses=%d",
+	session, sc->sc_maxses);
+	KASSERT(isset(sc->sc_sessions, session));
 	clrbit(sc->sc_sessions, session);
 	mutex_spin_exit(&sc->sc_mtx);
 	return (0);
@@ -2185,10 +2177,8 @@ hifn_process(void *arg, struct cryptop *
 
 	mutex_spin_enter(&sc->sc_mtx);
 	session = HIFN_SESSION(crp->crp_sid);
-	if (session >= sc->sc_maxses) {
-		err = EINVAL;
-		goto errout;
-	}
+	KASSERTMSG(session < sc->sc_maxses, "session=%d maxses=%d",
+	session, sc->sc_maxses);
 
 	if (crp->crp_flags & CRYPTO_F_IMBUF) {
 		cmd->srcu.src_m = (struct mbuf *)crp->crp_buf;



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:38:34 UTC 2022

Modified Files:
src/sys/dev/pci: hifn7751.c

Log Message:
hifn(4): Prune dead branches.  Assert session id validity.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/dev/pci/hifn7751.c

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



CVS commit: src/sys/dev/marvell

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:38:26 UTC 2022

Modified Files:
src/sys/dev/marvell: mvcesa.c

Log Message:
mvcesa(4): Prune dead branches.  Assert session id validity.


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

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



CVS commit: src/sys/dev/marvell

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:38:26 UTC 2022

Modified Files:
src/sys/dev/marvell: mvcesa.c

Log Message:
mvcesa(4): Prune dead branches.  Assert session id validity.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/marvell/mvcesa.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/marvell/mvcesa.c
diff -u src/sys/dev/marvell/mvcesa.c:1.4 src/sys/dev/marvell/mvcesa.c:1.5
--- src/sys/dev/marvell/mvcesa.c:1.4	Sun Dec  5 02:41:44 2021
+++ src/sys/dev/marvell/mvcesa.c	Sun May 22 11:38:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: mvcesa.c,v 1.4 2021/12/05 02:41:44 msaitoh Exp $	*/
+/*	$NetBSD: mvcesa.c,v 1.5 2022/05/22 11:38:26 riastradh Exp $	*/
 /*
  * Copyright (c) 2008 KIYOHARA Takashi
  * All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mvcesa.c,v 1.4 2021/12/05 02:41:44 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mvcesa.c,v 1.5 2022/05/22 11:38:26 riastradh Exp $");
 
 #include 
 #include 
@@ -332,11 +332,10 @@ mvcesa_freesession(void *arg, u_int64_t 
 	int session;
 	uint32_t sid = ((uint32_t)tid) & 0x;
 
-	KASSERT(sc != NULL /*, ("mvcesa_freesession: null softc")*/);
-
 	session = MVCESA_SESSION(sid);
-	if (session >= sc->sc_nsessions)
-		return EINVAL;
+	KASSERTMSG(session >= 0, "session=%d", session);
+	KASSERTMSG(session < sc->sc_nsessions, "session=%d nsessions=%d",
+	session, sc->sc_nsessions);
 
 	memset(&sc->sc_sessions[session], 0, sizeof(sc->sc_sessions[session]));
 	return (0);
@@ -345,7 +344,7 @@ mvcesa_freesession(void *arg, u_int64_t 
 static int
 mvcesa_process(void *arg, struct cryptop *crp, int hint)
 {
-	struct mvcesa_softc *sc = (struct mvcesa_softc *)arg;
+	struct mvcesa_softc *sc = arg;
 	struct mvcesa_session *ses;
 	struct cryptodesc *crd;
 	struct mbuf *m = NULL;
@@ -353,20 +352,9 @@ mvcesa_process(void *arg, struct cryptop
 	int session;
 	char *buf = NULL;
 
-	KASSERT(sc != NULL /*, ("mvcesa_process: null softc")*/);
-
-	if (crp == NULL)
-		return EINVAL;
-	if (crp->crp_callback == NULL || sc == NULL) {
-		crp->crp_etype = EINVAL;
-		goto done;
-	}
-
 	session = MVCESA_SESSION(crp->crp_sid);
-	if (session >= sc->sc_nsessions) {
-		crp->crp_etype = ENOENT;
-		goto done;
-	}
+	KASSERTMSG(session < sc->sc_nsessions, "session=%d nsessions=%d",
+	session, sc->sc_nsessions);
 	ses = &sc->sc_sessions[session];
 
 	if (crp->crp_flags & CRYPTO_F_IMBUF)



CVS commit: src/sys/arch/x86/x86

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:38:19 UTC 2022

Modified Files:
src/sys/arch/x86/x86: via_padlock.c

Log Message:
padlock(4): Prune dead branches.  Assert session id validity.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/x86/x86/via_padlock.c

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

Modified files:

Index: src/sys/arch/x86/x86/via_padlock.c
diff -u src/sys/arch/x86/x86/via_padlock.c:1.33 src/sys/arch/x86/x86/via_padlock.c:1.34
--- src/sys/arch/x86/x86/via_padlock.c:1.33	Sun May 22 11:38:02 2022
+++ src/sys/arch/x86/x86/via_padlock.c	Sun May 22 11:38:19 2022
@@ -1,5 +1,5 @@
 /*	$OpenBSD: via.c,v 1.8 2006/11/17 07:47:56 tom Exp $	*/
-/*	$NetBSD: via_padlock.c,v 1.33 2022/05/22 11:38:02 riastradh Exp $ */
+/*	$NetBSD: via_padlock.c,v 1.34 2022/05/22 11:38:19 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2003 Jason Wright
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: via_padlock.c,v 1.33 2022/05/22 11:38:02 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: via_padlock.c,v 1.34 2022/05/22 11:38:19 riastradh Exp $");
 
 #include 
 #include 
@@ -135,10 +135,6 @@ via_padlock_crypto_newsession(void *arg,
 	struct swcr_data *swd;
 	int sesn, i, cw0;
 
-	KASSERT(sc != NULL /*, ("via_padlock_crypto_freesession: null softc")*/);
-	if (sc == NULL || sidp == NULL || cri == NULL)
-		return (EINVAL);
-
 	if (sc->sc_sessions == NULL) {
 		ses = sc->sc_sessions = malloc(sizeof(*ses), M_DEVBUF,
 		M_NOWAIT);
@@ -311,13 +307,10 @@ via_padlock_crypto_freesession(void *arg
 	int sesn;
 	uint32_t sid = ((uint32_t)tid) & 0x;
 
-	KASSERT(sc != NULL /*, ("via_padlock_crypto_freesession: null softc")*/);
-	if (sc == NULL)
-		return (EINVAL);
-
 	sesn = VIAC3_SESSION(sid);
-	if (sesn >= sc->sc_nsessions)
-		return (EINVAL);
+	KASSERTMSG(sesn >= 0, "sesn=%d", sesn);
+	KASSERTMSG(sesn < sc->sc_nsessions, "sesn=%d nsessions=%d",
+	sesn, sc->sc_nsessions);
 
 	if (sc->sc_sessions[sesn].swd) {
 		swd = sc->sc_sessions[sesn].swd;



CVS commit: src/sys/arch/x86/x86

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:38:19 UTC 2022

Modified Files:
src/sys/arch/x86/x86: via_padlock.c

Log Message:
padlock(4): Prune dead branches.  Assert session id validity.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/x86/x86/via_padlock.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/i386/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:38:12 UTC 2022

Modified Files:
src/sys/arch/i386/pci: glxsb.c

Log Message:
glxsb(4): Prune dead branches.  Assert session id validity.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/i386/pci/glxsb.c

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

Modified files:

Index: src/sys/arch/i386/pci/glxsb.c
diff -u src/sys/arch/i386/pci/glxsb.c:1.17 src/sys/arch/i386/pci/glxsb.c:1.18
--- src/sys/arch/i386/pci/glxsb.c:1.17	Sun May 22 11:35:21 2022
+++ src/sys/arch/i386/pci/glxsb.c	Sun May 22 11:38:12 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: glxsb.c,v 1.17 2022/05/22 11:35:21 riastradh Exp $	*/
+/*	$NetBSD: glxsb.c,v 1.18 2022/05/22 11:38:12 riastradh Exp $	*/
 /* $OpenBSD: glxsb.c,v 1.7 2007/02/12 14:31:45 tom Exp $ */
 
 /*
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: glxsb.c,v 1.17 2022/05/22 11:35:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: glxsb.c,v 1.18 2022/05/22 11:38:12 riastradh Exp $");
 
 #include 
 #include 
@@ -314,8 +314,7 @@ glxsb_crypto_newsession(void *aux, uint3
 	struct glxsb_session *ses = NULL;
 	int sesn;
 
-	if (sc == NULL || sidp == NULL || cri == NULL ||
-	cri->cri_next != NULL || cri->cri_alg != CRYPTO_AES_CBC ||
+	if (cri->cri_next != NULL || cri->cri_alg != CRYPTO_AES_CBC ||
 	cri->cri_klen != 128)
 		return (EINVAL);
 
@@ -360,11 +359,10 @@ glxsb_crypto_freesession(void *aux, uint
 	int sesn;
 	uint32_t sid = ((uint32_t)tid) & 0x;
 
-	if (sc == NULL)
-		return (EINVAL);
 	sesn = GLXSB_SESSION(sid);
-	if (sesn >= sc->sc_nsessions)
-		return (EINVAL);
+	KASSERTMSG(sesn < sc->sc_nsessions, "sesn=%d nsessions=%d",
+	sesn, sc->sc_nsessions);
+
 	memset(&sc->sc_sessions[sesn], 0, sizeof(sc->sc_sessions[sesn]));
 	return (0);
 }



CVS commit: src/sys/arch/i386/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:38:12 UTC 2022

Modified Files:
src/sys/arch/i386/pci: glxsb.c

Log Message:
glxsb(4): Prune dead branches.  Assert session id validity.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/i386/pci/glxsb.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/x86/x86

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:38:03 UTC 2022

Modified Files:
src/sys/arch/x86/x86: via_padlock.c

Log Message:
padlock(4): Return zero, not error, if we've issued crypto_done.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/x86/x86/via_padlock.c

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

Modified files:

Index: src/sys/arch/x86/x86/via_padlock.c
diff -u src/sys/arch/x86/x86/via_padlock.c:1.32 src/sys/arch/x86/x86/via_padlock.c:1.33
--- src/sys/arch/x86/x86/via_padlock.c:1.32	Sun May 22 11:27:34 2022
+++ src/sys/arch/x86/x86/via_padlock.c	Sun May 22 11:38:02 2022
@@ -1,5 +1,5 @@
 /*	$OpenBSD: via.c,v 1.8 2006/11/17 07:47:56 tom Exp $	*/
-/*	$NetBSD: via_padlock.c,v 1.32 2022/05/22 11:27:34 andvar Exp $ */
+/*	$NetBSD: via_padlock.c,v 1.33 2022/05/22 11:38:02 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2003 Jason Wright
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: via_padlock.c,v 1.32 2022/05/22 11:27:34 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: via_padlock.c,v 1.33 2022/05/22 11:38:02 riastradh Exp $");
 
 #include 
 #include 
@@ -504,7 +504,7 @@ via_padlock_crypto_process(void *arg, st
 out:
 	crp->crp_etype = err;
 	crypto_done(crp);
-	return (err);
+	return 0;
 }
 
 static int



CVS commit: src/sys/arch/x86/x86

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:38:03 UTC 2022

Modified Files:
src/sys/arch/x86/x86: via_padlock.c

Log Message:
padlock(4): Return zero, not error, if we've issued crypto_done.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/x86/x86/via_padlock.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/i386/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:35:21 UTC 2022

Modified Files:
src/sys/arch/i386/pci: glxsb.c

Log Message:
glxsb(4): Return zero, not error, if we've issued crypto_done.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/i386/pci/glxsb.c

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

Modified files:

Index: src/sys/arch/i386/pci/glxsb.c
diff -u src/sys/arch/i386/pci/glxsb.c:1.16 src/sys/arch/i386/pci/glxsb.c:1.17
--- src/sys/arch/i386/pci/glxsb.c:1.16	Mon Jun 29 23:32:24 2020
+++ src/sys/arch/i386/pci/glxsb.c	Sun May 22 11:35:21 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: glxsb.c,v 1.16 2020/06/29 23:32:24 riastradh Exp $	*/
+/*	$NetBSD: glxsb.c,v 1.17 2022/05/22 11:35:21 riastradh Exp $	*/
 /* $OpenBSD: glxsb.c,v 1.7 2007/02/12 14:31:45 tom Exp $ */
 
 /*
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: glxsb.c,v 1.16 2020/06/29 23:32:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: glxsb.c,v 1.17 2022/05/22 11:35:21 riastradh Exp $");
 
 #include 
 #include 
@@ -581,7 +581,7 @@ out:
 	crp->crp_etype = err;
 	crypto_done(crp);
 	splx(s);
-	return (err);
+	return 0;
 }
 
 int



CVS commit: src/sys/arch/i386/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:35:21 UTC 2022

Modified Files:
src/sys/arch/i386/pci: glxsb.c

Log Message:
glxsb(4): Return zero, not error, if we've issued crypto_done.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/i386/pci/glxsb.c

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



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:35:14 UTC 2022

Modified Files:
src/sys/dev/pci: ubsec.c

Log Message:
ubsec(4): Tidy up error branches of ubsec_process.

Make sure to return zero, not error, when we've already done
crypto_done and set crp_etype.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/pci/ubsec.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/pci/ubsec.c
diff -u src/sys/dev/pci/ubsec.c:1.56 src/sys/dev/pci/ubsec.c:1.57
--- src/sys/dev/pci/ubsec.c:1.56	Sun May 22 11:35:05 2022
+++ src/sys/dev/pci/ubsec.c	Sun May 22 11:35:13 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ubsec.c,v 1.56 2022/05/22 11:35:05 riastradh Exp $	*/
+/*	$NetBSD: ubsec.c,v 1.57 2022/05/22 11:35:13 riastradh Exp $	*/
 /* $FreeBSD: src/sys/dev/ubsec/ubsec.c,v 1.6.2.6 2003/01/23 21:06:43 sam Exp $ */
 /*	$OpenBSD: ubsec.c,v 1.143 2009/03/27 13:31:30 reyk Exp$	*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.56 2022/05/22 11:35:05 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.57 2022/05/22 11:35:13 riastradh Exp $");
 
 #undef UBSEC_DEBUG
 
@@ -1163,14 +1163,12 @@ ubsec_process(void *arg, struct cryptop 
 	crp->crp_sid, sc->sc_nsessions);
 
 	mutex_spin_enter(&sc->sc_mtx);
-
 	if (SIMPLEQ_EMPTY(&sc->sc_freequeue)) {
 		ubsecstats.hst_queuefull++;
-		sc->sc_needwakeup |= CRYPTO_SYMQ;
 		mutex_spin_exit(&sc->sc_mtx);
-		return(ERESTART);
+		err = ERESTART;
+		goto errout;
 	}
-
 	q = SIMPLEQ_FIRST(&sc->sc_freequeue);
 	SIMPLEQ_REMOVE_HEAD(&sc->sc_freequeue, /*q,*/ q_next);
 	mutex_spin_exit(&sc->sc_mtx);
@@ -1760,7 +1758,7 @@ ubsec_process(void *arg, struct cryptop 
 	if ((hint & CRYPTO_HINT_MORE) == 0 || sc->sc_nqueue >= ubsec_maxbatch)
 		ubsec_feed(sc);
 	mutex_spin_exit(&sc->sc_mtx);
-	return (0);
+	return 0;
 
 errout:
 	if (q != NULL) {
@@ -1778,19 +1776,15 @@ errout:
 		SIMPLEQ_INSERT_TAIL(&sc->sc_freequeue, q, q_next);
 		mutex_spin_exit(&sc->sc_mtx);
 	}
-#if 0 /* jonathan says: this openbsd code seems to be subsumed elsewhere */
-	if (err == EINVAL)
-		ubsecstats.hst_invalid++;
-	else
-		ubsecstats.hst_nomem++;
-#endif
-	if (err != ERESTART) {
-		crp->crp_etype = err;
-		crypto_done(crp);
-	} else {
+	if (err == ERESTART) {
+		mutex_spin_enter(&sc->sc_mtx);
 		sc->sc_needwakeup |= CRYPTO_SYMQ;
+		mutex_spin_exit(&sc->sc_mtx);
+		return ERESTART;
 	}
-	return (err);
+	crp->crp_etype = err;
+	crypto_done(crp);
+	return 0;
 }
 
 static void



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:35:14 UTC 2022

Modified Files:
src/sys/dev/pci: ubsec.c

Log Message:
ubsec(4): Tidy up error branches of ubsec_process.

Make sure to return zero, not error, when we've already done
crypto_done and set crp_etype.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/pci/ubsec.c

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



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:35:05 UTC 2022

Modified Files:
src/sys/dev/pci: ubsec.c

Log Message:
ubsec(4): Assert crp_sid is valid.

If opencrypto passes a bad sid in, that's a bug in opencrypto that
needs to be fixed, not a user-triggered invalid input that we need to
fail gracefully on.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/dev/pci/ubsec.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/pci/ubsec.c
diff -u src/sys/dev/pci/ubsec.c:1.55 src/sys/dev/pci/ubsec.c:1.56
--- src/sys/dev/pci/ubsec.c:1.55	Sun May 22 11:30:58 2022
+++ src/sys/dev/pci/ubsec.c	Sun May 22 11:35:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ubsec.c,v 1.55 2022/05/22 11:30:58 riastradh Exp $	*/
+/*	$NetBSD: ubsec.c,v 1.56 2022/05/22 11:35:05 riastradh Exp $	*/
 /* $FreeBSD: src/sys/dev/ubsec/ubsec.c,v 1.6.2.6 2003/01/23 21:06:43 sam Exp $ */
 /*	$OpenBSD: ubsec.c,v 1.143 2009/03/27 13:31:30 reyk Exp$	*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.55 2022/05/22 11:30:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.56 2022/05/22 11:35:05 riastradh Exp $");
 
 #undef UBSEC_DEBUG
 
@@ -1158,10 +1158,9 @@ ubsec_process(void *arg, struct cryptop 
 	u_int16_t flags = 0;
 	int ivlen = 0, keylen = 0;
 
-	if (UBSEC_SESSION(crp->crp_sid) >= sc->sc_nsessions) {
-		ubsecstats.hst_badsession++;
-		return (EINVAL);
-	}
+	KASSERTMSG(UBSEC_SESSION(crp->crp_sid) < sc->sc_nsessions,
+	"invalid session id 0x%"PRIx64", nsessions=%d",
+	crp->crp_sid, sc->sc_nsessions);
 
 	mutex_spin_enter(&sc->sc_mtx);
 



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:35:05 UTC 2022

Modified Files:
src/sys/dev/pci: ubsec.c

Log Message:
ubsec(4): Assert crp_sid is valid.

If opencrypto passes a bad sid in, that's a bug in opencrypto that
needs to be fixed, not a user-triggered invalid input that we need to
fail gracefully on.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/dev/pci/ubsec.c

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



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:34:57 UTC 2022

Modified Files:
src/sys/dev/pci: hifn7751.c

Log Message:
hifn(4): Make ERESTART return more obvious.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/dev/pci/hifn7751.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/pci/hifn7751.c
diff -u src/sys/dev/pci/hifn7751.c:1.77 src/sys/dev/pci/hifn7751.c:1.78
--- src/sys/dev/pci/hifn7751.c:1.77	Sun May 22 11:34:48 2022
+++ src/sys/dev/pci/hifn7751.c	Sun May 22 11:34:57 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: hifn7751.c,v 1.77 2022/05/22 11:34:48 riastradh Exp $	*/
+/*	$NetBSD: hifn7751.c,v 1.78 2022/05/22 11:34:57 riastradh Exp $	*/
 /*	$OpenBSD: hifn7751.c,v 1.179 2020/01/11 21:34:03 cheloha Exp $	*/
 
 /*
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.77 2022/05/22 11:34:48 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.78 2022/05/22 11:34:57 riastradh Exp $");
 
 #include 
 #include 
@@ -2408,7 +2408,7 @@ hifn_process(void *arg, struct cryptop *
 		sc->sc_needwakeup |= CRYPTO_SYMQ;
 		mutex_spin_exit(&sc->sc_mtx);
 		pool_cache_put(sc->sc_cmd_cache, cmd);
-		return (err);
+		return ERESTART;
 	}
 
 errout:
@@ -2426,7 +2426,7 @@ errout:
 		pool_cache_put(sc->sc_cmd_cache, cmd);
 	}
 	crypto_done(crp);
-	return (0);
+	return 0;
 }
 
 static void



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:34:57 UTC 2022

Modified Files:
src/sys/dev/pci: hifn7751.c

Log Message:
hifn(4): Make ERESTART return more obvious.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/dev/pci/hifn7751.c

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



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:34:48 UTC 2022

Modified Files:
src/sys/dev/pci: hifn7751.c

Log Message:
hifn(4): Nix dead code.  crp and callback are guaranteed nonnull.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/pci/hifn7751.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/pci/hifn7751.c
diff -u src/sys/dev/pci/hifn7751.c:1.76 src/sys/dev/pci/hifn7751.c:1.77
--- src/sys/dev/pci/hifn7751.c:1.76	Sun May 22 11:31:33 2022
+++ src/sys/dev/pci/hifn7751.c	Sun May 22 11:34:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: hifn7751.c,v 1.76 2022/05/22 11:31:33 riastradh Exp $	*/
+/*	$NetBSD: hifn7751.c,v 1.77 2022/05/22 11:34:48 riastradh Exp $	*/
 /*	$OpenBSD: hifn7751.c,v 1.179 2020/01/11 21:34:03 cheloha Exp $	*/
 
 /*
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.76 2022/05/22 11:31:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.77 2022/05/22 11:34:48 riastradh Exp $");
 
 #include 
 #include 
@@ -2177,11 +2177,6 @@ hifn_process(void *arg, struct cryptop *
 	int session, err = 0, ivlen;
 	struct cryptodesc *crd1, *crd2, *maccrd, *enccrd;
 
-	if (crp == NULL || crp->crp_callback == NULL) {
-		hifnstats.hst_invalid++;
-		return (EINVAL);
-	}
-
 	if ((cmd = pool_cache_get(sc->sc_cmd_cache, PR_NOWAIT)) == NULL) {
 		hifnstats.hst_nomem++;
 		err = ENOMEM;



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:34:48 UTC 2022

Modified Files:
src/sys/dev/pci: hifn7751.c

Log Message:
hifn(4): Nix dead code.  crp and callback are guaranteed nonnull.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/pci/hifn7751.c

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



CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:34:40 UTC 2022

Modified Files:
src/sys/opencrypto: crypto.c

Log Message:
opencrypto: Assert crp_desc and crp_buf are nonnull.

- crypto_getreq ensures crp_desc is nonnull.
- Caller is responsible for setting crp_buf.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/opencrypto/crypto.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/opencrypto/crypto.c
diff -u src/sys/opencrypto/crypto.c:1.122 src/sys/opencrypto/crypto.c:1.123
--- src/sys/opencrypto/crypto.c:1.122	Sun May 22 11:34:17 2022
+++ src/sys/opencrypto/crypto.c	Sun May 22 11:34:40 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypto.c,v 1.122 2022/05/22 11:34:17 riastradh Exp $ */
+/*	$NetBSD: crypto.c,v 1.123 2022/05/22 11:34:40 riastradh Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $	*/
 /*	$OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $	*/
 
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.122 2022/05/22 11:34:17 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.123 2022/05/22 11:34:40 riastradh Exp $");
 
 #include 
 #include 
@@ -1287,6 +1287,8 @@ crypto_dispatch(struct cryptop *crp)
 	struct crypto_crp_q *crp_q;
 
 	KASSERT(crp != NULL);
+	KASSERT(crp->crp_desc != NULL);
+	KASSERT(crp->crp_buf != NULL);
 	KASSERT(!cpu_intr_p());
 
 	DPRINTF("crp %p, alg %d\n", crp, crp->crp_desc->crd_alg);



CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:34:40 UTC 2022

Modified Files:
src/sys/opencrypto: crypto.c

Log Message:
opencrypto: Assert crp_desc and crp_buf are nonnull.

- crypto_getreq ensures crp_desc is nonnull.
- Caller is responsible for setting crp_buf.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/opencrypto/crypto.c

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



CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:34:29 UTC 2022

Modified Files:
src/sys/opencrypto: cryptodev.c

Log Message:
crypto(4): Refuse crypto operations with nothing in them earlier.

This way we avoid passing 0 to crypto_getreq -- makes it easier to
reason about everything downstream.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/opencrypto/cryptodev.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/opencrypto/cryptodev.c
diff -u src/sys/opencrypto/cryptodev.c:1.117 src/sys/opencrypto/cryptodev.c:1.118
--- src/sys/opencrypto/cryptodev.c:1.117	Sun May 22 11:30:41 2022
+++ src/sys/opencrypto/cryptodev.c	Sun May 22 11:34:29 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: cryptodev.c,v 1.117 2022/05/22 11:30:41 riastradh Exp $ */
+/*	$NetBSD: cryptodev.c,v 1.118 2022/05/22 11:34:29 riastradh Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $	*/
 /*	$OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $	*/
 
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.117 2022/05/22 11:30:41 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.118 2022/05/22 11:34:29 riastradh Exp $");
 
 #include 
 #include 
@@ -471,6 +471,9 @@ cryptodev_op(struct csession *cse, struc
 			return EINVAL;
 	}
 
+	if (cse->tcomp == NULL && cse->txform == NULL && cse->thash == NULL)
+		return EINVAL;
+
 	DPRINTF("cryptodev_op[%u]: iov_len %d\n",
 		CRYPTO_SESID2LID(cse->sid), iov_len);
 	if ((cse->tcomp) && cop->dst_len) {
@@ -1131,6 +1134,13 @@ cryptodev_mop(struct fcrypt *fcr, 
 			}
 		}
 
+		if (cse->txform == NULL &&
+		cse->thash == NULL &&
+		cse->tcomp == NULL) {
+			cnop[req].status = EINVAL;
+			goto bail;
+		}
+
 		/* sanitize */
 		if (cnop[req].len <= 0) {
 			cnop[req].status = ENOMEM;



CVS commit: src/sys/opencrypto

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:34:29 UTC 2022

Modified Files:
src/sys/opencrypto: cryptodev.c

Log Message:
crypto(4): Refuse crypto operations with nothing in them earlier.

This way we avoid passing 0 to crypto_getreq -- makes it easier to
reason about everything downstream.


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

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



CVS commit: src

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:34:17 UTC 2022

Modified Files:
src/share/man/man9: opencrypto.9
src/sys/opencrypto: crypto.c

Log Message:
opencrypto: Assert num>0 in crypto_getreq, num=1 in crypto_kgetreq.

- For crypto_getreq this makes downstream reasoning easier: on
  success, crp_desc is guaranteed to be nonnull.

- For crypto_kgetreq, this was already assumed, just silently
  ignored and not checked by anything.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/share/man/man9/opencrypto.9
cvs rdiff -u -r1.121 -r1.122 src/sys/opencrypto/crypto.c

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

Modified files:

Index: src/share/man/man9/opencrypto.9
diff -u src/share/man/man9/opencrypto.9:1.17 src/share/man/man9/opencrypto.9:1.18
--- src/share/man/man9/opencrypto.9:1.17	Mon Jul  3 21:28:48 2017
+++ src/share/man/man9/opencrypto.9	Sun May 22 11:34:17 2022
@@ -1,5 +1,5 @@
 .\"	$OpenBSD: crypto.9,v 1.25 2003/07/11 13:47:41 jmc Exp $
-.\"	$NetBSD: opencrypto.9,v 1.17 2017/07/03 21:28:48 wiz Exp $
+.\"	$NetBSD: opencrypto.9,v 1.18 2022/05/22 11:34:17 riastradh Exp $
 .\"
 .\" The author of this man page is Angelos D. Keromytis (ange...@cis.upenn.edu)
 .\"
@@ -417,7 +417,8 @@ allocates a
 .Fa cryptop
 structure with a linked list of as many
 .Fa cryptodesc
-structures as were specified in the argument passed to it.
+structures as were specified in the argument passed to it, which must
+be at least 1.
 .Pp
 .Fn crypto_freereq
 deallocates a structure
@@ -462,7 +463,8 @@ allocates a
 .Fa cryptkop
 structure.
 The first argument means the same as
-.Fn crypto_getreq .
+.Fn crypto_getreq ,
+except it is currently limited to be exactly 1.
 The second argument means flags passed to
 .Fn pool_get .
 .Pp

Index: src/sys/opencrypto/crypto.c
diff -u src/sys/opencrypto/crypto.c:1.121 src/sys/opencrypto/crypto.c:1.122
--- src/sys/opencrypto/crypto.c:1.121	Sun May 22 11:30:05 2022
+++ src/sys/opencrypto/crypto.c	Sun May 22 11:34:17 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypto.c,v 1.121 2022/05/22 11:30:05 riastradh Exp $ */
+/*	$NetBSD: crypto.c,v 1.122 2022/05/22 11:34:17 riastradh Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $	*/
 /*	$OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $	*/
 
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.121 2022/05/22 11:30:05 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.122 2022/05/22 11:34:17 riastradh Exp $");
 
 #include 
 #include 
@@ -1641,6 +1641,8 @@ crypto_getreq(int num)
 	struct cryptop *crp;
 	struct crypto_crp_ret_qs *qs;
 
+	KASSERT(num > 0);
+
 	/*
 	 * When crp_ret_q is full, we restrict here to avoid crp_ret_q overflow
 	 * by error callback.
@@ -1701,11 +1703,13 @@ crypto_kfreereq(struct cryptkop *krp)
  * Currently, support one descriptor only.
  */
 struct cryptkop *
-crypto_kgetreq(int num __unused, int prflags)
+crypto_kgetreq(int num __diagused, int prflags)
 {
 	struct cryptkop *krp;
 	struct crypto_crp_ret_qs *qs;
 
+	KASSERTMSG(num == 1, "num=%d not supported", num);
+
 	/*
 	 * When crp_ret_kq is full, we restrict here to avoid crp_ret_kq
 	 * overflow by error callback.



CVS commit: src

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:34:17 UTC 2022

Modified Files:
src/share/man/man9: opencrypto.9
src/sys/opencrypto: crypto.c

Log Message:
opencrypto: Assert num>0 in crypto_getreq, num=1 in crypto_kgetreq.

- For crypto_getreq this makes downstream reasoning easier: on
  success, crp_desc is guaranteed to be nonnull.

- For crypto_kgetreq, this was already assumed, just silently
  ignored and not checked by anything.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/share/man/man9/opencrypto.9
cvs rdiff -u -r1.121 -r1.122 src/sys/opencrypto/crypto.c

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



Re: CVS commit: src/sys/dev/marvell

2022-05-22 Thread Rin Okuyama

On 2022/05/21 19:27, Rin Okuyama wrote:

Module Name:src
Committed By:   rin
Date:   Sat May 21 10:27:30 UTC 2022

Modified Files:
src/sys/dev/marvell: if_mvgbe.c

Log Message:
m_freem() *after* bus_dmamap_sync() and bus_dmamap_load() for
that mbuf. This is mandatory for some archs.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/dev/marvell/if_mvgbe.c


s/load/unload/ here. Thanks riastradh@ for pointing out.

rin


CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:31:33 UTC 2022

Modified Files:
src/sys/dev/pci: hifn7751.c

Log Message:
hifn(4): hifn_compression always returns zero.  Prune dead branches.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/pci/hifn7751.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/pci/hifn7751.c
diff -u src/sys/dev/pci/hifn7751.c:1.75 src/sys/dev/pci/hifn7751.c:1.76
--- src/sys/dev/pci/hifn7751.c:1.75	Sun May 22 11:31:25 2022
+++ src/sys/dev/pci/hifn7751.c	Sun May 22 11:31:33 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: hifn7751.c,v 1.75 2022/05/22 11:31:25 riastradh Exp $	*/
+/*	$NetBSD: hifn7751.c,v 1.76 2022/05/22 11:31:33 riastradh Exp $	*/
 /*	$OpenBSD: hifn7751.c,v 1.179 2020/01/11 21:34:03 cheloha Exp $	*/
 
 /*
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.75 2022/05/22 11:31:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.76 2022/05/22 11:31:33 riastradh Exp $");
 
 #include 
 #include 
@@ -128,7 +128,7 @@ static void	hifn_alloc_slot(struct hifn_
 static void	hifn_write_4(struct hifn_softc *, int, bus_size_t, uint32_t);
 static uint32_t hifn_read_4(struct hifn_softc *, int, bus_size_t);
 #ifdef CRYPTO_LZS_COMP
-static int	hifn_compression(struct hifn_softc *, struct cryptop *,
+static void	hifn_compression(struct hifn_softc *, struct cryptop *,
  struct hifn_command *);
 static struct mbuf *hifn_mkmbuf_chain(int, struct mbuf *);
 static int	hifn_compress_enter(struct hifn_softc *, struct hifn_command *);
@@ -2230,9 +2230,9 @@ hifn_process(void *arg, struct cryptop *
 			enccrd = crd1;
 #ifdef CRYPTO_LZS_COMP
 		} else if (crd1->crd_alg == CRYPTO_LZS_COMP) {
-			err = hifn_compression(sc, crp, cmd);
+			hifn_compression(sc, crp, cmd);
 			mutex_spin_exit(&sc->sc_mtx);
-			return err;
+			return 0;
 #endif
 		} else {
 			err = EINVAL;
@@ -2616,7 +2616,7 @@ hifn_callback(struct hifn_softc *sc, str
 
 #ifdef CRYPTO_LZS_COMP
 
-static int
+static void
 hifn_compression(struct hifn_softc *sc, struct cryptop *crp,
 struct hifn_command *cmd)
 {
@@ -2706,10 +2706,10 @@ hifn_compression(struct hifn_softc *sc, 
 	cmd->softc = sc;
 
 	err = hifn_compress_enter(sc, cmd);
-
-	if (err != 0)
+	if (err)
 		goto fail;
-	return (0);
+
+	return;
 
 fail:
 	if (cmd->dst_map != NULL) {
@@ -2728,7 +2728,6 @@ fail:
 		hifnstats.hst_nomem++;
 	crp->crp_etype = err;
 	crypto_done(crp);
-	return (0);
 }
 
 static int



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:31:33 UTC 2022

Modified Files:
src/sys/dev/pci: hifn7751.c

Log Message:
hifn(4): hifn_compression always returns zero.  Prune dead branches.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/pci/hifn7751.c

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



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:31:25 UTC 2022

Modified Files:
src/sys/dev/pci: hifn7751.c

Log Message:
hifn(4): Fix error branches to do crypto_done, not return error.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/dev/pci/hifn7751.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/pci/hifn7751.c
diff -u src/sys/dev/pci/hifn7751.c:1.74 src/sys/dev/pci/hifn7751.c:1.75
--- src/sys/dev/pci/hifn7751.c:1.74	Sun May 17 16:01:06 2020
+++ src/sys/dev/pci/hifn7751.c	Sun May 22 11:31:25 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: hifn7751.c,v 1.74 2020/05/17 16:01:06 riastradh Exp $	*/
+/*	$NetBSD: hifn7751.c,v 1.75 2022/05/22 11:31:25 riastradh Exp $	*/
 /*	$OpenBSD: hifn7751.c,v 1.179 2020/01/11 21:34:03 cheloha Exp $	*/
 
 /*
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.74 2020/05/17 16:01:06 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.75 2022/05/22 11:31:25 riastradh Exp $");
 
 #include 
 #include 
@@ -2184,7 +2184,8 @@ hifn_process(void *arg, struct cryptop *
 
 	if ((cmd = pool_cache_get(sc->sc_cmd_cache, PR_NOWAIT)) == NULL) {
 		hifnstats.hst_nomem++;
-		return (ENOMEM);
+		err = ENOMEM;
+		goto errout;
 	}
 
 	mutex_spin_enter(&sc->sc_mtx);
@@ -2631,7 +2632,7 @@ hifn_compression(struct hifn_softc *sc, 
 		 * XXX dynamically resize them.
 		 */
 		err = EINVAL;
-		return (ENOMEM);
+		goto fail;
 	}
 
 	if ((crd->crd_flags & CRD_F_COMP) == 0)



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:31:25 UTC 2022

Modified Files:
src/sys/dev/pci: hifn7751.c

Log Message:
hifn(4): Fix error branches to do crypto_done, not return error.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/dev/pci/hifn7751.c

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



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:30:58 UTC 2022

Modified Files:
src/sys/dev/pci: ubsec.c

Log Message:
ubsec(4): ubsec_kprocess always returns zero.  Prune dead branches.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/dev/pci/ubsec.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/pci/ubsec.c
diff -u src/sys/dev/pci/ubsec.c:1.54 src/sys/dev/pci/ubsec.c:1.55
--- src/sys/dev/pci/ubsec.c:1.54	Sun May 22 11:30:49 2022
+++ src/sys/dev/pci/ubsec.c	Sun May 22 11:30:58 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ubsec.c,v 1.54 2022/05/22 11:30:49 riastradh Exp $	*/
+/*	$NetBSD: ubsec.c,v 1.55 2022/05/22 11:30:58 riastradh Exp $	*/
 /* $FreeBSD: src/sys/dev/ubsec/ubsec.c,v 1.6.2.6 2003/01/23 21:06:43 sam Exp $ */
 /*	$OpenBSD: ubsec.c,v 1.143 2009/03/27 13:31:30 reyk Exp$	*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.54 2022/05/22 11:30:49 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.55 2022/05/22 11:30:58 riastradh Exp $");
 
 #undef UBSEC_DEBUG
 
@@ -118,11 +118,11 @@ static	void	ubsec_dma_free(struct ubsec_
 static	int	ubsec_dmamap_aligned(bus_dmamap_t);
 
 static	int	ubsec_kprocess(void*, struct cryptkop *, int);
-static	int	ubsec_kprocess_modexp_sw(struct ubsec_softc *,
+static	void	ubsec_kprocess_modexp_sw(struct ubsec_softc *,
 	 struct cryptkop *, int);
-static	int	ubsec_kprocess_modexp_hw(struct ubsec_softc *,
+static	void	ubsec_kprocess_modexp_hw(struct ubsec_softc *,
 	 struct cryptkop *, int);
-static	int	ubsec_kprocess_rsapriv(struct ubsec_softc *,
+static	void	ubsec_kprocess_rsapriv(struct ubsec_softc *,
    struct cryptkop *, int);
 static	void	ubsec_kfree(struct ubsec_softc *, struct ubsec_q2 *);
 static	int	ubsec_ksigbits(struct crparam *);
@@ -2396,7 +2396,6 @@ static int
 ubsec_kprocess(void *arg, struct cryptkop *krp, int hint)
 {
 	struct ubsec_softc *sc = arg;
-	int r;
 
 	while (!SIMPLEQ_EMPTY(&sc->sc_q2free)) {
 		struct ubsec_q2 *q;
@@ -2409,27 +2408,26 @@ ubsec_kprocess(void *arg, struct cryptko
 	switch (krp->krp_op) {
 	case CRK_MOD_EXP:
 		if (sc->sc_flags & UBS_FLAGS_HWNORM)
-			r = ubsec_kprocess_modexp_hw(sc, krp, hint);
+			ubsec_kprocess_modexp_hw(sc, krp, hint);
 		else
-			r = ubsec_kprocess_modexp_sw(sc, krp, hint);
+			ubsec_kprocess_modexp_sw(sc, krp, hint);
 		break;
 	case CRK_MOD_EXP_CRT:
-		r = ubsec_kprocess_rsapriv(sc, krp, hint);
+		ubsec_kprocess_rsapriv(sc, krp, hint);
 		break;
 	default:
 		printf("%s: kprocess: invalid op 0x%x\n",
 		device_xname(sc->sc_dev), krp->krp_op);
 		krp->krp_status = EOPNOTSUPP;
 		crypto_kdone(krp);
-		r = 0;
 	}
-	return (r);
+	return 0;
 }
 
 /*
  * Start computation of cr[C] = (cr[M] ^ cr[E]) mod cr[N] (sw normalization)
  */
-static int
+static void
 ubsec_kprocess_modexp_sw(struct ubsec_softc *sc, struct cryptkop *krp,
 			 int hint)
 {
@@ -2600,7 +2598,7 @@ ubsec_kprocess_modexp_sw(struct ubsec_so
 	ubsecstats.hst_modexp++;
 	mutex_spin_exit(&sc->sc_mtx);
 
-	return (0);
+	return;
 
 errout:
 	if (me != NULL) {
@@ -2629,13 +2627,12 @@ errout:
 	}
 	krp->krp_status = err;
 	crypto_kdone(krp);
-	return (0);
 }
 
 /*
  * Start computation of cr[C] = (cr[M] ^ cr[E]) mod cr[N] (hw normalization)
  */
-static int
+static void
 ubsec_kprocess_modexp_hw(struct ubsec_softc *sc, struct cryptkop *krp,
 			 int hint)
 {
@@ -2805,7 +2802,7 @@ ubsec_kprocess_modexp_hw(struct ubsec_so
 	ubsec_feed2(sc);
 	mutex_spin_exit(&sc->sc_mtx);
 
-	return (0);
+	return;
 
 errout:
 	if (me != NULL) {
@@ -2834,10 +2831,9 @@ errout:
 	}
 	krp->krp_status = err;
 	crypto_kdone(krp);
-	return (0);
 }
 
-static int
+static void
 ubsec_kprocess_rsapriv(struct ubsec_softc *sc, struct cryptkop *krp,
 		   int hint)
 {
@@ -3004,7 +3000,7 @@ ubsec_kprocess_rsapriv(struct ubsec_soft
 	ubsec_feed2(sc);
 	ubsecstats.hst_modexpcrt++;
 	mutex_spin_exit(&sc->sc_mtx);
-	return (0);
+	return;
 
 errout:
 	if (rp != NULL) {
@@ -3024,7 +3020,6 @@ errout:
 	}
 	krp->krp_status = err;
 	crypto_kdone(krp);
-	return (0);
 }
 
 #ifdef UBSEC_DEBUG



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:30:58 UTC 2022

Modified Files:
src/sys/dev/pci: ubsec.c

Log Message:
ubsec(4): ubsec_kprocess always returns zero.  Prune dead branches.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/dev/pci/ubsec.c

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



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:30:49 UTC 2022

Modified Files:
src/sys/dev/pci: ubsec.c

Log Message:
ubsec(4): Fix error branch: call crypto_kdone, don't return error.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/dev/pci/ubsec.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/pci/ubsec.c
diff -u src/sys/dev/pci/ubsec.c:1.53 src/sys/dev/pci/ubsec.c:1.54
--- src/sys/dev/pci/ubsec.c:1.53	Wed May 18 12:48:49 2022
+++ src/sys/dev/pci/ubsec.c	Sun May 22 11:30:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ubsec.c,v 1.53 2022/05/18 12:48:49 riastradh Exp $	*/
+/*	$NetBSD: ubsec.c,v 1.54 2022/05/22 11:30:49 riastradh Exp $	*/
 /* $FreeBSD: src/sys/dev/ubsec/ubsec.c,v 1.6.2.6 2003/01/23 21:06:43 sam Exp $ */
 /*	$OpenBSD: ubsec.c,v 1.143 2009/03/27 13:31:30 reyk Exp$	*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.53 2022/05/18 12:48:49 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.54 2022/05/22 11:30:49 riastradh Exp $");
 
 #undef UBSEC_DEBUG
 
@@ -2883,8 +2883,10 @@ ubsec_kprocess_rsapriv(struct ubsec_soft
 	}
 
 	rp = malloc(sizeof *rp, M_DEVBUF, M_NOWAIT|M_ZERO);
-	if (rp == NULL)
-		return (ENOMEM);
+	if (rp == NULL) {
+		err = ENOMEM;
+		goto errout;
+	}
 	rp->rpr_krp = krp;
 	rp->rpr_q.q_type = UBS_CTXOP_RSAPRIV;
 



CVS commit: src/sys/dev/pci

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:30:49 UTC 2022

Modified Files:
src/sys/dev/pci: ubsec.c

Log Message:
ubsec(4): Fix error branch: call crypto_kdone, don't return error.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/dev/pci/ubsec.c

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



CVS commit: src/sys

2022-05-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 22 11:30:41 UTC 2022

Modified Files:
src/sys/netipsec: xform_ah.c xform_esp.c xform_ipcomp.c
src/sys/opencrypto: cryptodev.c cryptodev.h

Log Message:
opencrypto: Make crp_callback, krp_callback return void.

Nothing uses the return values inside opencrypto, so let's stop
making users return them.


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.101 -r1.102 src/sys/netipsec/xform_esp.c
cvs rdiff -u -r1.69 -r1.70 src/sys/netipsec/xform_ipcomp.c
cvs rdiff -u -r1.116 -r1.117 src/sys/opencrypto/cryptodev.c
cvs rdiff -u -r1.45 -r1.46 src/sys/opencrypto/cryptodev.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/netipsec/xform_ah.c
diff -u src/sys/netipsec/xform_ah.c:1.109 src/sys/netipsec/xform_ah.c:1.110
--- src/sys/netipsec/xform_ah.c:1.109	Fri Nov  1 04:23:21 2019
+++ src/sys/netipsec/xform_ah.c	Sun May 22 11:30:40 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_ah.c,v 1.109 2019/11/01 04:23:21 knakahara Exp $	*/
+/*	$NetBSD: xform_ah.c,v 1.110 2022/05/22 11:30:40 riastradh Exp $	*/
 /*	$FreeBSD: xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */
 /*
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.109 2019/11/01 04:23:21 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.110 2022/05/22 11:30:40 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -108,8 +108,8 @@ static const char ipseczeroes[256];
 
 int ah_max_authsize;			/* max authsize over all algorithms */
 
-static int ah_input_cb(struct cryptop *);
-static int ah_output_cb(struct cryptop *);
+static void ah_input_cb(struct cryptop *);
+static void ah_output_cb(struct cryptop *);
 
 const uint8_t ah_stats[256] = { SADB_AALG_STATS_INIT };
 
@@ -713,24 +713,24 @@ bad:
 #ifdef INET6
 #define	IPSEC_COMMON_INPUT_CB(m, sav, skip, protoff) do {		 \
 	if (saidx->dst.sa.sa_family == AF_INET6) {			 \
-		error = ipsec6_common_input_cb(m, sav, skip, protoff);	 \
+		(void)ipsec6_common_input_cb(m, sav, skip, protoff);	 \
 	} else {			 \
-		error = ipsec4_common_input_cb(m, sav, skip, protoff);	 \
+		(void)ipsec4_common_input_cb(m, sav, skip, protoff);	 \
 	} \
 } while (0)
 #else
 #define	IPSEC_COMMON_INPUT_CB(m, sav, skip, protoff)			 \
-	(error = ipsec4_common_input_cb(m, sav, skip, protoff))
+	((void)ipsec4_common_input_cb(m, sav, skip, protoff))
 #endif
 
 /*
  * AH input callback from the crypto driver.
  */
-static int
+static void
 ah_input_cb(struct cryptop *crp)
 {
 	char buf[IPSEC_ADDRSTRLEN];
-	int rplen, ahsize, error, skip, protoff;
+	int rplen, ahsize, skip, protoff;
 	unsigned char calc[AH_ALEN_MAX];
 	struct mbuf *m;
 	struct tdb_crypto *tc;
@@ -776,12 +776,12 @@ ah_input_cb(struct cryptop *crp)
 
 		if (crp->crp_etype == EAGAIN) {
 			IPSEC_RELEASE_GLOBAL_LOCKS();
-			return crypto_dispatch(crp);
+			(void)crypto_dispatch(crp);
+			return;
 		}
 
 		AH_STATINC(AH_STAT_NOXFORM);
 		DPRINTF("crypto error %d\n", crp->crp_etype);
-		error = crp->crp_etype;
 		goto bad;
 	} else {
 		AH_STATINC(AH_STAT_HIST + ah_stats[sav->alg_auth]);
@@ -814,7 +814,6 @@ ah_input_cb(struct cryptop *crp)
 		 [4], [5], [6], [7],
 		 [8], [9], [10], [11]);
 		AH_STATINC(AH_STAT_BADAUTH);
-		error = EACCES;
 		goto bad;
 	}
 
@@ -845,7 +844,6 @@ ah_input_cb(struct cryptop *crp)
 		sizeof(seq), &seq);
 		if (ipsec_updatereplay(ntohl(seq), sav)) {
 			AH_STATINC(AH_STAT_REPLAY);
-			error = EACCES;
 			goto bad;
 		}
 	}
@@ -853,8 +851,7 @@ ah_input_cb(struct cryptop *crp)
 	/*
 	 * Remove the AH header and authenticator from the mbuf.
 	 */
-	error = m_striphdr(m, skip, ahsize);
-	if (error) {
+	if (m_striphdr(m, skip, ahsize) != 0) {
 		DPRINTF("mangled mbuf chain for SA %s/%08lx\n",
 		ipsec_address(&saidx->dst, buf, sizeof(buf)),
 		(u_long) ntohl(sav->spi));
@@ -867,7 +864,7 @@ ah_input_cb(struct cryptop *crp)
 
 	KEY_SA_UNREF(&sav);
 	IPSEC_RELEASE_GLOBAL_LOCKS();
-	return error;
+	return;
 
 bad:
 	if (sav)
@@ -883,7 +880,7 @@ bad:
 	}
 	if (crp != NULL)
 		crypto_freereq(crp);
-	return error;
+	return;
 }
 
 /*
@@ -1135,16 +1132,16 @@ bad:
 /*
  * AH output callback from the crypto driver.
  */
-static int
+static void
 ah_output_cb(struct cryptop *crp)
 {
-	int skip, error;
+	int skip;
 	struct tdb_crypto *tc;
 	const struct ipsecrequest *isr;
 	struct secasvar *sav;
 	struct mbuf *m;
 	void *ptr;
-	int err, flags;
+	int flags;
 	size_t size;
 	bool pool_used;
 	IPSEC_DECLARE_LOCK_VARIABLE;
@@ -1169,12 +1166,12 @@ ah_output_cb(struct cryptop *crp)
 
 		if (crp->crp_etype == EAGAIN) {
 			IPSEC_RELEASE_GLOBAL_LOCKS();
-			return crypto_dispatch(crp);
+			(void)crypto_dispatch(crp);
+			return;
 		}
 
 		A

  1   2   >