Skip to content

ALSA: pcm: Fix ioctl races

Takashi Iwai alsa-devel lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4ALSA: pcm: Fix races among concurrent hw_params and hw_free callsinclude/sound/pcm.h sound/core/pcm.c sound/core/pcm_native.c+42 -220 replies
2/4ALSA: pcm: Fix races among concurrent read/write and buffer changessound/core/pcm_lib.c+4 -00 replies
3/4ALSA: pcm: Fix races among concurrent prepare and hw_params/hw_free callssound/core/pcm_native.c+18 -143 replies
4/4ALSA: pcm: Fix races among concurrent prealloc proc writessound/core/pcm_memory.c+7 -40 replies

Reviews trailers per patch

None of the 4 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchJaroslav Kysela
SeriesR-b
1/4
2/4
3/4
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/4] ALSA: pcm: Fix ioctl races

Hi,

this is a patch set to address the recently reported bug for the racy PCM ioctls. In short, the current ALSA PCM core doesn't take enough care of concurrent ioctl calls, and the concurrent calls may result in a use-after-free. The reported problem was the concurrent hw_free calls, but there can be similar cases with other code paths like hw_params, prepare, etc, too.

The patch set introduces the new runtime->buffer_mutex for protecting those. The first patch is the fix for the reported issue (the races with hw_free), while the rest three are more hardening for the other similar executions.

[ Note that the patch 3 was slightly modified from the version I sent
to distros list, as I noticed possible lockdep (false-positive) warnings. The behavior is almost same, just written differently. ]

thanks,

Takashi

===

Takashi Iwai (4):
ALSA: pcm: Fix races among concurrent hw_params and hw_free calls
ALSA: pcm: Fix races among concurrent read/write and buffer changes
ALSA: pcm: Fix races among concurrent prepare and hw_params/hw_free
calls
ALSA: pcm: Fix races among concurrent prealloc proc writes

 include/sound/pcm.h     |  1 +
 sound/core/pcm.c        |  2 +
 sound/core/pcm_lib.c    |  4 ++
 sound/core/pcm_memory.c | 11 +++--
 sound/core/pcm_native.c | 93 +++++++++++++++++++++++++----------------
 5 files changed, 71 insertions(+), 40 deletions(-)
Signature · 1 line
2.31.1