05 Oct, 2020

1 commit

  • When a new incoming call arrives at an userspace rxrpc socket on a new
    connection that has a security class set, the code currently pushes it onto
    the accept queue to hold a ref on it for the socket. This doesn't work,
    however, as recvmsg() pops it off, notices that it's in the SERVER_SECURING
    state and discards the ref. This means that the call runs out of refs too
    early and the kernel oopses.

    By contrast, a kernel rxrpc socket manually pre-charges the incoming call
    pool with calls that already have user call IDs assigned, so they are ref'd
    by the call tree on the socket.

    Change the mode of operation for userspace rxrpc server sockets to work
    like this too. Although this is a UAPI change, server sockets aren't
    currently functional.

    Fixes: 248f219cb8bc ("rxrpc: Rewrite the data and ack handling code")
    Signed-off-by: David Howells

    David Howells
     

24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

31 Jul, 2020

1 commit

  • There's a race between rxrpc_sendmsg setting up a call, but then failing to
    send anything on it due to an error, and recvmsg() seeing the call
    completion occur and trying to return the state to the user.

    An assertion fails in rxrpc_recvmsg() because the call has already been
    released from the socket and is about to be released again as recvmsg deals
    with it. (The recvmsg_q queue on the socket holds a ref, so there's no
    problem with use-after-free.)

    We also have to be careful not to end up reporting an error twice, in such
    a way that both returns indicate to userspace that the user ID supplied
    with the call is no longer in use - which could cause the client to
    malfunction if it recycles the user ID fast enough.

    Fix this by the following means:

    (1) When sendmsg() creates a call after the point that the call has been
    successfully added to the socket, don't return any errors through
    sendmsg(), but rather complete the call and let recvmsg() retrieve
    them. Make sendmsg() return 0 at this point. Further calls to
    sendmsg() for that call will fail with ESHUTDOWN.

    Note that at this point, we haven't send any packets yet, so the
    server doesn't yet know about the call.

    (2) If sendmsg() returns an error when it was expected to create a new
    call, it means that the user ID wasn't used.

    (3) Mark the call disconnected before marking it completed to prevent an
    oops in rxrpc_release_call().

    (4) recvmsg() will then retrieve the error and set MSG_EOR to indicate
    that the user ID is no longer known by the kernel.

    An oops like the following is produced:

    kernel BUG at net/rxrpc/recvmsg.c:605!
    ...
    RIP: 0010:rxrpc_recvmsg+0x256/0x5ae
    ...
    Call Trace:
    ? __init_waitqueue_head+0x2f/0x2f
    ____sys_recvmsg+0x8a/0x148
    ? import_iovec+0x69/0x9c
    ? copy_msghdr_from_user+0x5c/0x86
    ___sys_recvmsg+0x72/0xaa
    ? __fget_files+0x22/0x57
    ? __fget_light+0x46/0x51
    ? fdget+0x9/0x1b
    do_recvmmsg+0x15e/0x232
    ? _raw_spin_unlock+0xa/0xb
    ? vtime_delta+0xf/0x25
    __x64_sys_recvmmsg+0x2c/0x2f
    do_syscall_64+0x4c/0x78
    entry_SYSCALL_64_after_hwframe+0x44/0xa9

    Fixes: 357f5ef64628 ("rxrpc: Call rxrpc_release_call() on error in rxrpc_new_client_call()")
    Reported-by: syzbot+b54969381df354936d96@syzkaller.appspotmail.com
    Signed-off-by: David Howells
    Reviewed-by: Marc Dionne
    Signed-off-by: David S. Miller

    David Howells
     

21 Jul, 2020

1 commit

  • rxrpc_sendmsg() returns EPIPE if there's an outstanding error, such as if
    rxrpc_recvmsg() indicating ENODATA if there's nothing for it to read.

    Change rxrpc_recvmsg() to return EAGAIN instead if there's nothing to read
    as this particular error doesn't get stored in ->sk_err by the networking
    core.

    Also change rxrpc_sendmsg() so that it doesn't fail with delayed receive
    errors (there's no way for it to report which call, if any, the error was
    caused by).

    Fixes: 17926a79320a ("[AF_RXRPC]: Provide secure RxRPC sockets for use by userspace and kernel both")
    Signed-off-by: David Howells
    Signed-off-by: David S. Miller

    David Howells
     

