qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Volker Rümelin" <vr_qemu@t-online.de>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>
Cc: QEMU <qemu-devel@nongnu.org>, "Zoltán Kővágó" <dirty.ice.hu@gmail.com>
Subject: Re: [PATCH] ossaudio: fix out of bounds write
Date: Wed, 8 Jul 2020 22:09:43 +0200	[thread overview]
Message-ID: <82608aa1-33d6-4b72-1ff3-a426f38178cd@t-online.de> (raw)
In-Reply-To: <4591613b-067d-ac5d-99d0-d8b7a3cf0ce1@redhat.com>

> On 7/7/20 8:08 PM, Volker Rümelin wrote:
>> In function oss_read() a read error currently does not exit the
>> read loop. With no data to read the variable pos will quickly
>> underflow and a subsequent successful read overwrites memory
>> outside the buffer. This patch adds the missing break statement
>> to the error path of the function.
> Correct, but ...
>
>> To reproduce start qemu with -audiodev oss,id=audio0 and in the
>> guest start audio recording. After some time this will trigger
>> an exception.
>>
>> Fixes: 3ba4066d08 "ossaudio: port to the new audio backend api"
>>
>> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
>> ---
>>  audio/ossaudio.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/audio/ossaudio.c b/audio/ossaudio.c
>> index f88d076ec2..a7dcaa31ad 100644
>> --- a/audio/ossaudio.c
>> +++ b/audio/ossaudio.c
>> @@ -691,6 +691,7 @@ static size_t oss_read(HWVoiceIn *hw, void *buf, size_t len)
>>                             len, dst);
>>                  break;
>>              }
>> +            break;
>>          }
>>  
>>          pos += nread;
> ... now pos += -1, then the size returned misses the last byte.
>
Hi Philippe,

no, the added break breaks the while loop. The next executed instruction after this break is the return pos statement not pos += nread.

With best regards,
Volker



  reply	other threads:[~2020-07-08 20:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 18:08 [PATCH] ossaudio: fix out of bounds write Volker Rümelin
2020-07-08  8:30 ` Philippe Mathieu-Daudé
2020-07-08 20:09   ` Volker Rümelin [this message]
2020-07-09  1:08   ` BALATON Zoltan
2020-07-09 12:55   ` Gerd Hoffmann

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=82608aa1-33d6-4b72-1ff3-a426f38178cd@t-online.de \
    --to=vr_qemu@t-online.de \
    --cc=dirty.ice.hu@gmail.com \
    --cc=kraxel@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).