Commit 8527c8f
ALSA: pcm: Fix races among concurrent read/write and buffer changes
commit dca947d upstream.
In the current PCM design, the read/write syscalls (as well as the
equivalent ioctls) are allowed before the PCM stream is running, that
is, at PCM PREPARED state. Meanwhile, we also allow to re-issue
hw_params and hw_free ioctl calls at the PREPARED state that may
change or free the buffers, too. The problem is that there is no
protection against those mix-ups.
This patch applies the previously introduced runtime->buffer_mutex to
the read/write operations so that the concurrent hw_params or hw_free
call can no longer interfere during the operation. The mutex is
unlocked before scheduling, so we don't take it too long.
Cc: <stable@vger.kernel.org>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20220322170720.3529-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 0f6947f commit 8527c8f
1 file changed
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1871 | 1871 | | |
1872 | 1872 | | |
1873 | 1873 | | |
| 1874 | + | |
1874 | 1875 | | |
1875 | 1876 | | |
1876 | 1877 | | |
| 1878 | + | |
1877 | 1879 | | |
1878 | 1880 | | |
1879 | 1881 | | |
| |||
2167 | 2169 | | |
2168 | 2170 | | |
2169 | 2171 | | |
| 2172 | + | |
2170 | 2173 | | |
2171 | 2174 | | |
2172 | 2175 | | |
| |||
2254 | 2257 | | |
2255 | 2258 | | |
2256 | 2259 | | |
| 2260 | + | |
2257 | 2261 | | |
2258 | 2262 | | |
2259 | 2263 | | |
| |||
0 commit comments