All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@gnu.org>
To: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	QEMU Developers <qemu-devel@nongnu.org>,
	"patches@linaro.org" <patches@linaro.org>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Prasad J Pandit <pjp@fedoraproject.org>,
	liqsub1 <liqsub1@163.com>
Subject: Re: [Qemu-devel] [PATCH for-3.0] slirp: Correct size check in m_inc()
Date: Thu, 9 Aug 2018 23:54:21 +0200	[thread overview]
Message-ID: <20180809215421.hexdewc3igklwvob@var.youpi.perso.aquilenet.fr> (raw)
In-Reply-To: <20180809113204.GB2618@work-vm>

Dr. David Alan Gilbert, le jeu. 09 août 2018 12:32:05 +0100, a ecrit:
> >    |--datasize---->|---m_len------->
> >    |----------m_size------------------------------>
> >                    |----M_ROOM-------------------->
> >                                     |-M_FREEROOM-->
> > 
> >    ^               ^                               ^
> >    m_dat           m_data                          end of buffer
> > 
> > ("datasize" is a bit misnamed, as it's "size of the leading
> > gap between the start of the buffer and the data"; "gapsize"
> > would be more helpful.)
> > 
> > Anyway, we allocate size + datasize, and
> > m_size == datasize + M_ROOM. We know that size >= M_ROOM,
> > so the allocated buffer must be at least m_size big.
> 
> Ah OK, thanks.
> (That ascii art could do with being in a comment somewhere!)

Indeed. Peter, maybe your Signed-off-by on this? :)

Samuel

commit 4be85a1eeb6b19e91491e689d4d0d054030cbb49
Author: Peter Maydell <peter.maydell@linaro.org>
Date:   Thu Aug 9 23:52:59 2018 +0200

    slirp: document mbuf pointers and sizes
    
    Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

diff --git a/slirp/mbuf.h b/slirp/mbuf.h
index 33b84485d6..a5bb3f9e66 100644
--- a/slirp/mbuf.h
+++ b/slirp/mbuf.h
@@ -47,6 +47,16 @@
  * free the m_ext.  This is inefficient memory-wise, but who cares.
  */
 
+/*
+ *  |--gapsize----->|---m_len------->
+ *  |----------m_size------------------------------>
+ *                  |----M_ROOM-------------------->
+ *                                   |-M_FREEROOM-->
+ *
+ *  ^               ^                               ^
+ *  m_dat/m_ext     m_data                          end of buffer
+ */
+
 /*
  * How much room is in the mbuf, from m_data to the end of the mbuf
  */

  reply	other threads:[~2018-08-09 21:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-07 11:45 [Qemu-devel] [PATCH for-3.0] slirp: Correct size check in m_inc() Peter Maydell
2018-08-07 11:54 ` Samuel Thibault
2018-08-07 12:52 ` Dr. David Alan Gilbert
2018-08-07 12:58   ` Daniel P. Berrangé
2018-08-07 13:07     ` Thomas Huth
2018-08-07 13:09       ` Daniel P. Berrangé
2018-08-07 13:47         ` Peter Maydell
2018-08-07 15:47           ` Markus Armbruster
2018-08-07 15:58             ` Peter Maydell
2018-08-07 13:45 ` Peter Maydell
2018-08-09 11:12 ` Dr. David Alan Gilbert
2018-08-09 11:25   ` Peter Maydell
2018-08-09 11:32     ` Dr. David Alan Gilbert
2018-08-09 21:54       ` Samuel Thibault [this message]
2018-08-10  9:02         ` Peter Maydell
2018-08-10  9:08           ` Samuel Thibault
2018-08-10  9:13             ` Peter Maydell

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=20180809215421.hexdewc3igklwvob@var.youpi.perso.aquilenet.fr \
    --to=samuel.thibault@gnu.org \
    --cc=dgilbert@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=liqsub1@163.com \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=pjp@fedoraproject.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.