25 Aug, 2020

1 commit


10 Dec, 2019

1 commit

  • Commit 312434617cb1 ("sctp: cache netns in sctp_ep_common") set netns
    in asoc and ep base since they're created, and it will never change.
    It's a better way to get netns from asoc and ep base, comparing to
    calling sock_net().

    This patch is to replace them.

    v1->v2:
    - no change.

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

    Xin Long
     

10 Oct, 2019

1 commit

  • This patch is to add a new event SCTP_SEND_FAILED_EVENT described in
    rfc6458#section-6.1.11. It's a update of SCTP_SEND_FAILED event:

    struct sctp_sndrcvinfo ssf_info is replaced with
    struct sctp_sndinfo ssfe_info in struct sctp_send_failed_event.

    SCTP_SEND_FAILED is being deprecated, but we don't remove it in this
    patch. Both are being processed in sctp_datamsg_destroy() when the
    corresp event flag is set.

    Signed-off-by: Xin Long
    Acked-by: Neil Horman
    Signed-off-by: Jakub Kicinski

    Xin Long
     

24 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this sctp implementation 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 either version 2 or at
    your option any later version this sctp implementation 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 you should have received a copy of the gnu general
    public license along with gnu cc see the file copying if not see
    http www gnu org licenses

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

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

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

    Thomas Gleixner
     

01 Mar, 2019

1 commit

  • According to Documentation/core-api/printk-formats.rst, size_t should be
    printed with %zu, rather than %Zu.

    In addition, using %Zu triggers a warning on clang (-Wformat-extra-args):

    net/sctp/chunk.c:196:25: warning: data argument not used by format string [-Wformat-extra-args]
    __func__, asoc, max_data);
    ~~~~~~~~~~~~~~~~^~~~~~~~~
    ./include/linux/printk.h:440:49: note: expanded from macro 'pr_warn_ratelimited'
    printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
    ./include/linux/printk.h:424:17: note: expanded from macro 'printk_ratelimited'
    printk(fmt, ##__VA_ARGS__); \
    ~~~ ^

    Fixes: 5b5e0928f742 ("lib/vsprintf.c: remove %Z support")
    Link: https://github.com/ClangBuiltLinux/linux/issues/378
    Signed-off-by: Matthias Maennich
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Matthias Maennich
     

10 Dec, 2018

1 commit

  • Several conflicts, seemingly all over the place.

    I used Stephen Rothwell's sample resolutions for many of these, if not
    just to double check my own work, so definitely the credit largely
    goes to him.

    The NFP conflict consisted of a bug fix (moving operations
    past the rhashtable operation) while chaning the initial
    argument in the function call in the moved code.

    The net/dsa/master.c conflict had to do with a bug fix intermixing of
    making dsa_master_set_mtu() static with the fixing of the tagging
    attribute location.

    cls_flower had a conflict because the dup reject fix from Or
    overlapped with the addition of port range classifiction.

    __set_phy_supported()'s conflict was relatively easy to resolve
    because Andrew fixed it in both trees, so it was just a matter
    of taking the net-next copy. Or at least I think it was :-)

    Joe Stringer's fix to the handling of netns id 0 in bpf_sk_lookup()
    intermixed with changes on how the sdif and caller_net are calculated
    in these code paths in net-next.

    The remaining BPF conflicts were largely about the addition of the
    __bpf_md_ptr stuff in 'net' overlapping with adjustments and additions
    to the relevant data structure where the MD pointer macros are used.

    Signed-off-by: David S. Miller

    David S. Miller
     

06 Dec, 2018

1 commit

  • If for some reason an association's fragmentation point is zero,
    sctp_datamsg_from_user will try to endlessly try to divide a message
    into zero-sized chunks. This eventually causes kernel panic due to
    running out of memory.

    Although this situation is quite unlikely, it has occurred before as
    reported. I propose to add this simple last-ditch sanity check due to
    the severity of the potential consequences.

    Signed-off-by: Jakub Audykowicz
    Acked-by: Neil Horman
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Jakub Audykowicz
     

20 Nov, 2018

2 commits

  • The member subscribe should be per asoc, so that sockopt SCTP_EVENT
    in the next patch can subscribe a event from one asoc only.

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

    Xin Long
     
  • The member subscribe in sctp_sock is used to indicate to which of
    the events it is subscribed, more like a group of flags. So it's
    better to be defined as __u16 (2 bytpes), instead of struct
    sctp_event_subscribe (13 bytes).

    Note that sctp_event_subscribe is an UAPI struct, used on sockopt
    calls, and thus it will not be removed. This patch only changes
    the internal storage of the flags.

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

    Xin Long
     

