<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/sound/core/seq/seq_queue.c, branch linux-4.1.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.1.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.1.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2018-05-23T01:33:47Z</updated>
<entry>
<title>ALSA: seq: Fix possible UAF in snd_seq_check_queue()</title>
<updated>2018-05-23T01:33:47Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2018-03-09T20:58:28Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a3424ba004f531a379f488a2b5a2843bfc47c53c'/>
<id>urn:sha1:a3424ba004f531a379f488a2b5a2843bfc47c53c</id>
<content type='text'>
[ Upstream commit d0f833065221cbfcbadf19fd4102bcfa9330006a ]

Although we've covered the races between concurrent write() and
ioctl() in the previous patch series, there is still a possible UAF in
the following scenario:

A: user client closed		B: timer irq
  -&gt; snd_seq_release()		  -&gt; snd_seq_timer_interrupt()
    -&gt; snd_seq_free_client()	    -&gt; snd_seq_check_queue()
				      -&gt; cell = snd_seq_prioq_cell_peek()
      -&gt; snd_seq_prioq_leave()
         .... removing all cells
      -&gt; snd_seq_pool_done()
         .... vfree()
				      -&gt; snd_seq_compare_tick_time(cell)
				         ... Oops

So the problem is that a cell is peeked and accessed without any
protection until it's retrieved from the queue again via
snd_seq_prioq_cell_out().

This patch tries to address it, also cleans up the code by a slight
refactoring.  snd_seq_prioq_cell_out() now receives an extra pointer
argument.  When it's non-NULL, the function checks the event timestamp
with the given pointer.  The caller needs to pass the right reference
either to snd_seq_tick or snd_seq_realtime depending on the event
timestamp type.

A good news is that the above change allows us to remove the
snd_seq_prioq_cell_peek(), too, thus the patch actually reduces the
code size.

Reviewed-by: Nicolai Stange &lt;nstange@suse.de&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
</content>
</entry>
<entry>
<title>ALSA: seq: 2nd attempt at fixing race creating a queue</title>
<updated>2017-10-04T01:36:29Z</updated>
<author>
<name>Daniel Mentz</name>
</author>
<published>2017-08-14T21:46:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=624e20caa0777050a0057b2dea49711220b3371f'/>
<id>urn:sha1:624e20caa0777050a0057b2dea49711220b3371f</id>
<content type='text'>
[ Upstream commit 7e1d90f60a0d501c8503e636942ca704a454d910 ]

