qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Hugo Lefeuvre <hle@debian.org>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: P J P <ppandit@redhat.com>, Eric Blake <eblake@redhat.com>,
	Qemu Developers <qemu-devel@nongnu.org>,
	Laurent Vivier <lvivier@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Thomas Huth <thuth@redhat.com>,
	Prasad J Pandit <pjp@fedoraproject.org>,
	Arash TC <tohidi.arash@gmail.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	debian-lts@lists.debian.org
Subject: Re: [Qemu-devel] [PATCH v2] bt: use size_t type for length parameters instead of int
Date: Tue, 29 Jan 2019 14:13:11 +0100	[thread overview]
Message-ID: <20190129131311.GA1478@hle-laptop> (raw)
In-Reply-To: <83722857-5a7f-c722-4b56-6b04d78a9e2e@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1878 bytes --]

Hi Philippe,

> I have been assigned to fix this issue, but rather fixing locally this
> BT device, fix the pattern on all devices.
> I'll post the series during the week and Cc you (and eventually the
> Debian LTS list when it gets merged). The series obsoletes this patch,
> so the plan is to not apply it.

Thanks ! I will wait for your patch then.

> > Any reason why assert() calls are used here ?
> > 
> > These checks should always be executed, but they won't if user compiles
> > without asserts. Also, AFAIK any assert failure will stop the qemu host
> > process which is not what we want in this case.
> 
> There was a discussion about this, and the outcome is QEMU does not
> support building without assertions. See this commit:
> 
> https://git.qemu.org/?p=qemu.git;a=blobdiff;f=include/qemu/osdep.h;h=9966638;hp=6855b94;hb=262a69f42;hpb=825bfa005

Makes sense. But I'm still sceptical about assert() being used here.

For example:

    @@ -113,6 +113,7 @@ static void vhci_host_send(void *opaque,
         static uint8_t buf[4096];
     
         buf[0] = type;
    +    assert(len < sizeof(buf));
         memcpy(buf + 1, data, len);
     
         while (write(s->fd, buf, len + 1) < 0)

From my understanding assert() calls are supposed to be a way to verify
code assumptions at runtime. assert failures are always bugs, so they
terminate the process.

If len is passed by guest systems, an excessive value should not be
considered a bug but invalid user passed input, that is normal behaviour,
right? In this case I expect qemu to simply reject the input instead of
triggering an assert failure and terminating.

regards,
 Hugo

-- 
                Hugo Lefeuvre (hle)    |    www.owl.eu.com
RSA4096_ 360B 03B3 BF27 4F4D 7A3F D5E8 14AA 1EB8 A247 3DFD
ed25519_ 37B2 6D38 0B25 B8A2 6B9F 3A65 A36F 5357 5F2D DC4C

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2019-01-29 13:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-19 11:07 [Qemu-devel] [PATCH v2] bt: use size_t type for length parameters instead of int P J P
2018-11-28  7:06 ` P J P
2018-11-28  8:53 ` Thomas Huth
2018-11-28  9:05   ` [Qemu-devel] [Qemu-trivial] " Laurent Vivier
2019-01-28  9:31 ` [Qemu-devel] " Hugo Lefeuvre
2019-01-28 11:50   ` Philippe Mathieu-Daudé
2019-01-29 13:13     ` Hugo Lefeuvre [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=20190129131311.GA1478@hle-laptop \
    --to=hle@debian.org \
    --cc=debian-lts@lists.debian.org \
    --cc=eblake@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=pjp@fedoraproject.org \
    --cc=ppandit@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    --cc=tohidi.arash@gmail.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;
as well as URLs for NNTP newsgroup(s).