12 Aug, 2018

1 commit

  • This patch introduces wrappers for accessing in/out streams indirectly.
    This will enable to replace physically contiguous memory arrays
    of streams with flexible arrays (or maybe any other appropriate
    mechanism) which do memory allocation on a per-page basis.

    Signed-off-by: Oleg Babin
    Signed-off-by: Konstantin Khorenko
    Signed-off-by: David S. Miller

    Konstantin Khorenko
     

21 Jun, 2018

1 commit

  • Currently it is incrementing SctpFragUsrMsgs when the user message size
    is of the exactly same size as the maximum fragment size, which is wrong.

    The fix is to increment it only when user message is bigger than the
    maximum fragment size.

    Fixes: bfd2e4b8734d ("sctp: refactor sctp_datamsg_from_user")
    Signed-off-by: Marcelo Ricardo Leitner
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller

    Marcelo Ricardo Leitner
     

28 Apr, 2018

1 commit


07 Apr, 2018

1 commit

  • Pull SELinux updates from Paul Moore:
    "A bigger than usual pull request for SELinux, 13 patches (lucky!)
    along with a scary looking diffstat.

    Although if you look a bit closer, excluding the usual minor
    tweaks/fixes, there are really only two significant changes in this
    pull request: the addition of proper SELinux access controls for SCTP
    and the encapsulation of a lot of internal SELinux state.

    The SCTP changes are the result of a multi-month effort (maybe even a
    year or longer?) between the SELinux folks and the SCTP folks to add
    proper SELinux controls. A special thanks go to Richard for seeing
    this through and keeping the effort moving forward.

    The state encapsulation work is a bit of janitorial work that came out
    of some early work on SELinux namespacing. The question of namespacing
    is still an open one, but I believe there is some real value in the
    encapsulation work so we've split that out and are now sending that up
    to you"

    * tag 'selinux-pr-20180403' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
    selinux: wrap AVC state
    selinux: wrap selinuxfs state
    selinux: fix handling of uninitialized selinux state in get_bools/classes
    selinux: Update SELinux SCTP documentation
    selinux: Fix ltp test connect-syscall failure
    selinux: rename the {is,set}_enforcing() functions
    selinux: wrap global selinux state
    selinux: fix typo in selinux_netlbl_sctp_sk_clone declaration
    selinux: Add SCTP support
    sctp: Add LSM hooks
    sctp: Add ip option support
    security: Add support for SCTP security hooks
    netlabel: If PF_INET6, check sk_buff ip header version

    Linus Torvalds
     

15 Mar, 2018

2 commits

  • This patch is to add support for SCTP AUTH Information for sendmsg,
    as described in section 5.3.8 of RFC6458.

    With this option, you can provide shared key identifier used for
    sending the user message.

    It's also a necessary send info for sctp_sendv.

    Note that it reuses sinfo->sinfo_tsn to indicate if this option is
    set and sinfo->sinfo_ssn to save the shkey ID which can be 0.

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

    Xin Long
     
  • With refcnt support for sh_key, chunks auth sh_keys can be decided
    before enqueuing it. Changing the active key later will not affect
    the chunks already enqueued.

    Furthermore, this is necessary when adding the support for authinfo
    for sendmsg in next patch.

    Note that struct sctp_chunk can't be grown due to that performance
    drop issue on slow cpu, so it just reuses head_skb memory for shkey
    in sctp_chunk.

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

    Xin Long
     

27 Feb, 2018

1 commit

  • Add ip option support to allow LSM security modules to utilise CIPSO/IPv4
    and CALIPSO/IPv6 services.

    Signed-off-by: Richard Haines
    Acked-by: Neil Horman
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: Paul Moore

    Richard Haines
     

12 Dec, 2017

2 commits

  • enqueue_event is added as a member of sctp_stream_interleave, used to
    enqueue either data, idata or notification events into user socket rx
    queue.

    It replaces sctp_ulpq_tail_event used in the other places with
    enqueue_event.

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

    Xin Long
     
  • To avoid hundreds of checks for the different process on I-DATA chunk,
    struct sctp_stream_interleave is defined as a group of functions used
    to replace the codes in some place where it needs to do different job
    according to if the asoc intl_enabled is set.

    With these ops, it only needs to initialize asoc->stream.si with
    sctp_stream_interleave_0 for normal data if asoc intl_enable is 0,
    or sctp_stream_interleave_1 for idata if asoc intl_enable is set in
    sctp_stream_init.

    After that, the members in asoc->stream.si can be used directly in
    some special places without checking asoc intl_enable.

    make_datafrag is the first member for sctp_stream_interleave, it's
    used to make data or idata frags, called in sctp_datamsg_from_user.
    The old function sctp_make_datafrag_empty needs to be adjust some
    to fit in this ops.

    Note that as idata and data chunks have different length, it also
    defines data_chunk_len for sctp_stream_interleave to describe the
    chunk size.

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

    Xin Long
     

