<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/sound/drivers/dummy.c, branch linux-3.2.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.2.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.2.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2016-08-22T21:37:16Z</updated>
<entry>
<title>ALSA: dummy: Fix a use-after-free at closing</title>
<updated>2016-08-22T21:37:16Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2016-06-24T13:15:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ea1a2cfd86cd727b6276003848b794c43700793b'/>
<id>urn:sha1:ea1a2cfd86cd727b6276003848b794c43700793b</id>
<content type='text'>
commit d5dbbe6569481bf12dcbe3e12cff72c5f78d272c upstream.

syzkaller fuzzer spotted a potential use-after-free case in snd-dummy
driver when hrtimer is used as backend:
&gt; ==================================================================
&gt; BUG: KASAN: use-after-free in rb_erase+0x1b17/0x2010 at addr ffff88005e5b6f68
&gt;  Read of size 8 by task syz-executor/8984
&gt; =============================================================================
&gt; BUG kmalloc-192 (Not tainted): kasan: bad access detected
&gt; -----------------------------------------------------------------------------
&gt;
&gt; Disabling lock debugging due to kernel taint
&gt; INFO: Allocated in 0xbbbbbbbbbbbbbbbb age=18446705582212484632
&gt; ....
&gt; [&lt;      none      &gt;] dummy_hrtimer_create+0x49/0x1a0 sound/drivers/dummy.c:464
&gt; ....
&gt; INFO: Freed in 0xfffd8e09 age=18446705496313138713 cpu=2164287125 pid=-1
&gt; [&lt;      none      &gt;] dummy_hrtimer_free+0x68/0x80 sound/drivers/dummy.c:481
&gt; ....
&gt; Call Trace:
&gt;  [&lt;ffffffff8179e59e&gt;] __asan_report_load8_noabort+0x3e/0x40 mm/kasan/report.c:333
&gt;  [&lt;     inline     &gt;] rb_set_parent include/linux/rbtree_augmented.h:111
&gt;  [&lt;     inline     &gt;] __rb_erase_augmented include/linux/rbtree_augmented.h:218
&gt;  [&lt;ffffffff82ca5787&gt;] rb_erase+0x1b17/0x2010 lib/rbtree.c:427
&gt;  [&lt;ffffffff82cb02e8&gt;] timerqueue_del+0x78/0x170 lib/timerqueue.c:86
&gt;  [&lt;ffffffff814d0c80&gt;] __remove_hrtimer+0x90/0x220 kernel/time/hrtimer.c:903
&gt;  [&lt;     inline     &gt;] remove_hrtimer kernel/time/hrtimer.c:945
&gt;  [&lt;ffffffff814d23da&gt;] hrtimer_try_to_cancel+0x22a/0x570 kernel/time/hrtimer.c:1046
&gt;  [&lt;ffffffff814d2742&gt;] hrtimer_cancel+0x22/0x40 kernel/time/hrtimer.c:1066
&gt;  [&lt;ffffffff85420531&gt;] dummy_hrtimer_stop+0x91/0xb0 sound/drivers/dummy.c:417
&gt;  [&lt;ffffffff854228bf&gt;] dummy_pcm_trigger+0x17f/0x1e0 sound/drivers/dummy.c:507
&gt;  [&lt;ffffffff85392170&gt;] snd_pcm_do_stop+0x160/0x1b0 sound/core/pcm_native.c:1106
&gt;  [&lt;ffffffff85391b26&gt;] snd_pcm_action_single+0x76/0x120 sound/core/pcm_native.c:956
&gt;  [&lt;ffffffff85391e01&gt;] snd_pcm_action+0x231/0x290 sound/core/pcm_native.c:974
&gt;  [&lt;     inline     &gt;] snd_pcm_stop sound/core/pcm_native.c:1139
&gt;  [&lt;ffffffff8539754d&gt;] snd_pcm_drop+0x12d/0x1d0 sound/core/pcm_native.c:1784
&gt;  [&lt;ffffffff8539d3be&gt;] snd_pcm_common_ioctl1+0xfae/0x2150 sound/core/pcm_native.c:2805
&gt;  [&lt;ffffffff8539ee91&gt;] snd_pcm_capture_ioctl1+0x2a1/0x5e0 sound/core/pcm_native.c:2976
&gt;  [&lt;ffffffff8539f2ec&gt;] snd_pcm_kernel_ioctl+0x11c/0x160 sound/core/pcm_native.c:3020
&gt;  [&lt;ffffffff853d9a44&gt;] snd_pcm_oss_sync+0x3a4/0xa30 sound/core/oss/pcm_oss.c:1693
&gt;  [&lt;ffffffff853da27d&gt;] snd_pcm_oss_release+0x1ad/0x280 sound/core/oss/pcm_oss.c:2483
&gt;  .....

