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
This commit is contained in:
Mark Johnston 2025-04-05 16:22:20 +00:00
parent ee9ce1078c
commit d35c4cfad5

View file

@ -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 */