02 Dec, 2017

2 commits

  • Now for the abandoned chunks in unsent outq, it would just free the chunks.
    Because no tsn is assigned to them yet, there's no need to send fwd tsn to
    peer, unlike for the abandoned chunks in sent outq.

    The problem is when parts of the msg have been sent and the other frags
    are still in unsent outq, if they are abandoned/dropped, the peer would
    never get this msg reassembled.

    So these frags in unsent outq can't be dropped if this msg already has
    outstanding frags.

    This patch does the check in sctp_chunk_abandoned and
    sctp_prsctp_prune_unsent.

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

    Xin Long
     
  • As rfc3758#section-3.1 demands:

    A3) When a TSN is "abandoned", if it is part of a fragmented message,
    all other TSN's within that fragmented message MUST be abandoned
    at the same time.

    Besides, if it couldn't handle this, the rest frags would never get
    assembled in peer side.

    This patch supports it by adding abandoned flag in sctp_datamsg, when
    one chunk is being abandoned, set chunk->msg->abandoned as well. Next
    time when checking for abandoned, go checking chunk->msg->abandoned
    first.

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

    Xin Long
     

04 Oct, 2017

1 commit

  • With the stream schedulers, sctp_stream_out will become too big to be
    allocated by kmalloc and as we need to allocate with BH disabled, we
    cannot use __vmalloc in sctp_stream_init().

    This patch moves out the stats from sctp_stream_out to
    sctp_stream_out_ext, which will be allocated only when the application
    tries to sendmsg something on it.

    Just the introduction of sctp_stream_out_ext would already fix the issue
    described above by splitting the allocation in two. Moving the stats
    to it also reduces the pressure on the allocator as we will ask for less
    memory atomically when creating the socket and we will use GFP_KERNEL
    later.

    Then, for stream schedulers, we will just use sctp_stream_out_ext.

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

    Marcelo Ricardo Leitner
     

04 Aug, 2017

1 commit

  • This patch is to remove the typedef sctp_auth_chunk_t, and
    replace with struct sctp_auth_chunk in the places where it's
    using this typedef.

    It is also to use sizeof(variable) instead of sizeof(type).

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

    Xin Long
     

25 Jul, 2017

1 commit


05 Jul, 2017

1 commit

  • refcount_t type and corresponding API should be
    used instead of atomic_t when the variable is used as
    a reference counter. This allows to avoid accidental
    refcounter overflows that might lead to use-after-free
    situations.

    Signed-off-by: Elena Reshetova
    Signed-off-by: Hans Liljestrand
    Signed-off-by: Kees Cook
    Signed-off-by: David Windsor
    Signed-off-by: David S. Miller

    Reshetova, Elena
     

03 Jun, 2017

1 commit

  • As Marcelo's suggestion, stream is a fixed size member of asoc and would
    not grow with more streams. To avoid an allocation for it, this patch is
    to define it as an object instead of pointer and update the places using
    it, also create sctp_stream_update() called in sctp_assoc_update() to
    migrate the stream info from one stream to another.

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

    Xin Long
     

04 Apr, 2017

1 commit

  • Before when implementing sctp prsctp, SCTP_PR_STREAM_STATUS wasn't
    added, as it needs to save abandoned_(un)sent for every stream.

    After sctp stream reconf is added in sctp, assoc has structure
    sctp_stream_out to save per stream info.

    This patch is to add SCTP_PR_STREAM_STATUS by putting the prsctp
    per stream statistics into sctp_stream_out.

    v1->v2:
    fix an indent issue.

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

    Xin Long
     

30 Dec, 2016

1 commit

  • This patch refactors sctp_datamsg_from_user() in an attempt to make it
    better to read and avoid code duplication for handling the last
    fragment.

    It also avoids doing division and remaining operations. Even though, it
    should still operate similarly as before this patch.

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

    Marcelo Ricardo Leitner
     

13 Oct, 2016

1 commit

  • The prsctp polices include ttl expires policy already, we should remove
    the old ttl expires codes, and just adjust the new polices' codes to be
    compatible with the old one for users.

    This patch is to remove all the old expires codes, and if prsctp polices
    are not set, it will still set msg's expires_at and check the expires in
    sctp_check_abandoned.

    Note that asoc->prsctp_enable is set by default, so users can't feel any
    difference even if they use the old expires api in userspace.

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

    Xin Long
     

03 Oct, 2016

1 commit


30 Sep, 2016

2 commits

  • 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
     

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

1 commit

  • 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
     

12 Jul, 2016

3 commits

  • prsctp PRIO policy is a policy to abandon lower priority chunks when
    asoc doesn't have enough snd buffer, so that the current chunk with
    higher priority can be queued successfully.

    Similar to TTL/RTX policy, we will set the priority of the chunk to
    prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
    So if PRIO policy is enabled, msg->expire_at won't work.

    asoc->sent_cnt_removable will record how many chunks can be checked to
    remove. If priority policy is enabled, when the chunk is queued into
    the out_queue, we will increase sent_cnt_removable. When the chunk is
    moved to abandon_queue or dequeue and free, we will decrease
    sent_cnt_removable.

    In sctp_sendmsg, we will check if there is enough snd buffer for current
    msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
    sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
    free chunks from out_queue in right order until the abandon+free size >
    msg_len - sctp_wfree. For the abandon size, we have to wait until it
    sends FORWARD TSN, receives the sack and the chunks are really freed.

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

    Xin Long
     
  • prsctp RTX policy is a policy to abandon chunks when they are
    retransmitted beyond the max count.

    This patch uses sent_count to count how many times one chunk has
    been sent, and prsctp_param is the max rtx count, which is from
    sinfo->sinfo_timetolive in sctp_set_prsctp_policy(). So similar
    to TTL policy, if RTX policy is enabled, msg->expire_at won't
    work.

    Then in sctp_chunk_abandoned, this patch checks if chunk->sent_count
    is bigger than chunk->prsctp_param to abandon this chunk.

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

    Xin Long
     
  • prsctp TTL policy is a policy to abandon chunks when they expire
    at the specific time in local stack. It's similar with expires_at
    in struct sctp_datamsg.

    This patch uses sinfo->sinfo_timetolive to set the specific time for
    TTL policy. sinfo->sinfo_timetolive is also used for msg->expires_at.
    So if prsctp_enable or TTL policy is not enabled, msg->expires_at
    still works as before.

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

    Xin Long
     

28 Apr, 2016

1 commit

  • In the old days (before linux-3.0), SNMP counters were duplicated,
    one for user context, and one for BH context.

    After commit 8f0ea0fe3a03 ("snmp: reduce percpu needs by 50%")
    we have a single copy, and what really matters is preemption being
    enabled or disabled, since we use this_cpu_inc() or __this_cpu_inc()
    respectively.

    We therefore kill SNMP_INC_STATS_USER(), SNMP_ADD_STATS_USER(),
    NET_INC_STATS_USER(), NET_ADD_STATS_USER(), SCTP_INC_STATS_USER(),
    SNMP_INC_STATS64_USER(), SNMP_ADD_STATS64_USER(), TCP_ADD_STATS_USER(),
    UDP_INC_STATS_USER(), UDP6_INC_STATS_USER(), and XFRM_INC_STATS_USER()

    Following patches will rename __BH helpers to make clear their
    usage is not tied to BH being disabled.

    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

14 Mar, 2016

1 commit

  • Currently sctp_sendmsg() triggers some calls that will allocate memory
    with GFP_ATOMIC even when not necessary. In the case of
    sctp_packet_transmit it will allocate a linear skb that will be used to
    construct the packet and this may cause sends to fail due to ENOMEM more
    often than anticipated specially with big MTUs.

    This patch thus allows it to inherit gfp flags from upper calls so that
    it can use GFP_KERNEL if it was triggered by a sctp_sendmsg call or
    similar. All others, like retransmits or flushes started from BH, are
    still allocated using GFP_ATOMIC.

    In netperf tests this didn't result in any performance drawbacks when
    memory is not too fragmented and made it trigger ENOMEM way less often.

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

    Marcelo Ricardo Leitner
     

18 Feb, 2016

1 commit

  • Since commit 8b570dc9f7b6 ("sctp: only drop the reference on the datamsg
    after sending a msg") used sctp_datamsg_put in sctp_sendmsg, instead of
    sctp_datamsg_free, this function has no use in sctp.

    So we will remove it.

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

    Xin Long