12 Apr, 2014

1 commit

  • Several spots in the kernel perform a sequence like:

    skb_queue_tail(&sk->s_receive_queue, skb);
    sk->sk_data_ready(sk, skb->len);

    But at the moment we place the SKB onto the socket receive queue it
    can be consumed and freed up. So this skb->len access is potentially
    to freed up memory.

    Furthermore, the skb->len can be modified by the consumer so it is
    possible that the value isn't accurate.

    And finally, no actual implementation of this callback actually uses
    the length argument. And since nobody actually cared about it's
    value, lots of call sites pass arbitrary values in such as '0' and
    even '1'.

    So just remove the length argument from the callback, that way there
    is no confusion whatsoever and all of these use-after-free cases get
    fixed as a side effect.

    Based upon a patch by Eric Dumazet and his suggestion to audit this
    issue tree-wide.

    Signed-off-by: David S. Miller

    David S. Miller
     

27 Dec, 2013

3 commits


07 Dec, 2013

1 commit

  • Several files refer to an old address for the Free Software Foundation
    in the file header comment. Resolve by replacing the address with
    the URL so that we do not have to keep
    updating the header comments anytime the address changes.

    CC: Vlad Yasevich
    CC: Neil Horman
    Signed-off-by: Jeff Kirsher
    Signed-off-by: David S. Miller

    Jeff Kirsher
     

10 Aug, 2013

1 commit

  • With the restructuring of the lksctp.org site, we only allow bug
    reports through the SCTP mailing list linux-sctp@vger.kernel.org,
    not via SF, as SF is only used for web hosting and nothing more.
    While at it, also remove the obvious statement that bugs will be
    fixed and incooperated into the kernel.

    Signed-off-by: Daniel Borkmann
    Acked-by: Vlad Yasevich
    Signed-off-by: David S. Miller

    Daniel Borkmann
     

25 Jul, 2013

1 commit

  • The SCTP mailing list address to send patches or questions
    to is linux-sctp@vger.kernel.org and not
    lksctp-developers@lists.sourceforge.net anymore. Therefore,
    update all occurences.

    Signed-off-by: Daniel Borkmann
    Acked-by: Neil Horman
    Acked-by: Vlad Yasevich
    Signed-off-by: David S. Miller

    Daniel Borkmann
     

18 Apr, 2013

1 commit


01 Mar, 2013

3 commits

  • In sctp_ulpq_tail_data(), use return values 0,1 to indicate whether
    a complete event (with MSG_EOR set) was delivered. A return value
    of -ENOMEM continues to indicate an out-of-memory condition was
    encountered.

    In sctp_ulpq_retrieve_partial() and sctp_ulpq_retrieve_first(),
    correct message reassembly logic for SCTP partial delivery.
    Change logic to ensure that as much data as possible is sent
    with the initial partial delivery and that following partial
    deliveries contain all available data.

    In sctp_ulpq_partial_delivery(), attempt partial delivery only
    if the data on the head of the reassembly queue is at or before
    the cumulative TSN ACK point.

    In sctp_ulpq_renege(), use the modified return values from
    sctp_ulpq_tail_data() to choose whether to attempt partial
    delivery or to attempt to drain the reassembly queue as a
    means to reduce memory pressure. Remove call to
    sctp_tsnmap_mark(), as this is handled correctly in call to
    sctp_ulpq_tail_data().

    Signed-off-by: Lee A. Roberts
    Acked-by: Vlad Yasevich
    Acked-by: Neil Horman

    Lee A. Roberts
     
  • In sctp_ulpq_renege_list(), events being reneged from the
    ordering queue may correspond to multiple TSNs. Identify
    all affected packets; sum freed space and renege from the
    tsnmap.

    Signed-off-by: Lee A. Roberts
    Acked-by: Vlad Yasevich
    Acked-by: Neil Horman

    Lee A. Roberts
     
  • In sctp_ulpq_renege_list(), do not renege packets below the
    cumulative TSN ACK point.

    Signed-off-by: Lee A. Roberts
    Acked-by: Vlad Yasevich
    Acked-by: Neil Horman

    Lee A. Roberts
     

04 Nov, 2012

1 commit

  • Lots of points in the sctp_cmd_interpreter function treat the sctp_cmd_t arg as
    a void pointer, even though they are written as various other types. Theres no
    need for this as doing so just leads to possible type-punning issues that could
    cause crashes, and if we remain type-consistent we can actually just remove the
    void * member of the union entirely.

    Change Notes:

    v2)
    * Dropped chunk that modified SCTP_NULL to create a marker pattern
    should anyone try to use a SCTP_NULL() assigned sctp_arg_t, Assigning
    to .zero provides the same effect and should be faster, per Vlad Y.

    v3)
    * Reverted part of V2, opting to use memset instead of .zero, so that
    the entire union is initalized thus avoiding the i164 speculative load
    problems previously encountered, per Dave M.. Also rewrote
    SCTP_[NO]FORCE so as to use common infrastructure a little more

    Signed-off-by: Neil Horman
    CC: "David S. Miller"
    CC: linux-sctp@vger.kernel.org
    Signed-off-by: David S. Miller

    Neil Horman
     

15 Aug, 2012

1 commit


01 Jul, 2012

1 commit

  • It was noticed recently that when we send data on a transport, its possible that
    we might bundle a sack that arrived on a different transport. While this isn't
    a major problem, it does go against the SHOULD requirement in section 6.4 of RFC
    2960:

    An endpoint SHOULD transmit reply chunks (e.g., SACK, HEARTBEAT ACK,
    etc.) to the same destination transport address from which it
    received the DATA or control chunk to which it is replying. This
    rule should also be followed if the endpoint is bundling DATA chunks
    together with the reply chunk.

    This patch seeks to correct that. It restricts the bundling of sack operations
    to only those transports which have moved the ctsn of the association forward
    since the last sack. By doing this we guarantee that we only bundle outbound
    saks on a transport that has received a chunk since the last sack. This brings
    us into stricter compliance with the RFC.

    Vlad had initially suggested that we strictly allow only sack bundling on the
    transport that last moved the ctsn forward. While this makes sense, I was
    concerned that doing so prevented us from bundling in the case where we had
    received chunks that moved the ctsn on multiple transports. In those cases, the
    RFC allows us to select any of the transports having received chunks to bundle
    the sack on. so I've modified the approach to allow for that, by adding a state
    variable to each transport that tracks weather it has moved the ctsn since the
    last sack. This I think keeps our behavior (and performance), close enough to
    our current profile that I think we can do this without a sysctl knob to
    enable/disable it.

    Signed-off-by: Neil Horman
    CC: Vlad Yaseivch
    CC: David S. Miller
    CC: linux-sctp@vger.kernel.org
    Reported-by: Michele Baldessari
    Reported-by: sorin serban
    Acked-by: Vlad Yasevich
    Signed-off-by: David S. Miller

    Neil Horman
     

31 Mar, 2011

1 commit


08 Mar, 2011

1 commit


18 May, 2010

1 commit

  • This patch removes from net/ (but not any netfilter files)
    all the unnecessary return; statements that precede the
    last closing brace of void functions.

    It does not remove the returns that are immediately
    preceded by a label as gcc doesn't like that.

    Done via:
    $ grep -rP --include=*.[ch] -l "return;\n}" net/ | \
    xargs perl -i -e 'local $/ ; while (<>) { s/\n[ \t\n]+return;\n}/\n}/g; print; }'

    Signed-off-by: Joe Perches
    Signed-off-by: David S. Miller

    Joe Perches
     

30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

22 Sep, 2008

1 commit


07 Feb, 2008

1 commit


05 Feb, 2008

2 commits


29 Jan, 2008

1 commit

  • This patch introduces new memory accounting functions for each network
    protocol. Most of them are renamed from memory accounting functions
    for stream protocols. At the same time, some stream memory accounting
    functions are removed since other functions do same thing.

    Renaming:
    sk_stream_free_skb() -> sk_wmem_free_skb()
    __sk_stream_mem_reclaim() -> __sk_mem_reclaim()
    sk_stream_mem_reclaim() -> sk_mem_reclaim()
    sk_stream_mem_schedule -> __sk_mem_schedule()
    sk_stream_pages() -> sk_mem_pages()
    sk_stream_rmem_schedule() -> sk_rmem_schedule()
    sk_stream_wmem_schedule() -> sk_wmem_schedule()
    sk_charge_skb() -> sk_mem_charge()

    Removeing
    sk_stream_rfree(): consolidates into sock_rfree()
    sk_stream_set_owner_r(): consolidates into skb_set_owner_r()
    sk_stream_mem_schedule()

    The following functions are added.
    sk_has_account(): check if the protocol supports accounting
    sk_mem_uncharge(): do the opposite of sk_mem_charge()

    In addition, to achieve consolidation, updating sk_wmem_queued is
    removed from sk_mem_charge().

    Next, to consolidate memory accounting functions, this patch adds
    memory accounting calls to network core functions. Moreover, present
    memory accounting call is renamed to new accounting call.

    Finally we replace present memory accounting calls with new interface
    in TCP and SCTP.

    Signed-off-by: Takahiro Yasui
    Signed-off-by: Hideo Aoki
    Signed-off-by: David S. Miller

    Hideo Aoki
     

17 Dec, 2007

1 commit

  • At the end of partial delivery, we may have complete messages
    sitting on the fragment queue. These messages are stuck there
    until a new fragment arrives. This can comletely stall a
    given association. When clearing partial delivery state, flush
    any complete messages from the fragment queue and send them on
    their way up.

    Signed-off-by: Vlad Yasevich
    Signed-off-by: David S. Miller

    Vlad Yasevich
     

10 Nov, 2007

1 commit


24 Oct, 2007

1 commit


11 Oct, 2007

1 commit

  • This patch introduces autotuning to the sctp buffer management code
    similar to the TCP. The buffer space can be grown if the advertised
    receive window still has room. This might happen if small message
    sizes are used, which is common in telecom environmens.
    New tunables are introduced that provide limits to buffer growth
    and memory pressure is entered if to much buffer spaces is used.

    Signed-off-by: Neil Horman
    Signed-off-by: Vlad Yasevich
    Signed-off-by: David S. Miller

    Neil Horman
     

30 Aug, 2007

1 commit


26 Apr, 2007

3 commits

  • Spring cleaning time...

    There seems to be a lot of places in the network code that have
    extra bogus semicolons after conditionals. Most commonly is a
    bogus semicolon after: switch() { }

    Signed-off-by: Stephen Hemminger
    Signed-off-by: David S. Miller

    Stephen Hemminger
     
  • This option induces partial delivery to run as soon
    as the specified amount of data has been accumulated on
    the association. However, we give preference to fully
    reassembled messages over PD messages. In any case,
    window and buffer is freed up.

    Signed-off-by: Vlad Yasevich
    Signed-off-by: David S. Miller

    Vlad Yasevich
     
  • This option was introduced in draft-ietf-tsvwg-sctpsocket-13. It
    prevents head-of-line blocking in the case of one-to-many endpoint.
    Applications enabling this option really must enable SCTP_SNDRCV event
    so that they would know where the data belongs. Based on an
    earlier patch by Ivan Skytte Jørgensen.

    Additionally, this functionality now permits multiple associations
    on the same endpoint to enter Partial Delivery. Applications should
    be extra careful, when using this functionality, to track EOR indicators.

    Signed-off-by: Vlad Yasevich
    Signed-off-by: David S. Miller

    Vlad Yasevich
     

19 Apr, 2007

1 commit

  • The way partial delivery is currently implemnted, it is possible to
    intereleave a message (either from another steram, or unordered) that
    is not part of partial delivery process. The only way to this is for
    a message to not be a fragment and be 'in order' or unorderd for a
    given stream. This will result in bypassing the reassembly/ordering
    queues where things live duing partial delivery, and the
    message will be delivered to the socket in the middle of partial delivery.

    This is a two-fold problem, in that:
    1. the app now must check the stream-id and flags which it may not
    be doing.
    2. this clearing partial delivery state from the association and results
    in ulp hanging.

    This patch is a band-aid over a much bigger problem in that we
    don't do stream interleave.

    Signed-off-by: Vlad Yasevich
    Signed-off-by: David S. Miller

    Vlad Yasevich
     

20 Mar, 2007

1 commit

  • During association restart we may have stale data sitting
    on the ULP queue waiting for ordering or reassembly. This
    data may cause severe problems if not cleaned up. In particular
    stale data pending ordering may cause problems with receive
    window exhaustion if our peer has decided to restart the
    association.

    Signed-off-by: Vlad Yasevich
    Signed-off-by: Sridhar Samudrala
    Signed-off-by: David S. Miller

    Vlad Yasevich
     

11 Feb, 2007

1 commit


12 Oct, 2006

1 commit

  • When doing receiver buffer accounting, we always used skb->truesize.
    This is problematic when processing bundled DATA chunks because for
    every DATA chunk that could be small part of one large skb, we would
    charge the size of the entire skb. The new approach is to store the
    size of the DATA chunk we are accounting for in the sctp_ulpevent
    structure and use that stored value for accounting.

    Signed-off-by: Vlad Yasevich
    Signed-off-by: Sridhar Samudrala
    Signed-off-by: David S. Miller

    Vlad Yasevich
     

06 May, 2006

1 commit

  • There is a rare situation that causes lksctp to go into infinite recursion
    and crash the system. The trigger is a packet that contains at least the
    first two DATA fragments of a message bundled together. The recursion is
    triggered when the user data buffer is smaller that the full data message.
    The problem is that we clone the skb for every fragment in the message.
    When reassembling the full message, we try to link skbs from the "first
    fragment" clone using the frag_list. However, since the frag_list is shared
    between two clones in this rare situation, we end up setting the frag_list
    pointer of the second fragment to point to itself. This causes
    sctp_skb_pull() to potentially recurse indefinitely.

    Proposed solution is to make a copy of the skb when attempting to link
    things using frag_list.

    Signed-off-by: Vladislav Yasevich
    Signed-off-by: Sridhar Samudrala
    Signed-off-by: David S. Miller

    Vladislav Yasevich
     

09 Oct, 2005

1 commit

  • - added typedef unsigned int __nocast gfp_t;

    - replaced __nocast uses for gfp flags with gfp_t - it gives exactly
    the same warnings as far as sparse is concerned, doesn't change
    generated code (from gcc point of view we replaced unsigned int with
    typedef) and documents what's going on far better.

    Signed-off-by: Al Viro
    Signed-off-by: Linus Torvalds

    Al Viro
     

30 Aug, 2005

1 commit

  • Remove the "list" member of struct sk_buff, as it is entirely
    redundant. All SKB list removal callers know which list the
    SKB is on, so storing this in sk_buff does nothing other than
    taking up some space.

    Two tricky bits were SCTP, which I took care of, and two ATM
    drivers which Francois Romieu fixed
    up.

    Signed-off-by: David S. Miller
    Signed-off-by: Francois Romieu

    David S. Miller
     

12 Jul, 2005

1 commit


17 Apr, 2005

1 commit

  • Initial git repository build. I'm not bothering with the full history,
    even though we have it. We can create a separate "historical" git
    archive of that later if we want to, and in the meantime it's about
    3.2GB when imported into git - space that would just make the early
    git days unnecessarily complicated, when we don't have a lot of good
    infrastructure for it.

    Let it rip!

    Linus Torvalds