06 Jun, 2020

1 commit

  • Fix the following gcc-9.3 warning when building with 'make W=1':
    net/vmw_vsock/vmci_transport.c:2058:6: warning: no previous prototype
    for ‘vmci_vsock_transport_cb’ [-Wmissing-prototypes]
    2058 | void vmci_vsock_transport_cb(bool is_host)
    | ^~~~~~~~~~~~~~~~~~~~~~~

    Fixes: b1bba80a4376 ("vsock/vmci: register vmci_transport only when VMCI guest/host are active")
    Reported-by: kernel test robot
    Signed-off-by: Stefano Garzarella
    Signed-off-by: David S. Miller

    Stefano Garzarella
     

12 Dec, 2019

1 commit

  • The VMADDR_CID_RESERVED (1) was used by VMCI, but now it is not
    used anymore, so we can reuse it for local communication
    (loopback) adding the new well-know CID: VMADDR_CID_LOCAL.

    Cc: Jorgen Hansen
    Reviewed-by: Stefan Hajnoczi
    Reviewed-by: Jorgen Hansen
    Signed-off-by: Stefano Garzarella
    Signed-off-by: David S. Miller

    Stefano Garzarella
     

15 Nov, 2019

6 commits

  • This patch adds 'module' member in the 'struct vsock_transport'
    in order to get/put the transport module. This prevents the
    module unloading while sockets are assigned to it.

    We increase the module refcnt when a socket is assigned to a
    transport, and we decrease the module refcnt when the socket
    is destructed.

    Reviewed-by: Stefan Hajnoczi
    Reviewed-by: Jorgen Hansen
    Signed-off-by: Stefano Garzarella
    Signed-off-by: David S. Miller

    Stefano Garzarella
     
  • To allow other transports to be loaded with vmci_transport,
    we register the vmci_transport as G2H or H2G only when a VMCI guest
    or host is active.

    To do that, this patch adds a callback registered in the vmci driver
    that will be called when the host or guest becomes active.
    This callback will register the vmci_transport in the VSOCK core.

    Cc: Jorgen Hansen
    Signed-off-by: Stefano Garzarella
    Signed-off-by: David S. Miller

    Stefano Garzarella
     
  • This patch adds the support of multiple transports in the
    VSOCK core.

    With the multi-transports support, we can use vsock with nested VMs
    (using also different hypervisors) loading both guest->host and
    host->guest transports at the same time.

    Major changes:
    - vsock core module can be loaded regardless of the transports
    - vsock_core_init() and vsock_core_exit() are renamed to
    vsock_core_register() and vsock_core_unregister()
    - vsock_core_register() has a feature parameter (H2G, G2H, DGRAM)
    to identify which directions the transport can handle and if it's
    support DGRAM (only vmci)
    - each stream socket is assigned to a transport when the remote CID
    is set (during the connect() or when we receive a connection request
    on a listener socket).
    The remote CID is used to decide which transport to use:
    - remote CID host transport;
    - remote CID == local_cid (guest->host transport) will use guest->host
    transport for loopback (host->guest transports don't support loopback);
    - remote CID > VMADDR_CID_HOST will use host->guest transport;
    - listener sockets are not bound to any transports since no transport
    operations are done on it. In this way we can create a listener
    socket, also if the transports are not loaded or with VMADDR_CID_ANY
    to listen on all transports.
    - DGRAM sockets are handled as before, since only the vmci_transport
    provides this feature.

    Signed-off-by: Stefano Garzarella
    Signed-off-by: David S. Miller

    Stefano Garzarella
     
  • All transports call __vsock_create() with the same parameters,
    most of them depending on the parent socket. In order to simplify
    the VSOCK core APIs exposed to the transports, this patch adds
    the vsock_create_connected() callable from transports to create
    a new socket when a connection request is received.
    We also unexported the __vsock_create().

    Suggested-by: Stefan Hajnoczi
    Reviewed-by: Stefan Hajnoczi
    Reviewed-by: Jorgen Hansen
    Signed-off-by: Stefano Garzarella
    Signed-off-by: David S. Miller

    Stefano Garzarella
     
  • virtio_transport and vmci_transport handle the buffer_size
    sockopts in a very similar way.

    In order to support multiple transports, this patch moves this
    handling in the core to allow the user to change the options
    also if the socket is not yet assigned to any transport.

    This patch also adds the '.notify_buffer_size' callback in the
    'struct virtio_transport' in order to inform the transport,
    when the buffer_size is changed by the user. It is also useful
    to limit the 'buffer_size' requested (e.g. virtio transports).

    Acked-by: Dexuan Cui
    Reviewed-by: Stefan Hajnoczi
    Reviewed-by: Jorgen Hansen
    Signed-off-by: Stefano Garzarella
    Signed-off-by: David S. Miller

    Stefano Garzarella
     
  • The VSOCK_DEFAULT_CONNECT_TIMEOUT definition was introduced with
    commit d021c344051af ("VSOCK: Introduce VM Sockets"), but it is
    never used in the net/vmw_vsock/vmci_transport.c.

    VSOCK_DEFAULT_CONNECT_TIMEOUT is used and defined in
    net/vmw_vsock/af_vsock.c

    Cc: Jorgen Hansen
    Reviewed-by: Stefan Hajnoczi
    Reviewed-by: Jorgen Hansen
    Signed-off-by: Stefano Garzarella
    Signed-off-by: David S. Miller

    Stefano Garzarella
     

07 Nov, 2019

1 commit


05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation version 2 and no later version this
    program is distributed in the hope that it will be useful but
    without any warranty without even the implied warranty of
    merchantability or fitness for a particular purpose see the gnu
    general public license for more details

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 33 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Kate Stewart
    Reviewed-by: Alexios Zavras
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190530000435.345978407@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

09 Feb, 2019

1 commit

  • In the unlikely event that the kmalloc call in vmci_transport_socket_init()
    fails, we end-up calling vmci_transport_destruct() with a NULL vmci_trans()
    and oopsing.

    This change addresses the above explicitly checking for zero vmci_trans()
    at destruction time.

    Reported-by: Xiumei Mu
    Fixes: d021c344051a ("VSOCK: Introduce VM Sockets")
    Signed-off-by: Paolo Abeni
    Reviewed-by: Stefano Garzarella
    Reviewed-by: Jorgen Hansen
    Signed-off-by: David S. Miller

    Paolo Abeni
     

19 Dec, 2018

1 commit

  • If a server side socket is bound to an address, but not in the listening
    state yet, incoming connection requests should receive a reset control
    packet in response. However, the function used to send the reset
    silently drops the reset packet if the sending socket isn't bound
    to a remote address (as is the case for a bound socket not yet in
    the listening state). This change fixes this by using the src
    of the incoming packet as destination for the reset packet in
    this case.

    Fixes: d021c344051a ("VSOCK: Introduce VM Sockets")
    Reviewed-by: Adit Ranadive
    Reviewed-by: Vishnu Dasa
    Signed-off-by: Jorgen Hansen
    Signed-off-by: David S. Miller

    Jorgen Hansen
     

08 Aug, 2018

1 commit

  • syzbot reported that we reinitialize an active delayed
    work in vsock_stream_connect():

    ODEBUG: init active (active state 0) object type: timer_list hint:
    delayed_work_timer_fn+0x0/0x90 kernel/workqueue.c:1414
    WARNING: CPU: 1 PID: 11518 at lib/debugobjects.c:329
    debug_print_object+0x16a/0x210 lib/debugobjects.c:326

    The pattern is apparently wrong, we should only initialize
    the dealyed work once and could repeatly schedule it. So we
    have to move out the initializations to allocation side.
    And to avoid confusion, we can split the shared dwork
    into two, instead of re-using the same one.

    Fixes: d021c344051a ("VSOCK: Introduce VM Sockets")
    Reported-by:
    Cc: Andy king
    Cc: Stefan Hajnoczi
    Cc: Jorgen Hansen
    Signed-off-by: Cong Wang
    Signed-off-by: David S. Miller

    Cong Wang
     

29 Nov, 2017

1 commit

  • A recent commit (3b4477d2dcf2) converted the sk_state to use
    TCP constants. In that change, vmci_transport_handle_detach
    was changed such that sk->sk_state was set to TCP_CLOSE before
    we test whether it is TCP_SYN_SENT. This change moves the
    sk_state change back to the original locations in that function.

    Signed-off-by: Jorgen Hansen
    Reviewed-by: Stefan Hajnoczi
    Signed-off-by: David S. Miller

    Jorgen Hansen
     

26 Nov, 2017

1 commit

  • When using the host personality, VMCI will grab a mutex for any
    queue pair access. In the detach callback for the vmci vsock
    transport, we call vsock_stream_has_data while holding a spinlock,
    and vsock_stream_has_data will access a queue pair.

    To avoid this, we can simply omit calling vsock_stream_has_data
    for host side queue pairs, since the QPs are empty per default
    when the guest has detached.

    This bug affects users of VMware Workstation using kernel version
    4.4 and later.

    Testing: Ran vsock tests between guest and host, and verified that
    with this change, the host isn't calling vsock_stream_has_data
    during detach. Ran mixedTest between guest and host using both
    guest and host as server.

    v2: Rebased on top of recent change to sk_state values
    Reviewed-by: Adit Ranadive
    Reviewed-by: Aditya Sarwade
    Reviewed-by: Stefan Hajnoczi
    Signed-off-by: Jorgen Hansen
    Signed-off-by: David S. Miller

    Jorgen Hansen
     

06 Oct, 2017

1 commit

  • There are two state fields: socket->state and sock->sk_state. The
    socket->state field uses SS_UNCONNECTED, SS_CONNECTED, etc while the
    sock->sk_state typically uses values that match TCP state constants
    (TCP_CLOSE, TCP_ESTABLISHED). AF_VSOCK does not follow this convention
    and instead uses SS_* constants for both fields.

    The sk_state field will be exposed to userspace through the vsock_diag
    interface for ss(8), netstat(8), and other programs.

    This patch switches sk_state to TCP state constants so that the meaning
    of this field is consistent with other address families. Not just
    AF_INET and AF_INET6 use the TCP constants, AF_UNIX and others do too.

    The following mapping was used to convert the code:

    SS_FREE -> TCP_CLOSE
    SS_UNCONNECTED -> TCP_CLOSE
    SS_CONNECTING -> TCP_SYN_SENT
    SS_CONNECTED -> TCP_ESTABLISHED
    SS_DISCONNECTING -> TCP_CLOSING
    VSOCK_SS_LISTEN -> TCP_LISTEN

    In __vsock_create() the sk_state initialization was dropped because
    sock_init_data() already initializes sk_state to TCP_CLOSE.

    Signed-off-by: Stefan Hajnoczi
    Signed-off-by: David S. Miller

    Stefan Hajnoczi
     

20 Sep, 2017

1 commit


31 Mar, 2017

1 commit

  • Rather than assign the positive errno values to ret and then
    checking if it is positive and flip the sign, just return the
    errno value.

    Detected by CoverityScan, CID#986649 ("Logically Dead Code")

    Signed-off-by: Colin Ian King
    Reviewed-by: Stefan Hajnoczi
    Reviewed-by: Jorgen Hansen
    Acked-by: Michael S. Tsirkin
    Signed-off-by: David S. Miller

    Colin Ian King
     

02 Aug, 2016

1 commit

  • The virtio transport will implement graceful shutdown and the related
    SO_LINGER socket option. This requires orphaning the sock but keeping
    it in the table of connections after .release().

    This patch adds the vsock_remove_sock() function and leaves it up to the
    transport when to remove the sock.

    Signed-off-by: Stefan Hajnoczi
    Signed-off-by: Michael S. Tsirkin

    Stefan Hajnoczi
     

04 May, 2016

1 commit


20 Apr, 2016

1 commit


07 Apr, 2016

1 commit

  • The check in vmci_transport_peer_detach_cb should only allow a
    detach when the qp handle of the transport matches the one in
    the detach message.

    Testing: Before this change, a detach from a peer on a different
    socket would cause an active stream socket to register a detach.

    Reviewed-by: George Zhang
    Signed-off-by: Jorgen Hansen
    Signed-off-by: David S. Miller

    Jorgen Hansen
     

05 Nov, 2015

1 commit

  • When a listen socket enqueues a connection for userspace to accept(),
    the sk->sk_data_ready() callback should be invoked. In-kernel socket
    users rely on this callback to detect when incoming connections are
    available.

    Currently the sk->sk_state_change() callback is invoked by
    vmci_transport.c. This happens to work for userspace applications since
    sk->sk_state_change = sock_def_wakeup() and sk->sk_data_ready =
    sock_def_readable() both wake up the accept() waiter. In-kernel socket
    users, on the other hand, fail to detect incoming connections.

    Signed-off-by: Stefan Hajnoczi
    Signed-off-by: David S. Miller

    Stefan Hajnoczi
     

02 Nov, 2015

1 commit

  • The SS_LISTEN socket state is defined by both af_vsock.c and
    vmci_transport.c. This is risky since the value could be changed in one
    file and the other would be out of sync.

    Rename from SS_LISTEN to VSOCK_SS_LISTEN since the constant is not part
    of enum socket_state (SS_CONNECTED, ...). This way it is clear that the
    constant is vsock-specific.

    The big text reflow in af_vsock.c was necessary to keep to the maximum
    line length. Text is unchanged except for s/SS_LISTEN/VSOCK_SS_LISTEN/.

    Signed-off-by: Stefan Hajnoczi
    Signed-off-by: David S. Miller

    Stefan Hajnoczi
     

23 Oct, 2015

1 commit

  • The recent fix for the vsock sock_put issue used the wrong
    initializer for the transport spin_lock causing an issue when
    running with lockdep checking.

    Testing: Verified fix on kernel with lockdep enabled.

    Reviewed-by: Thomas Hellstrom
    Signed-off-by: Jorgen Hansen
    Signed-off-by: David S. Miller

    Jorgen Hansen
     

22 Oct, 2015

1 commit

  • In the vsock vmci_transport driver, sock_put wasn't safe to call
    in interrupt context, since that may call the vsock destructor
    which in turn calls several functions that should only be called
    from process context. This change defers the callling of these
    functions to a worker thread. All these functions were
    deallocation of resources related to the transport itself.

    Furthermore, an unused callback was removed to simplify the
    cleanup.

    Multiple customers have been hitting this issue when using
    VMware tools on vSphere 2015.

    Also added a version to the vmci transport module (starting from
    1.0.2.0-k since up until now it appears that this module was
    sharing version with vsock that is currently at 1.0.1.0-k).

    Reviewed-by: Aditya Asarwade
    Reviewed-by: Thomas Hellstrom
    Signed-off-by: Jorgen Hansen
    Signed-off-by: David S. Miller

    Jorgen Hansen
     

11 May, 2015

1 commit


03 Mar, 2015

1 commit

  • After TIPC doesn't depend on iocb argument in its internal
    implementations of sendmsg() and recvmsg() hooks defined in proto
    structure, no any user is using iocb argument in them at all now.
    Then we can drop the redundant iocb argument completely from kinds of
    implementations of both sendmsg() and recvmsg() in the entire
    networking stack.

    Cc: Christoph Hellwig
    Suggested-by: Al Viro
    Signed-off-by: Ying Xue
    Signed-off-by: David S. Miller

    Ying Xue
     

04 Feb, 2015

1 commit


10 Dec, 2014

2 commits


24 Nov, 2014

1 commit


06 Nov, 2014

1 commit

  • This encapsulates all of the skb_copy_datagram_iovec() callers
    with call argument signature "skb, offset, msghdr->msg_iov, length".

    When we move to iov_iters in the networking, the iov_iter object will
    sit in the msghdr.

    Having a helper like this means there will be less places to touch
    during that transformation.

    Based upon descriptions and patch from Al Viro.

    Signed-off-by: David S. Miller

    David S. Miller
     

19 Jan, 2014

1 commit

  • This is a follow-up patch to f3d3342602f8bc ("net: rework recvmsg
    handler msg_name and msg_namelen logic").

    DECLARE_SOCKADDR validates that the structure we use for writing the
    name information to is not larger than the buffer which is reserved
    for msg->msg_name (which is 128 bytes). Also use DECLARE_SOCKADDR
    consistently in sendmsg code paths.

    Signed-off-by: Steffen Hurrle
    Suggested-by: Hannes Frederic Sowa
    Acked-by: Hannes Frederic Sowa
    Signed-off-by: David S. Miller

    Steffen Hurrle
     

21 Nov, 2013

1 commit


28 Jul, 2013

1 commit


24 Jun, 2013

2 commits


08 Apr, 2013

2 commits