From: mvs Date: Tue, 20 Aug 2024 07:44:36 +0000 (+0000) Subject: Unlock sysctl_audio(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=19686eace8335789f669ab42af1dd151660ec9a8;p=openbsd Unlock sysctl_audio(). It is the only KERN_AUDIO_RECORD. `audio_record_enable' is atomically accessed integer. Reasonable from deraadt --- diff --git a/sys/dev/audio.c b/sys/dev/audio.c index d1847f1ef42..f06eead7760 100644 --- a/sys/dev/audio.c +++ b/sys/dev/audio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: audio.c,v 1.207 2024/06/07 08:48:10 jsg Exp $ */ +/* $OpenBSD: audio.c,v 1.208 2024/08/20 07:44:36 mvs Exp $ */ /* * Copyright (c) 2015 Alexandre Ratchov * @@ -27,11 +27,17 @@ #include #include #include +#include #include #include #include "audio.h" #include "wskbd.h" +/* + * Locks used to protect data: + * a atomic + */ + #ifdef AUDIO_DEBUG #define DPRINTF(...) \ do { \ @@ -225,7 +231,7 @@ struct mutex audio_lock = MUTEX_INITIALIZER(IPL_AUDIO); * Global flag to control if audio recording is enabled when the * mixerctl setting is record.enable=sysctl */ -int audio_record_enable = 0; +int audio_record_enable = 0; /* [a] */ #ifdef AUDIO_DEBUG /* @@ -590,7 +596,7 @@ audio_rintr(void *addr) sc->rec.pos += sc->rec.blksz; if ((sc->record_enable == MIXER_RECORD_ENABLE_SYSCTL && - !audio_record_enable) || + atomic_load_int(&audio_record_enable) == 0) || sc->record_enable == MIXER_RECORD_ENABLE_OFF) { ptr = audio_buf_wgetblk(&sc->rec, &count); audio_fill_sil(sc, ptr, sc->rec.blksz); diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 99c8181f720..8b10fd14208 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.439 2024/08/14 17:52:47 mvs Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.440 2024/08/20 07:44:36 mvs Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -455,11 +455,6 @@ kern_sysctl_dirs(int top_name, int *name, u_int namelen, return witness_sysctl(name, namelen, oldp, oldlenp, newp, newlen); #endif -#if NAUDIO > 0 - case KERN_AUDIO: - return (sysctl_audio(name, namelen, oldp, oldlenp, - newp, newlen)); -#endif #if NVIDEO > 0 case KERN_VIDEO: return (sysctl_video(name, namelen, oldp, oldlenp, @@ -488,6 +483,16 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, /* dispatch the non-terminal nodes first */ if (namelen != 1) { + switch (name[0]) { +#if NAUDIO > 0 + case KERN_AUDIO: + return (sysctl_audio(name, namelen, oldp, oldlenp, + newp, newlen)); +#endif + default: + break; + } + savelen = *oldlenp; if ((error = sysctl_vslock(oldp, savelen))) return (error);