1. Jul 18, 2017
  2. Jul 17, 2017
    • Eric Dumazet's avatar
      inetpeer: remove AVL implementation in favor of RB tree · b145425f
      Eric Dumazet authored
      
      
      As discussed in Faro during Netfilter Workshop 2017, RB trees can be
      used with RCU, using a seqlock.
      
      Note that net/rxrpc/conn_service.c is already using this.
      
      This patch converts inetpeer from AVL tree to RB tree, since it allows
      to remove private AVL implementation in favor of shared RB code.
      
      $ size net/ipv4/inetpeer.before net/ipv4/inetpeer.after
         text    data     bss     dec     hex filename
         3195      40     128    3363     d23 net/ipv4/inetpeer.before
         1562      24       0    1586     632 net/ipv4/inetpeer.after
      
      The same technique can be used to speed up
      net/netfilter/nft_set_rbtree.c (removing rwlock contention in fast path)
      
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b145425f
    • David Herrmann's avatar
      net/unix: drop obsolete fd-recursion limits · 27eac47b
      David Herrmann authored
      All unix sockets now account inflight FDs to the respective sender.
      This was introduced in:
      
          commit 712f4aad
          Author: willy tarreau <w@1wt.eu>
          Date:   Sun Jan 10 07:54:56 2016 +0100
      
              unix: properly account for FDs passed over unix sockets
      
      and further refined in:
      
          commit 415e3d3e
      
      
          Author: Hannes Frederic Sowa <hannes@stressinduktion.org>
          Date:   Wed Feb 3 02:11:03 2016 +0100
      
              unix: correctly track in-flight fds in sending process user_struct
      
      Hence, regardless of the stacking depth of FDs, the total number of
      inflight FDs is limited, and accounted. There is no known way for a
      local user to exceed those limits or exploit the accounting.
      
      Furthermore, the GC logic is independent of the recursion/stacking depth
      as well. It solely depends on the total number of inflight FDs,
      regardless of their layout.
      
      Lastly, the current `recursion_level' suffers a TOCTOU race, since it
      checks and inherits depths only at queue time. If we consider `A<-B' to
      mean `queue-B-on-A', the following sequence circumvents the recursion
      level easily:
      
          A<-B
             B<-C
                C<-D
                   ...
                     Y<-Z
      
      resulting in:
      
          A<-B<-C<-...<-Z
      
      With all of this in mind, lets drop the recursion limit. It has no
      additional security value, anymore. On the contrary, it randomly
      confuses message brokers that try to forward file-descriptors, since
      any sendmsg(2) call can fail spuriously with ETOOMANYREFS if a client
      maliciously modifies the FD while inflight.
      
      Cc: Alban Crequy <alban.crequy@collabora.co.uk>
      Cc: Simon McVittie <simon.mcvittie@collabora.co.uk>
      Signed-off-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
      Reviewed-by: default avatarTom Gundersen <teg@jklm.no>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      27eac47b
    • linzhang's avatar
      skbuff: optimize the pull_pages code in __pskb_pull_tail() · 3ccc6c6f
      linzhang authored
      
      
      In the pull_pages code block, if the first frag size > eat,
      we can end the loop in advance to avoid extra copy.
      
      Signed-off-by: default avatarLin Zhang <xiaolou4617@gmail.com>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3ccc6c6f