Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1322961 > unrolled thread

sound: WARNING in snd_rawmidi_kernel_write1

Started byDmitry Vyukov <dvyukov@google.com>
First post2016-02-01 11:20 +0100
Last post2016-02-03 14:30 +0100
Articles 5 — 2 participants

Back to article view | Back to linux.kernel


Contents

  sound: WARNING in snd_rawmidi_kernel_write1 Dmitry Vyukov <dvyukov@google.com> - 2016-02-01 11:20 +0100
    Re: sound: WARNING in snd_rawmidi_kernel_write1 Takashi Iwai <tiwai@suse.de> - 2016-02-01 11:40 +0100
      Re: sound: WARNING in snd_rawmidi_kernel_write1 Dmitry Vyukov <dvyukov@google.com> - 2016-02-02 22:30 +0100
        Re: sound: WARNING in snd_rawmidi_kernel_write1 Takashi Iwai <tiwai@suse.de> - 2016-02-03 00:30 +0100
          Re: sound: WARNING in snd_rawmidi_kernel_write1 Dmitry Vyukov <dvyukov@google.com> - 2016-02-03 14:30 +0100

#1322961 — sound: WARNING in snd_rawmidi_kernel_write1

FromDmitry Vyukov <dvyukov@google.com>
Date2016-02-01 11:20 +0100
Subjectsound: WARNING in snd_rawmidi_kernel_write1
Message-ID<qXjKq-15d-7@gated-at.bofh.it>
Hello,

The following program triggers WARNING in snd_rawmidi_kernel_write1:

// autogenerated by syzkaller (http://github.com/google/syzkaller)
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/uio.h>
#include <fcntl.h>

int main()
{
  int fd;
  struct iovec iov;

  fd = open("/dev/snd/midiC3D0", O_RDWR);
  iov.iov_base = "";
  iov.iov_len = 0;
  writev(fd, &iov, 1);
  return 0;
}


------------[ cut here ]------------
WARNING: CPU: 1 PID: 27775 at sound/core/rawmidi.c:1181
snd_rawmidi_kernel_write1+0x4e1/0x780()
Modules linked in:
CPU: 1 PID: 27775 Comm: syz-executor Not tainted 4.5.0-rc1+ #305
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
 00000000ffffffff ffff88003158f958[  845.661205] ------------[ cut
here ]------------
WARNING: CPU: 3 PID: 27781 at sound/core/rawmidi.c:1181
snd_rawmidi_kernel_write1+0x4e1/0x780()
Modules linked in:
 ffffffff82be11ad 0000000000000000
 ffff880032138000 ffffffff87188ec0 ffff88003158f998 ffffffff813536d9
 ffffffff8527ab31 ffffffff87188ec0 000000000000049d ffff8800321e4b88
Call Trace:
 [<     inline     >] __dump_stack lib/dump_stack.c:15
 [<ffffffff82be11ad>] dump_stack+0x6f/0xa2 lib/dump_stack.c:50
 [<ffffffff813536d9>] warn_slowpath_common+0xd9/0x140 kernel/panic.c:482
 [<ffffffff81353909>] warn_slowpath_null+0x29/0x30 kernel/panic.c:515
 [<ffffffff8527ab31>] snd_rawmidi_kernel_write1+0x4e1/0x780
sound/core/rawmidi.c:1181
 [<ffffffff8527cc93>] snd_rawmidi_write+0x543/0xb30 sound/core/rawmidi.c:1273
 [<ffffffff817b7611>] do_loop_readv_writev+0x141/0x1e0 fs/read_write.c:719
 [<ffffffff817bb478>] do_readv_writev+0x5f8/0x6e0 fs/read_write.c:849
 [<ffffffff817bb696>] vfs_writev+0x86/0xc0 fs/read_write.c:886
 [<     inline     >] SYSC_writev fs/read_write.c:919
 [<ffffffff817be801>] SyS_writev+0x111/0x2b0 fs/read_write.c:911
 [<ffffffff866531b6>] entry_SYSCALL_64_fastpath+0x16/0x7a
arch/x86/entry/entry_64.S:185
---[ end trace 35fa82e449e91fae ]---


On commit 26cd83670f2f5a3d5b5514a1f7d96567cdb9558b

[toc] | [next] | [standalone]


#1322981

