1. 21 11月, 2013 1 次提交
    • H
      net: rework recvmsg handler msg_name and msg_namelen logic · f3d33426
      Hannes Frederic Sowa 提交于
      This patch now always passes msg->msg_namelen as 0. recvmsg handlers must
      set msg_namelen to the proper size <= sizeof(struct sockaddr_storage)
      to return msg_name to the user.
      
      This prevents numerous uninitialized memory leaks we had in the
      recvmsg handlers and makes it harder for new code to accidentally leak
      uninitialized memory.
      
      Optimize for the case recvfrom is called with NULL as address. We don't
      need to copy the address at all, so set it to NULL before invoking the
      recvmsg handler. We can do so, because all the recvmsg handlers must
      cope with the case a plain read() is called on them. read() also sets
      msg_name to NULL.
      
      Also document these changes in include/linux/net.h as suggested by David
      Miller.
      
      Changes since RFC:
      
      Set msg->msg_name = NULL if user specified a NULL in msg_name but had a
      non-null msg_namelen in verify_iovec/verify_compat_iovec. This doesn't
      affect sendto as it would bail out earlier while trying to copy-in the
      address. It also more naturally reflects the logic by the callers of
      verify_iovec.
      
      With this change in place I could remove "
      if (!uaddr || msg_sys->msg_namelen == 0)
      	msg->msg_name = NULL
      ".
      
      This change does not alter the user visible error logic as we ignore
      msg_namelen as long as msg_name is NULL.
      
      Also remove two unnecessary curly brackets in ___sys_recvmsg and change
      comments to netdev style.
      
      Cc: David Miller <davem@davemloft.net>
      Suggested-by: NEric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: NHannes Frederic Sowa <hannes@stressinduktion.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f3d33426
  2. 29 5月, 2013 1 次提交
  3. 08 4月, 2013 1 次提交
  4. 28 2月, 2013 1 次提交
    • S
      hlist: drop the node parameter from iterators · b67bfe0d
      Sasha Levin 提交于
      I'm not sure why, but the hlist for each entry iterators were conceived
      
              list_for_each_entry(pos, head, member)
      
      The hlist ones were greedy and wanted an extra parameter:
      
              hlist_for_each_entry(tpos, pos, head, member)
      
      Why did they need an extra pos parameter? I'm not quite sure. Not only
      they don't really need it, it also prevents the iterator from looking
      exactly like the list iterator, which is unfortunate.
      
      Besides the semantic patch, there was some manual work required:
      
       - Fix up the actual hlist iterators in linux/list.h
       - Fix up the declaration of other iterators based on the hlist ones.
       - A very small amount of places were using the 'node' parameter, this
       was modified to use 'obj->member' instead.
       - Coccinelle didn't handle the hlist_for_each_entry_safe iterator
       properly, so those had to be fixed up manually.
      
      The semantic patch which is mostly the work of Peter Senna Tschudin is here:
      
      @@
      iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
      
      type T;
      expression a,c,d,e;
      identifier b;
      statement S;
      @@
      
      -T b;
          <+... when != b
      (
      hlist_for_each_entry(a,
      - b,
      c, d) S
      |
      hlist_for_each_entry_continue(a,
      - b,
      c) S
      |
      hlist_for_each_entry_from(a,
      - b,
      c) S
      |
      hlist_for_each_entry_rcu(a,
      - b,
      c, d) S
      |
      hlist_for_each_entry_rcu_bh(a,
      - b,
      c, d) S
      |
      hlist_for_each_entry_continue_rcu_bh(a,
      - b,
      c) S
      |
      for_each_busy_worker(a, c,
      - b,
      d) S
      |
      ax25_uid_for_each(a,
      - b,
      c) S
      |
      ax25_for_each(a,
      - b,
      c) S
      |
      inet_bind_bucket_for_each(a,
      - b,
      c) S
      |
      sctp_for_each_hentry(a,
      - b,
      c) S
      |
      sk_for_each(a,
      - b,
      c) S
      |
      sk_for_each_rcu(a,
      - b,
      c) S
      |
      sk_for_each_from
      -(a, b)
      +(a)
      S
      + sk_for_each_from(a) S
      |
      sk_for_each_safe(a,
      - b,
      c, d) S
      |
      sk_for_each_bound(a,
      - b,
      c) S
      |
      hlist_for_each_entry_safe(a,
      - b,
      c, d, e) S
      |
      hlist_for_each_entry_continue_rcu(a,
      - b,
      c) S
      |
      nr_neigh_for_each(a,
      - b,
      c) S
      |
      nr_neigh_for_each_safe(a,
      - b,
      c, d) S
      |
      nr_node_for_each(a,
      - b,
      c) S
      |
      nr_node_for_each_safe(a,
      - b,
      c, d) S
      |
      - for_each_gfn_sp(a, c, d, b) S
      + for_each_gfn_sp(a, c, d) S
      |
      - for_each_gfn_indirect_valid_sp(a, c, d, b) S
      + for_each_gfn_indirect_valid_sp(a, c, d) S
      |
      for_each_host(a,
      - b,
      c) S
      |
      for_each_host_safe(a,
      - b,
      c, d) S
      |
      for_each_mesh_entry(a,
      - b,
      c, d) S
      )
          ...+>
      
      [akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
      [akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
      [akpm@linux-foundation.org: checkpatch fixes]
      [akpm@linux-foundation.org: fix warnings]
      [akpm@linux-foudnation.org: redo intrusive kvm changes]
      Tested-by: NPeter Senna Tschudin <peter.senna@gmail.com>
      Acked-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Signed-off-by: NSasha Levin <sasha.levin@oracle.com>
      Cc: Wu Fengguang <fengguang.wu@intel.com>
      Cc: Marcelo Tosatti <mtosatti@redhat.com>
      Cc: Gleb Natapov <gleb@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b67bfe0d
  5. 19 2月, 2013 2 次提交
  6. 29 3月, 2012 1 次提交
  7. 14 4月, 2011 1 次提交
  8. 28 3月, 2011 1 次提交
  9. 15 2月, 2011 1 次提交
    • B
      ROSE: AX25: finding routes simplification · 68aa3fd5
      Bernard Pidoux 提交于
      With previous patch, rose_get_neigh() routine
      investigates the full list of neighbor nodes
      until it finds or not an already connected node whether
      it is called locally or through a level 3 transit frame.
      If no routes are opened through an adjacent connected node
      then a classical connect request is attempted.
      
      Then there is no more reason for an extra loop such
      as the one removed by this patch.
      Signed-off-by: NBernard Pidoux <f6bvp@free.fr>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      68aa3fd5
  10. 21 9月, 2010 1 次提交
  11. 21 4月, 2010 1 次提交
  12. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit 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: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  13. 11 2月, 2010 1 次提交
  14. 26 11月, 2009 1 次提交
  15. 06 11月, 2009 1 次提交
  16. 07 10月, 2009 1 次提交
  17. 01 10月, 2009 1 次提交
  18. 15 9月, 2009 1 次提交
  19. 07 8月, 2009 1 次提交
  20. 27 7月, 2009 1 次提交
  21. 18 6月, 2009 1 次提交
  22. 17 6月, 2009 1 次提交
  23. 15 4月, 2009 1 次提交
  24. 27 3月, 2009 1 次提交
  25. 22 1月, 2009 1 次提交
  26. 25 11月, 2008 1 次提交
    • B
      rose: zero length frame filtering in af_rose.c · 244f46ae
      Bernard Pidoux 提交于
      Since changeset e79ad711 from  mainline,
      >From David S. Miller,
      empty packet can be transmitted on connected socket for datagram protocols.
      
      However, this patch broke a high level application using ROSE network protocol with connected datagram.
      
      Bulletin Board Stations perform bulletins forwarding between BBS stations via ROSE network using a forward protocol.
      Now, if for some reason, a buffer in the application software happens to be empty at a specific moment,
      ROSE sends an empty packet via unfiltered packet socket.
      When received, this ROSE packet introduces perturbations of data exchange of BBS forwarding,
      for the application message forwarding protocol is waiting for something else.
      We agree that a more careful programming of the application protocol would avoid this situation and we are
      willing to debug it.
      But, as an empty frame is no use and does not have any meaning for ROSE protocol,
      we may consider filtering zero length data both when sending and receiving socket data.
      
      The proposed patch repaired BBS data exchange through ROSE network that were broken since 2.6.22.11 kernel.
      Signed-off-by: NBernard Pidoux <f6bvp@amsat.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      244f46ae
  27. 14 11月, 2008 1 次提交
  28. 23 7月, 2008 1 次提交
  29. 20 7月, 2008 1 次提交
  30. 18 7月, 2008 1 次提交
    • D
      netdev: Allocate multiple queues for TX. · e8a0464c
      David S. Miller 提交于
      alloc_netdev_mq() now allocates an array of netdev_queue
      structures for TX, based upon the queue_count argument.
      
      Furthermore, all accesses to the TX queues are now vectored
      through the netdev_get_tx_queue() and netdev_for_each_tx_queue()
      interfaces.  This makes it easy to grep the tree for all
      things that want to get to a TX queue of a net device.
      
      Problem spots which are not really multiqueue aware yet, and
      only work with one queue, can easily be spotted by grepping
      for all netdev_get_tx_queue() calls that pass in a zero index.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e8a0464c
  31. 09 7月, 2008 1 次提交
  32. 18 6月, 2008 1 次提交
    • B
      rose: improving AX25 routing frames via ROSE network · fe2c802a
      Bernard Pidoux 提交于
      ROSE network is organized through nodes connected via hamradio or Internet.
      AX25 packet radio frames sent to a remote ROSE address destination are routed
      through these nodes.
      
      Without the present patch, automatic routing mechanism did not work optimally
      due to an improper parameter checking.
      
      rose_get_neigh() function is called either by rose_connect() or by
      rose_route_frame().
      
      In the case of a call from rose_connect(), f0 timer is checked to find if a connection
      is already pending. In that case it returns the address of the neighbour, or returns a NULL otherwise.
      
      When called by rose_route_frame() the purpose was to route a packet AX25 frame
      through an adjacent node given a destination rose address.
      However, in that case, t0 timer checked does not indicate if the adjacent node
      is actually connected even if the timer is not null. Thus, for each frame sent, the
      function often tried to start a new connexion even if the adjacent node was already connected.
      
      The patch adds a "new" parameter that is true when the function is called by
      rose route_frame().
      This instructs rose_get_neigh() to check node parameter "restarted". 
      If restarted is true it means that the route to the destination address is opened via a neighbour
      node already connected.
      If "restarted" is false the function returns a NULL.
      In that case the calling function will initiate a new connection as before.
      
      This results in a fast routing of frames, from nodes to nodes, until
      destination is reached, as originaly specified by ROSE protocole.
      Signed-off-by: NBernard Pidoux <f6bvp@amsat.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      fe2c802a
  33. 17 6月, 2008 1 次提交
  34. 20 4月, 2008 1 次提交
    • B
      rose: Socket lock was not released before returning to user space · 43837b1e
      Bernard Pidoux 提交于
      ================================================
      [ BUG: lock held when returning to user space! ]
      ------------------------------------------------
      xfbbd/3683 is leaving the kernel with locks still held!
      1 lock held by xfbbd/3683:
        #0:  (sk_lock-AF_ROSE){--..}, at: [<c8cd1eb3>] rose_connect+0x73/0x420 [rose]
      
      INFO: task xfbbd:3683 blocked for more than 120 seconds.
      "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      xfbbd         D 00000246     0  3683   3669
              c6965ee0 00000092 c02c5c40 00000246 c0f6b5f0 c0f6b5c0 c0f6b5f0 c0f6b5c0
              c0f6b614 c6965f18 c024b74b ffffffff c06ba070 00000000 00000000 00000001
              c6ab07c0 c012d450 c0f6b634 c0f6b634 c7b5bf10 c0d6004c c7b5bf10 c6965f40
      Call Trace:
        [<c024b74b>] lock_sock_nested+0x6b/0xd0
        [<c012d450>] ? autoremove_wake_function+0x0/0x40
        [<c02488f1>] sock_fasync+0x41/0x150
        [<c0249e69>] sock_close+0x19/0x40
        [<c0175d54>] __fput+0xb4/0x170
        [<c0176018>] fput+0x18/0x20
        [<c017300e>] filp_close+0x3e/0x70
        [<c01744e9>] sys_close+0x69/0xb0
        [<c0103bda>] sysenter_past_esp+0x5f/0xa5
        =======================
      INFO: lockdep is turned off.
      Signed-off-by: NBernard Pidoux <f6bvp@amsat.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      43837b1e
  35. 02 4月, 2008 1 次提交
  36. 26 3月, 2008 2 次提交
  37. 29 1月, 2008 2 次提交
    • E
      [ROSE]: Supress sparse warnings · 95b7d924
      Eric Dumazet 提交于
        CHECK   net/rose/af_rose.c
      net/rose/af_rose.c:125:11: warning: expensive signed divide
      net/rose/af_rose.c:976:46: warning: expensive signed divide
      net/rose/af_rose.c:1379:13: warning: context imbalance in 'rose_info_start' - wrong count at exit
      net/rose/af_rose.c:1406:13: warning: context imbalance in 'rose_info_stop' - unexpected unlock
        CHECK   net/rose/rose_in.c
      net/rose/rose_in.c:185:25: warning: expensive signed divide
        CHECK   net/rose/rose_route.c
      net/rose/rose_route.c:997:46: warning: expensive signed divide
      net/rose/rose_route.c:1070:13: warning: context imbalance in 'rose_node_start' - wrong count at exit
      net/rose/rose_route.c:1093:13: warning: context imbalance in 'rose_node_stop' - unexpected unlock
      net/rose/rose_route.c:1146:13: warning: context imbalance in 'rose_neigh_start' - wrong count at exit
      net/rose/rose_route.c:1169:13: warning: context imbalance in 'rose_neigh_stop' - unexpected unlock
      net/rose/rose_route.c:1229:13: warning: context imbalance in 'rose_route_start' - wrong count at exit
      net/rose/rose_route.c:1252:13: warning: context imbalance in 'rose_route_stop' - unexpected unlock
      Signed-off-by: NEric Dumazet <dada1@cosmosbay.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      95b7d924
    • P
      [NET]: Convert init_timer into setup_timer · b24b8a24
      Pavel Emelyanov 提交于
      Many-many code in the kernel initialized the timer->function
      and  timer->data together with calling init_timer(timer). There
      is already a helper for this. Use it for networking code.
      
      The patch is HUGE, but makes the code 130 lines shorter
      (98 insertions(+), 228 deletions(-)).
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Acked-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b24b8a24