lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <s5hlh722ksl.wl-tiwai@suse.de>
Date:	Wed, 03 Feb 2016 10:41:14 +0100
From:	Takashi Iwai <tiwai@...e.de>
To:	"Dmitry Vyukov" <dvyukov@...gle.com>
Cc:	<alsa-devel@...a-project.org>, "Jaroslav Kysela" <perex@...ex.cz>,
	"LKML" <linux-kernel@...r.kernel.org>,
	"Alexander Potapenko" <glider@...gle.com>,
	"Kostya Serebryany" <kcc@...gle.com>,
	"syzkaller" <syzkaller@...glegroups.com>,
	"Sasha Levin" <sasha.levin@...cle.com>
Subject: Re: sound: out-of-bounds write in snd_rawmidi_kernel_write1

On Wed, 03 Feb 2016 10:35:14 +0100,
Takashi Iwai wrote:
> 
> On Wed, 03 Feb 2016 09:57:50 +0100,
> Dmitry Vyukov wrote:
> > 
> > Hello,
> > 
> > The following program triggers an out-of-bounds write in
> > snd_rawmidi_kernel_write1 (run in parallel loop). It seems to try to
> > copy -1 bytes (aka 4GB) from user space into kernel smashing all on
> > its way.
> 
> What card is /dev/midi3?  Please check /proc/asound/cards.
> Is it MTPAV?

In anyway the patch below should paper over it.  But it's still
strange that it gets a negative value there.  Could you put

   WARN_ON(count1 < 0)

before the newly added check?

I tried it locally with virmidi but it didn't appear, so far.  Maybe
my setup is too slow and has fewer CPUs than yours.


thanks,

Takashi

---
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index 26ca02248885..2fef77d9de50 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -1239,6 +1239,8 @@ static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream,
 	}
 	while (count > 0 && runtime->avail > 0) {
 		count1 = runtime->buffer_size - runtime->appl_ptr;
+		if (count1 <= 0)
+			break;
 		if (count1 > count)
 			count1 = count;
 		if (count1 > (long)runtime->avail)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