[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PULL v1 03/11] sockets: Handle race condition between
From: |
Daniel P. Berrange |
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 |
User-agent: |
Mutt/1.9.1 (2017-09-22) |
On Fri, Nov 03, 2017 at 06:54:44PM +0000, Peter Maydell wrote:
> On 16 October 2017 at 21:16, Daniel P. Berrange <address@hidden> wrote:
> > From: Knut Omang <address@hidden>
> >
> > 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 <address@hidden>
> > Reviewed-by: Yuval Shaia <address@hidden>
> > Reviewed-by: Girish Moodalbail <address@hidden>
> > Signed-off-by: Knut Omang <address@hidden>
> > Reviewed-by: Daniel P. Berrange <address@hidden>
> > Signed-off-by: Daniel P. Berrange <address@hidden>
>
> 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 :|