]> www.infradead.org Git - users/jedix/linux-maple.git/commit
ALSA: pcm: Fix potential deadlock in OSS emulation
authorTakashi Iwai <tiwai@suse.de>
Sun, 31 Jan 2016 09:32:37 +0000 (10:32 +0100)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 26 May 2016 22:44:40 +0000 (15:44 -0700)
commit9d787b739e891982a08011786a389051c6dc2a52
tree4d9cf63709f9e0e4438e845a8143d8f2e1a0245a
parentcdfa02ddd57547ad5286a609d520af5309406119
ALSA: pcm: Fix potential deadlock in OSS emulation

Orabug: 23330801

[ Upstream commit b248371628aad599a48540962f6b85a21a8a0c3f ]

There are potential deadlocks in PCM OSS emulation code while
accessing read/write and mmap concurrently.  This comes from the
infamous mmap_sem usage in copy_from/to_user().  Namely,

   snd_pcm_oss_write() ->
     &runtime->oss.params_lock ->
        copy_to_user() ->
          &mm->mmap_sem
  mmap() ->
    &mm->mmap_sem ->
      snd_pcm_oss_mmap() ->
        &runtime->oss.params_lock

Since we can't avoid taking params_lock from mmap code path, use
trylock variant and aborts with -EAGAIN as a workaround of this AB/BA
deadlock.

BugLink: http://lkml.kernel.org/r/CACT4Y+bVrBKDG0G2_AcUgUQa+X91VKTeS4v+wN7BSHwHtqn3kQ@mail.gmail.com
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
(cherry picked from commit 666f365e85209f799819793d475cd7cde98a2be2)

Signed-off-by: Dan Duval <dan.duval@oracle.com>
sound/core/oss/pcm_oss.c