public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: syzbot <syzbot+803e0047ac3a3096bb4f@syzkaller.appspotmail.com>,
	alsa-devel@alsa-project.org, syzkaller-bugs@googlegroups.com,
	Jaroslav Kysela <perex@perex.cz>,
	Takashi Sakamoto <o-takashi@sakamocchi.jp>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: WARNING in snd_pcm_hw_params
Date: Mon, 09 Apr 2018 17:44:21 +0200	[thread overview]
Message-ID: <s5hzi2ce65m.wl-tiwai@suse.de> (raw)
In-Reply-To: <s5h6050fl7q.wl-tiwai@suse.de>

On Mon, 09 Apr 2018 17:33:45 +0200,
Takashi Iwai wrote:
> 
> On Mon, 09 Apr 2018 17:25:15 +0200,
> Dmitry Vyukov wrote:
> > 
> > On Mon, Apr 9, 2018 at 5:18 PM, Takashi Iwai <tiwai@suse.de> wrote:
> > > On Fri, 06 Apr 2018 02:02:02 +0200,
> > > syzbot wrote:
> > >>
> > >> WARNING: CPU: 0 PID: 4468 at sound/core/pcm_native.c:620
> > >> snd_pcm_hw_params_choose sound/core/pcm_native.c:620 [inline]
> > >
> > > This is a WARN_ON() to catch the inconsistent hw_params call.
> > > This shouldn't happen in theory, but the reality looks weirder.
> > >
> > > The necessary "fix" is just to get rid of snd_BUG_ON(), but still
> > > wonder which condition it hits.  If it's an empty parameter, the
> > > previous snd_pcm_hw_refine() should have caught and returned the error
> > > beforehand...
> > 
> > Hi Takashi,
> > 
> > The reproducer for this is trivially simple:
> > 
> > https://syzkaller.appspot.com/x/repro.syz?id=4913841943085056
> > 
> > (and I guess perf_event_open is red herring).
> > 
> > But the really important part there is probably this: Fault:true
> > FaultCall:2 FaultNth:18
> > And you can see where it actually happened in the raw console log:
> > 
> > Raw console output: https://syzkaller.appspot.com/x/log.txt?id=6314122077536256
> > 
> > Does it explain things?
> 
> Yes, it does.  So it's the kmalloc error from snd_pcm_hw_refine().
> I overlooked this, as this kmalloc is relatively new, and that
> possibility wasn't considered in the WARN_ON() in question.
> 
> I'll rephrase the changelog text.

... and below is the revised patch.  I'll queue for 4.17-rc1 merge.


Takashi

-- 8< --
From: Takashi Iwai <tiwai@suse.de>
Subject: [PATCH] ALSA: pcm: Remove WARN_ON() at snd_pcm_hw_params() error

snd_pcm_hw_params() (more exactly snd_pcm_hw_params_choose()) contains
a check of the return error from snd_pcm_hw_param_first() and _last()
with snd_BUG_ON() -- i.e. it may trigger WARN_ON() depending on the
kconfig.

This was a valid check in the past, as these functions shouldn't
return any error if the parameters have been already refined via
snd_pcm_hw_refine() beforehand.  However, the recent rewrite
introduced a kmalloc() in snd_pcm_hw_refine() for removing VLA, and
this brought a possibility to trigger an error.  As a result, syzbot
caught lots of superfluous kernel WARN_ON() and paniced via fault
injection.

As the WARN_ON() is no longer valid with the introduction of
kmalloc(), let's drop snd_BUG_ON() check, in order to make the world
peaceful place again.

Reported-by: syzbot+803e0047ac3a3096bb4f@syzkaller.appspotmail.com
Fixes: 5730f9f744cf ("ALSA: pcm: Remove VLA usage")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/core/pcm_native.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index b84554893fab..35ffccea94c3 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -617,7 +617,7 @@ static int snd_pcm_hw_params_choose(struct snd_pcm_substream *pcm,
 			changed = snd_pcm_hw_param_first(pcm, params, *v, NULL);
 		else
 			changed = snd_pcm_hw_param_last(pcm, params, *v, NULL);
-		if (snd_BUG_ON(changed < 0))
+		if (changed < 0)
 			return changed;
 		if (changed == 0)
 			continue;
-- 
2.16.3

      reply	other threads:[~2018-04-09 15:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-06  0:02 WARNING in snd_pcm_hw_params syzbot
2018-04-09 15:18 ` Takashi Iwai
2018-04-09 15:25   ` Dmitry Vyukov
2018-04-09 15:33     ` Takashi Iwai
2018-04-09 15:44       ` Takashi Iwai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hzi2ce65m.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=dvyukov@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=o-takashi@sakamocchi.jp \
    --cc=perex@perex.cz \
    --cc=syzbot+803e0047ac3a3096bb4f@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox