18 Feb, 2017

2 commits

  • commit 92e55f412cffd016cc245a74278cb4d7b89bb3bc upstream.

    Unlike ipv4, this control socket is shared by all cpus so we cannot use
    it as scratchpad area to annotate the mark that we pass to ip6_xmit().

    Add a new parameter to ip6_xmit() to indicate the mark. The SCTP socket
    family caches the flowi6 structure in the sctp_transport structure, so
    we cannot use to carry the mark unless we later on reset it back, which
    I discarded since it looks ugly to me.

    Fixes: bf99b4ded5f8 ("tcp: fix mark propagation with fwmark_reflect enabled")
    Suggested-by: Eric Dumazet
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Pablo Neira
     
  • [ Upstream commit 2dcab598484185dea7ec22219c76dcdd59e3cb90 ]

    Alexander Popov reported that an application may trigger a BUG_ON in
    sctp_wait_for_sndbuf if the socket tx buffer is full, a thread is
    waiting on it to queue more data and meanwhile another thread peels off
    the association being used by the first thread.

    This patch replaces the BUG_ON call with a proper error handling. It
    will return -EPIPE to the original sendmsg call, similarly to what would
    have been done if the association wasn't found in the first place.

    Acked-by: Alexander Popov
    Signed-off-by: Marcelo Ricardo Leitner
    Reviewed-by: Xin Long
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Marcelo Ricardo Leitner
     

15 Jan, 2017

1 commit

  • [ Upstream commit 08abb79542c9e8c367d1d8e44fe1026868d3f0a7 ]

    Prior to this patch, sctp_transport_lookup_process didn't rcu_read_unlock
    when it failed to find a transport by sctp_addrs_lookup_transport.

    This patch is to fix it by moving up rcu_read_unlock right before checking
    transport and also to remove the out path.

    Fixes: 1cceda784980 ("sctp: fix the issue sctp_diag uses lock_sock in rcu_read_lock")
    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Xin Long
     

15 Nov, 2016

1 commit

  • Now when users shutdown a sock with SEND_SHUTDOWN in sctp, even if
    this sock has no connection (assoc), sk state would be changed to
    SCTP_SS_CLOSING, which is not as we expect.

    Besides, after that if users try to listen on this sock, kernel
    could even panic when it dereference sctp_sk(sk)->bind_hash in
    sctp_inet_listen, as bind_hash is null when sock has no assoc.

    This patch is to move sk state change after checking sk assocs
    is not empty, and also merge these two if() conditions and reduce
    indent level.

    Fixes: d46e416c11c8 ("sctp: sctp should change socket state when shutdown is received")
    Reported-by: Andrey Konovalov
    Tested-by: Andrey Konovalov
    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller

    Xin Long
     

08 Nov, 2016

1 commit

  • sctp_wait_for_connect() currently already holds the asoc to keep it
    alive during the sleep, in case another thread release it. But Andrey
    Konovalov and Dmitry Vyukov reported an use-after-free in such
    situation.

    Problem is that __sctp_connect() doesn't get a ref on the asoc and will
    do a read on the asoc after calling sctp_wait_for_connect(), but by then
    another thread may have closed it and the _put on sctp_wait_for_connect
    will actually release it, causing the use-after-free.

    Fix is, instead of doing the read after waiting for the connect, do it
    before so, and avoid this issue as the socket is still locked by then.
    There should be no issue on returning the asoc id in case of failure as
    the application shouldn't trust on that number in such situations
    anyway.

    This issue doesn't exist in sctp_sendmsg() path.

    Reported-by: Dmitry Vyukov
    Reported-by: Andrey Konovalov
    Tested-by: Andrey Konovalov
    Signed-off-by: Marcelo Ricardo Leitner
    Reviewed-by: Xin Long
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller

    Marcelo Ricardo Leitner
     

01 Nov, 2016

