qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] c41868: slirp: Don't pass possibly -1 fd to s


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] c41868: slirp: Don't pass possibly -1 fd to send()
Date: Mon, 12 Nov 2018 02:58:34 -0800

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: c41868152a95db5f759bb7da491615eca99e9a40
      
https://github.com/qemu/qemu/commit/c41868152a95db5f759bb7da491615eca99e9a40
  Author: Peter Maydell <address@hidden>
  Date:   2018-11-10 (Sat, 10 Nov 2018)

  Changed paths:
    M slirp/slirp.c

  Log Message:
  -----------
  slirp: Don't pass possibly -1 fd to send()

Coverity complains (CID 1005726) that we might pass -1 as the fd
argument to send() in slirp_send(), because we previously checked for
"so->s == -1 && so->extra".  The case of "so->s == -1 but so->extra
NULL" should not in theory happen, but it is hard to guarantee
because various places in the code do so->s = qemu_socket(...) and so
will end up with so->s == -1 on failure, and not all the paths which
call that always throw away the socket in that case (eg
tcp_fconnect()).  So just check specifically for the condition and
fail slirp_send().

Signed-off-by: Peter Maydell <address@hidden>
Signed-off-by: Samuel Thibault <address@hidden>


  Commit: 84ec9bfaf239b61bac3e43f708772937401e0e63
      
https://github.com/qemu/qemu/commit/84ec9bfaf239b61bac3e43f708772937401e0e63
  Author: Peter Maydell <address@hidden>
  Date:   2018-11-10 (Sat, 10 Nov 2018)

  Changed paths:
    M slirp/socket.c
    M slirp/tcp_input.c
    M slirp/tcp_subr.c

  Log Message:
  -----------
  slirp: Use g_new() to allocate sockets in socreate()

The slirp socreate() function can only fail if the attempt
to malloc() the struct socket fails. Switch to using
g_new() instead, which will allow us to remove the
error-handling code from its callers.

Signed-off-by: Peter Maydell <address@hidden>
Signed-off-by: Samuel Thibault <address@hidden>


  Commit: 4ded9bb54ceefeb68e766fe9aafc10de934c4501
      
https://github.com/qemu/qemu/commit/4ded9bb54ceefeb68e766fe9aafc10de934c4501
  Author: Peter Maydell <address@hidden>
  Date:   2018-11-10 (Sat, 10 Nov 2018)

  Changed paths:
    M slirp/ip_icmp.c
    M slirp/slirp.c
    M slirp/socket.c
    M slirp/tcp_input.c
    M slirp/tcp_subr.c
    M slirp/udp.c
    M slirp/udp6.c

  Log Message:
  -----------
  slirp: Remove code that handles socreate() failure

Now that socreate() can never fail, we can remove the code
that was trying to handle that situation.

In particular this removes code in tcp_connect() that
provoked Coverity to complain (CID 1005724): in
 closesocket(accept(inso->s, (struct sockaddr *)&addr, &addrlen));
if the accept() call fails then we pass closesocket() -1
instead of a valid file descriptor.

Signed-off-by: Peter Maydell <address@hidden>
Signed-off-by: Samuel Thibault <address@hidden>


  Commit: 5c75f3adbbfcdf8fae6e74875b44efb8d928974a
      
https://github.com/qemu/qemu/commit/5c75f3adbbfcdf8fae6e74875b44efb8d928974a
  Author: Peter Maydell <address@hidden>
  Date:   2018-11-10 (Sat, 10 Nov 2018)

  Changed paths:
    M slirp/misc.c

  Log Message:
  -----------
  slirp: fork_exec(): create and connect child socket before fork()

Currently fork_exec() fork()s, and then creates and connects the
child socket which it uses for communication with the parent in
the child process. This is awkward because the child has no
mechanism to report failure back to the parent, which might end
up blocked forever in accept(). The child code also has an issue
pointed out by Coverity (CID 1005727), where if the qemu_socket()
call fails it will pass -1 as a file descriptor to connect().

Fix these issues by moving the creation of the child's end of
the socket to before the fork(), where we are in a position to
handle a possible failure.

Signed-off-by: Peter Maydell <address@hidden>
Signed-off-by: Samuel Thibault <address@hidden>


  Commit: 460f0236c12a86a38692c12d9bf8e2391dc10a77
      
https://github.com/qemu/qemu/commit/460f0236c12a86a38692c12d9bf8e2391dc10a77
  Author: Peter Maydell <address@hidden>
  Date:   2018-11-12 (Mon, 12 Nov 2018)

  Changed paths:
    M slirp/ip_icmp.c
    M slirp/misc.c
    M slirp/slirp.c
    M slirp/socket.c
    M slirp/tcp_input.c
    M slirp/tcp_subr.c
    M slirp/udp.c
    M slirp/udp6.c

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/thibault/tags/samuel-thibault' into 
staging

slirp updates

Peter Maydell (4):
  slirp: Don't pass possibly -1 fd to send()
  slirp: Use g_new() to allocate sockets in socreate()
  slirp: Remove code that handles socreate() failure
  slirp: fork_exec(): create and connect child socket before fork()

# gpg: Signature made Sat 10 Nov 2018 14:08:53 GMT
# gpg:                using RSA key E3F65A9E9560DB4C
# gpg: Good signature from "Samuel Thibault <address@hidden>"
# gpg:                 aka "Samuel Thibault <address@hidden>"
# gpg:                 aka "Samuel Thibault <address@hidden>"
# gpg:                 aka "Samuel Thibault <address@hidden>"
# gpg:                 aka "Samuel Thibault <address@hidden>"
# gpg:                 aka "Samuel Thibault <address@hidden>"
# gpg:                 aka "Samuel Thibault <address@hidden>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 900C B024 B679 31D4 0F82  304B D017 8C76 7D06 9EE6
#      Subkey fingerprint: 33FA 7B64 6195 01F8 CE9C  8F97 E3F6 5A9E 9560 DB4C

* remotes/thibault/tags/samuel-thibault:
  slirp: fork_exec(): create and connect child socket before fork()
  slirp: Remove code that handles socreate() failure
  slirp: Use g_new() to allocate sockets in socreate()
  slirp: Don't pass possibly -1 fd to send()

Signed-off-by: Peter Maydell <address@hidden>


Compare: https://github.com/qemu/qemu/compare/160e5c22e55b...460f0236c12a
      **NOTE:** This service has been marked for deprecation: 
https://developer.github.com/changes/2018-04-25-github-services-deprecation/

      Functionality will be removed from GitHub.com on January 31st, 2019.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]