FromTakashi Iwai <tiwai@suse.de>
Date2016-02-01 11:40 +0100
Message-ID<qXk3M-1dK-25@gated-at.bofh.it>
In reply to#1322961
On Mon, 01 Feb 2016 11:15:08 +0100,
Dmitry Vyukov wrote:
> 
> Hello,
> 
> The following program triggers WARNING in snd_rawmidi_kernel_write1:
> 
> // autogenerated by syzkaller (http://github.com/google/syzkaller)
> #include <unistd.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <sys/uio.h>
> #include <fcntl.h>
> 
> int main()
> {
>   int fd;
>   struct iovec iov;
> 
>   fd = open("/dev/snd/midiC3D0", O_RDWR);

What is the 3rd device?  Please show /proc/asound/cards content.


>   iov.iov_base = "";
>   iov.iov_len = 0;
>   writev(fd, &iov, 1);
>   return 0;
> }
> 
> 
> ------------[ cut here ]------------
> WARNING: CPU: 1 PID: 27775 at sound/core/rawmidi.c:1181

The fix is easy, just remove snd_BUG_ON() like below.


thanks,

Takashi

---
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index a7759846fbaa..f75d1656272c 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -1178,7 +1178,7 @@ static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream,
 	long count1, result;
 	struct snd_rawmidi_runtime *runtime = substream->runtime;
 
-	if (snd_BUG_ON(!kernelbuf && !userbuf))
+	if (!kernelbuf && !userbuf)
 		return -EINVAL;
 	if (snd_BUG_ON(!runtime->buffer))
 		return -EINVAL;

[toc] | [prev] | [next] | [standalone]


#1324649

FromDmitry Vyukov <dvyukov@google.com>
Date2016-02-02 22:30 +0100
Message-ID<qXQGn-FZ-25@gated-at.bofh.it>
In reply to#1322981
On Mon, Feb 1, 2016 at 11:36 AM, Takashi Iwai <tiwai@suse.de> wrote:
> On Mon, 01 Feb 2016 11:15:08 +0100,
> Dmitry Vyukov wrote:
>>
>> Hello,
>>
>> The following program triggers WARNING in snd_rawmidi_kernel_write1:
>>
>> // autogenerated by syzkaller (http://github.com/google/syzkaller)
>> #include <unistd.h>
>> #include <sys/types.h>
>> #include <sys/stat.h>
>> #include <sys/uio.h>
>> #include <fcntl.h>
>>
>> int main()
>> {
>>   int fd;
>>   struct iovec iov;
>>
>>   fd = open("/dev/snd/midiC3D0", O_RDWR);
>
> What is the 3rd device?  Please show /proc/asound/cards content.

Missed this question. Here is it. I run qemu with "-soundhw all" flag.

 0 [Dummy          ]: Dummy - Dummy
                      Dummy 1
 1 [Loopback       ]: Loopback - Loopback
                      Loopback 1
 2 [VirMIDI        ]: VirMIDI - VirMIDI
                      Virtual MIDI Card 1
 3 [port           ]: MTPAV - MTPAV on parallel port
                      MTPAV on parallel port at 0x378
 4 [pcsp           ]: PC-Speaker - pcsp
                      Internal PC-Speaker at port 0x61
 5 [Intel          ]: HDA-Intel - HDA Intel
                      HDA Intel at 0xfebf0000 irq 24

But the patch helps with the warning message :)


>>   iov.iov_base = "";
>>   iov.iov_len = 0;
>>   writev(fd, &iov, 1);
>>   return 0;
>> }
>>
>>
>> ------------[ cut here ]------------
>> WARNING: CPU: 1 PID: 27775 at sound/core/rawmidi.c:1181
>
> The fix is easy, just remove snd_BUG_ON() like below.
>
>
> thanks,
>
> Takashi
>
> ---
> diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
> index a7759846fbaa..f75d1656272c 100644
> --- a/sound/core/rawmidi.c
> +++ b/sound/core/rawmidi.c
> @@ -1178,7 +1178,7 @@ static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream,
>         long count1, result;
>         struct snd_rawmidi_runtime *runtime = substream->runtime;
>
> -       if (snd_BUG_ON(!kernelbuf && !userbuf))
> +       if (!kernelbuf && !userbuf)
>                 return -EINVAL;
>         if (snd_BUG_ON(!runtime->buffer))
>                 return -EINVAL;
>
>

[toc] | [prev] | [next] | [standalone]


#1324729

FromTakashi Iwai <tiwai@suse.de>
Date2016-02-03 00:30 +0100
Message-ID<qXSyu-23G-5@gated-at.bofh.it>
In reply to#1324649
On Tue, 02 Feb 2016 22:25:45 +0100,
Dmitry Vyukov wrote:
> 
> On Mon, Feb 1, 2016 at 11:36 AM, Takashi Iwai <tiwai@suse.de> wrote:
> > On Mon, 01 Feb 2016 11:15:08 +0100,
> > Dmitry Vyukov wrote:
> >>
> >> Hello,
> >>
> >> The following program triggers WARNING in snd_rawmidi_kernel_write1:
> >>
> >> // autogenerated by syzkaller (http://github.com/google/syzkaller)
> >> #include <unistd.h>
> >> #include <sys/types.h>
> >> #include <sys/stat.h>
> >> #include <sys/uio.h>
> >> #include <fcntl.h>
> >>
> >> int main()
> >> {
> >>   int fd;
> >>   struct iovec iov;
> >>
> >>   fd = open("/dev/snd/midiC3D0", O_RDWR);
> >
> > What is the 3rd device?  Please show /proc/asound/cards content.
> 
> Missed this question. Here is it. I run qemu with "-soundhw all" flag.
> 
>  0 [Dummy          ]: Dummy - Dummy
>                       Dummy 1
>  1 [Loopback       ]: Loopback - Loopback
>                       Loopback 1
>  2 [VirMIDI        ]: VirMIDI - VirMIDI
>                       Virtual MIDI Card 1
>  3 [port           ]: MTPAV - MTPAV on parallel port
>                       MTPAV on parallel port at 0x378
>  4 [pcsp           ]: PC-Speaker - pcsp
>                       Internal PC-Speaker at port 0x61
>  5 [Intel          ]: HDA-Intel - HDA Intel
>                       HDA Intel at 0xfebf0000 irq 24
> 
> But the patch helps with the warning message :)

Ah, you enabled MTPAV driver.  Please drop CONFIG_SND_MTPAV for your
testing.  This is known to be unstable and is only for a dedicated
parport device, not meant as a generic device to be covered at all.


Takashi

[toc] | [prev] | [next] | [standalone]


#1325437

FromDmitry Vyukov <dvyukov@google.com>
Date2016-02-03 14:30 +0100
Message-ID<qY5Fr-2vi-79@gated-at.bofh.it>
In reply to#1324729
On Wed, Feb 3, 2016 at 12:20 AM, Takashi Iwai <tiwai@suse.de> wrote:
> On Tue, 02 Feb 2016 22:25:45 +0100,
> Dmitry Vyukov wrote:
>>
>> On Mon, Feb 1, 2016 at 11:36 AM, Takashi Iwai <tiwai@suse.de> wrote:
>> > On Mon, 01 Feb 2016 11:15:08 +0100,
>> > Dmitry Vyukov wrote:
>> >>
>> >> Hello,
>> >>
>> >> The following program triggers WARNING in snd_rawmidi_kernel_write1:
>> >>
>> >> // autogenerated by syzkaller (http://github.com/google/syzkaller)
>> >> #include <unistd.h>
>> >> #include <sys/types.h>
>> >> #include <sys/stat.h>
>> >> #include <sys/uio.h>
>> >> #include <fcntl.h>
>> >>
>> >> int main()
>> >> {
>> >>   int fd;
>> >>   struct iovec iov;
>> >>
>> >>   fd = open("/dev/snd/midiC3D0", O_RDWR);
>> >
>> > What is the 3rd device?  Please show /proc/asound/cards content.
>>
>> Missed this question. Here is it. I run qemu with "-soundhw all" flag.
>>
>>  0 [Dummy          ]: Dummy - Dummy
>>                       Dummy 1
>>  1 [Loopback       ]: Loopback - Loopback
>>                       Loopback 1
>>  2 [VirMIDI        ]: VirMIDI - VirMIDI
>>                       Virtual MIDI Card 1
>>  3 [port           ]: MTPAV - MTPAV on parallel port
>>                       MTPAV on parallel port at 0x378
>>  4 [pcsp           ]: PC-Speaker - pcsp
>>                       Internal PC-Speaker at port 0x61
>>  5 [Intel          ]: HDA-Intel - HDA Intel
>>                       HDA Intel at 0xfebf0000 irq 24
>>
>> But the patch helps with the warning message :)
>
> Ah, you enabled MTPAV driver.  Please drop CONFIG_SND_MTPAV for your
> testing.  This is known to be unstable and is only for a dedicated
> parport device, not meant as a generic device to be covered at all.


Dropped CONFIG_SND_MTPAV.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web