qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
	Knut Omang <knut.omang@oracle.com>
Subject: Re: [Qemu-devel] [PULL v1 03/11] sockets: Handle race condition between binds to the same port
Date: Mon, 6 Nov 2017 10:40:53 +0000	[thread overview]
Message-ID: <20171106104053.GD23361@redhat.com> (raw)
In-Reply-To: <CAFEAcA-0as0ACWy-KHv9+DoS+6aaiHShR4xAMj9bXAMQGr3_Lw@mail.gmail.com>

On Fri, Nov 03, 2017 at 06:54:44PM +0000, Peter Maydell wrote:
> On 16 October 2017 at 21:16, Daniel P. Berrange <berrange@redhat.com> wrote:
> > From: Knut Omang <knut.omang@oracle.com>
> >
> > If an offset of ports is specified to the inet_listen_saddr function(),
> > and two or more processes tries to bind from these ports at the same time,
> > occasionally more than one process may be able to bind to the same
> > port. The condition is detected by listen() but too late to avoid a failure.
> >
> > This function is called by socket_listen() and used
> > by all socket listening code in QEMU, so all cases where any form of dynamic
> > port selection is used should be subject to this issue.
> >
> > Add code to close and re-establish the socket when this
> > condition is observed, hiding the race condition from the user.
> >
> > Also clean up some issues with error handling to allow more
> > accurate reporting of the cause of an error.
> >
> > This has been developed and tested by means of the
> > test-listen unit test in the previous commit.
> > Enable the test for make check now that it passes.
> >
> > Reviewed-by: Bhavesh Davda <bhavesh.davda@oracle.com>
> > Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
> > Reviewed-by: Girish Moodalbail <girish.moodalbail@oracle.com>
> > Signed-off-by: Knut Omang <knut.omang@oracle.com>
> > Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
> > Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> 
> Hi. Coverity points out that this code could leak a socket fd
> (CID 1381805):

Yeah, I have a patch posted a week or two back to fix this. I'll get a pull
request in before release to fix it, along with test suite

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

  reply	other threads:[~2017-11-06 10:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-16 20:16 [Qemu-devel] [PULL v1 00/11] Merge QIO 2017-10-16 Daniel P. Berrange
2017-10-16 20:16 ` [Qemu-devel] [PULL v1 01/11] sockets: factor out a new try_bind() function Daniel P. Berrange
2017-10-16 20:16 ` [Qemu-devel] [PULL v1 02/11] sockets: factor out create_fast_reuse_socket Daniel P. Berrange
2017-10-16 20:16 ` [Qemu-devel] [PULL v1 03/11] sockets: Handle race condition between binds to the same port Daniel P. Berrange
2017-11-03 18:54   ` Peter Maydell
2017-11-06 10:40     ` Daniel P. Berrange [this message]
2017-10-16 20:16 ` [Qemu-devel] [PULL v1 04/11] io: monitor encoutput buffer size from websocket GSource Daniel P. Berrange
2017-10-16 20:16 ` [Qemu-devel] [PULL v1 05/11] io: simplify websocket ping reply handling Daniel P. Berrange
2017-10-16 20:16 ` [Qemu-devel] [PULL v1 06/11] io: get rid of qio_channel_websock_encode helper method Daniel P. Berrange
2017-10-16 20:16 ` [Qemu-devel] [PULL v1 07/11] io: pass a struct iovec into qio_channel_websock_encode Daniel P. Berrange
2017-10-16 20:16 ` [Qemu-devel] [PULL v1 08/11] io: get rid of bounce buffering in websock write path Daniel P. Berrange
2017-10-16 20:16 ` [Qemu-devel] [PULL v1 09/11] io: cope with websock 'Connection' header having multiple values Daniel P. Berrange
2017-10-16 20:16 ` [Qemu-devel] [PULL v1 10/11] io: add trace points for websocket HTTP protocol headers Daniel P. Berrange
2017-10-16 20:16 ` [Qemu-devel] [PULL v1 11/11] io: fix mem leak in websock error path Daniel P. Berrange
2017-10-17 12:12 ` [Qemu-devel] [PULL v1 00/11] Merge QIO 2017-10-16 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=20171106104053.GD23361@redhat.com \
    --to=berrange@redhat.com \
    --cc=knut.omang@oracle.com \
    --cc=peter.maydell@linaro.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 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).