From: mvs Date: Thu, 8 Aug 2024 10:25:00 +0000 (+0000) Subject: Unlock KERN_MSGBUFSIZE and KERN_CONSBUFSIZE. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d6054cd7feb9efd1218d54e03c14096628f86813;p=openbsd Unlock KERN_MSGBUFSIZE and KERN_CONSBUFSIZE. `msgbufp' and `consbufp' are immutable, such as `msg_magic' and `msg_bufs'. initmsgbuf() and initconsbuf() which initialize this buffers are called during kernel bootstrap, when concurrent sysctl(2) is impossible, so they don't need to be reordered or use barriers. ok bluhm --- diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index cc0d4537ee9..3ac262a25a2 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.434 2024/08/06 12:36:54 mvs Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.435 2024/08/08 10:25:00 mvs Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -533,6 +533,18 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, return (sysctl_rdstruct(oldp, oldlenp, newp, &mbs, sizeof(mbs))); } + case KERN_MSGBUFSIZE: + case KERN_CONSBUFSIZE: { + struct msgbuf *mp; + mp = (name[0] == KERN_MSGBUFSIZE) ? msgbufp : consbufp; + /* + * deal with cases where the message buffer has + * become corrupted. + */ + if (!mp || mp->msg_magic != MSG_MAGIC) + return (ENXIO); + return (sysctl_rdint(oldp, oldlenp, newp, mp->msg_bufs)); + } case KERN_OSREV: case KERN_NFILES: case KERN_TTYCOUNT: @@ -616,18 +628,6 @@ kern_sysctl_locked(int *name, u_int namelen, void *oldp, size_t *oldlenp, error = sysctl_int(oldp, oldlenp, newp, newlen, &inthostid); hostid = inthostid; return (error); - case KERN_MSGBUFSIZE: - case KERN_CONSBUFSIZE: { - struct msgbuf *mp; - mp = (name[0] == KERN_MSGBUFSIZE) ? msgbufp : consbufp; - /* - * deal with cases where the message buffer has - * become corrupted. - */ - if (!mp || mp->msg_magic != MSG_MAGIC) - return (ENXIO); - return (sysctl_rdint(oldp, oldlenp, newp, mp->msg_bufs)); - } case KERN_CONSBUF: if ((error = suser(p))) return (error); @@ -635,7 +635,10 @@ kern_sysctl_locked(int *name, u_int namelen, void *oldp, size_t *oldlenp, case KERN_MSGBUF: { struct msgbuf *mp; mp = (name[0] == KERN_MSGBUF) ? msgbufp : consbufp; - /* see note above */ + /* + * deal with cases where the message buffer has + * become corrupted. + */ if (!mp || mp->msg_magic != MSG_MAGIC) return (ENXIO); return (sysctl_rdstruct(oldp, oldlenp, newp, mp,