lkml.org 
[lkml]   [2018]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 4.4 53/97] ALSA: pcm: Fix UAF at PCM release via PCM timer access
From
Date
On Sun, 2018-04-22 at 15:53 +0200, Greg Kroah-Hartman wrote:
> 4.4-stable review patch.  If anyone has any objections, please let me know.
>
> ------------------
>
> From: Takashi Iwai <tiwai@suse.de>
>
> 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.
[...]

This seems to depend on:

commit f65e0d299807d8a11812845c972493c3f9a18e10
Author: Takashi Iwai <tiwai@suse.de>
Date:   Wed Feb 10 12:47:03 2016 +0100

    ALSA: timer: Call notifier in the same spinlock

(But I'm not totally convinced that snd_pcm_timer_resolution() is
always called with the timer lock held, even after that.)

Ben.

--
Ben Hutchings
Software Developer, Codethink Ltd.

\
 
 \ /
  Last update: 2018-05-16 22:52    [W:0.395 / U:0.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site