<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/sound/core, 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:36:39Z</updated>
<entry>
<title>ALSA: seq: Fix races at MIDI encoding in snd_virmidi_output_trigger()</title>
<updated>2018-05-23T01:36:39Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2018-04-26T07:17:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=105ab3b63f3525fd2d234c24d43c9226162b22ae'/>
<id>urn:sha1:105ab3b63f3525fd2d234c24d43c9226162b22ae</id>
<content type='text'>
[ Upstream commit 8f22e52528cc372b218b5f100457469615c733ce ]

The sequencer virmidi code has an open race at its output trigger
callback: namely, virmidi keeps only one event packet for processing
while it doesn't protect for concurrent output trigger calls.

snd_virmidi_output_trigger() tries to process the previously
unfinished event before starting encoding the given MIDI stream, but
this is done without any lock.  Meanwhile, if another rawmidi stream
starts the output trigger, this proceeds further, and overwrites the
event package that is being processed in another thread.  This
eventually corrupts and may lead to the invalid memory access if the
event type is like SYSEX.

The fix is just to move the spinlock to cover both the pending event
and the new stream.

The bug was spotted by a new fuzzer, RaceFuzzer.

BugLink: http://lkml.kernel.org/r/20180426045223.GA15307@dragonet.kaist.ac.kr
Reported-by: DaeRyong Jeong &lt;threeearcat@gmail.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@microsoft.com&gt;
</content>
</entry>
<entry>
<title>ALSA: pcm: Check PCM state at xfern compat ioctl</title>
<updated>2018-05-23T01:36:39Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2018-05-02T06:48:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1d139fd4a10bc8d4352e9805fb4a5bbe4e1f1409'/>
<id>urn:sha1:1d139fd4a10bc8d4352e9805fb4a5bbe4e1f1409</id>
<content type='text'>
[ Upstream commit f13876e2c33a657a71bcbb10f767c0951b165020 ]

Since snd_pcm_ioctl_xfern_compat() has no PCM state check, it may go
further and hit the sanity check pcm_sanity_check() when the ioctl is
called right after open.  It may eventually spew a kernel warning, as
triggered by syzbot, depending on kconfig.

The lack of PCM state check there was just an oversight.  Although
it's no real crash, the spurious kernel warning is annoying, so let's
add the proper check.

Reported-by: syzbot+1dac3a4f6bc9c1c675d4@syzkaller.appspotmail.com
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: oss: Hardening for potential Spectre v1</title>
<updated>2018-05-23T01:36:38Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2018-04-24T05:31:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9ad08cc48adcd4d8cd58a6d748a7b4b30b0d0d96'/>
<id>urn:sha1:9ad08cc48adcd4d8cd58a6d748a7b4b30b0d0d96</id>
<content type='text'>
[ Upstream commit 8d218dd8116695ecda7164f97631c069938aa22e ]

As Smatch recently suggested, a few places in OSS sequencer codes may
expand the array directly from the user-space value with speculation,
namely there are a significant amount of references to either
info-&gt;ch[] or dp-&gt;synths[] array:

  sound/core/seq/oss/seq_oss_event.c:315 note_on_event() warn: potential spectre issue 'info-&gt;ch' (local cap)
  sound/core/seq/oss/seq_oss_event.c:362 note_off_event() warn: potential spectre issue 'info-&gt;ch' (local cap)
  sound/core/seq/oss/seq_oss_synth.c:470 snd_seq_oss_synth_load_patch() warn: potential spectre issue 'dp-&gt;synths' (local cap)
  sound/core/seq/oss/seq_oss_event.c:293 note_on_event() warn: potential spectre issue 'dp-&gt;synths'
  sound/core/seq/oss/seq_oss_event.c:353 note_off_event() warn: potential spectre issue 'dp-&gt;synths'
  sound/core/seq/oss/seq_oss_synth.c:506 snd_seq_oss_synth_sysex() warn: potential spectre issue 'dp-&gt;synths'
  sound/core/seq/oss/seq_oss_synth.c:580 snd_seq_oss_synth_ioctl() warn: potential spectre issue 'dp-&gt;synths'

Although all these seem doing only the first load without further
reference, we may want to stay in a safer side, so hardening with
array_index_nospec() would still make sense.

We may put array_index_nospec() at each place, but here we take a
different approach:

- For dp-&gt;synths[], change the helpers to retrieve seq_oss_synthinfo
  pointer directly instead of the array expansion at each place

- For info-&gt;ch[], harden in a normal way, as there are only a couple
  of places

As a result, the existing helper, snd_seq_oss_synth_is_valid() is
replaced with snd_seq_oss_synth_info().  Also, we cover MIDI device
where a similar array expansion is done, too, although it wasn't
reported by Smatch.

BugLink: https://marc.info/?l=linux-kernel&amp;m=152411496503418&amp;w=2
Reported-by: Dan Carpenter &lt;dan.carpenter@oracle.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@microsoft.com&gt;
</content>
</entry>
<entry>
<title>ALSA: seq: oss: Fix unbalanced use lock for synth MIDI device</title>
<updated>2018-05-23T01:36:38Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2018-04-24T05:26:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=fc2fc4694a85effc0fc920997241f20c0775eb9e'/>
<id>urn:sha1:fc2fc4694a85effc0fc920997241f20c0775eb9e</id>
<content type='text'>
[ Upstream commit f5e94b4c6ebdabe0f602d796e0430180927521a0 ]

When get_synthdev() is called for a MIDI device, it returns the fixed
midi_synth_dev without the use refcounting.  OTOH, the caller is
supposed to unreference unconditionally after the usage, so this would
lead to unbalanced refcount.

This patch corrects the behavior and keep up the refcount balance also
for the MIDI synth device.

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: core: Report audio_tstamp in snd_pcm_sync_ptr</title>
<updated>2018-05-23T01:36:38Z</updated>
<author>
<name>David Henningsson</name>
</author>
<published>2018-04-21T12:57:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=13cc4cf41d6bd031b714b7fa5561d937533ff526'/>
<id>urn:sha1:13cc4cf41d6bd031b714b7fa5561d937533ff526</id>
<content type='text'>
[ Upstream commit f853dcaae2f5bbe021161e421bd1576845bae8f6 ]

It looks like a simple mistake that this struct member
was forgotten.

Audio_tstamp isn't used much, and on some archs (such as x86) this
ioctl is not used by default, so that might be the reason why this
has slipped for so long.

Fixes: 4eeaaeaea1ce ("ALSA: core: add hooks for audio timestamps")
Signed-off-by: David Henningsson &lt;diwic@ubuntu.com&gt;
Reviewed-by: Takashi Sakamoto &lt;o-takashi@sakamocchi.jp&gt;
Cc: &lt;stable@vger.kernel.org&gt; # v3.8+
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: rawmidi: Fix missing input substream checks in compat ioctls</title>
<updated>2018-05-23T01:36:34Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2018-04-19T16:16:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=874ce787c160db6730d7c6314d55d7d7ea58940c'/>
<id>urn:sha1:874ce787c160db6730d7c6314d55d7d7ea58940c</id>
<content type='text'>
[ Upstream commit 8a56ef4f3ffba9ebf4967b61ef600b0a7ba10f11 ]

Some rawmidi compat ioctls lack of the input substream checks
(although they do check only for rfile-&gt;output).  This many eventually
lead to an Oops as NULL substream is passed to the rawmidi core
functions.

Fix it by adding the proper checks before each function call.

The bug was spotted by syzkaller.

Reported-by: syzbot+f7a0348affc3b67bc617@syzkaller.appspotmail.com
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: pcm: Fix endless loop for XRUN recovery in OSS emulation</title>
<updated>2018-05-23T01:36:34Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2018-04-07T09:48:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6dab42d43597e2b204bfc3c557931e3c4e4e11bd'/>
<id>urn:sha1:6dab42d43597e2b204bfc3c557931e3c4e4e11bd</id>
<content type='text'>
[ Upstream commit e15dc99dbb9cf99f6432e8e3c0b3a8f7a3403a86 ]

