<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/sound/core/rawmidi.c, branch linux-4.3.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.3.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.3.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2016-02-19T22:28:31Z</updated>
<entry>
<title>ALSA: rawmidi: Fix race at copying &amp; updating the position</title>
<updated>2016-02-19T22:28:31Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2016-02-03T13:41:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5cac180add9f132bcbca844b51d5ae9a20a708d4'/>
<id>urn:sha1:5cac180add9f132bcbca844b51d5ae9a20a708d4</id>
<content type='text'>
commit 81f577542af15640cbcb6ef68baa4caa610cbbfc upstream.

The rawmidi read and write functions manage runtime stream status
such as runtime-&gt;appl_ptr and runtime-&gt;avail.  These point where to
copy the new data and how many bytes have been copied (or to be
read).  The problem is that rawmidi read/write call copy_from_user()
or copy_to_user(), and the runtime spinlock is temporarily unlocked
and relocked while copying user-space.  Since the current code
advances and updates the runtime status after the spin unlock/relock,
the copy and the update may be asynchronous, and eventually
runtime-&gt;avail might go to a negative value when many concurrent
accesses are done.  This may lead to memory corruption in the end.

For fixing this race, in this patch, the status update code is
performed in the same lock before the temporary unlock.  Also, the
spinlock is now taken more widely in snd_rawmidi_kernel_read1() for
protecting more properly during the whole operation.

BugLink: http://lkml.kernel.org/r/CACT4Y+b-dCmNf1GpgPKfDO0ih+uZCL2JV4__j-r1kdhPLSgQCQ@mail.gmail.com
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: rawmidi: Remove kernel WARNING for NULL user-space buffer check</title>
<updated>2016-02-19T22:28:31Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2016-02-01T11:04:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5b68916055c08c0ec26117e708a955dfb15f49b1'/>
<id>urn:sha1:5b68916055c08c0ec26117e708a955dfb15f49b1</id>
<content type='text'>
commit cc85f7a634cfaf9f0713c6aa06d08817424db37a upstream.

NULL user-space buffer can be passed even in a normal path, thus it's
not good to spew a kernel warning with stack trace at each time.
Just drop snd_BUG_ON() macro usage there.

BugLink: http://lkml.kernel.org/r/CACT4Y+YfVJ3L+q0i-4vyQVyyPD7V=OMX0PWPi29x9Bo3QaBLdw@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: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ALSA: rawmidi: Make snd_rawmidi_transmit() race-free</title>
<updated>2016-02-19T22:28:31Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2016-01-31T10:57:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6824f2eeb92bdee8277616ae163f91bd936e3504'/>
<id>urn:sha1:6824f2eeb92bdee8277616ae163f91bd936e3504</id>
<content type='text'>
commit 06ab30034ed9c200a570ab13c017bde248ddb2a6 upstream.

A kernel WARNING in snd_rawmidi_transmit_ack() is triggered by
syzkaller fuzzer:
  WARNING: CPU: 1 PID: 20739 at sound/core/rawmidi.c:1136
