git: 4f3ce62ff7ef - stable/14 - sysctl: Panic on OID reuse

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 06 May 2025 14:16:05 UTC
The branch stable/14 has been updated by markj:

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

commit 4f3ce62ff7ef930eddaf3c7de59195092eee3e00
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-04-05 16:22:20 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-05-06 14:15:38 +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
    
    (cherry picked from commit d35c4cfad5800b15ab730af5246df0366f2be558)
---
 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 b9ca0e7e5041..479792b4fff1 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -518,7 +518,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 */