CVS commit: [netbsd-10] src/doc

2023-03-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar 20 17:25:14 UTC 2023

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

Log Message:
Ticket #122


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

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



CVS commit: [netbsd-10] src/doc

2023-03-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar 20 17:25:14 UTC 2023

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

Log Message:
Ticket #122


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

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

Modified files:

Index: src/doc/CHANGES-10.0
diff -u src/doc/CHANGES-10.0:1.1.2.45 src/doc/CHANGES-10.0:1.1.2.46
--- src/doc/CHANGES-10.0:1.1.2.45	Wed Mar 15 18:42:44 2023
+++ src/doc/CHANGES-10.0	Mon Mar 20 17:25:14 2023
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-10.0,v 1.1.2.45 2023/03/15 18:42:44 martin Exp $
+# $NetBSD: CHANGES-10.0,v 1.1.2.46 2023/03/20 17:25:14 martin Exp $
 
 A complete list of changes from the initial NetBSD 10.0 branch on 2022-12-16
 until the 10.0 release:
@@ -1488,3 +1488,13 @@ sys/dev/vnd.c	1.288
 	vnd(4): PR 57263: avoid deadlock.
 	[hannken, ticket #121]
 
+sys/dev/wscons/wsdisplay.c			1.166
+sys/dev/wscons/wsdisplayvar.h			1.57
+sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c 1.11
+sys/external/bsd/drm2/nouveau/nouveau_pci.c	1.37
+sys/external/bsd/drm2/radeon/radeon_pci.c	1.22
+
+	PRs 53126, 56714: fix nouveau and amdgpu booting via UEFI bootloader.
+	Fix bogus loop invariant assertions.
+	[mrg, ticket #122]
+



CVS commit: [netbsd-10] src/sys

2023-03-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar 20 17:24:15 UTC 2023

Modified Files:
src/sys/dev/wscons [netbsd-10]: wsdisplay.c wsdisplayvar.h
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu [netbsd-10]:
amdgpu_gart.c
src/sys/external/bsd/drm2/nouveau [netbsd-10]: nouveau_pci.c
src/sys/external/bsd/drm2/radeon [netbsd-10]: radeon_pci.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #122):

sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c: revision 1.11
sys/external/bsd/drm2/nouveau/nouveau_pci.c: revision 1.37
sys/external/bsd/drm2/radeon/radeon_pci.c: revision 1.22
sys/dev/wscons/wsdisplay.c: revision 1.166
sys/dev/wscons/wsdisplayvar.h: revision 1.57

amdgpu: Fix bogus loop invariant assertions in amdgpu_gart_map.
nouveau: Kick out genfb on firmware framebuffer before initializing.

PR kern/53126

radeon: Kick out genfb on firmware framebuffer before initializing.
this is the same change as nouveau_pci.c:1.37, and should fix at
least PR#56714 and i thought at least another PR i can't find right
now.  it fixes at least 2 different radeon cards for me on UEFI
booted system.


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.165.4.1 src/sys/dev/wscons/wsdisplay.c
cvs rdiff -u -r1.56 -r1.56.4.1 src/sys/dev/wscons/wsdisplayvar.h
cvs rdiff -u -r1.10 -r1.10.4.1 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c
cvs rdiff -u -r1.36 -r1.36.4.1 \
src/sys/external/bsd/drm2/nouveau/nouveau_pci.c
cvs rdiff -u -r1.21 -r1.21.4.1 src/sys/external/bsd/drm2/radeon/radeon_pci.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/wscons/wsdisplay.c
diff -u src/sys/dev/wscons/wsdisplay.c:1.165 src/sys/dev/wscons/wsdisplay.c:1.165.4.1
--- src/sys/dev/wscons/wsdisplay.c:1.165	Sun Jul 17 11:43:39 2022
+++ src/sys/dev/wscons/wsdisplay.c	Mon Mar 20 17:24:15 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: wsdisplay.c,v 1.165 2022/07/17 11:43:39 riastradh Exp $ */
+/* $NetBSD: wsdisplay.c,v 1.165.4.1 2023/03/20 17:24:15 martin Exp $ */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.165 2022/07/17 11:43:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.165.4.1 2023/03/20 17:24:15 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_wsdisplay_compat.h"
@@ -982,6 +982,15 @@ wsdisplay_preattach(const struct wsscree
 }
 
 void
+wsdisplay_predetach(void)
+{
+	KASSERT(wsdisplay_console_initted == 1);
+
+	cn_tab = wsdisplay_ocn;
+	wsdisplay_console_initted = 0;
+}
+
+void
 wsdisplay_cndetach(void)
 {
 	KASSERT(wsdisplay_console_initted == 2);

Index: src/sys/dev/wscons/wsdisplayvar.h
diff -u src/sys/dev/wscons/wsdisplayvar.h:1.56 src/sys/dev/wscons/wsdisplayvar.h:1.56.4.1
--- src/sys/dev/wscons/wsdisplayvar.h:1.56	Sat Jan 29 01:19:30 2022
+++ src/sys/dev/wscons/wsdisplayvar.h	Mon Mar 20 17:24:15 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: wsdisplayvar.h,v 1.56 2022/01/29 01:19:30 uwe Exp $ */
+/* $NetBSD: wsdisplayvar.h,v 1.56.4.1 2023/03/20 17:24:15 martin Exp $ */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -172,6 +172,7 @@ void	wsdisplay_cnattach(const struct wss
 long);
 void	wsdisplay_preattach(const struct wsscreen_descr *, void *, int, int,
 long);
+void	wsdisplay_predetach(void);
 void	wsdisplay_cndetach(void);
 void	wsdisplay_multicons_suspend(bool);
 

Index: src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c
diff -u src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c:1.10 src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c:1.10.4.1
--- src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c:1.10	Sat Jul 30 17:12:39 2022
+++ src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c	Mon Mar 20 17:24:14 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdgpu_gart.c,v 1.10 2022/07/30 17:12:39 riastradh Exp $	*/
+/*	$NetBSD: amdgpu_gart.c,v 1.10.4.1 2023/03/20 17:24:14 martin Exp $	*/
 
 /*
  * Copyright 2008 Advanced Micro Devices, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_gart.c,v 1.10 2022/07/30 17:12:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_gart.c,v 1.10.4.1 2023/03/20 17:24:14 martin Exp $");
 
 #include 
 #include 
@@ -440,8 +440,9 @@ int amdgpu_gart_map(struct amdgpu_device
 	t = gpu_start / AMDGPU_GPU_PAGE_SIZE;
 
 	for (i = 0; npages --> 0;) {
-		KASSERT(i < dmamap->dm_nsegs);
 		for (j = 0; j < AMDGPU_GPU_PAGES_IN_CPU_PAGE; j++) {
+			KASSERT(i < dmamap->dm_nsegs);
+			KASSERT(seg_off < dmamap->dm_segs[i].ds_len);
 			amdgpu_gmc_set_pte_pde(adev, dst, t,
 			dmamap->dm_segs[i].ds_addr + seg_off, flags);
 			seg_off += AMDGPU_GPU_PAGE_SIZE;
@@ -449,7 +450,6 @@ int amdgpu_gart_map(struct amdgpu_device
 i++;
 seg_off 

CVS commit: [netbsd-10] src/sys

2023-03-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar 20 17:24:15 UTC 2023

Modified Files:
src/sys/dev/wscons [netbsd-10]: wsdisplay.c wsdisplayvar.h
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu [netbsd-10]:
amdgpu_gart.c
src/sys/external/bsd/drm2/nouveau [netbsd-10]: nouveau_pci.c
src/sys/external/bsd/drm2/radeon [netbsd-10]: radeon_pci.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #122):

sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c: revision 1.11
sys/external/bsd/drm2/nouveau/nouveau_pci.c: revision 1.37
sys/external/bsd/drm2/radeon/radeon_pci.c: revision 1.22
sys/dev/wscons/wsdisplay.c: revision 1.166
sys/dev/wscons/wsdisplayvar.h: revision 1.57

amdgpu: Fix bogus loop invariant assertions in amdgpu_gart_map.
nouveau: Kick out genfb on firmware framebuffer before initializing.

PR kern/53126

radeon: Kick out genfb on firmware framebuffer before initializing.
this is the same change as nouveau_pci.c:1.37, and should fix at
least PR#56714 and i thought at least another PR i can't find right
now.  it fixes at least 2 different radeon cards for me on UEFI
booted system.


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.165.4.1 src/sys/dev/wscons/wsdisplay.c
cvs rdiff -u -r1.56 -r1.56.4.1 src/sys/dev/wscons/wsdisplayvar.h
cvs rdiff -u -r1.10 -r1.10.4.1 \
src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c
cvs rdiff -u -r1.36 -r1.36.4.1 \
src/sys/external/bsd/drm2/nouveau/nouveau_pci.c
cvs rdiff -u -r1.21 -r1.21.4.1 src/sys/external/bsd/drm2/radeon/radeon_pci.c

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



CVS commit: src

2023-03-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Mar 20 11:19:30 UTC 2023

Modified Files:
src/sys/arch/sparc/sparc: syscall.c vm_machdep.c
src/tests/lib/libc/sys: t_ptrace_syscall_wait.h

Log Message:
Adjust pc/npc before syscall allowing EJUSTRETURN to return
to the next instruction.  Only ERESTART should return to
the same instruction.  Differences to sparc64 reduced.

Test t_ptrace_wait:syscallemu1 now passes on sparc.

Fixes PR kern/52166 "syscallemu does not work on sparc (32-bit)"

Ok: Martin Husemann


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/sparc/sparc/syscall.c
cvs rdiff -u -r1.107 -r1.108 src/sys/arch/sparc/sparc/vm_machdep.c
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_ptrace_syscall_wait.h

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

Modified files:

Index: src/sys/arch/sparc/sparc/syscall.c
diff -u src/sys/arch/sparc/sparc/syscall.c:1.31 src/sys/arch/sparc/sparc/syscall.c:1.32
--- src/sys/arch/sparc/sparc/syscall.c:1.31	Sat Apr  6 11:54:20 2019
+++ src/sys/arch/sparc/sparc/syscall.c	Mon Mar 20 11:19:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: syscall.c,v 1.31 2019/04/06 11:54:20 kamil Exp $ */
+/*	$NetBSD: syscall.c,v 1.32 2023/03/20 11:19:29 hannken Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.31 2019/04/06 11:54:20 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.32 2023/03/20 11:19:29 hannken Exp $");
 
 #include "opt_sparc_arch.h"
 #include "opt_multiprocessor.h"
@@ -106,6 +106,17 @@ handle_new(struct trapframe *tf, registe
 {
 	int new = *code & (SYSCALL_G7RFLAG|SYSCALL_G2RFLAG|SYSCALL_G5RFLAG);
 	*code &= ~(SYSCALL_G7RFLAG|SYSCALL_G2RFLAG|SYSCALL_G5RFLAG);
+	if (new) {
+		/* jmp %g5, (or %g2 or %g7, deprecated) on success */
+		if (__predict_true((new & SYSCALL_G5RFLAG) == SYSCALL_G5RFLAG))
+			tf->tf_pc = tf->tf_global[5];
+		else if (new & SYSCALL_G2RFLAG)
+			tf->tf_pc = tf->tf_global[2];
+		else
+			tf->tf_pc = tf->tf_global[7];
+	} else {
+		tf->tf_pc = tf->tf_npc;
+	}
 	return new;
 }
 
@@ -207,7 +218,7 @@ syscall(register_t code, struct trapfram
 	int error, new;
 	union args args;
 	union rval rval;
-	register_t i;
+	int opc, onpc;
 	u_quad_t sticks;
 
 	curcpu()->ci_data.cpu_nsyscall++;	/* XXXSMP */
@@ -221,8 +232,18 @@ syscall(register_t code, struct trapfram
 #ifdef FPU_DEBUG
 	save_fpu(tf);
 #endif
+
+	/*
+	 * save pc/npc in case of ERESTART
+	 * adjust pc/npc to new values
+	 */
+	opc = tf->tf_pc;
+	onpc = tf->tf_npc;
+
 	new = handle_new(tf, );
 
+	tf->tf_npc = tf->tf_pc + 4;
+
 	if ((error = getargs(p, tf, , , )) != 0)
 		goto bad;
 
@@ -236,29 +257,17 @@ syscall(register_t code, struct trapfram
 		/* Note: fork() does not return here in the child */
 		tf->tf_out[0] = rval.o[0];
 		tf->tf_out[1] = rval.o[1];
-		if (new) {
-			/* jmp %g5, (or %g2 or %g7, deprecated) on success */
-			if (__predict_true((new & SYSCALL_G5RFLAG) ==
-	SYSCALL_G5RFLAG))
-i = tf->tf_global[5];
-			else if (new & SYSCALL_G2RFLAG)
-i = tf->tf_global[2];
-			else
-i = tf->tf_global[7];
-			if (i & 3) {
-error = EINVAL;
-goto bad;
-			}
-		} else {
+		if (!new) {
 			/* old system call convention: clear C on success */
 			tf->tf_psr &= ~PSR_C;	/* success */
-			i = tf->tf_npc;
 		}
-		tf->tf_pc = i;
-		tf->tf_npc = i + 4;
 		break;
 
 	case ERESTART:
+		tf->tf_pc = opc;
+		tf->tf_npc = onpc;
+		break;
+
 	case EJUSTRETURN:
 		/* nothing to do */
 		break;
@@ -269,9 +278,8 @@ syscall(register_t code, struct trapfram
 			error = p->p_emul->e_errno[error];
 		tf->tf_out[0] = error;
 		tf->tf_psr |= PSR_C;	/* fail */
-		i = tf->tf_npc;
-		tf->tf_pc = i;
-		tf->tf_npc = i + 4;
+		tf->tf_pc = onpc;
+		tf->tf_npc = tf->tf_pc + 4;
 		break;
 	}
 

Index: src/sys/arch/sparc/sparc/vm_machdep.c
diff -u src/sys/arch/sparc/sparc/vm_machdep.c:1.107 src/sys/arch/sparc/sparc/vm_machdep.c:1.108
--- src/sys/arch/sparc/sparc/vm_machdep.c:1.107	Sun Feb 19 21:06:30 2012
+++ src/sys/arch/sparc/sparc/vm_machdep.c	Mon Mar 20 11:19:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_machdep.c,v 1.107 2012/02/19 21:06:30 rmind Exp $ */
+/*	$NetBSD: vm_machdep.c,v 1.108 2023/03/20 11:19:29 hannken Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.107 2012/02/19 21:06:30 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.108 2023/03/20 11:19:29 hannken Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -268,8 +268,6 @@ cpu_lwp_fork(struct lwp *l1, struct lwp 
 	 * to user mode.
 	 */
 	/*tf2->tf_psr &= ~PSR_C;   -* success */
-	tf2->tf_pc = tf2->tf_npc;
-	tf2->tf_npc = tf2->tf_pc + 4;
 
 	/* Set return values in child mode */
 	tf2->tf_out[0] = 0;

Index: src/tests/lib/libc/sys/t_ptrace_syscall_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_syscall_wait.h:1.2 src/tests/lib/libc/sys/t_ptrace_syscall_wait.h:1.3
--- 

CVS commit: src

2023-03-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Mar 20 11:19:30 UTC 2023

Modified Files:
src/sys/arch/sparc/sparc: syscall.c vm_machdep.c
src/tests/lib/libc/sys: t_ptrace_syscall_wait.h

Log Message:
Adjust pc/npc before syscall allowing EJUSTRETURN to return
to the next instruction.  Only ERESTART should return to
the same instruction.  Differences to sparc64 reduced.

Test t_ptrace_wait:syscallemu1 now passes on sparc.

Fixes PR kern/52166 "syscallemu does not work on sparc (32-bit)"

Ok: Martin Husemann


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/sparc/sparc/syscall.c
cvs rdiff -u -r1.107 -r1.108 src/sys/arch/sparc/sparc/vm_machdep.c
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_ptrace_syscall_wait.h

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



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

2023-03-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar 20 11:07:33 UTC 2023

Modified Files:
src/sys/arch/sparc/include: types.h

Log Message:
__HAVE_HASHLOCKED_ATOMICS needs to be visible to userland


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/sparc/include/types.h

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

Modified files:

Index: src/sys/arch/sparc/include/types.h
diff -u src/sys/arch/sparc/include/types.h:1.72 src/sys/arch/sparc/include/types.h:1.73
--- src/sys/arch/sparc/include/types.h:1.72	Sat Jul 30 14:13:27 2022
+++ src/sys/arch/sparc/include/types.h	Mon Mar 20 11:07:33 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: types.h,v 1.72 2022/07/30 14:13:27 riastradh Exp $ */
+/*	$NetBSD: types.h,v 1.73 2023/03/20 11:07:33 martin Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -136,7 +136,7 @@ typedef unsigned long int	__register_t;
 #define	__HAVE_FAST_SOFTINTS
 #else
 #define	__HAVE_MM_MD_READWRITE
-#ifdef MULTIPROCESSOR
+#if !defined(_KERNEL) || defined(MULTIPROCESSOR)
 #define	__HAVE_HASHLOCKED_ATOMICS
 #endif
 #endif



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

2023-03-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar 20 11:07:33 UTC 2023

Modified Files:
src/sys/arch/sparc/include: types.h

Log Message:
__HAVE_HASHLOCKED_ATOMICS needs to be visible to userland


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/sparc/include/types.h

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



CVS commit: src/sys/netinet6

2023-03-20 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Mar 20 09:15:52 UTC 2023

Modified Files:
src/sys/netinet6: ip6_output.c

Log Message:
in6: reject setting negative values but -1 via setsockopt(IPV6_CHECKSUM)

Same as OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.232 -r1.233 src/sys/netinet6/ip6_output.c

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

Modified files:

Index: src/sys/netinet6/ip6_output.c
diff -u src/sys/netinet6/ip6_output.c:1.232 src/sys/netinet6/ip6_output.c:1.233
--- src/sys/netinet6/ip6_output.c:1.232	Fri Jan 27 09:33:43 2023
+++ src/sys/netinet6/ip6_output.c	Mon Mar 20 09:15:52 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_output.c,v 1.232 2023/01/27 09:33:43 ozaki-r Exp $	*/
+/*	$NetBSD: ip6_output.c,v 1.233 2023/03/20 09:15:52 ozaki-r Exp $	*/
 /*	$KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.232 2023/01/27 09:33:43 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.233 2023/03/20 09:15:52 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1984,8 +1984,12 @@ ip6_raw_ctloutput(int op, struct socket 
 			error = sockopt_getint(sopt, );
 			if (error)
 break;
-			if ((optval % 2) != 0) {
-/* the API assumes even offset values */
+			if (optval < -1 ||
+			(optval > 0 && (optval % 2) != 0)) {
+/*
+ * The API assumes non-negative even offset
+ * values or -1 as a special value.
+ */
 error = EINVAL;
 			} else if (so->so_proto->pr_protocol ==
 			IPPROTO_ICMPV6) {



CVS commit: src/sys/netinet6

2023-03-20 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Mar 20 09:15:52 UTC 2023

Modified Files:
src/sys/netinet6: ip6_output.c

Log Message:
in6: reject setting negative values but -1 via setsockopt(IPV6_CHECKSUM)

Same as OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.232 -r1.233 src/sys/netinet6/ip6_output.c

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