commit 4842e98f26dd80be3623c4714a244ba52ea096a8 ("ALSA: seq: Fix race at
creating a queue") attempted to fix a race reported by syzkaller. That
fix has been described as follows:

"
When a sequencer queue is created in snd_seq_queue_alloc(),it adds the
new queue element to the public list before referencing it.  Thus the
queue might be deleted before the call of snd_seq_queue_use(), and it
results in the use-after-free error, as spotted by syzkaller.

The fix is to reference the queue object at the right time.
"

Even with that fix in place, syzkaller reported a use-after-free error.
It specifically pointed to the last instruction "return q-&gt;queue" in
snd_seq_queue_alloc(). The pointer q is being used after kfree() has
been called on it.

It turned out that there is still a small window where a race can
happen. The window opens at
snd_seq_ioctl_create_queue()-&gt;snd_seq_queue_alloc()-&gt;queue_list_add()
and closes at
snd_seq_ioctl_create_queue()-&gt;queueptr()-&gt;snd_use_lock_use(). Between
these two calls, a different thread could delete the queue and possibly
re-create a different queue in the same location in queue_list.

This change prevents this situation by calling snd_use_lock_use() from
snd_seq_queue_alloc() prior to calling queue_list_add(). It is then the
caller's responsibility to call snd_use_lock_free(&amp;q-&gt;use_lock).

Fixes: 4842e98f26dd ("ALSA: seq: Fix race at creating a queue")
Reported-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Daniel Mentz &lt;danielmentz@google.com&gt;
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</content>
</entry>
<entry>
<title>ALSA: seq: Fix race at creating a queue</title>
<updated>2017-03-06T22:31:13Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2017-02-08T11:35:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=be97d0ec54e1b75e28f2f238c3b0310396028215'/>
<id>urn:sha1:be97d0ec54e1b75e28f2f238c3b0310396028215</id>
<content type='text'>
[ Upstream commit 4842e98f26dd80be3623c4714a244ba52ea096a8 ]

When a sequencer queue is created in snd_seq_queue_alloc(),it adds the
new queue element to the public list before referencing it.  Thus the
queue might be deleted before the call of snd_seq_queue_use(), and it
results in the use-after-free error, as spotted by syzkaller.

The fix is to reference the queue object at the right time.

Reported-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</content>
</entry>
<entry>
<title>ALSA: seq: Fix race at timer setup and close</title>
<updated>2016-01-31T19:23:33Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2016-01-12T14:36:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=49c9eb3db86407868a664ade6da041fabeb457f8'/>
<id>urn:sha1:49c9eb3db86407868a664ade6da041fabeb457f8</id>
<content type='text'>
commit 3567eb6af614dac436c4b16a8d426f9faed639b3 upstream.

ALSA sequencer code has an open race between the timer setup ioctl and
the close of the client.  This was triggered by syzkaller fuzzer, and
a use-after-free was caught there as a result.

This patch papers over it by adding a proper queue-&gt;timer_mutex lock
around the timer-related calls in the relevant code path.

Reported-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Tested-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ALSA: seq: Drop superfluous error/debug messages after malloc failures</title>
<updated>2015-03-10T14:41:18Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2015-03-10T14:41:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=24db8bbaa3fcfaf0c2faccbff5864b58088ac1f6'/>
<id>urn:sha1:24db8bbaa3fcfaf0c2faccbff5864b58088ac1f6</id>
<content type='text'>
The kernel memory allocators already report the errors when the
requested allocation fails, thus we don't need to warn it again in
each caller side.

Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: seq: Use standard printk helpers</title>
<updated>2014-02-14T07:14:18Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2014-02-04T17:24:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=04cc79a048ee215ec39af05d61f1fc8a4ab3d8c1'/>
<id>urn:sha1:04cc79a048ee215ec39af05d61f1fc8a4ab3d8c1</id>
<content type='text'>
Use the standard pr_xxx() helpers instead of home-baked snd_print*().

Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: core: remove unused variables.</title>
<updated>2011-05-26T06:19:04Z</updated>
<author>
<name>Luca Tettamanti</name>
</author>
<published>2011-05-25T20:43:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=78fa2c4d2465d014e67d3e12d948425856587251'/>
<id>urn:sha1:78fa2c4d2465d014e67d3e12d948425856587251</id>
<content type='text'>
Drop a few variables that are never read.

Signed-off-by: Luca Tettamanti &lt;kronos.it@gmail.com&gt;
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: Kill snd_assert() in sound/core/*</title>
<updated>2008-08-13T09:46:35Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2008-08-08T15:09:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7eaa943c8ed8e91e05d0f5d0dc7a18e3319b45cf'/>
<id>urn:sha1:7eaa943c8ed8e91e05d0f5d0dc7a18e3319b45cf</id>
<content type='text'>
Kill snd_assert() in sound/core/*, either removed or replaced with
if () with snd_BUG_ON().

Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
Signed-off-by: Jaroslav Kysela &lt;perex@perex.cz&gt;
</content>
</entry>
<entry>
<title>[ALSA] Remove sound/driver.h</title>
<updated>2008-01-31T16:29:48Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2008-01-08T17:13:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9004acc70e8c49c50c4c7b652f906f1e0ed5709d'/>
<id>urn:sha1:9004acc70e8c49c50c4c7b652f906f1e0ed5709d</id>
<content type='text'>
This header file exists only for some hacks to adapt alsa-driver
tree.  It's useless for building in the kernel.  Let's move a few
lines in it to sound/core.h and remove it.
With this patch, sound/driver.h isn't removed but has just a single
compile warning to include it.  This should be really killed in
future.

Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
Signed-off-by: Jaroslav Kysela &lt;perex@perex.cz&gt;
</content>
</entry>
<entry>
<title>[ALSA] semaphore -&gt; mutex (core part)</title>
<updated>2006-03-22T09:24:50Z</updated>
<author>
<name>Ingo Molnar</name>
</author>
<published>2006-01-16T15:29:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1a60d4c5a0c4028559585a74e48593b16e1ca9b2'/>
<id>urn:sha1:1a60d4c5a0c4028559585a74e48593b16e1ca9b2</id>
<content type='text'>
Semaphore to mutex conversion.

The conversion was generated via scripts, and the result was validated
automatically via a script as well.

Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
</feed>
