]> git.proxmox.com Git - mirror_ubuntu-kernels.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)
committerTakashi Iwai <tiwai@suse.de>
Mon, 1 Feb 2016 11:23:29 +0000 (12:23 +0100)
commitb248371628aad599a48540962f6b85a21a8a0c3f
treeb53a2028b511afaa11cacf8eecbb09cd43aaa190
parentcc85f7a634cfaf9f0713c6aa06d08817424db37a
ALSA: pcm: Fix potential deadlock in OSS emulation

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>
sound/core/oss/pcm_oss.c