05 Jun, 2020

2 commits

  • Under some circumstances, rxrpc will fail a transmit a packet through the
    underlying UDP socket (ie. UDP sendmsg returns an error). This may result
    in a call getting stuck.

    In the instance being seen, where AFS tries to send a probe to the Volume
    Location server, tracepoints show the UDP Tx failure (in this case returing
    error 99 EADDRNOTAVAIL) and then nothing more:

    afs_make_vl_call: c=0000015d VL.GetCapabilities
    rxrpc_call: c=0000015d NWc u=1 sp=rxrpc_kernel_begin_call+0x106/0x170 [rxrpc] a=00000000dd89ee8a
    rxrpc_call: c=0000015d Gus u=2 sp=rxrpc_new_client_call+0x14f/0x580 [rxrpc] a=00000000e20e4b08
    rxrpc_call: c=0000015d SEE u=2 sp=rxrpc_activate_one_channel+0x7b/0x1c0 [rxrpc] a=00000000e20e4b08
    rxrpc_call: c=0000015d CON u=2 sp=rxrpc_kernel_begin_call+0x106/0x170 [rxrpc] a=00000000e20e4b08
    rxrpc_tx_fail: c=0000015d r=1 ret=-99 CallDataNofrag

    The problem is that if the initial packet fails and the retransmission
    timer hasn't been started, the call is set to completed and an error is
    returned from rxrpc_send_data_packet() to rxrpc_queue_packet(). Though
    rxrpc_instant_resend() is called, this does nothing because the call is
    marked completed.

    So rxrpc_notify_socket() isn't called and the error is passed back up to
    rxrpc_send_data(), rxrpc_kernel_send_data() and thence to afs_make_call()
    and afs_vl_get_capabilities() where it is simply ignored because it is
    assumed that the result of a probe will be collected asynchronously.

    Fileserver probing is similarly affected via afs_fs_get_capabilities().

    Fix this by always issuing a notification in __rxrpc_set_call_completion()
    if it shifts a call to the completed state, even if an error is also
    returned to the caller through the function return value.

    Also put in a little bit of optimisation to avoid taking the call
    state_lock and disabling softirqs if the call is already in the completed
    state and remove some now redundant rxrpc_notify_socket() calls.

    Fixes: f5c17aaeb2ae ("rxrpc: Calls should only have one terminal state")
    Reported-by: Gerry Seidman
    Signed-off-by: David Howells
    Reviewed-by: Marc Dionne

    David Howells
     
  • Move the handling of call completion out of line so that the next patch can
    add more code in that area.

    Signed-off-by: David Howells
    Reviewed-by: Marc Dionne

    David Howells
     

11 May, 2020

1 commit

  • rxrpc currently uses a fixed 4s retransmission timeout until the RTT is
    sufficiently sampled. This can cause problems with some fileservers with
    calls to the cache manager in the afs filesystem being dropped from the
    fileserver because a packet goes missing and the retransmission timeout is
    greater than the call expiry timeout.

    Fix this by:

    (1) Copying the RTT/RTO calculation code from Linux's TCP implementation
    and altering it to fit rxrpc.

    (2) Altering the various users of the RTT to make use of the new SRTT
    value.

    (3) Replacing the use of rxrpc_resend_timeout to use the calculated RTO
    value instead (which is needed in jiffies), along with a backoff.

    Notes:

    (1) rxrpc provides RTT samples by matching the serial numbers on outgoing
    DATA packets that have the RXRPC_REQUEST_ACK set and PING ACK packets
    against the reference serial number in incoming REQUESTED ACK and
    PING-RESPONSE ACK packets.

    (2) Each packet that is transmitted on an rxrpc connection gets a new
    per-connection serial number, even for retransmissions, so an ACK can
    be cross-referenced to a specific trigger packet. This allows RTT
    information to be drawn from retransmitted DATA packets also.

    (3) rxrpc maintains the RTT/RTO state on the rxrpc_peer record rather than
    on an rxrpc_call because many RPC calls won't live long enough to
    generate more than one sample.

    (4) The calculated SRTT value is in units of 8ths of a microsecond rather
    than nanoseconds.

    The (S)RTT and RTO values are displayed in /proc/net/rxrpc/peers.

    Fixes: 17926a79320a ([AF_RXRPC]: Provide secure RxRPC sockets for use by userspace and kernel both"")
    Signed-off-by: David Howells

    David Howells
     

