Skip to content

ALSA: control: Fix locking around snd_ctl_elem_read/write

Alexander Grund cip-dev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3ALSA: control: code refactoring for ELEM_READ/ELEM_WRITE operationssound/core/control.c+38 -402 replies
2/3ALSA: control: Fix memory corruption risk in snd_ctl_elem_readsound/core/control.c+1 -12 replies
3/3ALSA: control: use counting semaphore as write lock for ELEM_WRITE operationsound/core/control.c+2 -24 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 4.4 0/3] ALSA: control: Fix locking around snd_ctl_elem_read/write

I found a bug in v4.4-st38 caused by e8064dec769e6 "ALSA: pcm: Move rwsem lock inside snd_ctl_elem_read to prevent UAF" The most serious part is a down_write call before calling snd_ctl_elem_write which will do a down_read on the same mutex causing a deadlock. I fix this by taking missing commits from 4.14.y, especially "ALSA: control: code refactoring for ELEM_READ/ELEM_WRITE operations" which moves the locking out of those 2 functions such that the bug fixed
by the above commit is actually introduced so that it can be fixed
avoiding the deadlock.
This also requires a follow-up commit to fix a bug introduced in a
condition by that commit.
The final commit replaces down_read by down_write in snd_ctl_elem_write_user
similar to what e8064dec769e6 does in control_compat.c so that this use
is uniform (and correct).

Richard Fitzgerald (1):
ALSA: control: Fix memory corruption risk in snd_ctl_elem_read

Takashi Sakamoto (2):
ALSA: control: code refactoring for ELEM_READ/ELEM_WRITE operations
ALSA: control: use counting semaphore as write lock for ELEM_WRITE
operation

 sound/core/control.c | 78 +++++++++++++++++++++-----------------------
 1 file changed, 38 insertions(+), 40 deletions(-)
Signature · 1 line
2.40.0