git: d35c4cfad580 - main - sysctl: Panic on OID reuse

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Sat, 05 Apr 2025 16:30:36 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=d35c4cfad5800b15ab730af5246df0366f2be558

commit d35c4cfad5800b15ab730af5246df0366f2be558
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-04-05 16:22:20 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-04-05 16:22:20 +0000

    sysctl: Panic on OID reuse
    
    In CheriBSD we had a conflict in the KERN_PROC OID space and didn't
    notice for some time.  Let's panic instead to make such conflicts easier
    to detect.  Note that this doesn't affect conflicts arising from name
    collisions in OID_AUTO sysctls, which happen sometimes due to driver
    bugs.
    
    Reviewed by:    brooks, kib, jhb
    MFC after:      1 month
    Differential Revision:  https://reviews.freebsd.org/D49351
---
 sys/kern/kern_sysctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 8cf8e7b19c89..46226cc31980 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -516,7 +516,7 @@ sysctl_register_oid(struct sysctl_oid *oidp)
 	/* check for non-auto OID number collision */
 	if (oidp->oid_number >= 0 && oidp->oid_number < CTL_AUTO_START &&
 	    oid_number >= CTL_AUTO_START) {
-		printf("sysctl: OID number(%d) is already in use for '%s'\n",
+		panic("sysctl: OID number(%d) is already in use for '%s'\n",
 		    oidp->oid_number, oidp->oid_name);
 	}
 	/* update the OID number, if any */