14 Mar, 2020

3 commits

  • Fix the handling of sendmsg() with MSG_WAITALL for userspace to round the
    timeout for when a signal occurs up to at least two jiffies as a 1 jiffy
    timeout may end up being effectively 0 if jiffies wraps at the wrong time.

    Fixes: bc5e3a546d55 ("rxrpc: Use MSG_WAITALL to tell sendmsg() to temporarily ignore signals")
    Signed-off-by: David Howells

    David Howells
     
  • Fix the interruptibility of kernel-initiated client calls so that they're
    either only interruptible when they're waiting for a call slot to come
    available or they're not interruptible at all. Either way, they're not
    interruptible during transmission.

    This should help prevent StoreData calls from being interrupted when
    writeback is in progress. It doesn't, however, handle interruption during
    the receive phase.

    Userspace-initiated calls are still interruptable. After the signal has
    been handled, sendmsg() will return the amount of data copied out of the
    buffer and userspace can perform another sendmsg() call to continue
    transmission.

    Fixes: bc5e3a546d55 ("rxrpc: Use MSG_WAITALL to tell sendmsg() to temporarily ignore signals")
    Signed-off-by: David Howells

    David Howells
     
  • Abstract out the calculation of there being sufficient Tx buffer space.
    This is reproduced several times in the rxrpc sendmsg code.

    Signed-off-by: David Howells

    David Howells
     

07 Oct, 2019

2 commits

  • Fix the cleanup of the crypto state on a call after the call has been
    disconnected. As the call has been disconnected, its connection ref has
    been discarded and so we can't go through that to get to the security ops
    table.

    Fix this by caching the security ops pointer in the rxrpc_call struct and
    using that when freeing the call security state. Also use this in other
    places we're dealing with call-specific security.

    The symptoms look like:

    BUG: KASAN: use-after-free in rxrpc_release_call+0xb2d/0xb60
    net/rxrpc/call_object.c:481
    Read of size 8 at addr ffff888062ffeb50 by task syz-executor.5/4764

    Fixes: 1db88c534371 ("rxrpc: Fix -Wframe-larger-than= warnings from on-stack crypto")
    Reported-by: syzbot+eed305768ece6682bb7f@syzkaller.appspotmail.com
    Signed-off-by: David Howells

    David Howells
     
  • When sendmsg() finds a call to continue on with, if the call is in an
    inappropriate state, it doesn't release the ref it just got on that call
    before returning an error.

    This causes the following symptom to show up with kasan:

    BUG: KASAN: use-after-free in rxrpc_send_keepalive+0x8a2/0x940
    net/rxrpc/output.c:635
    Read of size 8 at addr ffff888064219698 by task kworker/0:3/11077

    where line 635 is:

    whdr.epoch = htonl(peer->local->rxnet->epoch);

    The local endpoint (which cannot be pinned by the call) has been released,
    but not the peer (which is pinned by the call).

    Fix this by releasing the call in the error path.

    Fixes: 37411cad633f ("rxrpc: Fix potential NULL-pointer exception")
    Reported-by: syzbot+d850c266e3df14da1d31@syzkaller.appspotmail.com
    Signed-off-by: David Howells

    David Howells
     

27 Aug, 2019

2 commits


30 Jul, 2019

1 commit

  • Fix the fact that a notification isn't sent to the recvmsg side to indicate
    a call failed when sendmsg() fails to transmit a DATA packet with the error
    ENETUNREACH, EHOSTUNREACH or ECONNREFUSED.

    Without this notification, the afs client just sits there waiting for the
    call to complete in some manner (which it's not now going to do), which
    also pins the rxrpc call in place.

    This can be seen if the client has a scope-level IPv6 address, but not a
    global-level IPv6 address, and we try and transmit an operation to a
    server's IPv6 address.

    Looking in /proc/net/rxrpc/calls shows completed calls just sat there with
    an abort code of RX_USER_ABORT and an error code of -ENETUNREACH.

    Fixes: c54e43d752c7 ("rxrpc: Fix missing start of call timeout")
    Signed-off-by: David Howells
    Reviewed-by: Marc Dionne
    Reviewed-by: Jeffrey Altman

    David Howells
     

24 May, 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 licence as published by
    the free software foundation either version 2 of the licence or at
    your option any later version

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

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

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

    Thomas Gleixner
     

16 May, 2019

1 commit

  • Allow kernel services using AF_RXRPC to indicate that a call should be
    non-interruptible. This allows kafs to make things like lock-extension and
    writeback data storage calls non-interruptible.

    If this is set, signals will be ignored for operations on that call where
    possible - such as waiting to get a call channel on an rxrpc connection.

    It doesn't prevent UDP sendmsg from being interrupted, but that will be
    handled by packet retransmission.

    rxrpc_kernel_recv_data() isn't affected by this since that never waits,
    preferring instead to return -EAGAIN and leave the waiting to the caller.

    Userspace initiated calls can't be set to be uninterruptible at this time.

    Signed-off-by: David Howells

    David Howells
     

13 Apr, 2019

1 commit

  • Change rxrpc_queue_packet()'s signature so that it can return any error
    code it may encounter when trying to send the packet.

    This allows the caller to eventually do something in case of error - though
    it should be noted that the packet has been queued and a resend is
    scheduled.

    Signed-off-by: Marc Dionne
    Signed-off-by: David Howells
    Signed-off-by: David S. Miller

    Marc Dionne
     

16 Jan, 2019

1 commit

  • The changes introduced to allow rxrpc calls to be retried creates an issue
    when it comes to refcounting afs_call structs. The problem is that when
    rxrpc_send_data() queues the last packet for an asynchronous call, the
    following sequence can occur:

    (1) The notify_end_tx callback is invoked which causes the state in the
    afs_call to be changed from AFS_CALL_CL_REQUESTING or
    AFS_CALL_SV_REPLYING.

    (2) afs_deliver_to_call() can then process event notifications from rxrpc
    on the async_work queue.

    (3) Delivery of events, such as an abort from the server, can cause the
    afs_call state to be changed to AFS_CALL_COMPLETE on async_work.

    (4) For an asynchronous call, afs_process_async_call() notes that the call
    is complete and tried to clean up all the refs on async_work.

    (5) rxrpc_send_data() might return the amount of data transferred
    (success) or an error - which could in turn reflect a local error or a
    received error.

    Synchronising the clean up after rxrpc_kernel_send_data() returns an error
    with the asynchronous cleanup is then tricky to get right.

    Mostly revert commit c038a58ccfd6704d4d7d60ed3d6a0fca13cf13a4. The two API
    functions the original commit added aren't currently used. This makes
    rxrpc_kernel_send_data() always return successfully if it queued the data
    it was given.

    Note that this doesn't affect synchronous calls since their Rx notification
    function merely pokes a wait queue and does not refcounting. The
    asynchronous call notification function *has* to do refcounting and pass a
    ref over the work item to avoid the need to sync the workqueue in call
    cleanup.

    Signed-off-by: David Howells
    Signed-off-by: David S. Miller

    David Howells
     

11 May, 2018

1 commit

  • The expect_rx_by call timeout is supposed to be set when a call is started
    to indicate that we need to receive a packet by that point. This is
    currently put back every time we receive a packet, but it isn't started
    when we first send a packet. Without this, the call may wait forever if
    the server doesn't deign to reply.

    Fix this by setting the timeout upon a successful UDP sendmsg call for the
    first DATA packet. The timeout is initiated only for initial transmission
    and not for subsequent retries as we don't want the retry mechanism to
    extend the timeout indefinitely.

    Fixes: a158bdd3247b ("rxrpc: Fix call timeouts")
    Reported-by: Marc Dionne
    Signed-off-by: David Howells

    David Howells
     

31 Mar, 2018

3 commits

  • When a new client call is requested, an rxrpc_conn_parameters struct object
    is passed in with a bunch of parameters set, such as the local endpoint to
    use. A pointer to the target peer record is also placed in there by
    rxrpc_get_client_conn() - and this is removed if and only if a new
    connection object is allocated. Thus it leaks if a new connection object
    isn't allocated.

    Fix this by putting any peer object attached to the rxrpc_conn_parameters
    object in the function that allocated it.

    Fixes: 19ffa01c9c45 ("rxrpc: Use structs to hold connection params and protocol info")
    Signed-off-by: David Howells

    David Howells
     
  • Fix various issues detected by checker.

    Errors:

    (*) rxrpc_discard_prealloc() should be using rcu_assign_pointer to set
    call->socket.

    Warnings:

    (*) rxrpc_service_connection_reaper() should be passing NULL rather than 0 to
    trace_rxrpc_conn() as the where argument.

    (*) rxrpc_disconnect_client_call() should get its net pointer via the
    call->conn rather than call->sock to avoid a warning about accessing
    an RCU pointer without protection.

    (*) Proc seq start/stop functions need annotation as they pass locks
    between the functions.

    False positives:

    (*) Checker doesn't correctly handle of seq-retry lock context balance in
    rxrpc_find_service_conn_rcu().

    (*) Checker thinks execution may proceed past the BUG() in
    rxrpc_publish_service_conn().

    (*) Variable length array warnings from SKCIPHER_REQUEST_ON_STACK() in
    rxkad.c.

    Signed-off-by: David Howells

    David Howells
     
  • rxrpc calls have a ring of packets that are awaiting ACK or retransmission
    and a parallel ring of annotations that tracks the state of those packets.
    If the initial transmission of a packet on the underlying UDP socket fails
    then the packet annotation is marked for resend - but the setting of this
    mark accidentally erases the last-packet mark also stored in the same
    annotation slot. If this happens, a call won't switch out of the Tx phase
    when all the packets have been transmitted.

    Fix this by retaining the last-packet mark and only altering the packet
    state.

    Fixes: 248f219cb8bc ("rxrpc: Rewrite the data and ack handling code")
    Signed-off-by: David Howells

    David Howells
     

28 Mar, 2018

1 commit

  • In rxrpc and afs, use the debug_ids that are monotonically allocated to
    various objects as they're allocated rather than pointers as kernel
    pointers are now hashed making them less useful. Further, the debug ids
    aren't reused anywhere nearly as quickly.

    In addition, allow kernel services that use rxrpc, such as afs, to take
    numbers from the rxrpc counter, assign them to their own call struct and
    pass them in to rxrpc for both client and service calls so that the trace
    lines for each will have the same ID tag.

    Signed-off-by: David Howells

    David Howells
     

29 Nov, 2017

1 commit

  • Values assigned to both variable resend_at and ack_at are overwritten
    before they can be used.

    The correct fix here is to add 'now' to the previously computed value in
    resend_at and ack_at.

    Addresses-Coverity-ID: 1462262
    Addresses-Coverity-ID: 1462263
    Addresses-Coverity-ID: 1462264
    Fixes: beb8e5e4f38c ("rxrpc: Express protocol timeouts in terms of RTT")
    Link: https://marc.info/?i=17004.1511808959%40warthog.procyon.org.uk
    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: David Howells

    Gustavo A. R. Silva
     

24 Nov, 2017

6 commits

  • Add an extra timeout that is set/updated when we send a DATA packet that
    has the request-ack flag set. This allows us to detect if we don't get an
    ACK in response to the latest flagged packet.

    The ACK packet is adjudged to have been lost if it doesn't turn up within
    2*RTT of the transmission.

    If the timeout occurs, we schedule the sending of a PING ACK to find out
    the state of the other side. If a new DATA packet is ready to go sooner,
    we cancel the sending of the ping and set the request-ack flag on that
    instead.

    If we get back a PING-RESPONSE ACK that indicates a lower tx_top than what
    we had at the time of the ping transmission, we adjudge all the DATA
    packets sent between the response tx_top and the ping-time tx_top to have
    been lost and retransmit immediately.

    Rather than sending a PING ACK, we could just pick a DATA packet and
    speculatively retransmit that with request-ack set. It should result in
    either a REQUESTED ACK or a DUPLICATE ACK which we can then use in lieu the
    a PING-RESPONSE ACK mentioned above.

    Signed-off-by: David Howells

    David Howells
     
  • Express protocol timeouts for data retransmission and deferred ack
    generation in terms on RTT rather than specified timeouts once we have
    sufficient RTT samples.

    For the moment, this requires just one RTT sample to be able to use this
    for ack deferral and two for data retransmission.

    The data retransmission timeout is set at RTT*1.5 and the ACK deferral
    timeout is set at RTT.

    Note that the calculated timeout is limited to a minimum of 4ns to make
    sure it doesn't happen too quickly.

    Signed-off-by: David Howells

    David Howells
     
  • Fix the rxrpc call expiration timeouts and make them settable from
    userspace. By analogy with other rx implementations, there should be three
    timeouts:

    (1) "Normal timeout"

    This is set for all calls and is triggered if we haven't received any
    packets from the peer in a while. It is measured from the last time
    we received any packet on that call. This is not reset by any
    connection packets (such as CHALLENGE/RESPONSE packets).

    If a service operation takes a long time, the server should generate
    PING ACKs at a duration that's substantially less than the normal
    timeout so is to keep both sides alive. This is set at 1/6 of normal
    timeout.

    (2) "Idle timeout"

    This is set only for a service call and is triggered if we stop
    receiving the DATA packets that comprise the request data. It is
    measured from the last time we received a DATA packet.

    (3) "Hard timeout"

    This can be set for a call and specified the maximum lifetime of that
    call. It should not be specified by default. Some operations (such
    as volume transfer) take a long time.

    Allow userspace to set/change the timeouts on a call with sendmsg, using a
    control message:

    RXRPC_SET_CALL_TIMEOUTS

    The data to the message is a number of 32-bit words, not all of which need
    be given:

    u32 hard_timeout; /* sec from first packet */
    u32 idle_timeout; /* msec from packet Rx */
    u32 normal_timeout; /* msec from data Rx */

    This can be set in combination with any other sendmsg() that affects a
    call.

    Signed-off-by: David Howells

    David Howells
     
  • When rxrpc_sendmsg() parses the control message buffer, it places the
    parameters extracted into a structure, but lumps together call parameters
    (such as user call ID) with operation parameters (such as whether to send
    data, send an abort or accept a call).

    Split the call parameters out into their own structure, a copy of which is
    then embedded in the operation parameters struct.

    The call parameters struct is then passed down into the places that need it
    instead of passing the individual parameters. This allows for extra call
    parameters to be added.

    Signed-off-by: David Howells

    David Howells
     
  • Don't set upgrade by default when creating a call from sendmsg(). This is
    a holdover from when I was testing the code.

    Signed-off-by: David Howells

    David Howells
     
  • The caller of rxrpc_accept_call() must release the lock on call->user_mutex
    returned by that function.

    Signed-off-by: David Howells

    David Howells
     

24 Oct, 2017

1 commit


18 Oct, 2017

1 commit

  • Make AF_RXRPC accept MSG_WAITALL as a flag to sendmsg() to tell it to
    ignore signals whilst loading up the message queue, provided progress is
    being made in emptying the queue at the other side.

    Progress is defined as the base of the transmit window having being
    advanced within 2 RTT periods. If the period is exceeded with no progress,
    sendmsg() will return anyway, indicating how much data has been copied, if
    any.

    Once the supplied buffer is entirely decanted, the sendmsg() will return.

    Signed-off-by: David Howells

    David Howells
     

29 Aug, 2017

3 commits

  • Allow a client call that failed on network error to be retried, provided
    that the Tx queue still holds DATA packet 1. This allows an operation to
    be submitted to another server or another address for the same server
    without having to repackage and re-encrypt the data so far processed.

    Two new functions are provided:

    (1) rxrpc_kernel_check_call() - This is used to find out the completion
    state of a call to guess whether it can be retried and whether it
    should be retried.

    (2) rxrpc_kernel_retry_call() - Disconnect the call from its current
    connection, reset the state and submit it as a new client call to a
    new address. The new address need not match the previous address.

    A call may be retried even if all the data hasn't been loaded into it yet;
    a partially constructed will be retained at the same point it was at when
    an error condition was detected. msg_data_left() can be used to find out
    how much data was packaged before the error occurred.

    Signed-off-by: David Howells

    David Howells
     
  • Add a callback to rxrpc_kernel_send_data() so that a kernel service can get
    a notification that the AF_RXRPC call has transitioned out the Tx phase and
    is now waiting for a reply or a final ACK.

    This is called from AF_RXRPC with the call state lock held so the
    notification is guaranteed to come before any reply is passed back.

    Further, modify the AFS filesystem to make use of this so that we don't have
    to change the afs_call state before sending the last bit of data.

    Signed-off-by: David Howells

    David Howells
     
  • call->error is stored as 0 or a negative error code. Don't negate this
    value (ie. make it positive) before returning it from a kernel function
    (though it should still be negated before passing to userspace through a
    control message).

    Signed-off-by: David Howells

    David Howells
     

16 Jun, 2017

1 commit

  • There were many places that my previous spatch didn't find,
    as pointed out by yuan linyu in various patches.

    The following spatch found many more and also removes the
    now unnecessary casts:

    @@
    identifier p, p2;
    expression len;
    expression skb;
    type t, t2;
    @@
    (
    -p = skb_put(skb, len);
    +p = skb_put_zero(skb, len);
    |
    -p = (t)skb_put(skb, len);
    +p = skb_put_zero(skb, len);
    )
    ... when != p
    (
    p2 = (t2)p;
    -memset(p2, 0, len);
    |
    -memset(p, 0, len);
    )

    @@
    type t, t2;
    identifier p, p2;
    expression skb;
    @@
    t *p;
    ...
    (
    -p = skb_put(skb, sizeof(t));
    +p = skb_put_zero(skb, sizeof(t));
    |
    -p = (t *)skb_put(skb, sizeof(t));
    +p = skb_put_zero(skb, sizeof(t));
    )
    ... when != p
    (
    p2 = (t2)p;
    -memset(p2, 0, sizeof(*p));
    |
    -memset(p, 0, sizeof(*p));
    )

    @@
    expression skb, len;
    @@
    -memset(skb_put(skb, len), 0, len);
    +skb_put_zero(skb, len);

    Apply it to the tree (with one manual fixup to keep the
    comment in vxlan.c, which spatch removed.)

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     

08 Jun, 2017

2 commits

  • Provide a control message that can be specified on the first sendmsg() of a
    client call or the first sendmsg() of a service response to indicate the
    total length of the data to be transmitted for that call.

    Currently, because the length of the payload of an encrypted DATA packet is
    encrypted in front of the data, the packet cannot be encrypted until we
    know how much data it will hold.

    By specifying the length at the beginning of the transmit phase, each DATA
    packet length can be set before we start loading data from userspace (where
    several sendmsg() calls may contribute to a particular packet).

    An error will be returned if too little or too much data is presented in
    the Tx phase.

    Signed-off-by: David Howells

    David Howells
     
  • Consolidate the sendmsg control message parameters into a struct rather
    than passing them individually through the argument list of
    rxrpc_sendmsg_cmsg(). This makes it easier to add more parameters.

    Signed-off-by: David Howells

    David Howells
     

05 Jun, 2017

1 commit

  • Make it possible for a client to use AuriStor's service upgrade facility.

    The client does this by adding an RXRPC_UPGRADE_SERVICE control message to
    the first sendmsg() of a call. This takes no parameters.

    When recvmsg() starts returning data from the call, the service ID field in
    the returned msg_name will reflect the result of the upgrade attempt. If
    the upgrade was ignored, srx_service will match what was set in the
    sendmsg(); if the upgrade happened the srx_service will be altered to
    indicate the service the server upgraded to.

    Note that:

    (1) The choice of upgrade service is up to the server

    (2) Further client calls to the same server that would share a connection
    are blocked if an upgrade probe is in progress.

    (3) This should only be used to probe the service. Clients should then
    use the returned service ID in all subsequent communications with that
    server (and not set the upgrade). Note that the kernel will not
    retain this information should the connection expire from its cache.

    (4) If a server that supports upgrading is replaced by one that doesn't,
    whilst a connection is live, and if the replacement is running, say,
    OpenAFS 1.6.4 or older or an older IBM AFS, then the replacement
    server will not respond to packets sent to the upgraded connection.

    At this point, calls will time out and the server must be reprobed.

    Signed-off-by: David Howells

    David Howells