3 commits

  • Prior to this patch, in rx path, before calling lock_sock, it needed to
    hold assoc when got it by __sctp_lookup_association, in case other place
    would free/put assoc.

    But in __sctp_lookup_association, it lookup and hold transport, then got
    assoc by transport->assoc, then hold assoc and put transport. It means
    it didn't hold transport, yet it was returned and later on directly
    assigned to chunk->transport.

    Without the protection of sock lock, the transport may be freed/put by
    other places, which would cause a use-after-free issue.

    This patch is to fix this issue by holding transport instead of assoc.
    As holding transport can make sure to access assoc is also safe, and
    actually it looks up assoc by searching transport rhashtable, to hold
    transport here makes more sense.

    Note that the function will be renamed later on on another patch.

    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Xin Long
     
  • Prior to this patch, it used a local variable to save the transport that is
    looked up by __sctp_lookup_association(), and didn't return it back. But in
    sctp_rcv, it is used to initialize chunk->transport. So when hitting this,
    even if it found the transport, it was still initializing chunk->transport
    with null instead.

    This patch is to return the transport back through transport pointer
    that is from __sctp_rcv_lookup_harder().

    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Xin Long
     
  • In sctp_transport_lookup_process(), Commit 1cceda784980 ("sctp: fix
    the issue sctp_diag uses lock_sock in rcu_read_lock") moved cb() out
    of rcu lock, but it put transport and hold assoc instead, and ignore
    that cb() still uses transport. It may cause a use-after-free issue.

    This patch is to hold transport instead of assoc there.

    Fixes: 1cceda784980 ("sctp: fix the issue sctp_diag uses lock_sock in rcu_read_lock")
    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Xin Long
     

30 Oct, 2016

1 commit

  • Andrey Konovalov reported that KASAN detected that SCTP was using a slab
    beyond the boundaries. It was caused because when handling out of the
    blue packets in function sctp_sf_ootb() it was checking the chunk len
    only after already processing the first chunk, validating only for the
    2nd and subsequent ones.

    The fix is to just move the check upwards so it's also validated for the
    1st chunk.

    Reported-by: Andrey Konovalov
    Tested-by: Andrey Konovalov
    Signed-off-by: Marcelo Ricardo Leitner
    Reviewed-by: Xin Long
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller

    Marcelo Ricardo Leitner
     

27 Oct, 2016

1 commit

  • Commit 7303a1475008 ("sctp: identify chunks that need to be fragmented
    at IP level") made the chunk be fragmented at IP level in the next round
    if it's size exceed PMTU.

    But there still is another case, PMTU can be updated if transport's dst
    expires and transport's pmtu_pending is set in sctp_packet_transmit. If
    the new PMTU is less than the chunk, the same issue with that commit can
    be triggered.

    So we should drop this packet and let it retransmit in another round
    where it would be fragmented at IP level.

    This patch is to fix it by checking the chunk size after PMTU may be
    updated and dropping this packet if it's size exceed PMTU.

    Fixes: 90017accff61 ("sctp: Add GSO support")
    Signed-off-by: Xin Long
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller

    Xin Long
     

24 Oct, 2016

1 commit

  • Most of getsockopt handlers in net/sctp/socket.c check len against
    sizeof some structure like:
    if (len < sizeof(int))
    return -EINVAL;

    On the first look, the check seems to be correct. But since len is int
    and sizeof returns size_t, int gets promoted to unsigned size_t too. So
    the test returns false for negative lengths. Yes, (-1 < sizeof(long)) is
    false.

    Fix this in sctp by explicitly checking len < 0 before any getsockopt
    handler is called.

    Note that sctp_getsockopt_events already handled the negative case.
    Since we added the < 0 check elsewhere, this one can be removed.

    If not checked, this is the result:
    UBSAN: Undefined behaviour in ../mm/page_alloc.c:2722:19
    shift exponent 52 is too large for 32-bit type 'int'
    CPU: 1 PID: 24535 Comm: syz-executor Not tainted 4.8.1-0-syzkaller #1
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.1-0-gb3ef39f-prebuilt.qemu-project.org 04/01/2014
    0000000000000000 ffff88006d99f2a8 ffffffffb2f7bdea 0000000041b58ab3
    ffffffffb4363c14 ffffffffb2f7bcde ffff88006d99f2d0 ffff88006d99f270
    0000000000000000 0000000000000000 0000000000000034 ffffffffb5096422
    Call Trace:
    [] ? __ubsan_handle_shift_out_of_bounds+0x29c/0x300
    ...
    [] ? kmalloc_order+0x24/0x90
    [] ? kmalloc_order_trace+0x24/0x220
    [] ? __kmalloc+0x330/0x540
    [] ? sctp_getsockopt_local_addrs+0x174/0xca0 [sctp]
    [] ? sctp_getsockopt+0x10d/0x1b0 [sctp]
    [] ? sock_common_getsockopt+0xb9/0x150
    [] ? SyS_getsockopt+0x1a5/0x270

    Signed-off-by: Jiri Slaby
    Cc: Vlad Yasevich
    Cc: Neil Horman
    Cc: "David S. Miller"
    Cc: linux-sctp@vger.kernel.org
    Cc: netdev@vger.kernel.org
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller

    Jiri Slaby
     

03 Oct, 2016

1 commit


30 Sep, 2016

5 commits

  • When sctp dumps all the ep->assocs, it needs to lock_sock first,
    but now it locks sock in rcu_read_lock, and lock_sock may sleep,
    which would break rcu_read_lock.

    This patch is to get and hold one sock when traversing the list.
    After that and get out of rcu_read_lock, lock and dump it. Then
    it will traverse the list again to get the next one until all
    sctp socks are dumped.

    For sctp_diag_dump_one, it fixes this issue by holding asoc and
    moving cb() out of rcu_read_lock in sctp_transport_lookup_process.

    Fixes: 8f840e47f190 ("sctp: add the sctp_diag.c file")
    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller

    Xin Long
     
  • Now before using prsctp polices, sctp uses asoc->prsctp_enable to
    check if prsctp is enabled. However asoc->prsctp_enable is set only
    means local host support prsctp, sctp should not abandon packet if
    peer host doesn't enable prsctp.

    So this patch is to use asoc->peer.prsctp_capable to check if prsctp
    is enabled on both side, instead of asoc->prsctp_enable, as asoc's
    peer.prsctp_capable is set only when local and peer both enable prsctp.

    Fixes: a6c2f792873a ("sctp: implement prsctp TTL policy")
    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller

    Xin Long
     
  • Now sctp uses chunk->prsctp_param to save the prsctp param for all the
    prsctp polices, we didn't need to introduce prsctp_param to sctp_chunk.
    We can just use chunk->sinfo.sinfo_timetolive for RTX and BUF polices,
    and reuse msg->expires_at for TTL policy, as the prsctp polices and old
    expires policy are mutual exclusive.

    This patch is to remove prsctp_param from sctp_chunk, and reuse msg's
    expires_at for TTL and chunk's sinfo.sinfo_timetolive for RTX and BUF
    polices.

    Note that sctp can't use chunk's sinfo.sinfo_timetolive for TTL policy,
    as it needs a u64 variables to save the expires_at time.

    This one also fixes the "netperf-Throughput_Mbps -37.2% regression"
    issue.

    Fixes: a6c2f792873a ("sctp: implement prsctp TTL policy")
    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller

    Xin Long
     
  • This is to suppress the checkpatch.pl warning "Comparison to NULL
    could be written". No functional changes here.

    Signed-off-by: Jia He
    Signed-off-by: David S. Miller

    Jia He
     
  • This is to use the generic interfaces snmp_get_cpu_field{,64}_batch to
    aggregate the data by going through all the items of each cpu sequentially.

    Signed-off-by: Jia He
    Signed-off-by: David S. Miller

    Jia He
     

23 Sep, 2016

2 commits

  • sctp_acked() is using 32bit arithmetics on 16bits vars, via TSN_lte()
    macros, which is weird and confusing.

    Once the offset to ctsn is calculated, all wrapping is already handled
    and thus to verify the Gap Ack blocks we can just use pure
    less/big-or-equal than checks.

    Also, rename gap variable to tsn_offset, so it's more meaningful, as
    it doesn't point to any gap at all.

    Even so, I don't think this discrepancy resulted in any practical bug.

    This patch is a preparation for the next one, which will introduce
    typecheck() for TSN_lte() macros and would cause a compile error here.

    Suggested-by: David Laight
    Reported-by: David Laight
    Signed-off-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Marcelo Ricardo Leitner
     
  • David S. Miller
     

22 Sep, 2016

2 commits

  • And avoid the usage of '&~3'. This is the last place still not using
    the macro.
    Also break the line to make it easier to read.

    Signed-off-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Marcelo Ricardo Leitner
     
  • To something more meaningful these days, specially because this is
    working on packet headers or lengths and which are not tied to any CPU
    arch but to the protocol itself.

    So, WORD_TRUNC becomes SCTP_TRUNC4 and WORD_ROUND becomes SCTP_PAD4.

    Reported-by: David Laight
    Reported-by: David Miller
    Signed-off-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Marcelo Ricardo Leitner
     

19 Sep, 2016

7 commits

  • In commit 311b21774f13 ("sctp: simplify sk_receive_queue locking"), a call
    to 'skb_queue_splice_tail_init()' has been made explicit. Previously it was
    hidden in 'sctp_skb_list_tail()'

    Now, the code around it looks redundant. The '_init()' part of
    'skb_queue_splice_tail_init()' should already do the same.

    Signed-off-by: Christophe JAILLET
    Acked-by: Marcelo Ricardo Leitner
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller

    Christophe Jaillet
     
  • As David and Marcelo's suggestion, ENOMEM err shouldn't return back to
    user in transmit path. Instead, sctp's retransmit would take care of
    the chunks that fail to send because of ENOMEM.

    This patch is only to do some release job when alloc_skb fails, not to
    return ENOMEM back any more.

    Besides, it also cleans up sctp_packet_transmit's err path, and fixes
    some issues in err path:

    - It didn't free the head skb in nomem: path.
    - No need to check nskb in no_route: path.
    - It should goto err: path if alloc_skb fails for head.
    - Not all the NOMEMs should free nskb.

    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller

    Xin Long
     
  • sctp_outq_flush return value is meaningless now, this patch is
    to make sctp_outq_flush return void, as well as sctp_outq_fail
    and sctp_outq_uncork.

    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller

    Xin Long
     
  • Every time when sctp calls sctp_outq_flush, it sends out the chunks of
    control queue, retransmit queue and data queue. Even if some trunks are
    failed to transmit, it still has to flush all the transports, as it's
    the only chance to clean that transmit_list.

    So the latest transmit error here should be returned back. This transmit
    error is an internal error of sctp stack.

    I checked all the places where it uses the transmit error (the return
    value of sctp_outq_flush), most of them are actually just save it to
    sk_err.

    Except for sctp_assoc/endpoint_bh_rcv, they will drop the chunk if
    it's failed to send a REPLY, which is actually incorrect, as we can't
    be sure the error that sctp_outq_flush returns is from sending that
    REPLY.

    So it's meaningless for sctp_outq_flush to return error back.

    This patch is to save transmit error to sk_err in sctp_outq_flush, the
    new error can update the old value. Eventually, sctp_wait_for_* would
    check for it.

    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller

    Xin Long
     
  • Last patch "sctp: do not return the transmit err back to sctp_sendmsg"
    made sctp_primitive_SEND return err only when asoc state is unavailable.
    In this case, chunks are not enqueued, they have no chance to be freed if
    we don't take care of them later.

    This Patch is actually to revert commit 1cd4d5c4326a ("sctp: remove the
    unused sctp_datamsg_free()"), commit 69b5777f2e57 ("sctp: hold the chunks
    only after the chunk is enqueued in outq") and commit 8b570dc9f7b6 ("sctp:
    only drop the reference on the datamsg after sending a msg"), to use
    sctp_datamsg_free to free the chunks of current msg.

    Fixes: 8b570dc9f7b6 ("sctp: only drop the reference on the datamsg after sending a msg")
    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller

    Xin Long
     
  • Once a chunk is enqueued successfully, sctp queues can take care of it.
    Even if it is failed to transmit (like because of nomem), it should be
    put into retransmit queue.

    If sctp report this error to users, it confuses them, they may resend
    that msg, but actually in kernel sctp stack is in charge of retransmit
    it already.

    Besides, this error probably is not from the failure of transmitting
    current msg, but transmitting or retransmitting another msg's chunks,
    as sctp_outq_flush just tries to send out all transports' chunks.

    This patch is to make sctp_cmd_send_msg return avoid, and not return the
    transmit err back to sctp_sendmsg

    Fixes: 8b570dc9f7b6 ("sctp: only drop the reference on the datamsg after sending a msg")
    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller

    Xin Long
     
  • Data Chunks are only sent by sctp_primitive_SEND, in which sctp checks
    the asoc's state through statetable before calling sctp_outq_tail. So
    there's no need to check the asoc's state again in sctp_outq_tail.

    Besides, sctp_do_sm is protected by lock_sock, even if sending msg is
    interrupted by timer events, the event's processes still need to acquire
    lock_sock first. It means no others CMDs can be enqueue into side effect
    list before CMD_SEND_MSG to change asoc->state, so it's safe to remove it.

    This patch is to remove redundant asoc->state check from sctp_outq_tail.

    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller

    Xin Long
     

13 Sep, 2016

2 commits

  • Since commit 4f0087812648 ("sctp: apply rhashtable api to send/recv
    path"), sctp uses transport rhashtable with .obj_cmpfn sctp_hash_cmp,
    in which it compares the members of the transport with the rhashtable
    args to check if it's the right transport.

    But sctp uses the transport without holding it in sctp_hash_cmp, it can
    cause a use-after-free panic. As after it gets transport from hashtable,
    another CPU may close the sk and free the asoc. In sctp_association_free,
    it frees all the transports, meanwhile, the assoc's refcnt may be reduced
    to 0, assoc can be destroyed by sctp_association_destroy.

    So after that, transport->assoc is actually an unavailable memory address
    in sctp_hash_cmp. Although sctp_hash_cmp is under rcu_read_lock, it still
    can not avoid this, as assoc is not freed by RCU.

    This patch is to hold the transport before checking it's members with
    sctp_transport_hold, in which it checks the refcnt first, holds it if
    it's not 0.

    Fixes: 4f0087812648 ("sctp: apply rhashtable api to send/recv path")
    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Xin Long
     
  • Conflicts:
    drivers/net/ethernet/mediatek/mtk_eth_soc.c
    drivers/net/ethernet/qlogic/qed/qed_dcbx.c
    drivers/net/phy/Kconfig

    All conflicts were cases of overlapping commits.

    Signed-off-by: David S. Miller

    David S. Miller
     

11 Sep, 2016

1 commit


10 Sep, 2016

1 commit

  • Previously, without GSO, it was easy to identify it: if the chunk didn't
    fit and there was no data chunk in the packet yet, we could fragment at
    IP level. So if there was an auth chunk and we were bundling a big data
    chunk, it would fragment regardless of the size of the auth chunk. This
    also works for the context of PMTU reductions.

    But with GSO, we cannot distinguish such PMTU events anymore, as the
    packet is allowed to exceed PMTU.

    So we need another check: to ensure that the chunk that we are adding,
    actually fits the current PMTU. If it doesn't, trigger a flush and let
    it be fragmented at IP level in the next round.

    Signed-off-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Marcelo Ricardo Leitner
     

09 Sep, 2016

1 commit

  • This adds the capability for a process that has CAP_NET_ADMIN on
    a socket to see the socket mark in socket dumps.

    Commit a52e95abf772 ("net: diag: allow socket bytecode filters to
    match socket marks") recently gave privileged processes the
    ability to filter socket dumps based on mark. This patch is
    complementary: it ensures that the mark is also passed to
    userspace in the socket's netlink attributes. It is useful for
    tools like ss which display information about sockets.

    Tested: https://android-review.googlesource.com/270210
    Signed-off-by: Lorenzo Colitti
    Signed-off-by: David S. Miller

    Lorenzo Colitti
     

24 Aug, 2016

1 commit

  • The function sctp_diag_dump_one() currently performs a memcpy()
    of 64 bytes from a 16 byte field into another 16 byte field. Fix
    by using correct size, use sizeof to obtain correct size instead
    of using a hard-coded constant.

    Fixes: 8f840e47f190 ("sctp: add the sctp_diag.c file")
    Signed-off-by: Lance Richardson
    Reviewed-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Lance Richardson
     

20 Aug, 2016

1 commit

  • Because otherwise when crc computation is still needed it's way more
    expensive than on a linear buffer to the point that it affects
    performance.

    It's so expensive that netperf test gives a perf output as below:

    Overhead Command Shared Object Symbol
    18,62% netserver [kernel.vmlinux] [k] crc32_generic_shift
    2,57% netserver [kernel.vmlinux] [k] __pskb_pull_tail
    1,94% netserver [kernel.vmlinux] [k] fib_table_lookup
    1,90% netserver [kernel.vmlinux] [k] copy_user_enhanced_fast_string
    1,66% swapper [kernel.vmlinux] [k] intel_idle
    1,63% netserver [kernel.vmlinux] [k] _raw_spin_lock
    1,59% netserver [sctp] [k] sctp_packet_transmit
    1,55% netserver [kernel.vmlinux] [k] memcpy_erms
    1,42% netserver [sctp] [k] sctp_rcv

    # netperf -H 192.168.10.1 -l 10 -t SCTP_STREAM -cC -- -m 12000
    SCTP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.10.1 () port 0 AF_INET
    Recv Send Send Utilization Service Demand
    Socket Socket Message Elapsed Send Recv Send Recv
    Size Size Size Time Throughput local remote local remote
    bytes bytes bytes secs. 10^6bits/s % S % S us/KB us/KB

    212992 212992 12000 10.00 3016.42 2.88 3.78 1.874 2.462

    After patch:
    Overhead Command Shared Object Symbol
    2,75% netserver [kernel.vmlinux] [k] memcpy_erms
    2,63% netserver [kernel.vmlinux] [k] copy_user_enhanced_fast_string
    2,39% netserver [kernel.vmlinux] [k] fib_table_lookup
    2,04% netserver [kernel.vmlinux] [k] __pskb_pull_tail
    1,91% netserver [kernel.vmlinux] [k] _raw_spin_lock
    1,91% netserver [sctp] [k] sctp_packet_transmit
    1,72% netserver [mlx4_en] [k] mlx4_en_process_rx_cq
    1,68% netserver [sctp] [k] sctp_rcv

    # netperf -H 192.168.10.1 -l 10 -t SCTP_STREAM -cC -- -m 12000
    SCTP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.10.1 () port 0 AF_INET
    Recv Send Send Utilization Service Demand
    Socket Socket Message Elapsed Send Recv Send Recv
    Size Size Size Time Throughput local remote local remote
    bytes bytes bytes secs. 10^6bits/s % S % S us/KB us/KB

    212992 212992 12000 10.00 3681.77 3.83 3.46 2.045 1.849

    Fixes: 3acb50c18d8d ("sctp: delay as much as possible skb_linearize")
    Signed-off-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Marcelo Ricardo Leitner
     

14 Aug, 2016

1 commit

  • sctp_transport_seq_start() does not currently clear iter->start_fail on
    success, but relies on it being zero when it is allocated (by
    seq_open_net()).

    This can be a problem in the following sequence:

    open() // allocates iter (and implicitly sets iter->start_fail = 0)
    read()
    - iter->start() // fails and sets iter->start_fail = 1
    - iter->stop() // doesn't call sctp_transport_walk_stop() (correct)
    read() again
    - iter->start() // succeeds, but doesn't change iter->start_fail
    - iter->stop() // doesn't call sctp_transport_walk_stop() (wrong)

    We should initialize sctp_ht_iter::start_fail to zero if ->start()
    succeeds, otherwise it's possible that we leave an old value of 1 there,
    which will cause ->stop() to not call sctp_transport_walk_stop(), which
    causes all sorts of problems like not calling rcu_read_unlock() (and
    preempt_enable()), eventually leading to more warnings like this:

    BUG: sleeping function called from invalid context at mm/slab.h:388
    in_atomic(): 0, irqs_disabled(): 0, pid: 16551, name: trinity-c2
    Preemption disabled at:[] rhashtable_walk_start+0x46/0x150

    [] preempt_count_add+0x1fb/0x280
    [] _raw_spin_lock+0x12/0x40
    [] rhashtable_walk_start+0x46/0x150
    [] sctp_transport_walk_start+0x2f/0x60
    [] sctp_transport_seq_start+0x4d/0x150
    [] traverse+0x170/0x850
    [] seq_read+0x7cc/0x1180
    [] proc_reg_read+0xbc/0x180
    [] do_loop_readv_writev+0x134/0x210
    [] do_readv_writev+0x565/0x660
    [] vfs_readv+0x67/0xa0
    [] do_preadv+0x126/0x170
    [] SyS_preadv+0xc/0x10
    [] do_syscall_64+0x19c/0x410
    [] return_from_SYSCALL_64+0x0/0x6a
    [] 0xffffffffffffffff

    Notice that this is a subtly different stacktrace from the one in commit
    5fc382d875 ("net/sctp: terminate rhashtable walk correctly").

    Cc: Xin Long
    Cc: Herbert Xu
    Cc: Eric W. Biederman
    Cc: Marcelo Ricardo Leitner
    Signed-off-by: Vegard Nossum
    Acked-By: Neil Horman
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Vegard Nossum
     

09 Aug, 2016

3 commits

  • Commit 52253db924d1 ("sctp: also point GSO head_skb to the sk when
    it's available") used event->chunk->head_skb to get the head_skb in
    sctp_ulpevent_set_owner().

    But at that moment, the event->chunk was NULL, as it cloned the skb
    in sctp_ulpevent_make_rcvmsg(). Therefore, that patch didn't really
    work.

    This patch is to move the event->chunk initialization before calling
    sctp_ulpevent_receive_data() so that it uses event->chunk when it's
    valid.

    Fixes: 52253db924d1 ("sctp: also point GSO head_skb to the sk when it's available")
    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller

    Xin Long
     
  • Since 'ss' always adds TCPF_CLOSE to idiag_states flags, sctp_diag can't
    rely upon TCPF_LISTEN flag solely being present when listening sockets
    are requested.

    Signed-off-by: Phil Sutter
    Signed-off-by: David S. Miller

    Phil Sutter
     
  • The asoc's timer value is not kept in asoc->timeouts array but in it's
    primary transport instead.

    Furthermore, we must export the timer only if it is pending, otherwise
    the value will underrun when stored in an unsigned variable and
    user space will only see a very large timeout value.

    Signed-off-by: Phil Sutter
    Signed-off-by: David S. Miller

    Phil Sutter
     

31 Jul, 2016

1 commit

  • Commit 141ddefce7c8 ("sctp: change sk state to CLOSED instead of
    CLOSING in sctp_sock_migrate") changed sk state to CLOSED if the
    assoc is closed when sctp_accept clones a new sk.

    If there is still data in sk receive queue, users will not be able
    to read it any more, as sctp_recvmsg returns directly if sk state
    is CLOSED.

    This patch is to add CLOSED state check in sctp_recvmsg to allow
    reading data from TCP-style sk with CLOSED state as what TCP does.

    Signed-off-by: Xin Long
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Xin Long