Call Trace:
 [&lt;     inline     &gt;] __dump_stack lib/dump_stack.c:15
 [&lt;ffffffff82999e2d&gt;] dump_stack+0x6f/0xa2 lib/dump_stack.c:50
 [&lt;ffffffff81352089&gt;] warn_slowpath_common+0xd9/0x140 kernel/panic.c:482
 [&lt;ffffffff813522b9&gt;] warn_slowpath_null+0x29/0x30 kernel/panic.c:515
 [&lt;ffffffff84f80bd5&gt;] snd_rawmidi_transmit_ack+0x275/0x400 sound/core/rawmidi.c:1136
 [&lt;ffffffff84fdb3c1&gt;] snd_virmidi_output_trigger+0x4b1/0x5a0 sound/core/seq/seq_virmidi.c:163
 [&lt;     inline     &gt;] snd_rawmidi_output_trigger sound/core/rawmidi.c:150
 [&lt;ffffffff84f87ed9&gt;] snd_rawmidi_kernel_write1+0x549/0x780 sound/core/rawmidi.c:1223
 [&lt;ffffffff84f89fd3&gt;] snd_rawmidi_write+0x543/0xb30 sound/core/rawmidi.c:1273
 [&lt;ffffffff817b0323&gt;] __vfs_write+0x113/0x480 fs/read_write.c:528
 [&lt;ffffffff817b1db7&gt;] vfs_write+0x167/0x4a0 fs/read_write.c:577
 [&lt;     inline     &gt;] SYSC_write fs/read_write.c:624
 [&lt;ffffffff817b50a1&gt;] SyS_write+0x111/0x220 fs/read_write.c:616
 [&lt;ffffffff86336c36&gt;] entry_SYSCALL_64_fastpath+0x16/0x7a arch/x86/entry/entry_64.S:185

Also a similar warning is found but in another path:
Call Trace:
 [&lt;     inline     &gt;] __dump_stack lib/dump_stack.c:15
 [&lt;ffffffff82be2c0d&gt;] dump_stack+0x6f/0xa2 lib/dump_stack.c:50
 [&lt;ffffffff81355139&gt;] warn_slowpath_common+0xd9/0x140 kernel/panic.c:482
 [&lt;ffffffff81355369&gt;] warn_slowpath_null+0x29/0x30 kernel/panic.c:515
 [&lt;ffffffff8527e69a&gt;] rawmidi_transmit_ack+0x24a/0x3b0 sound/core/rawmidi.c:1133
 [&lt;ffffffff8527e851&gt;] snd_rawmidi_transmit_ack+0x51/0x80 sound/core/rawmidi.c:1163
 [&lt;ffffffff852d9046&gt;] snd_virmidi_output_trigger+0x2b6/0x570 sound/core/seq/seq_virmidi.c:185
 [&lt;     inline     &gt;] snd_rawmidi_output_trigger sound/core/rawmidi.c:150
 [&lt;ffffffff85285a0b&gt;] snd_rawmidi_kernel_write1+0x4bb/0x760 sound/core/rawmidi.c:1252
 [&lt;ffffffff85287b73&gt;] snd_rawmidi_write+0x543/0xb30 sound/core/rawmidi.c:1302
 [&lt;ffffffff817ba5f3&gt;] __vfs_write+0x113/0x480 fs/read_write.c:528
 [&lt;ffffffff817bc087&gt;] vfs_write+0x167/0x4a0 fs/read_write.c:577
 [&lt;     inline     &gt;] SYSC_write fs/read_write.c:624
 [&lt;ffffffff817bf371&gt;] SyS_write+0x111/0x220 fs/read_write.c:616
 [&lt;ffffffff86660276&gt;] entry_SYSCALL_64_fastpath+0x16/0x7a arch/x86/entry/entry_64.S:185

In the former case, the reason is that virmidi has an open code
calling snd_rawmidi_transmit_ack() with the value calculated outside
the spinlock.   We may use snd_rawmidi_transmit() in a loop just for
consuming the input data, but even there, there is a race between
snd_rawmidi_transmit_peek() and snd_rawmidi_tranmit_ack().

Similarly in the latter case, it calls snd_rawmidi_transmit_peek() and
snd_rawmidi_tranmit_ack() separately without protection, so they are
racy as well.

The patch tries to address these issues by the following ways:
- Introduce the unlocked versions of snd_rawmidi_transmit_peek() and
  snd_rawmidi_transmit_ack() to be called inside the explicit lock.
- Rewrite snd_rawmidi_transmit() to be race-free (the former case).
- Make the split calls (the latter case) protected in the rawmidi spin
  lock.