A workaround is to call hrtimer_cancel() in dummy_hrtimer_sync() which
is called certainly before other blocking ops.

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: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>ALSA: dummy: Implement timer backend switching more safely</title>
<updated>2016-02-27T14:28:47Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2016-02-02T14:27:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=98aa5568b6f785499a6970f5b783bf4f2256ba6e'/>
<id>urn:sha1:98aa5568b6f785499a6970f5b783bf4f2256ba6e</id>
<content type='text'>
commit ddce57a6f0a2d8d1bfacfa77f06043bc760403c2 upstream.

Currently the selected timer backend is referred at any moment from
the running PCM callbacks.  When the backend is switched, it's
possible to lead to inconsistency from the running backend.  This was
pointed by syzkaller fuzzer, and the commit [7ee96216c31a: ALSA:
dummy: Disable switching timer backend via sysfs] disabled the dynamic
switching for avoiding the crash.

This patch improves the handling of timer backend switching.  It keeps
the reference to the selected backend during the whole operation of an
opened stream so that it won't be changed by other streams.

Together with this change, the hrtimer parameter is reenabled as
writable now.

NOTE: this patch also turned out to fix the still remaining race.
Namely, ops was still replaced dynamically at dummy_pcm_open:

  static int dummy_pcm_open(struct snd_pcm_substream *substream)
  {
  ....
          dummy-&gt;timer_ops = &amp;dummy_systimer_ops;
          if (hrtimer)
                  dummy-&gt;timer_ops = &amp;dummy_hrtimer_ops;

Since dummy-&gt;timer_ops is common among all streams, and when the
replacement happens during accesses of other streams, it may lead to a
crash.  This was actually triggered by syzkaller fuzzer and KASAN.

This patch rewrites the code not to use the ops shared by all streams
any longer, too.

BugLink: http://lkml.kernel.org/r/CACT4Y+aZ+xisrpuM6cOXbL21DuM0yVxPYXf4cD4Md9uw0C3dBQ@mail.gmail.com
Reported-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>ALSA: dummy: Disable switching timer backend via sysfs</title>
<updated>2016-02-27T14:28:44Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2016-01-28T06:54:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=426c3ec8cb2d9dff76dbc34c3b19c4e681ac554e'/>
<id>urn:sha1:426c3ec8cb2d9dff76dbc34c3b19c4e681ac554e</id>
<content type='text'>
commit 7ee96216c31aabe1eb42fb91ff50dae9fcd014b2 upstream.

ALSA dummy driver can switch the timer backend between system timer
and hrtimer via its hrtimer module option.  This can be also switched
dynamically via sysfs, but it may lead to a memory corruption when
switching is done while a PCM stream is running; the stream instance
for the newly switched timer method tries to access the memory that
was allocated by another timer method although the sizes differ.

As the simplest fix, this patch just disables the switch via sysfs by
dropping the writable bit.

BugLink: http://lkml.kernel.org/r/CACT4Y+ZGEeEBntHW5WHn2GoeE0G_kRrCmUh6=dWyy-wfzvuJLg@mail.gmail.com
Reported-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>sound: fix drivers needing module.h not moduleparam.h</title>
<updated>2011-10-31T23:31:19Z</updated>
<author>
<name>Paul Gortmaker</name>
</author>
<published>2011-07-15T17:13:37Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=65a772172b06e6e9b43e5ad77dccbcc767ff9831'/>
<id>urn:sha1:65a772172b06e6e9b43e5ad77dccbcc767ff9831</id>
<content type='text'>
The implicit presence of module.h lured several users into
incorrectly thinking that they only needed/used modparam.h
but once we clean up the module.h presence, these will show
up as build failures, so fix 'em now.

Signed-off-by: Paul Gortmaker &lt;paul.gortmaker@windriver.com&gt;
</content>
</entry>
<entry>
<title>ALSA: dummy driver - add model parameter</title>
<updated>2010-02-02T16:50:57Z</updated>
<author>
<name>Jaroslav Kysela</name>
</author>
<published>2010-02-02T16:48:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d5e1ca05f758fec2845a97fd7aa1eeca91c51a21'/>
<id>urn:sha1:d5e1ca05f758fec2845a97fd7aa1eeca91c51a21</id>
<content type='text'>
This is a cleanup for the dummy driver. The model kernel module parameter
is introduced to select the soundcard emulation.

Signed-off-by: Jaroslav Kysela &lt;perex@perex.cz&gt;
</content>
</entry>
<entry>
<title>ALSA: dummy - Fix descriptions of pcm_substreams parameter</title>
<updated>2009-11-02T13:11:55Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2009-11-02T13:10:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=23aebca486429b74c35b41ac5cac7ce97609fd6a'/>
<id>urn:sha1:23aebca486429b74c35b41ac5cac7ce97609fd6a</id>
<content type='text'>
Now up to 128 substreams are supported.

Reported-by: Adrian Bridgett &lt;adrian@smop.co.uk&gt;
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: sound: Move dereference after NULL test and drop unnecessary NULL tests</title>
<updated>2009-10-30T11:01:27Z</updated>
<author>
<name>Julia Lawall</name>
</author>
<published>2009-10-17T06:33:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4b3be6afa4ab8b3fdce39df68bad71f8b85164de'/>
<id>urn:sha1:4b3be6afa4ab8b3fdce39df68bad71f8b85164de</id>
<content type='text'>
In pcm.c, if the NULL test on pcm is needed, then the dereference should be
after the NULL test.

In dummy.c and ali5451.c, the context of the calls to
snd_card_dummy_new_mixer and snd_ali_free_voice show that dummy and pvoice,
respectively cannot be NULL.

A simplified version of the semantic match that detects this problem is as
follows (http://coccinelle.lip6.fr/):

// &lt;smpl&gt;
@match exists@
expression x, E;
identifier fld;
@@

* x-&gt;fld
  ... when != \(x = E\|&amp;x\)
* x == NULL
// &lt;/smpl&gt;

Signed-off-by: Julia Lawall &lt;julia@diku.dk&gt;
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: dummy - Increase MAX_PCM_SUBSTREAMS to 128</title>
<updated>2009-09-08T16:15:17Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2009-09-08T16:15:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b888d1ce82ebd2bafecf64c765754968e78b4228'/>
<id>urn:sha1:b888d1ce82ebd2bafecf64c765754968e78b4228</id>
<content type='text'>
Increase the limit of PCM substreams to 128.  The default value is
unchanged; only the max accept value is increased.

Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: dummy - Add debug proc file</title>
<updated>2009-09-08T12:46:49Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2009-09-08T12:30:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9b151fec139d32ab3acce5da5761d868e205fadd'/>
<id>urn:sha1:9b151fec139d32ab3acce5da5761d868e205fadd</id>
<content type='text'>
Added the debug proc file to see or change the snd_pcm_hardware fields
to emulate.  The parameters can be changed by writing to a proc file like:

    # echo periods_min 4 &gt; /proc/asound/card1/dummy_pcm

Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: dummy - Fake buffer allocations</title>
<updated>2009-09-07T07:01:10Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2009-09-04T10:19:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a68c4d11336610dc348620766119db09675707c2'/>
<id>urn:sha1:a68c4d11336610dc348620766119db09675707c2</id>
<content type='text'>
Instead of allocating the real buffers, use a fake buffer and ignore
read/write in the dummy driver so that we can save the resources.
For mmap, a single page (unique to the direction, though) is reused
to all buffers.

When the app requires to read/write the real buffers, pass fake_buffer=0
module option at loading time.  This will get back to the old behavior.

Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
</feed>
