1. 06 Jul, 2016 11 commits
    • David Howells's avatar
      rxrpc: Access socket accept queue under right lock · 30b515f4
      David Howells authored
      The socket's accept queue (socket->acceptq) should be accessed under
      socket->call_lock, not under the connection lock.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      30b515f4
    • David Howells's avatar
      rxrpc: Add RCU destruction for connections and calls · dee46364
      David Howells authored
      Add RCU destruction for connections and calls as the RCU lookup from the
      transport socket data_ready handler is going to come along shortly.
      
      Whilst we're at it, move the cleanup workqueue flushing and RCU barrierage
      into the destruction code for the objects that need it (locals and
      connections) and add the extra RCU barrier required for connection cleanup.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      dee46364
    • David Howells's avatar
      rxrpc: Release a call's connection ref on call disconnection · e653cfe4
      David Howells authored
      When a call is disconnected, clear the call's pointer to the connection and
      release the associated ref on that connection.  This means that the call no
      longer pins the connection and the connection can be discarded even before
      the call is.
      
      As the code currently stands, the call struct is effectively pinned by
      userspace until userspace has enacted a recvmsg() to retrieve the final
      call state as sk_buffs on the receive queue pin the call to which they're
      related because:
      
       (1) The rxrpc_call struct contains the userspace ID that recvmsg() has to
           include in the control message buffer to indicate which call is being
           referred to.  This ID must remain valid until the terminal packet is
           completely read and must be invalidated immediately at that point as
           userspace is entitled to immediately reuse it.
      
       (2) The final ACK to the reply to a client call isn't sent until the last
           data packet is entirely read (it's probably worth altering this in
           future to be send the ACK as soon as all the data has been received).
      
      
      This change requires a bit of rearrangement to make sure that the call
      isn't going to try and access the connection again after protocol
      completion:
      
       (1) Delete the error link earlier when we're releasing the call.  Possibly
           network errors should be distributed via connections at the cost of
           adding in an access to the rxrpc_connection struct.
      
       (2) Remove the call from the connection's call tree before disconnecting
           the call.  The call tree needs to be removed anyway and incoming
           packets delivered by channel pointer instead.
      
       (3) The release call event should be considered last after all other
           events have been processed so that we don't need access to the
           connection again.
      
       (4) Move the channel_lock taking from rxrpc_release_call() to
           rxrpc_disconnect_call() where it will be required in future.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      e653cfe4
    • David Howells's avatar
      rxrpc: Fix handling of connection failure in client call creation · d1e858c5
      David Howells authored
      If rxrpc_connect_call() fails during the creation of a client connection,
      there are two bugs that we can hit that need fixing:
      
       (1) The call state should be moved to RXRPC_CALL_DEAD before the call
           cleanup phase is invoked.  If not, this can cause an assertion failure
           later.
      
       (2) call->link should be reinitialised after being deleted in
           rxrpc_new_client_call() - which otherwise leads to a failure later
           when the call cleanup attempts to delete the link again.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      d1e858c5
    • David Howells's avatar
      rxrpc: Move usage count getting into rxrpc_queue_conn() · 2c4579e4
      David Howells authored
      Rather than calling rxrpc_get_connection() manually before calling
      rxrpc_queue_conn(), do it inside the queue wrapper.
      
      This allows us to do some important fixes:
      
       (1) If the usage count is 0, do nothing.  This prevents connections from
           being reanimated once they're dead.
      
       (2) If rxrpc_queue_work() fails because the work item is already queued,
           retract the usage count increment which would otherwise be lost.
      
       (3) Don't take a ref on the connection in the work function.  By passing
           the ref through the work item, this is unnecessary.  Doing it in the
           work function is too late anyway.  Previously, connection-directed
           packets held a ref on the connection, but that's not really the best
           idea.
      
      And another useful changes:
      
       (*) Don't need to take a refcount on the connection in the data_ready
           handler unless we invoke the connection's work item.  We're using RCU
           there so that's otherwise redundant.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      2c4579e4
    • David Howells's avatar
      rxrpc: Check that the client conns cache is empty before module removal · eb9b9d22
      David Howells authored
      Check that the client conns cache is empty before module removal and bug if
      not, listing any offending connections that are still present.  Unfortunately,
      if there are connections still around, then the transport socket is still
      unexpectedly open and active, so we can't just unallocate the connections.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      eb9b9d22
    • David Howells's avatar
      rxrpc: Turn connection #defines into enums and put outside struct def · bba304db
      David Howells authored
      Turn the connection event and state #define lists into enums and move
      outside of the struct definition.
      
      Whilst we're at it, change _SERVER to _SERVICE in those identifiers and add
      EV_ into the event name to distinguish them from flags and states.
      
      Also add a symbol indicating the number of states and use that in the state
      text array.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      bba304db
    • David Howells's avatar
      rxrpc: Provide queuing helper functions · 5acbee46
      David Howells authored
      Provide queueing helper functions so that the queueing of local and
      connection objects can be fixed later.
      
      The issue is that a ref on the object needs to be passed to the work queue,
      but the act of queueing the object may fail because the object is already
      queued.  Testing the queuedness of an object before hand doesn't work
      because there can be a race with someone else trying to queue it.  What
      will have to be done is to adjust the refcount depending on the result of
      the queue operation.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      5acbee46
    • Herbert Xu's avatar
      rxrpc: Avoid using stack memory in SG lists in rxkad · a263629d
      Herbert Xu authored
      rxkad uses stack memory in SG lists which would not work if stacks were
      allocated from vmalloc memory.  In fact, in most cases this isn't even
      necessary as the stack memory ends up getting copied over to kmalloc
      memory.
      
      This patch eliminates all the unnecessary stack memory uses by supplying
      the final destination directly to the crypto API.  In two instances where a
      temporary buffer is actually needed we also switch use a scratch area in
      the rxrpc_call struct (only one DATA packet will be being secured or
      verified at a time).
      
      Finally there is no need to split a split-page buffer into two SG entries
      so code dealing with that has been removed.
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      a263629d
    • David Howells's avatar
      rxrpc: Check the source of a packet to a client conn · 689f4c64
      David Howells authored
      When looking up a client connection to which to route a packet, we need to
      check that the packet came from the correct source so that a peer can't try
      to muck around with another peer's connection.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      689f4c64
    • David Howells's avatar
      rxrpc: Fix some sparse errors · 88b99d0b
      David Howells authored
      Fix the following sparse errors:
      
      ../net/rxrpc/conn_object.c:77:17: warning: incorrect type in assignment (different base types)
      ../net/rxrpc/conn_object.c:77:17:    expected restricted __be32 [usertype] call_id
      ../net/rxrpc/conn_object.c:77:17:    got unsigned int [unsigned] [usertype] call_id
      ../net/rxrpc/conn_object.c:84:21: warning: restricted __be32 degrades to integer
      ../net/rxrpc/conn_object.c:86:26: warning: restricted __be32 degrades to integer
      ../net/rxrpc/conn_object.c:357:15: warning: incorrect type in assignment (different base types)
      ../net/rxrpc/conn_object.c:357:15:    expected restricted __be32 [usertype] epoch
      ../net/rxrpc/conn_object.c:357:15:    got unsigned int [unsigned] [usertype] epoch
      ../net/rxrpc/conn_object.c:369:21: warning: restricted __be32 degrades to integer
      ../net/rxrpc/conn_object.c:371:26: warning: restricted __be32 degrades to integer
      ../net/rxrpc/conn_object.c:411:21: warning: restricted __be32 degrades to integer
      ../net/rxrpc/conn_object.c:413:26: warning: restricted __be32 degrades to integer
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      88b99d0b
  2. 01 Jul, 2016 1 commit
    • David Howells's avatar
      rxrpc: Fix processing of authenticated/encrypted jumbo packets · ac5d2683
      David Howells authored
      When a jumbo packet is being split up and processed, the crypto checksum
      for each split-out packet is in the jumbo header and needs placing in the
      reconstructed packet header.
      
      When the code was changed to keep the stored copy of the packet header in
      host byte order, this reconstruction was missed.
      
      Found with sparse with CF=-D__CHECK_ENDIAN__:
      
          ../net/rxrpc/input.c:479:33: warning: incorrect type in assignment (different base types)
          ../net/rxrpc/input.c:479:33:    expected unsigned short [unsigned] [usertype] _rsvd
          ../net/rxrpc/input.c:479:33:    got restricted __be16 [addressable] [usertype] _rsvd
      
      Fixes: 0d12f8a4 ("rxrpc: Keep the skb private record of the Rx header in host byte order")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      ac5d2683
  3. 27 Jun, 2016 28 commits