BugLink: http://lkml.kernel.org/r/CACT4Y+YPq1+cYLkadwjWa5XjzF1_Vki1eHnVn-Lm0hzhSpu5PA@mail.gmail.com
BugLink: http://lkml.kernel.org/r/CACT4Y+acG4iyphdOZx47Nyq_VHGbpJQK-6xNpiqUjaZYqsXOGw@mail.gmail.com
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: core: Drop superfluous error/debug messages after malloc failures</title>
<updated>2015-03-10T14:42:14Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2015-03-10T14:42:14Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ec0e9937aaa8b0a4b0633711c4d70d622acd9a7f'/>
<id>urn:sha1:ec0e9937aaa8b0a4b0633711c4d70d622acd9a7f</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: Simplify snd_device_register() variants</title>
<updated>2015-02-02T16:01:26Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2015-01-30T07:34:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=40a4b263854346fe7c7d1c3964c106296f690816'/>
<id>urn:sha1:40a4b263854346fe7c7d1c3964c106296f690816</id>
<content type='text'>
Now that all callers have been replaced with
snd_device_register_for_dev(), let's drop the obsolete device
registration code and concentrate only on the code handling struct
device directly.  That said,

- remove the old snd_device_register(),
- rename snd_device_register_for_dev() with snd_device_register(),
- drop superfluous arguments from snd_device_register(),
- change snd_unregister_device() to pass the device pointer directly

Reviewed-by: Jaroslav Kysela &lt;perex@perex.cz&gt;
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: rawmidi: Use rawmidi device file for kernel messages</title>
<updated>2015-02-02T13:42:43Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2015-01-30T14:31:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=07cc3e8bd57cd9d9f8f30c30ed859a55a7d8f4d3'/>
<id>urn:sha1:07cc3e8bd57cd9d9f8f30c30ed859a55a7d8f4d3</id>
<content type='text'>
... instead of card's device.  This will be helpful to distinguish
errors from multiple rawmidi devices on a single card.

Reviewed-by: Jaroslav Kysela &lt;perex@perex.cz&gt;
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: rawmidi: Embed struct device</title>
<updated>2015-02-02T13:42:43Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2015-01-29T16:55:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=aee5012fbb77dad6179c44d83d531ad62dd8098a'/>
<id>urn:sha1:aee5012fbb77dad6179c44d83d531ad62dd8098a</id>
<content type='text'>
Like previous patches, this changes the device management for rawmidi,
embedding the struct device into struct snd_rawmidi.  The required
change is more or less same as hwdep device.

The currently unused dev field is reused as the new embedded struct
field now.

Reviewed-by: Jaroslav Kysela &lt;perex@perex.cz&gt;
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: control: Provide a helper to look for the preferred subdevice</title>
<updated>2015-02-02T13:21:21Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2014-02-19T13:30:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=23c18d4bfd73ee24070849faf98b3ab01263a3c4'/>
<id>urn:sha1:23c18d4bfd73ee24070849faf98b3ab01263a3c4</id>
<content type='text'>
Instead of open-coding the search over the control file loop, provide
a helper function for the preferred subdevice assigned to the current
process.

Reviewed-by: Jaroslav Kysela &lt;perex@perex.cz&gt;
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: Move EXPORT_SYMBOL() in appropriate places</title>
<updated>2014-02-27T15:00:51Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2014-02-27T15:00:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6776a5d712a1e670e9cf31c6693480d4d9b30e33'/>
<id>urn:sha1:6776a5d712a1e670e9cf31c6693480d4d9b30e33</id>
<content type='text'>
Just a cleanup to follow the standard coding style.

Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: rawmidi: Use standard printk helpers</title>
<updated>2014-02-14T07:14:16Z</updated>
<author>
<name>Takashi Iwai</name>
</author>
<published>2014-02-04T17:21:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ca20d29275b90986e43de58ac6c218e826a4f985'/>
<id>urn:sha1:ca20d29275b90986e43de58ac6c218e826a4f985</id>
<content type='text'>
Use dev_err() &amp; co as much as possible.  If not available (no device
assigned at the calling point), use pr_xxx() helpers instead.

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