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
     

23 May, 2020

1 commit

  • Commit bdf6fa52f01b ("sctp: handle association restarts when the
    socket is closed.") starts shutdown when an association is restarted,
    if in SHUTDOWN-PENDING state and the socket is closed. However, the
    rationale stated in that commit applies also when in SHUTDOWN-SENT
    state - we don't want to move an association to ESTABLISHED state when
    the socket has been closed, because that results in an association
    that is unreachable from user space.

    The problem scenario:

    1. Client crashes and/or restarts.

    2. Server (using one-to-one socket) calls close(). SHUTDOWN is lost.

    3. Client reconnects using the same addresses and ports.

    4. Server's association is restarted. The association and the socket
    move to ESTABLISHED state, even though the server process has
    closed its descriptor.

    Also, after step 4 when the server process exits, some resources are
    leaked in an attempt to release the underlying inet sock structure in
    ESTABLISHED state:

    IPv4: Attempt to release TCP socket in state 1 00000000377288c7

    Fix by acting the same way as in SHUTDOWN-PENDING state. That is, if
    an association is restarted in SHUTDOWN-SENT state and the socket is
    closed, then start shutdown and don't move the association or the
    socket to ESTABLISHED state.

    Fixes: bdf6fa52f01b ("sctp: handle association restarts when the socket is closed.")
    Signed-off-by: Jere Leppänen
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Jere Leppänen
     

23 Apr, 2020

1 commit

  • When we start shutdown in sctp_sf_do_dupcook_a(), we want to bundle
    the SHUTDOWN with the COOKIE-ACK to ensure that the peer receives them
    at the same time and in the correct order. This bundling was broken by
    commit 4ff40b86262b ("sctp: set chunk transport correctly when it's a
    new asoc"), which assigns a transport for the COOKIE-ACK, but not for
    the SHUTDOWN.

    Fix this by passing a reference to the COOKIE-ACK chunk as an argument
    to sctp_sf_do_9_2_start_shutdown() and onward to
    sctp_make_shutdown(). This way the SHUTDOWN chunk is assigned the same
    transport as the COOKIE-ACK chunk, which allows them to be bundled.

    In sctp_sf_do_9_2_start_shutdown(), the void *arg parameter was
    previously unused. Now that we're taking it into use, it must be a
    valid pointer to a chunk, or NULL. There is only one call site where
    it's not, in sctp_sf_autoclose_timer_expire(). Fix that too.

    Fixes: 4ff40b86262b ("sctp: set chunk transport correctly when it's a new asoc")
    Signed-off-by: Jere Leppänen
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Jere Leppänen
     

18 Feb, 2020

1 commit

  • When T2 timer is to be stopped, the asoc should also be deleted,
    otherwise, there will be no chance to call sctp_association_free
    and the asoc could last in memory forever.

    However, in sctp_sf_shutdown_sent_abort(), after adding the cmd
    SCTP_CMD_TIMER_STOP for T2 timer, it may return error due to the
    format error from __sctp_sf_do_9_1_abort() and miss adding
    SCTP_CMD_ASSOC_FAILED where the asoc will be deleted.

    This patch is to fix it by moving the format error check out of
    __sctp_sf_do_9_1_abort(), and do it before adding the cmd
    SCTP_CMD_TIMER_STOP for T2 timer.

    Thanks Hangbin for reporting this issue by the fuzz testing.

    v1->v2:
    - improve the comment in the code as Marcelo's suggestion.

    Fixes: 96ca468b86b0 ("sctp: check invalid value of length parameter in error cause")
    Reported-by: Hangbin Liu
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: Xin Long
    Signed-off-by: David S. Miller

    Xin Long
     

28 Dec, 2019

1 commit

  • The function sctp_sf_eat_sack_6_2 now performs the Verification
    Tag validation, Chunk length validation, Bogu check, and also
    the detection of out-of-order SACK based on the RFC2960
    Section 6.2 at the beginning, and finally performs the further
    processing of SACK. The trace_sctp_probe now triggered before
    the above necessary validation and check.

    this patch is to do the trace_sctp_probe after the chunk sanity
    tests, but keep doing trace if the SACK received is out of order,
    for the out-of-order SACK is valuable to congestion control
    debugging.

    v1->v2:
    - keep doing SCTP trace if the SACK is out of order as Marcelo's
    suggestion.
    v2->v3:
    - regenerate the patch as v2 generated on top of v1, and add
    'net-next' tag to the new one as Marcelo's comments.

    Signed-off-by: Kevin Kou
    Acked-by: Marcelo Ricardo Leitner
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller

    Kevin Kou
     

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
     

24 Nov, 2019

1 commit

  • In the implementation of sctp_sf_do_5_2_4_dupcook() the allocated
    new_asoc is leaked if security_sctp_assoc_request() fails. Release it
    via sctp_association_free().

    Fixes: 2277c7cd75e3 ("sctp: Add LSM hooks")
    Signed-off-by: Navid Emamdoost
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: Jakub Kicinski

    Navid Emamdoost
     

20 Aug, 2019

1 commit


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
     

03 May, 2019

1 commit


01 May, 2019

1 commit

  • Ying triggered a call trace when doing an asconf testing:

    BUG: scheduling while atomic: swapper/12/0/0x10000100
    Call Trace:
    [] dump_stack+0x19/0x1b
    [] __schedule_bug+0x64/0x72
    [] __schedule+0x9ba/0xa00
    [] __cond_resched+0x26/0x30
    [] _cond_resched+0x3a/0x50
    [] kmem_cache_alloc_node+0x38/0x200
    [] __alloc_skb+0x5d/0x2d0
    [] sctp_packet_transmit+0x610/0xa20 [sctp]
    [] sctp_outq_flush+0x2ce/0xc00 [sctp]
    [] sctp_outq_uncork+0x1c/0x20 [sctp]
    [] sctp_cmd_interpreter.isra.22+0xc8/0x1460 [sctp]
    [] sctp_do_sm+0xe1/0x350 [sctp]
    [] sctp_primitive_ASCONF+0x3d/0x50 [sctp]
    [] sctp_cmd_interpreter.isra.22+0x114/0x1460 [sctp]
    [] sctp_do_sm+0xe1/0x350 [sctp]
    [] sctp_assoc_bh_rcv+0xf4/0x1b0 [sctp]
    [] sctp_inq_push+0x51/0x70 [sctp]
    [] sctp_rcv+0xa8b/0xbd0 [sctp]

    As it shows, the first sctp_do_sm() running under atomic context (NET_RX
    softirq) invoked sctp_primitive_ASCONF() that uses GFP_KERNEL flag later,
    and this flag is supposed to be used in non-atomic context only. Besides,
    sctp_do_sm() was called recursively, which is not expected.

    Vlad tried to fix this recursive call in Commit c0786693404c ("sctp: Fix
    oops when sending queued ASCONF chunks") by introducing a new command
    SCTP_CMD_SEND_NEXT_ASCONF. But it didn't work as this command is still
    used in the first sctp_do_sm() call, and sctp_primitive_ASCONF() will
    be called in this command again.

    To avoid calling sctp_do_sm() recursively, we send the next queued ASCONF
    not by sctp_primitive_ASCONF(), but by sctp_sf_do_prm_asconf() in the 1st
    sctp_do_sm() directly.

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

    Xin Long
     

16 Apr, 2019

1 commit

  • sk_forward_alloc's updating is also done on rx path, but to be consistent
    we change to use sk_mem_charge() in sctp_skb_set_owner_r().

    In sctp_eat_data(), it's not enough to check sctp_memory_pressure only,
    which doesn't work for mem_cgroup_sockets_enabled, so we change to use
    sk_under_memory_pressure().

    When it's under memory pressure, sk_mem_reclaim() and sk_rmem_schedule()
    should be called on both RENEGE or CHUNK DELIVERY path exit the memory
    pressure status as soon as possible.

    Note that sk_rmem_schedule() is using datalen to make things easy there.

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

    Xin Long
     

08 May, 2018

1 commit

  • Now sctp only delays the authentication for the normal cookie-echo
    chunk by setting chunk->auth_chunk in sctp_endpoint_bh_rcv(). But
    for the duplicated one with auth, in sctp_assoc_bh_rcv(), it does
    authentication first based on the old asoc, which will definitely
    fail due to the different auth info in the old asoc.

    The duplicated cookie-echo chunk will create a new asoc with the
    auth info from this chunk, and the authentication should also be
    done with the new asoc's auth info for all of the collision 'A',
    'B' and 'D'. Otherwise, the duplicated cookie-echo chunk with auth
    will never pass the authentication and create the new connection.

    This issue exists since very beginning, and this fix is to make
    sctp_assoc_bh_rcv() follow the way sctp_endpoint_bh_rcv() does
    for the normal cookie-echo chunk to delay the authentication.

    While at it, remove the unused params from sctp_sf_authenticate()
    and define sctp_auth_chunk_verify() used for all the places that
    do the delayed authentication.

    v1->v2:
    fix the typo in changelog as Marcelo noticed.

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

    Xin Long
     

02 May, 2018

2 commits

  • When processing a duplicate cookie-echo chunk, for case 'D', sctp will
    not process the param from this chunk. It means old asoc has nothing
    to be updated, and the new temp asoc doesn't have the complete info.

    So there's no reason to use the new asoc when creating the cookie-ack
    chunk. Otherwise, like when auth is enabled for cookie-ack, the chunk
    can not be set with auth, and it will definitely be dropped by peer.

    This issue is there since very beginning, and we fix it by using the
    old asoc instead.

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

    Xin Long
     
  • When processing a duplicate cookie-echo chunk, for case 'A' and 'B',
    after sctp_process_init for the new asoc, if auth is enabled for the
    cookie-ack chunk, the active key should also be initialized.

    Otherwise, the cookie-ack chunk made later can not be set with auth
    shkey properly, and a crash can even be caused by this, as after
    Commit 1b1e0bc99474 ("sctp: add refcnt support for sh_key"), sctp
    needs to hold the shkey when making control chunks.

    Fixes: 1b1e0bc99474 ("sctp: add refcnt support for sh_key")
    Reported-by: Jianwen Ji
    Signed-off-by: Xin Long
    Acked-by: Neil Horman
    Acked-by: Marcelo Ricardo Leitner
    Signed-off-by: David S. Miller

    Xin Long
     

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

3 commits

  • This patch is to add SCTP_AUTH_NO_AUTH type for AUTHENTICATION_EVENT,
    as described in section 6.1.8 of RFC6458.

    SCTP_AUTH_NO_AUTH: This report indicates that the peer does not
    support SCTP authentication as defined in [RFC4895].

    Note that the implementation is quite similar as that of
    SCTP_ADAPTATION_INDICATION.

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

    Xin Long
     
  • This patch is to add SCTP_AUTH_FREE_KEY type for AUTHENTICATION_EVENT,
    as described in section 6.1.8 of RFC6458.

    SCTP_AUTH_FREE_KEY: This report indicates that the SCTP
    implementation will no longer use the key identifier specified
    in auth_keynumber.

    After deactivating a key, it would never be used again, which means
    it's refcnt can't be held/increased by new chunks. But there may be
    some chunks in out queue still using it. So only when refcnt is 1,
    which means no chunk in outqueue is using/holding this key either,
    this EVENT would be sent.

    When users receive this notification, they could do DEL_KEY sockopt to
    remove this shkey, and also tell the peer that this key won't be used
    in any chunk thoroughly from now on, then the peer can remove it as
    well safely.

    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


03 Jan, 2018

1 commit

  • Add SCTP ACK tracking trace event to trace the changes of SCTP
    association state in response to incoming packets.
    It is used for debugging SCTP congestion control algorithms,
    and will replace sctp_probe module.

    Note that this event a bit tricky. Since this consists of 2
    events (sctp_probe and sctp_probe_path) so you have to enable
    both events as below.

    # cd /sys/kernel/debug/tracing
    # echo 1 > events/sctp/sctp_probe/enable
    # echo 1 > events/sctp/sctp_probe_path/enable

    Or, you can enable all the events under sctp.

    # echo 1 > events/sctp/enable

    Since sctp_probe_path event is always invoked from sctp_probe
    event, you can not see any output if you only enable
    sctp_probe_path.

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: David S. Miller

    Masami Hiramatsu
     

16 Dec, 2017

1 commit

  • validate_ftsn is added as a member of sctp_stream_interleave, used to
    validate ssn/chunk type for fwdtsn or mid (message id)/chunk type for
    ifwdtsn, called in sctp_sf_eat_fwd_tsn, just as validate_data.

    If this check fails, an abort packet will be sent, as said in section
    2.3.1 of RFC8260.

    As ifwdtsn and fwdtsn chunks have different length, it also defines
    ftsn_chunk_len for sctp_stream_interleave to describe the chunk size.
    Then it replaces all sizeof(struct sctp_fwdtsn_chunk) with
    sctp_ftsnchk_len.

    It also adds the process for ifwdtsn in rx path. As Marcelo pointed
    out, there's no need to add event table for ifwdtsn, but just share
    prsctp_chunk_event_table with fwdtsn's. It would drop fwdtsn chunk
    for ifwdtsn and drop ifwdtsn chunk for fwdtsn by calling validate_ftsn
    in sctp_sf_eat_fwd_tsn.

    After this patch, the ifwdtsn can be accepted.

    Note that this patch also removes the sctp.intl_enable check for
    idata chunks in sctp_chunk_event_lookup, as it will do this check
    in validate_data later.

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

    Xin Long
     

12 Dec, 2017

1 commit

  • validate_data is added as a member of sctp_stream_interleave, used
    to validate ssn/chunk type for data or mid (message id)/chunk type
    for idata, called in sctp_eat_data.

    If this check fails, an abort packet will be sent, as said in
    section 2.2.3 of RFC8260.

    It also adds the process for idata in rx path. As Marcelo pointed
    out, there's no need to add event table for idata, but just share
    chunk_event_table with data's. It would drop data chunk for idata
    and drop idata chunk for data by calling validate_data in
    sctp_eat_data.

    As last patch did, it also replaces sizeof(struct sctp_data_chunk)
    with sctp_datachk_len for rx path.

    After this patch, the idata can be accepted and delivered to ulp
    layer.

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

    Xin Long
     

12 Aug, 2017

5 commits

  • This patch is to remove the typedef sctp_disposition_t, and
    replace with enum sctp_disposition in the places where it's
    using this typedef.

    It's also to fix the indent for many functions' defination.

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

    Xin Long
     
  • This patch is to remove the typedef sctp_verb_t, and
    replace with enum sctp_verb in the places where it's
    using this typedef.

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

    Xin Long
     
  • This patch is to remove the typedef sctp_arg_t, and
    replace with union sctp_arg in the places where it's
    using this typedef.

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

    Xin Long
     
  • This patch is to remove the typedef sctp_cmd_seq_t, and
    replace with struct sctp_cmd_seq in the places where it's
    using this typedef.

    Note that it doesn't fix many indents although it should,
    as sctp_disposition_t's removal would mess them up again.
    So better to fix them when removing sctp_disposition_t in
    the later patch.

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

    Xin Long
     
  • This patch is to remove the typedef sctp_sender_hb_info_t, and
    replace with struct sctp_sender_hb_info 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
     

07 Aug, 2017

2 commits

  • This patch is to remove the typedef sctp_subtype_t, and
    replace with union sctp_subtype in the places where it's
    using this typedef.

    Note that it doesn't fix many indents although it should,
    as sctp_disposition_t's removal would mess them up again.
    So better to fix them when removing sctp_disposition_t in
    later patch.

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

    Xin Long
     
  • This patch is to remove the typedef sctp_ierror_t, and
    replace with enum sctp_ierror in the places where it's
    using this typedef.

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

    Xin Long
     

04 Aug, 2017

10 commits