The commit 02a5d6925cd3 ("ALSA: pcm: Avoid potential races between OSS
ioctls and read/write") split the PCM preparation code to a locked
version, and it added a sanity check of runtime-&gt;oss.prepare flag
along with the change.  This leaded to an endless loop when the stream
gets XRUN: namely, snd_pcm_oss_write3() and co call
snd_pcm_oss_prepare() without setting runtime-&gt;oss.prepare flag and
the loop continues until the PCM state reaches to another one.

As the function is supposed to execute the preparation
unconditionally, drop the invalid state check there.

The bug was triggered by syzkaller.

Fixes: 02a5d6925cd3 ("ALSA: pcm: Avoid potential races between OSS ioctls and read/write")
Reported-by: syzbot+150189c103427d31a053@syzkaller.appspotmail.com
Reported-by: syzbot+7e3f31a52646f939c052@syzkaller.appspotmail.com
Reported-by: syzbot+4f2016cf5185da7759dc@syzkaller.appspotmail.com
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: pcm: Fix mutex unbalance in OSS emulation ioctls</title>
<updated>2018-05-23T01:36:34Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2018-03-27T12:32:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e9650576c4414657d21d3e20b1bbfd03aae1d758'/>
<id>urn:sha1:e9650576c4414657d21d3e20b1bbfd03aae1d758</id>
<content type='text'>
[ Upstream commit f6d297df4dd47ef949540e4a201230d0c5308325 ]

The previous fix 40cab6e88cb0 ("ALSA: pcm: Return -EBUSY for OSS
ioctls changing busy streams") introduced some mutex unbalance; the
check of runtime-&gt;oss.rw_ref was inserted in a wrong place after the
mutex lock.

This patch fixes the inconsistency by rewriting with the helper
functions to lock/unlock parameters with the stream check.

Fixes: 40cab6e88cb0 ("ALSA: pcm: Return -EBUSY for OSS ioctls changing busy streams")
Reported-by: Dan Carpenter &lt;dan.carpenter@oracle.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@microsoft.com&gt;
</content>
</entry>
<entry>
<title>ALSA: pcm: Return -EBUSY for OSS ioctls changing busy streams</title>
<updated>2018-05-23T01:36:34Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2018-03-23T07:03:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=151fafd90c4390c42c6414ecea21bb612692c5e1'/>
<id>urn:sha1:151fafd90c4390c42c6414ecea21bb612692c5e1</id>
<content type='text'>
[ Upstream commit 40cab6e88cb0b6c56d3f30b7491a20e803f948f6 ]

OSS PCM stream management isn't modal but it allows ioctls issued at
any time for changing the parameters.  In the previous hardening
patch ("ALSA: pcm: Avoid potential races between OSS ioctls and
read/write"), we covered these races and prevent the corruption by
protecting the concurrent accesses via params_lock mutex.  However,
this means that some ioctls that try to change the stream parameter
(e.g. channels or format) would be blocked until the read/write
finishes, and it may take really long.

Basically changing the parameter while reading/writing is an invalid
operation, hence it's even more user-friendly from the API POV if it
returns -EBUSY in such a situation.

This patch adds such checks in the relevant ioctls with the addition
of read/write access refcount.

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: pcm: Avoid potential races between OSS ioctls and read/write</title>
<updated>2018-05-23T01:36:34Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2018-03-22T17:10:14Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d6a12e6f4dd07fc1a894798fca352f7fdae122eb'/>
<id>urn:sha1:d6a12e6f4dd07fc1a894798fca352f7fdae122eb</id>
<content type='text'>
[ Upstream commit 02a5d6925cd34c3b774bdb8eefb057c40a30e870 ]

Although we apply the params_lock mutex to the whole read and write
operations as well as snd_pcm_oss_change_params(), we may still face
some races.

First off, the params_lock is taken inside the read and write loop.
This is intentional for avoiding the too long locking, but it allows
the in-between parameter change, which might lead to invalid
pointers.  We check the readiness of the stream and set up via
snd_pcm_oss_make_ready() at the beginning of read and write, but it's
called only once, by assuming that it remains ready in the rest.

Second, many ioctls that may change the actual parameters
(i.e. setting runtime-&gt;oss.params=1) aren't protected, hence they can
be processed in a half-baked state.

This patch is an attempt to plug these holes.  The stream readiness
check is moved inside the read/write inner loop, so that the stream is
always set up in a proper state before further processing.  Also, each
ioctl that may change the parameter is wrapped with the params_lock
for avoiding the races.

The issues were triggered by syzkaller in a few different scenarios,
particularly the one below appearing as GPF in loopback_pos_update.

Reported-by: syzbot+c4227aec125487ec3efa@syzkaller.appspotmail.com
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>
</feed>
