diff options
author | Takashi Iwai <tiwai@suse.de> | 2022-08-23 09:27:16 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-09-15 12:17:04 +0200 |
commit | e7ee1f3c64d080e48405db2fabe1f8a1a7cfb9e1 (patch) | |
tree | e5eb6ce9d68b8404e791f349d35f563816b6432a | |
parent | f70146c0d62c3afb92dcca3308f71305ab83123c (diff) | |
download | linux-stable-e7ee1f3c64d080e48405db2fabe1f8a1a7cfb9e1.tar.gz linux-stable-e7ee1f3c64d080e48405db2fabe1f8a1a7cfb9e1.tar.bz2 linux-stable-e7ee1f3c64d080e48405db2fabe1f8a1a7cfb9e1.zip |
ALSA: seq: oss: Fix data-race for max_midi_devs access
commit 22dec134dbfa825b963f8a1807ad19b943e46a56 upstream.
ALSA OSS sequencer refers to a global variable max_midi_devs at
creating a new port, storing it to its own field. Meanwhile this
variable may be changed by other sequencer events at
snd_seq_oss_midi_check_exit_port() in parallel, which may cause a data
race.
OTOH, this data race itself is almost harmless, as the access to the
MIDI device is done via get_mdev() and it's protected with a refcount,
hence its presence is guaranteed.
Though, it's sill better to address the data-race from the code sanity
POV, and this patch adds the proper spinlock for the protection.
Reported-by: Abhishek Shah <abhishek.shah@columbia.edu>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/CAEHB2493pZRXs863w58QWnUTtv3HHfg85aYhLn5HJHCwxqtHQg@mail.gmail.com
Link: https://lore.kernel.org/r/20220823072717.1706-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | sound/core/seq/oss/seq_oss_midi.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/sound/core/seq/oss/seq_oss_midi.c b/sound/core/seq/oss/seq_oss_midi.c index b7bef25b34cc..838c3c8b403c 100644 --- a/sound/core/seq/oss/seq_oss_midi.c +++ b/sound/core/seq/oss/seq_oss_midi.c @@ -280,7 +280,9 @@ snd_seq_oss_midi_clear_all(void) void snd_seq_oss_midi_setup(struct seq_oss_devinfo *dp) { + spin_lock_irq(®ister_lock); dp->max_mididev = max_midi_devs; + spin_unlock_irq(®ister_lock); } /* |