CVS commit: src/sys/dev/pci

2024-06-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Jun 14 03:15:04 UTC 2024

Modified Files:
src/sys/dev/pci: pcireg.h

Log Message:
PCI_CLASS_MASK: Use unsigned to avoid undefined behavior. Found by kUBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/sys/dev/pci/pcireg.h

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

Modified files:

Index: src/sys/dev/pci/pcireg.h
diff -u src/sys/dev/pci/pcireg.h:1.170 src/sys/dev/pci/pcireg.h:1.171
--- src/sys/dev/pci/pcireg.h:1.170	Fri Apr 19 21:24:00 2024
+++ src/sys/dev/pci/pcireg.h	Fri Jun 14 03:15:04 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcireg.h,v 1.170 2024/04/19 21:24:00 andvar Exp $	*/
+/*	$NetBSD: pcireg.h,v 1.171 2024/06/14 03:15:04 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1999, 2000
@@ -135,7 +135,7 @@ typedef u_int8_t pci_interface_t;
 typedef u_int8_t pci_revision_t;
 
 #define	PCI_CLASS_SHIFT			24
-#define	PCI_CLASS_MASK			0xff
+#define	PCI_CLASS_MASK			0xffU
 #define	PCI_CLASS(cr) \
 	(((cr) >> PCI_CLASS_SHIFT) & PCI_CLASS_MASK)
 



CVS commit: src/sys/dev/pci

2024-06-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Jun 14 03:15:04 UTC 2024

Modified Files:
src/sys/dev/pci: pcireg.h

Log Message:
PCI_CLASS_MASK: Use unsigned to avoid undefined behavior. Found by kUBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/sys/dev/pci/pcireg.h

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



CVS commit: src/external/bsd/libarchive/dist/libarchive/test

2024-06-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jun 13 23:24:25 UTC 2024

Modified Files:
src/external/bsd/libarchive/dist/libarchive/test:
test_read_disk_directory_traversals.c

Log Message:
PR/58342: Martin Husemann: NetBSD does not really support O_SEARCH


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \

src/external/bsd/libarchive/dist/libarchive/test/test_read_disk_directory_traversals.c

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

Modified files:

Index: src/external/bsd/libarchive/dist/libarchive/test/test_read_disk_directory_traversals.c
diff -u src/external/bsd/libarchive/dist/libarchive/test/test_read_disk_directory_traversals.c:1.3 src/external/bsd/libarchive/dist/libarchive/test/test_read_disk_directory_traversals.c:1.4
--- src/external/bsd/libarchive/dist/libarchive/test/test_read_disk_directory_traversals.c:1.3	Sun Jun  9 15:47:56 2024
+++ src/external/bsd/libarchive/dist/libarchive/test/test_read_disk_directory_traversals.c	Thu Jun 13 19:24:25 2024
@@ -1607,8 +1607,9 @@ test_parent(void)
 	int file_count;
 	int match_count;
 	int r;
-#if defined(O_PATH) || defined(O_SEARCH) || \
+#if defined(O_PATH) || (defined(O_SEARCH) && !defined(__NetBSD__)) || \
  (defined(__FreeBSD__) && defined(O_EXEC))
+#define IGNORE_TRAVERSALS_TEST4
 	const char *ignore_traversals_test4;
 
 	ignore_traversals_test4 = getenv("IGNORE_TRAVERSALS_TEST4");
@@ -1787,8 +1788,7 @@ test_parent(void)
 	archive_entry_clear(ae);
 	r = archive_read_next_header2(a, ae);
 	if (r == ARCHIVE_FAILED) {
-#if defined(O_PATH) || defined(O_SEARCH) || \
- (defined(__FreeBSD__) && defined(O_EXEC))
+#ifdef IGNORE_TRAVERSALS_TEST4
 		if (ignore_traversals_test4 == NULL)
 			assertEqualIntA(a, ARCHIVE_OK, r);
 #endif



CVS commit: src/external/bsd/libarchive/dist/libarchive/test

2024-06-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jun 13 23:24:25 UTC 2024

Modified Files:
src/external/bsd/libarchive/dist/libarchive/test:
test_read_disk_directory_traversals.c

Log Message:
PR/58342: Martin Husemann: NetBSD does not really support O_SEARCH


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \

src/external/bsd/libarchive/dist/libarchive/test/test_read_disk_directory_traversals.c

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



CVS commit: src

2024-06-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jun 13 21:03:33 UTC 2024

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/lib/libarchive: Makefile

Log Message:
Add new test files for new libarchive version


To generate a diff of this commit:
cvs rdiff -u -r1.1320 -r1.1321 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libarchive/Makefile

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



CVS commit: src

2024-06-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jun 13 21:03:33 UTC 2024

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/lib/libarchive: Makefile

Log Message:
Add new test files for new libarchive version


To generate a diff of this commit:
cvs rdiff -u -r1.1320 -r1.1321 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libarchive/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/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1320 src/distrib/sets/lists/tests/mi:1.1321
--- src/distrib/sets/lists/tests/mi:1.1320	Mon Jun 10 10:07:27 2024
+++ src/distrib/sets/lists/tests/mi	Thu Jun 13 21:03:33 2024
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1320 2024/06/10 10:07:27 kre Exp $
+# $NetBSD: mi,v 1.1321 2024/06/13 21:03:33 martin Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -2603,6 +2603,8 @@
 ./usr/tests/lib/libarchive/test_compat_lz4_B7BD.tar.lz4.uutests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_compat_lzip_1.tlz.uu	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_compat_lzip_2.tlz.uu	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libarchive/test_compat_lzip_3.lz.uu			tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libarchive/test_compat_lzip_4.tlz.uu			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_compat_lzma_1.tlz.uu	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_compat_lzma_2.tlz.uu	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_compat_lzma_3.tlz.uu	tests-lib-tests		compattestfile,atf
@@ -2618,6 +2620,7 @@
 ./usr/tests/lib/libarchive/test_compat_solaris_tar_acl.tar.uutests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_compat_star_acl_nfs4.tar.uutests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_compat_star_acl_posix1e.tar.uutests-lib-tests		compattestfile,atf
+./usr/tests/lib/libarchive/test_compat_tar_directory_1.tar.uutests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_compat_tar_hardlink_1.tar.uutests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_compat_uudecode_large.tar.Z.uutests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_compat_xz_1.txz.uu	tests-lib-tests		compattestfile,atf
@@ -2675,6 +2678,9 @@
 ./usr/tests/lib/libarchive/test_read_format_7zip_copy.7z.uutests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_read_format_7zip_copy_2.7z.uutests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_read_format_7zip_deflate.7z.uutests-lib-tests		compattestfile,atf
+./usr/tests/lib/libarchive/test_read_format_7zip_deflate_arm64.7z.uu	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libarchive/test_read_format_7zip_delta4_lzma1.7z.uu	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libarchive/test_read_format_7zip_delta4_lzma2.7z.uu	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_read_format_7zip_delta_lzma1.7z.uu			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_read_format_7zip_delta_lzma2.7z.uu			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_read_format_7zip_empty_archive.7z.uu			tests-lib-tests		compattestfile,atf
@@ -2686,10 +2692,12 @@
 ./usr/tests/lib/libarchive/test_read_format_7zip_lzma1_2.7z.uutests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_read_format_7zip_lzma1_lzma2.7z.uu			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_read_format_7zip_lzma2.7z.uutests-lib-tests		compattestfile,atf
+./usr/tests/lib/libarchive/test_read_format_7zip_lzma2_arm.7z.uu	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_read_format_7zip_malformed.7z.uu			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_read_format_7zip_malformed2.7z.uu			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_read_format_7zip_ppmd.7z.uutests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_read_format_7zip_symbolic_name.7z.uu			tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libarchive/test_read_format_7zip_win_attrib.7z.uu	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_read_format_ar.ar.uu	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_read_format_cab_1.cab.uutests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_read_format_cab_2.cab.uutests-lib-tests		compattestfile,atf
@@ -2745,8 +2753,15 @@
 ./usr/tests/lib/libarchive/test_read_format_mtree_noprint.mtree.uu			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_read_format_rar.rar.uu	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libarchive/test_read_format_rar5_arm.rar.uu

CVS commit: src/sys/arch/xen/xen

2024-06-13 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Jun 13 14:47:54 UTC 2024

Modified Files:
src/sys/arch/xen/xen: xbdback_xenbus.c

Log Message:
Get req->handle and req->sector_number from the correct structure for the
current opertation. They happen to be at the same offset in all structures
so NFC, but better be correct, it may help for future changes.
While there KASSERT() that our indirect segments fits in a single page.


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/arch/xen/xen/xbdback_xenbus.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/xen/xen/xbdback_xenbus.c
diff -u src/sys/arch/xen/xen/xbdback_xenbus.c:1.103 src/sys/arch/xen/xen/xbdback_xenbus.c:1.104
--- src/sys/arch/xen/xen/xbdback_xenbus.c:1.103	Sat Feb 25 00:35:28 2023
+++ src/sys/arch/xen/xen/xbdback_xenbus.c	Thu Jun 13 14:47:54 2024
@@ -1,4 +1,4 @@
-/*  $NetBSD: xbdback_xenbus.c,v 1.103 2023/02/25 00:35:28 riastradh Exp $  */
+/*  $NetBSD: xbdback_xenbus.c,v 1.104 2024/06/13 14:47:54 bouyer Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.103 2023/02/25 00:35:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.104 2024/06/13 14:47:54 bouyer Exp $");
 
 #include 
 #include 
@@ -1136,18 +1136,20 @@ xbdback_co_io(struct xbdback_instance *x
 	case XBDIP_NATIVE:
 		reqn = RING_GET_REQUEST(>xbdi_ring.ring_n,
 		xbdi->xbdi_ring.ring_n.req_cons);
-		req->handle = reqn->handle;
-		req->sector_number = reqn->sector_number;
 		if (reqn->operation == BLKIF_OP_INDIRECT) {
 			rinn = (blkif_request_indirect_t *)reqn;
 			req->operation = rinn->indirect_op;
-			req->nr_segments = (uint8_t)rinn->nr_segments;
-			if (req->nr_segments > VBD_MAX_INDIRECT_SEGMENTS)
+			req->handle = rinn->handle;
+			if (rinn->nr_segments > VBD_MAX_INDIRECT_SEGMENTS)
 goto bad_nr_segments;
+			req->nr_segments = (uint8_t)rinn->nr_segments;
+			req->sector_number = rinn->sector_number;
 			xbdi->xbdi_in_gntref = rinn->indirect_grefs[0];
 			/* first_sect and segment grefs fetched later */
 		} else {
+			req->handle = reqn->handle;
 			req->nr_segments = reqn->nr_segments;
+			req->sector_number = reqn->sector_number;
 			if (req->nr_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST)
 goto bad_nr_segments;
 			for (i = 0; i < req->nr_segments; i++)
@@ -1158,18 +1160,20 @@ xbdback_co_io(struct xbdback_instance *x
 	case XBDIP_32:
 		req32 = RING_GET_REQUEST(>xbdi_ring.ring_32,
 		xbdi->xbdi_ring.ring_n.req_cons);
-		req->handle = req32->handle;
-		req->sector_number = req32->sector_number;
 		if (req32->operation == BLKIF_OP_INDIRECT) {
 			rin32 = (blkif_x86_32_request_indirect_t *)req32;
 			req->operation = rin32->indirect_op;
-			req->nr_segments = (uint8_t)rin32->nr_segments;
-			if (req->nr_segments > VBD_MAX_INDIRECT_SEGMENTS)
+			req->handle = rin32->handle;
+			if (rin32->nr_segments > VBD_MAX_INDIRECT_SEGMENTS)
 goto bad_nr_segments;
+			req->nr_segments = (uint8_t)rin32->nr_segments;
+			req->sector_number = rin32->sector_number;
 			xbdi->xbdi_in_gntref = rin32->indirect_grefs[0];
 			/* first_sect and segment grefs fetched later */
 		} else {
+			req->handle = req32->handle;
 			req->nr_segments = req32->nr_segments;
+			req->sector_number = req32->sector_number;
 			if (req->nr_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST)
 goto bad_nr_segments;
 			for (i = 0; i < req->nr_segments; i++)
@@ -1180,17 +1184,20 @@ xbdback_co_io(struct xbdback_instance *x
 	case XBDIP_64:
 		req64 = RING_GET_REQUEST(>xbdi_ring.ring_64,
 		xbdi->xbdi_ring.ring_n.req_cons);
-		req->handle = req64->handle;
-		req->sector_number = req64->sector_number;
 		if (req64->operation == BLKIF_OP_INDIRECT) {
 			rin64 = (blkif_x86_64_request_indirect_t *)req64;
-			req->nr_segments = (uint8_t)rin64->nr_segments;
-			if (req->nr_segments > VBD_MAX_INDIRECT_SEGMENTS)
+			req->operation = rin64->indirect_op;
+			req->handle = rin64->handle;
+			if (rin64->nr_segments > VBD_MAX_INDIRECT_SEGMENTS)
 goto bad_nr_segments;
+			req->nr_segments = (uint8_t)rin64->nr_segments;
+			req->sector_number = rin64->sector_number;
 			xbdi->xbdi_in_gntref = rin64->indirect_grefs[0];
 			/* first_sect and segment grefs fetched later */
 		} else {
+			req->handle = req64->handle;
 			req->nr_segments = req64->nr_segments;
+			req->sector_number = req64->sector_number;
 			if (req->nr_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST)
 goto bad_nr_segments;
 			for (i = 0; i < req->nr_segments; i++)
@@ -1269,6 +1276,8 @@ xbdback_co_io_gotio(struct xbdback_insta
 		gop.dest.domid = DOMID_SELF;
 		gop.dest.u.gmfn = ma >> PAGE_SHIFT;
 
+		KASSERT(gop.dest.offset + gop.len <= PAGE_SIZE);
+
 		if (HYPERVISOR_grant_table_op(GNTTABOP_copy, , 1) != 0) {
 			printf("%s: GNTTABOP_copy failed\n", xbdi->xbdi_name);
 			

CVS commit: src/sys/arch/xen/xen

2024-06-13 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Jun 13 14:47:54 UTC 2024

Modified Files:
src/sys/arch/xen/xen: xbdback_xenbus.c

Log Message:
Get req->handle and req->sector_number from the correct structure for the
current opertation. They happen to be at the same offset in all structures
so NFC, but better be correct, it may help for future changes.
While there KASSERT() that our indirect segments fits in a single page.


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/arch/xen/xen/xbdback_xenbus.c

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