1. 04 3月, 2015 1 次提交
  2. 30 10月, 2013 1 次提交
  3. 26 10月, 2013 2 次提交
    • N
      netconsole: fix multiple race conditions · c7c6effd
      Nikolay Aleksandrov 提交于
      In every netconsole option that can be set through configfs there's a
      race when checking for nt->enabled since it can be modified at the same
      time. Probably the most damage can be done by store_enabled when racing
      with another instance of itself. Fix all the races with one stone by
      moving the mutex lock around the ->store call for all options.
      Signed-off-by: NNikolay Aleksandrov <nikolay@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c7c6effd
    • N
      netconsole: fix NULL pointer dereference · 45e526e8
      Nikolay Aleksandrov 提交于
      We need to disable the netconsole (enabled = 0) before setting nt->np.dev
      to NULL because otherwise we might still have users after the
      netpoll_cleanup() since nt->enabled is set afterwards and we can
      have a message which will result in a NULL pointer dereference.
      It is very easy to hit dereferences all over the netpoll_send_udp function
      by running the following two loops in parallel:
      while [ 1 ]; do echo 1 > enabled; echo 0 > enabled; done;
      while [ 1 ]; do echo 00:11:22:33:44:55 > remote_mac; done;
      (the second loop is to generate messages, it can be done by anything)
      
      We're safe to set nt->np.dev = NULL and nt->enabled = 0 with the spinlock
      since it's required in the write_msg() function.
      Signed-off-by: NNikolay Aleksandrov <nikolay@redhat.com>
      Reviewed-by: NVeacelsav Falico <vfalico@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      45e526e8
  4. 20 9月, 2013 1 次提交
  5. 04 9月, 2013 1 次提交
    • D
      netconsole: avoid a crash with multiple sysfs writers · 7a163bfb
      Dan Aloni 提交于
      When my 'ifup eth' script was fired multiple times and ran concurrent on
      my laptop, for some obscure /etc scripting reason, it was revealed
      that the store_enabled() function in netconsole doesn't handle it nicely,
      as recorded by the Oops below (a syslog paste, but not mangled too much
      to prevent from discerning the traceback).
      
      On Linux 3.10.4, this patch seeks to remedy the problem, and it has been
      running stable on my laptop for a few days.
      
      [52608.609325] BUG: unable to handle kernel NULL pointer dereference at 00000000000003e0
      [52608.609331] IP: [<ffffffff81532a17>] __netpoll_cleanup+0x27/0xe0
      [52608.609339] PGD 15e51a067 PUD 15433e067 PMD 0
      [52608.609343] Oops: 0000 [#1] SMP re firewire_ohci firewire_core crc_itu_t [last unloaded: kvm_intel]
      [52608.609347] Modules linked in: kvm_intel tun vfat fat ppdev parport_pc parport fuse ipt_MASQUERADE usb_storage nf_conntrack_netbios_ns nf_conn [..garbled..]
      [52608.609433] RAX: 0000000000000000 RBX: ffff880210bbcc68 RCX: 0000000000000000
      [52608.609435] RDX: 0000000000000000 RSI: ffff8801ba447da0 RDI: ffff880210bbcc68
      [52608.609437] RBP: ffff8801ba447e18 R08: 0000000000000000 R09: 0000000000000001
      [52608.609439] R10: 000000000000000a R11: f000000000000000 R12: ffff880210bbcc68
      [52608.609441] R13: ffff88020bc41000 R14: 0000000000000002 R15: 000000000000000200000000000
      [52608.609443] FS:  00007f38d7bff740(0000) GS:ffff88021dc40000(0000) knlGS:0000000000000000
      [52608.609446] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003300000000001427e0
      [52608.609448] CR2: 00000000000003e0 CR3: 0000000154103000 CR4: 00000000001427e0
      [52608.609450] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [52608.609452] netpoll: netconsole: local port 6665ess 10.0.0.27
      [52608.609454] netpoll: netconsole: local IPv4 address 10.0.0.27
      [52608.609456] netpoll: netconsole: interface 'em1'
      [52608.609457] netpoll: netconsole: remote port 514ress 10.0.0.15
      [52608.609459] netpoll: netconsole: remote IPv4 address 10.0.0.15:65:a8:9a:c7
      [52608.609461] netpoll: netconsole: remote ethernet address 1c:6f:65:a8:9a:c7
      [52608.609463] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
      [52608.609464] Stack:801ba447e08 ffff880210bbcc68 ffffffffffffffea ffff88020bc41000
      [52608.609466]  ffff8801ba447e08 ffff880210bbcc68 ffffffffffffffea ffff88020bc41000
      [52608.609471]  0000000000000002 0000000000000002 ffff8801ba447e38 ffffffff81532af4
      [52608.609475]  0000000000000000 ffff880210bbcc00 ffff8801ba447e78 ffffffff81420e7c
      [52608.609479] Call Trace:
      [52608.609484]  [<ffffffff81532af4>] netpoll_cleanup+0x24/0x50
      [52608.609489]  [<ffffffff81420e7c>] store_enabled+0x5c/0xe0
      [52608.609492]  [<ffffffff81420abe>] netconsole_target_attr_store+0x2e/0x40
      [52608.609498]  [<ffffffff811ff2a2>] configfs_write_file+0xd2/0x130
      [52608.609503]  [<ffffffff81188f95>] vfs_write+0xc5/0x1f0
      [52608.609506]  [<ffffffff81189482>] SyS_write+0x52/0xa0/0x10
      [52608.609511]  [<ffffffff81628c2e>] ? do_page_fault+0xe/0x10
      [52608.609516]  [<ffffffff8162d402>] system_call_fastpath+0x16/0x1b
      [52608.609517] Code: 1f 44 00 00 0f 1f 44 00 00 55 48 89 e5 48 83 ec 30 4c 89 65 e0 48 89 5d d8 49 89 fc 4c 89 6d e8 4c 89 75 f0 4c 89 7d f8 48 8 [..garbled..]
      [52608.609559] RIP  [<ffffffff81532a17>] __netpoll_cleanup+0x27/0xe0
      [52608.609563]  RSP <ffff8801ba447de8>
      [52608.609564] CR2: 00000000000003e0
      [52608.609567] ---[ end trace d25ec343349b61d2 ]---
      Signed-off-by: NDan Aloni <alonid@postram.com>
      Signed-off-by: NNeil Horman <nhorman@tuxdriver.com>
      CC: David S. Miller <davem@davemloft.net>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7a163bfb
  6. 06 6月, 2013 1 次提交
  7. 29 5月, 2013 1 次提交
  8. 12 3月, 2013 1 次提交
  9. 09 1月, 2013 2 次提交
  10. 09 11月, 2012 1 次提交
  11. 20 8月, 2012 1 次提交
  12. 15 8月, 2012 1 次提交
  13. 01 2月, 2012 1 次提交
  14. 19 10月, 2011 1 次提交
  15. 21 9月, 2011 1 次提交
  16. 23 5月, 2011 2 次提交
  17. 10 5月, 2011 2 次提交
  18. 23 4月, 2011 1 次提交
    • N
      netconsole: fix deadlock when removing net driver that netconsole is using (v2) · 13f172ff
      Neil Horman 提交于
      A deadlock was reported to me recently that occured when netconsole was being
      used in a virtual guest.  If the virtio_net driver was removed while netconsole
      was setup to use an interface that was driven by that driver, the guest
      deadlocked.  No backtrace was provided because netconsole was the only console
      configured, but it became clear pretty quickly what the problem was.  In
      netconsole_netdev_event, if we get an unregister event, we call
      __netpoll_cleanup with the target_list_lock held and irqs disabled.
      __netpoll_cleanup can, if pending netpoll packets are waiting call
      cancel_delayed_work_sync, which is a sleeping path.  the might_sleep call in
      that path gets triggered, causing a console warning to be issued.  The
      netconsole write handler of course tries to take the target_list_lock again,
      which we already hold, causing deadlock.
      
      The fix is pretty striaghtforward.  Simply drop the target_list_lock and
      re-enable irqs prior to calling __netpoll_cleanup, the re-acquire the lock, and
      restart the loop.  Confirmed by myself to fix the problem reported.
      Signed-off-by: NNeil Horman <nhorman@tuxdriver.com>
      CC: "David S. Miller" <davem@davemloft.net>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      13f172ff
  19. 07 1月, 2011 2 次提交
  20. 18 10月, 2010 1 次提交
  21. 06 5月, 2010 1 次提交
    • W
      netpoll: add generic support for bridge and bonding devices · 0e34e931
      WANG Cong 提交于
      This whole patchset is for adding netpoll support to bridge and bonding
      devices. I already tested it for bridge, bonding, bridge over bonding,
      and bonding over bridge. It looks fine now.
      
      To make bridge and bonding support netpoll, we need to adjust
      some netpoll generic code. This patch does the following things:
      
      1) introduce two new priv_flags for struct net_device:
         IFF_IN_NETPOLL which identifies we are processing a netpoll;
         IFF_DISABLE_NETPOLL is used to disable netpoll support for a device
         at run-time;
      
      2) introduce one new method for netdev_ops:
         ->ndo_netpoll_cleanup() is used to clean up netpoll when a device is
           removed.
      
      3) introduce netpoll_poll_dev() which takes a struct net_device * parameter;
         export netpoll_send_skb() and netpoll_poll_dev() which will be used later;
      
      4) hide a pointer to struct netpoll in struct netpoll_info, ditto.
      
      5) introduce ->real_dev for struct netpoll.
      
      6) introduce a new status NETDEV_BONDING_DESLAE, which is used to disable
         netconsole before releasing a slave, to avoid deadlocks.
      
      Cc: David Miller <davem@davemloft.net>
      Cc: Neil Horman <nhorman@tuxdriver.com>
      Signed-off-by: NWANG Cong <amwang@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0e34e931
  22. 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
  23. 02 5月, 2009 1 次提交
    • B
      netconsole: take care of NETDEV_UNREGISTER event · 2382b15b
      Bruno Prémont 提交于
      When netconsole is loaded and a network interface fades away (e.g. on
      rmmod $interface_driver_module) the rmmod remains stuck and some locks
      are taken that prevent any additional module loading/unloading as well
      as interface up/down changes.
      In addition kernel logs (and console) get flooded at 10s interval with
      
      [  122.464065] unregister_netdevice: waiting for eth0 to become free. Usage count = 1
      [  132.704059] unregister_netdevice: waiting for eth0 to become free. Usage count = 1
      
      This patch lets netconsole take NETDEV_UNREGISTER event into account
      and release the affected interface if it was in use.
      Signed-off-by: NBruno Prémont <bonbons@linux-vserver.org>
      Acked-by: NMatt Mackall <mpm@selenic.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2382b15b
  24. 29 3月, 2009 1 次提交
  25. 28 10月, 2008 1 次提交
  26. 02 8月, 2008 1 次提交
  27. 18 7月, 2008 2 次提交
  28. 15 7月, 2008 1 次提交
    • J
      configfs: Allow ->make_item() and ->make_group() to return detailed errors. · 11c3b792
      Joel Becker 提交于
      The configfs operations ->make_item() and ->make_group() currently
      return a new item/group.  A return of NULL signifies an error.  Because
      of this, -ENOMEM is the only return code bubbled up the stack.
      
      Multiple folks have requested the ability to return specific error codes
      when these operations fail.  This patch adds that ability by changing the
      ->make_item/group() ops to return an int.
      
      Also updated are the in-kernel users of configfs.
      Signed-off-by: NJoel Becker <joel.becker@oracle.com>
      11c3b792
  29. 15 4月, 2008 1 次提交
    • M
      netconsole: only set CON_PRINTBUFFER if the user specifies a netconsole · 0517deed
      Michael Ellerman 提交于
      Since 0bcc1816 (netconsole: Support
      dynamic reconfiguration using configfs), the netconsole is always
      registered, regardless of whether the user actually specified a
      netconsole configuration on the command line.
      
      However because netconsole has CON_PRINTBUFFER set, when it is
      registered it causes the printk buffer to be replayed to all consoles.
      When there is no netconsole configured this is a) pointless, and b)
      somewhat annoying for the user of the existing console.
      
      So instead we should only set CON_PRINTBUFFER if there is a netconsole
      configuration found on the command line. This retains the existing
      behaviour if a netconsole is setup by the user, and avoids spamming
      other consoles when we're only registering for the dynamic
      netconsole case.
      Signed-off-by: NMichael Ellerman <michael@ellerman.id.au>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0517deed
  30. 15 2月, 2008 1 次提交
  31. 29 1月, 2008 1 次提交
  32. 11 10月, 2007 3 次提交
    • J
      [NET]: Introduce and use print_mac() and DECLARE_MAC_BUF() · 0795af57
      Joe Perches 提交于
      This is nicer than the MAC_FMT stuff.
      Signed-off-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0795af57
    • S
      [NET] netconsole: Support dynamic reconfiguration using configfs · 0bcc1816
      Satyam Sharma 提交于
      Based upon initial work by Keiichi Kii <k-keiichi@bx.jp.nec.com>.
      
      This patch introduces support for dynamic reconfiguration (adding, removing
      and/or modifying parameters of netconsole targets at runtime) using a
      userspace interface exported via configfs.  Documentation is also updated
      accordingly.
      
      Issues and brief design overview:
      
      (1) Kernel-initiated creation / destruction of kernel objects is not
          possible with configfs -- the lifetimes of the "config items" is managed
          exclusively from userspace.  But netconsole must support boot/module
          params too, and these are parsed in kernel and hence netpolls must be
          setup from the kernel.  Joel Becker suggested to separately manage the
          lifetimes of the two kinds of netconsole_target objects -- those created
          via configfs mkdir(2) from userspace and those specified from the
          boot/module option string.  This adds complexity and some redundancy here
          and also means that boot/module param-created targets are not exposed
          through the configfs namespace (and hence cannot be updated / destroyed
          dynamically).  However, this saves us from locking / refcounting
          complexities that would need to be introduced in configfs to support
          kernel-initiated item creation / destroy there.
      
      (2) In configfs, item creation takes place in the call chain of the
          mkdir(2) syscall in the driver subsystem.  If we used an ioctl(2) to
          create / destroy objects from userspace, the special userspace program is
          able to fill out the structure to be passed into the ioctl and hence
          specify attributes such as local interface that are required at the time
          we set up the netpoll.  For configfs, this information is not available at
          the time of mkdir(2).  So, we keep all newly-created targets (via
          configfs) disabled by default.  The user is expected to set various
          attributes appropriately (including the local network interface if
          required) and then write(2) "1" to the "enabled" attribute.  Thus,
          netpoll_setup() is then called on the set parameters in the context of
          _this_ write(2) on the "enabled" attribute itself.  This design enables
          the user to reconfigure existing netconsole targets at runtime to be
          attached to newly-come-up interfaces that may not have existed when
          netconsole was loaded or when the targets were actually created.  All this
          effectively enables us to get rid of custom ioctls.
      
      (3) Ultra-paranoid configfs attribute show() and store() operations, with
          sanity and input range checking, using only safe string primitives, and
          compliant with the recommendations in Documentation/filesystems/sysfs.txt.
      
      (4) A new function netpoll_print_options() is created in the netpoll API,
          that just prints out the configured parameters for a netpoll structure.
          netpoll_parse_options() is modified to use that and it is also exported to
          be used from netconsole.
      Signed-off-by: NSatyam Sharma <satyam@infradead.org>
      Acked-by: NKeiichi Kii <k-keiichi@bx.jp.nec.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0bcc1816
    • S
      [NET] netconsole: Support multiple logging targets · b5427c27
      Satyam Sharma 提交于
      Based upon initial work by Keiichi Kii <k-keiichi@bx.jp.nec.com>.
      
      This patch introduces support for multiple targets, independent of
      CONFIG_NETCONSOLE_DYNAMIC -- this is useful even in the default case and
      (including the infrastructure introduced in previous patches) doesn't really
      add too many bytes to module text.  All the complexity (and size) comes with
      the dynamic reconfigurability / userspace interface patch, and so it's
      plausible users may want to keep this enabled but that disabled (say to avoid
      a dependency on CONFIG_CONFIGFS_FS too).
      
      Also update documentation to mention the use of ";" separator to specify
      multiple logging targets in the boot/module option string.
      
      Brief overview:
      
      We maintain a target_list (and corresponding lock).  Get rid of the static
      "default_target" and introduce allocation and release functions for our
      netconsole_target objects (but keeping sure to preserve previous behaviour
      such as default values).  During init_netconsole(), ";" is used as the
      separator to identify multiple target specifications in the boot/module option
      string.  The target specifications are parsed and netpolls setup.  During
      exit, the target_list is torn down and all items released.
      Signed-off-by: NSatyam Sharma <satyam@infradead.org>
      Signed-off-by: NKeiichi Kii <k-keiichi@bx.jp.nec.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b5427c27