]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
ALSA: pcm: Fix UAF at PCM release via PCM timer access
authorTakashi Iwai <tiwai@suse.de>
Mon, 2 Apr 2018 20:41:43 +0000 (22:41 +0200)
committerKhalid Elmously <khalid.elmously@canonical.com>
Wed, 6 Jun 2018 15:48:58 +0000 (11:48 -0400)
commit08b8768e5623bf3d9d8379be9bc417026eccc4cc
tree6e307d0cbd4e384050baf59a5c1e4b0d15cf3cb9
parent89c53e2e71e77842951c2d6ef4d9a11466b64ca2
ALSA: pcm: Fix UAF at PCM release via PCM timer access

BugLink: http://bugs.launchpad.net/bugs/1773233
commit a820ccbe21e8ce8e86c39cd1d3bc8c7d1cbb949b upstream.

The PCM runtime object is created and freed dynamically at PCM stream
open / close time.  This is tracked via substream->runtime, and it's
cleared at snd_pcm_detach_substream().

The runtime object assignment is protected by PCM open_mutex, so for
all PCM operations, it's safely handled.  However, each PCM substream
provides also an ALSA timer interface, and user-space can access to
this while closing a PCM substream.  This may eventually lead to a
UAF, as snd_pcm_timer_resolution() tries to access the runtime while
clearing it in other side.

Fortunately, it's the only concurrent access from the PCM timer, and
it merely reads runtime->timer_resolution field.  So, we can avoid the
race by reordering kfree() and wrapping the substream->runtime
clearance with the corresponding timer lock.

Reported-by: syzbot+8e62ff4e07aa2ce87826@syzkaller.appspotmail.com
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Acked-by: Khalid Elmously <khalid.elmously@canonical.com>
Acked-by: Brad Figg <brad.figg@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
sound/core/pcm.c