public inbox for cip-dev@lists.cip-project.org
 help / color / mirror / Atom feed
From: Alexander Grund <theflamefire89@gmail.com>
To: cip-dev@lists.cip-project.org
Cc: uli+cip@fpond.eu
Subject: [PATCH 4.4 0/3] ALSA: control: Fix locking around snd_ctl_elem_read/write
Date: Fri, 24 Mar 2023 18:18:09 +0100	[thread overview]
Message-ID: <20230324171812.221086-1-theflamefire89@gmail.com> (raw)

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(-)

-- 
2.40.0



             reply	other threads:[~2023-03-24 17:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-24 17:18 Alexander Grund [this message]
2023-03-24 17:18 ` [PATCH 4.4 1/3] ALSA: control: code refactoring for ELEM_READ/ELEM_WRITE operations Alexander Grund
2023-03-29 22:29   ` [cip-dev] " nobuhiro1.iwamatsu
2023-03-31 15:45     ` Alexander Grund
2023-03-24 17:18 ` [PATCH 4.4 2/3] ALSA: control: Fix memory corruption risk in snd_ctl_elem_read Alexander Grund
2023-03-29 22:33   ` [cip-dev] " nobuhiro1.iwamatsu
2023-03-31 15:52     ` Alexander Grund
2023-03-24 17:18 ` [PATCH 4.4 3/3] ALSA: control: use counting semaphore as write lock for ELEM_WRITE operation Alexander Grund
2023-03-29 22:39   ` [cip-dev] " nobuhiro1.iwamatsu
2023-03-31 15:51     ` Alexander Grund
2023-04-03  8:56       ` [cip-dev] " Ulrich Hecht
2023-04-03 17:13         ` Alexander Grund
2023-04-02 16:30 ` [cip-dev] [PATCH 4.4 0/3] ALSA: control: Fix locking around snd_ctl_elem_read/write Pavel Machek
2023-04-02 18:34   ` Alexander Grund
2023-04-03  8:56   ` [cip-dev] " Ulrich Hecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230324171812.221086-1-theflamefire89@gmail.com \
    --to=theflamefire89@gmail.com \
    --cc=cip-dev@lists.cip-project.org \
    --cc=uli+cip@fpond.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox