08 Oct, 2016

1 commit

  • Pull VFS splice updates from Al Viro:
    "There's a bunch of branches this cycle, both mine and from other folks
    and I'd rather send pull requests separately.

    This one is the conversion of ->splice_read() to ITER_PIPE iov_iter
    (and introduction of such). Gets rid of a lot of code in fs/splice.c
    and elsewhere; there will be followups, but these are for the next
    cycle... Some pipe/splice-related cleanups from Miklos in the same
    branch as well"

    * 'work.splice_read' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    pipe: fix comment in pipe_buf_operations
    pipe: add pipe_buf_steal() helper
    pipe: add pipe_buf_confirm() helper
    pipe: add pipe_buf_release() helper
    pipe: add pipe_buf_get() helper
    relay: simplify relay_file_read()
    switch default_file_splice_read() to use of pipe-backed iov_iter
    switch generic_file_splice_read() to use of ->read_iter()
    new iov_iter flavour: pipe-backed
    fuse_dev_splice_read(): switch to add_to_pipe()
    skb_splice_bits(): get rid of callback
    new helper: add_to_pipe()
    splice: lift pipe_lock out of splice_to_pipe()
    splice: switch get_iovec_page_array() to iov_iter
    splice_to_pipe(): don't open-code wakeup_pipe_readers()
    consistent treatment of EFAULT on O_DIRECT read/write

    Linus Torvalds
     

04 Oct, 2016

1 commit

  • since pipe_lock is the outermost now, we don't need to drop/regain
    socket locks around the call of splice_to_pipe() from skb_splice_bits(),
    which kills the need to have a socket-specific callback; we can just
    call splice_to_pipe() and be done with that.

    Signed-off-by: Al Viro

    Al Viro
     

13 Sep, 2016

1 commit


01 Sep, 2016

1 commit

  • Dmitry reported a double free on kcm socket, which could
    be easily reproduced by:

    #include
    #include

    int main()
    {
    int fd = syscall(SYS_socket, 0x29ul, 0x5ul, 0x0ul, 0, 0, 0);
    syscall(SYS_ioctl, fd, 0x89e2ul, 0x20a98000ul, 0, 0, 0);
    return 0;
    }

    This is because on the error path, after we install
    the new socket file, we call sock_release() to clean
    up the socket, which leaves the fd pointing to a freed
    socket. Fix this by calling sys_close() on that fd
    directly.

    Fixes: ab7ac4eb9832 ("kcm: Kernel Connection Multiplexor module")
    Reported-by: Dmitry Vyukov
    Cc: Tom Herbert
    Signed-off-by: Cong Wang
    Signed-off-by: David S. Miller

    WANG Cong
     

29 Aug, 2016

1 commit


24 Aug, 2016

1 commit

  • Lock the lower socket in kcm_unattach. Release during call to strp_done
    since that function cancels the RX timers and work queue with sync.

    Also added some status information in psock reporting.

    Signed-off-by: Tom Herbert
    Signed-off-by: David S. Miller

    Tom Herbert
     

18 Aug, 2016

1 commit

  • Adapt KCM to use the stream parser. This mostly involves removing
    the RX handling and setting up the strparser using the interface.

    Signed-off-by: Tom Herbert
    Signed-off-by: David S. Miller

    Tom Herbert
     

26 Jul, 2016

1 commit


02 Jul, 2016

1 commit

  • Since bpf_prog_get() and program type check is used in a couple of places,
    refactor this into a small helper function that we can make use of. Since
    the non RO prog->aux part is not used in performance critical paths and a
    program destruction via RCU is rather very unlikley when doing the put, we
    shouldn't have an issue just doing the bpf_prog_get() + prog->type != type
    check, but actually not taking the ref at all (due to being in fdget() /
    fdput() section of the bpf fd) is even cleaner and makes the diff smaller
    as well, so just go for that. Callsites are changed to make use of the new
    helper where possible.

    Signed-off-by: Daniel Borkmann
    Acked-by: Alexei Starovoitov
    Signed-off-by: David S. Miller

    Daniel Borkmann
     

23 Jun, 2016

1 commit

  • Every open of /proc/net/kcm leaks 16 bytes of memory as is reported by
    kmemleak:
    unreferenced object 0xffff88059c0e3458 (size 192):
    comm "cat", pid 1401, jiffies 4294935742 (age 310.720s)
    hex dump (first 32 bytes):
    28 45 71 96 05 88 ff ff 00 10 00 00 00 00 00 00 (Eq.............
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    backtrace:
    [] kmem_cache_alloc_trace+0x16e/0x230
    [] seq_open+0x79/0x1d0
    [] kcm_seq_open+0x0/0x30 [kcm]
    [] seq_open+0x79/0x1d0
    [] __seq_open_private+0x2f/0xa0
    [] seq_open_net+0x38/0xa0
    ...

    It is caused by a missing free in the ->release path. So fix it by
    providing seq_release_net as the ->release method.

    Signed-off-by: Jiri Slaby
    Fixes: cd6e111bf5 (kcm: Add statistics and proc interfaces)
    Cc: "David S. Miller"
    Cc: Tom Herbert
    Cc: netdev@vger.kernel.org
    Signed-off-by: David S. Miller

    Jiri Slaby
     

20 May, 2016

1 commit

  • skb_splice_bits() returns int, kcm_splice_read() returns ssize_t,
    both are signed.

    We may need another patch to make them all ssize_t, but that
    deserves a separated patch.

    Fixes: 91687355b927 ("kcm: Splice support")
    Reported-by: David Binderman
    Cc: Tom Herbert
    Signed-off-by: Cong Wang
    Signed-off-by: David S. Miller

    WANG Cong
     

10 Mar, 2016

6 commits

  • This patch adds receive timeout for message assembly on the attached TCP
    sockets. The timeout is set when a new messages is started and the whole
    message has not been received by TCP (not in the receive queue). If the
    completely message is subsequently received the timer is cancelled, if the
    timer expires the RX side is aborted.

    The timeout value is taken from the socket timeout (SO_RCVTIMEO) that is
    set on a TCP socket (i.e. set by get sockopt before attaching a TCP socket
    to KCM.

    Signed-off-by: Tom Herbert
    Signed-off-by: David S. Miller

    Tom Herbert
     
  • Message assembly is performed on the TCP socket. This is logically
    equivalent of an application that performs a peek on the socket to find
    out how much memory is needed for a receive buffer. The receive socket
    buffer also provides the maximum message size which is checked.

    The receive algorithm is something like:

    1) Receive the first skbuf for a message (or skbufs if multiple are
    needed to determine message length).
    2) Check the message length against the number of bytes in the TCP
    receive queue (tcp_inq()).
    - If all the bytes of the message are in the queue (incluing the
    skbuf received), then proceed with message assembly (it should
    complete with the tcp_read_sock)
    - Else, mark the psock with the number of bytes needed to
    complete the message.
    3) In TCP data ready function, if the psock indicates that we are
    waiting for the rest of the bytes of a messages, check the number
    of queued bytes against that.
    - If there are still not enough bytes for the message, just
    return
    - Else, clear the waiting bytes and proceed to receive the
    skbufs. The message should now be received in one
    tcp_read_sock

    Signed-off-by: Tom Herbert
    Signed-off-by: David S. Miller

    Tom Herbert
     
  • Implement kcm_sendpage. Set in sendpage to kcm_sendpage in both
    dgram and seqpacket ops.

    Signed-off-by: Tom Herbert
    Signed-off-by: David S. Miller

    Tom Herbert
     
  • Implement kcm_splice_read. This is supported only for seqpacket.
    Add kcm_seqpacket_ops and set splice read to kcm_splice_read.

    Signed-off-by: Tom Herbert
    Signed-off-by: David S. Miller

    Tom Herbert
     
  • This patch adds various counters for KCM. These include counters for
    messages and bytes received or sent, as well as counters for number of
    attached/unattached TCP sockets and other error or edge events.

    The statistics are exposed via a proc interface. /proc/net/kcm provides
    statistics per KCM socket and per psock (attached TCP sockets).
    /proc/net/kcm_stats provides aggregate statistics.

    Signed-off-by: Tom Herbert
    Signed-off-by: David S. Miller

    Tom Herbert
     
  • This module implements the Kernel Connection Multiplexor.

    Kernel Connection Multiplexor (KCM) is a facility that provides a
    message based interface over TCP for generic application protocols.
    With KCM an application can efficiently send and receive application
    protocol messages over TCP using datagram sockets.

    For more information see the included Documentation/networking/kcm.txt

    Signed-off-by: Tom Herbert
    Signed-off-by: David S. Miller

    Tom Herbert