1. 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
  2. 19 2月, 2013 2 次提交
  3. 17 7月, 2012 1 次提交
  4. 21 4月, 2012 1 次提交
  5. 20 4月, 2012 1 次提交
    • E
      net ax25: Reorder ax25_exit to remove races. · 3adadc08
      Eric W. Biederman 提交于
      While reviewing the sysctl code in ax25 I spotted races in ax25_exit
      where it is possible to receive notifications and packets after already
      freeing up some of the data structures needed to process those
      notifications and updates.
      
      Call unregister_netdevice_notifier early so that the rest of the cleanup
      code does not need to deal with network devices.  This takes advantage
      of my recent enhancement to unregister_netdevice_notifier to send
      unregister notifications of all network devices that are current
      registered.
      
      Move the unregistration for packet types, socket types and protocol
      types before we cleanup any of the ax25 data structures to remove the
      possibilities of other races.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3adadc08
  6. 29 3月, 2012 1 次提交
  7. 29 12月, 2011 1 次提交
    • X
      ax25: avoid overflows in ax25_setsockopt() · ba1cffe0
      Xi Wang 提交于
      Commit be639ac6 ("NET: AX.25: Check ioctl arguments to avoid overflows
      further down the road") rejects very large arguments, but doesn't
      completely fix overflows on 64-bit systems.  Consider the AX25_T2 case.
      
      	int opt;
      	...
      	if (opt < 1 || opt > ULONG_MAX / HZ) {
      		res = -EINVAL;
      		break;
      	}
      	ax25->t2 = opt * HZ;
      
      The 32-bit multiplication opt * HZ would overflow before being assigned
      to 64-bit ax25->t2.  This patch changes "opt" to unsigned long.
      Signed-off-by: NXi Wang <xi.wang@gmail.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ba1cffe0
  8. 29 11月, 2011 1 次提交
    • R
      NET: AX.25: Check ioctl arguments to avoid overflows further down the road. · be639ac6
      Ralf Baechle 提交于
      Very large, nonsenical arguments or use in very extreme conditions could
      result in integer overflows.  Check ioctls arguments to avoid such
      overflows and return -EINVAL for too large arguments.
      
      To allow the use of AX.25 for even the most extreme setup (think packet
      radio to the Phase 5E mars probe) we make no further attempt to clamp the
      argument range.
      
      Originally reported by Fan Long <longfancn@gmail.com> and a first patch
      was sent by Xi Wang <xi.wang@gmail.com>.
      Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      Cc: Xi Wang <xi.wang@gmail.com>
      Cc: Joerg Reuter <jreuter@yaina.de>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Cc: Thomas Osterried <thomas@osterried.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      be639ac6
  9. 14 4月, 2011 1 次提交
  10. 12 1月, 2011 1 次提交
  11. 11 11月, 2010 1 次提交
  12. 19 8月, 2010 1 次提交
  13. 21 4月, 2010 1 次提交
  14. 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
  15. 11 2月, 2010 1 次提交
  16. 26 11月, 2009 1 次提交
  17. 06 11月, 2009 1 次提交
  18. 30 10月, 2009 1 次提交
  19. 07 10月, 2009 1 次提交
  20. 01 10月, 2009 2 次提交
  21. 29 9月, 2009 1 次提交
  22. 26 9月, 2009 1 次提交
  23. 23 9月, 2009 1 次提交
  24. 18 6月, 2009 1 次提交
  25. 17 6月, 2009 1 次提交
  26. 28 3月, 2009 1 次提交
  27. 22 3月, 2009 2 次提交
  28. 10 3月, 2009 1 次提交
  29. 01 2月, 2009 1 次提交
  30. 14 11月, 2008 1 次提交
  31. 07 10月, 2008 1 次提交
  32. 20 7月, 2008 1 次提交
  33. 17 6月, 2008 1 次提交
    • D
      ax25: Use sock_graft() and remove bogus sk_socket and sk_sleep init. · 9375cb8a
      David S. Miller 提交于
      The way that listening sockets work in ax25 is that the packet input
      code path creates new socks via ax25_make_new() and attaches them
      to the incoming SKB.  This SKB gets queued up into the listening
      socket's receive queue.
      
      When accept()'d the sock gets hooked up to the real parent socket.
      Alternatively, if the listening socket is closed and released, any
      unborn socks stuff up in the receive queue get released.
      
      So during this time period these sockets are unreachable in any
      other way, so no wakeup events nor references to their ->sk_socket
      and ->sk_sleep members can occur.  And even if they do, all such
      paths have to make NULL checks.
      
      So do not deceptively initialize them in ax25_make_new() to the
      values in the listening socket.  Leave them at NULL.
      
      Finally, use sock_graft() in ax25_accept().
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9375cb8a
  34. 26 3月, 2008 2 次提交
  35. 13 2月, 2008 2 次提交
    • J
      [AX25] ax25_timer: use mod_timer instead of add_timer · 21fab4a8
      Jarek Poplawski 提交于
      According to one of Jann's OOPS reports it looks like
      BUG_ON(timer_pending(timer)) triggers during add_timer()
      in ax25_start_t1timer(). This patch changes current use
      of: init_timer(), add_timer() and del_timer() to
      setup_timer() with mod_timer(), which should be safer
      anyway.
      Reported-by: NJann Traschewski <jann@gmx.de>
      Signed-off-by: NJarek Poplawski <jarkao2@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      21fab4a8
    • J
      [AX25] af_ax25: remove sock lock in ax25_info_show() · 1105b5d1
      Jarek Poplawski 提交于
      This lockdep warning:
      
      > =======================================================
      > [ INFO: possible circular locking dependency detected ]
      > 2.6.24 #3
      > -------------------------------------------------------
      > swapper/0 is trying to acquire lock:
      >  (ax25_list_lock){-+..}, at: [<f91dd3b1>] ax25_destroy_socket+0x171/0x1f0 [ax25]
      >
      > but task is already holding lock:
      >  (slock-AF_AX25){-+..}, at: [<f91dbabc>] ax25_std_heartbeat_expiry+0x1c/0xe0 [ax25]
      >
      > which lock already depends on the new lock.
      ...
      
      shows that ax25_list_lock and slock-AF_AX25 are taken in different
      order: ax25_info_show() takes slock (bh_lock_sock(ax25->sk)) while
      ax25_list_lock is held, so reversely to other functions. To fix this
      the sock lock should be moved to ax25_info_start(), and there would
      be still problem with breaking ax25_list_lock (it seems this "proper"
      order isn't optimal yet). But, since it's only for reading proc info
      it seems this is not necessary (e.g.  ax25_send_to_raw() does similar
      reading without this lock too).
      
      So, this patch removes sock lock to avoid deadlock possibility; there
      is also used sock_i_ino() function, which reads sk_socket under proper
      read lock. Additionally printf format of this i_ino is changed to %lu.
      Reported-by: NBernard Pidoux F6BVP <f6bvp@free.fr>
      Signed-off-by: NJarek Poplawski <jarkao2@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1105b5d1