History

ALSA: pcm: Fix races among concurrent hw_params and hw_free calls

Currently we have neither proper check nor protection against the concurrent calls of PCM hw_params and hw_free ioctls, which may result in a UAF. Since the existing PCM stream lock can't be used for protecting the whole ioctl operations, we need a new mutex to protect those racy calls. This patch introduced a new mutex, runtime->buffer_mutex, and applies it to both hw_params and hw_free ioctl code paths. Along with it, the both functions are slightly modified (the mmap_count check is moved into the state-check block) for code simplicity.

Takashi Iwai committed 4 years ago

Commit 92ee3c61 parent 646b9073 files · +42 −22Browse files

Showing the changes to include (1 of 3 files). Show all

Unified · Split

include/sound/pcm.h+1−0
@@ -401,6 +401,7 @@ struct snd_pcm_runtime { · 400 unmodified lines
401401 wait_queue_head_t tsleep; /* transfer sleep */
402402 struct fasync_struct *fasync;
403403 bool stop_operating; /* sync_stop will be called */
404+ struct mutex buffer_mutex; /* protect for buffer changes */
404405
405406 /* -- private section -- */
406407 void *private_data;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t