summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorVitaliy Makkoveev <mvs@cvs.openbsd.org>2024-08-08 10:25:01 +0000
committerVitaliy Makkoveev <mvs@cvs.openbsd.org>2024-08-08 10:25:01 +0000
commit99932338f0f780d5fb698a209a890e348f245e2d (patch)
tree9b88707554899656b80946ea4aea0a16429ee5e4 /sys/kern
parent36b0b48d4e87f82391e4cfc3176ef16105cd1e21 (diff)
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
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_sysctl.c31
1 files changed, 17 insertions, 14 deletions
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,