1. 15 11月, 2012 2 次提交
    • C
      firmware loader: Fix the concurrent request_firmware() race for kref_get/put · bd9eb7fb
      Chuansheng Liu 提交于
      There is one race that both request_firmware() with the same
      firmware name.
      
      The race scenerio is as below:
      CPU1                                                  CPU2
      request_firmware() -->
      _request_firmware_load() return err                   another request_firmware() is coming -->
      _request_firmware_cleanup is called -->               _request_firmware_prepare -->
      release_firmware --->                                 fw_lookup_and_allocate_buf -->
                                                            spin_lock(&fwc->lock)
      ...                                                   __fw_lookup_buf() return true
      fw_free_buf() will be called -->                      ...
      kref_put -->
      decrease the refcount to 0
                                                            kref_get(&tmp->ref) ==> it will trigger warning
                                                                                    due to refcount == 0
      __fw_free_buf() -->
      ...                                                   spin_unlock(&fwc->lock)
      spin_lock(&fwc->lock)
      list_del(&buf->list)
      spin_unlock(&fwc->lock)
      kfree(buf)
                                                            After that, the freed buf will be used.
      
      The key race is decreasing refcount to 0 and list_del is not protected together by
      fwc->lock, and it is possible another thread try to get it between refcount==0
      and list_del.
      
      Fix it here to protect it together.
      Acked-by: NMing Lei <ming.lei@canonical.com>
      Signed-off-by: Nliu chuansheng <chuansheng.liu@intel.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bd9eb7fb
    • C
      firmware loader: Fix the race FW_STATUS_DONE is followed by class_timeout · ce2fcbd9
      Chuansheng Liu 提交于
      There is a race as below when calling request_firmware():
      CPU1                                   CPU2
      write 0 > loading
      mutex_lock(&fw_lock)
      ...
      set_bit FW_STATUS_DONE                 class_timeout is coming
                                             set_bit FW_STATUS_ABORT
      complete_all &completion
      ...
      mutex_unlock(&fw_lock)
      
      In this time, the bit FW_STATUS_DONE and FW_STATUS_ABORT are set,
      and request_firmware() will return failure due to condition in
      _request_firmware_load():
      	if (!buf->size || test_bit(FW_STATUS_ABORT, &buf->status))
      		retval = -ENOENT;
      
      But from the above scenerio, it should be a successful requesting.
      So we need judge if the bit FW_STATUS_DONE is already set before
      calling fw_load_abort() in timeout function.
      
      As Ming's proposal, we need change the timer into sched_work to
      benefit from using &fw_lock mutex also.
      Signed-off-by: Nliu chuansheng <chuansheng.liu@intel.com>
      Acked-by: NMing Lei <ming.lei@canonical.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ce2fcbd9
  2. 22 10月, 2012 4 次提交
  3. 05 10月, 2012 1 次提交
  4. 04 10月, 2012 1 次提交
    • L
      firmware: teach the kernel to load firmware files directly from the filesystem · abb139e7
      Linus Torvalds 提交于
      This is a first step in allowing people to by-pass udev for loading
      device firmware.  Current versions of udev will deadlock (causing us to
      block for the 30 second timeout) under some circumstances if the
      firmware is loaded as part of the module initialization path, and this
      is causing problems for media drivers in particular.
      
      The current patch hardcodes the firmware path that udev uses by default,
      and will fall back to the legacy udev mode if the firmware cannot be
      found there.  We'd like to add support for both configuring the paths
      and the fallback behaviour, but in the meantime this hopefully fixes the
      immediate problem, while also giving us a way forward.
      
      [ v2: Some VFS layer interface cleanups suggested by Al Viro ]
      [ v3: use the default udev paths suggested by Kay Sievers ]
      Suggested-by: NIvan Kalvachev <ikalvachev@gmail.com>
      Acked-by: NGreg KH <gregkh@linuxfoundation.org>
      Acked-by: NAl Viro <viro@zeniv.linux.org.uk>
      Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
      Cc: Kay Sievers <kay@redhat.com>
      Cc: Ming Lei <ming.lei@canonical.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      abb139e7
  5. 11 9月, 2012 1 次提交
  6. 07 9月, 2012 2 次提交
  7. 17 8月, 2012 15 次提交
  8. 17 7月, 2012 1 次提交
  9. 29 3月, 2012 5 次提交
  10. 24 1月, 2012 1 次提交
  11. 05 1月, 2012 1 次提交
    • N
      firmware: Fix an oops on reading fw_priv->fw in sysfs loading file · eea915bb
      Neil Horman 提交于
      This oops was reported recently:
      firmware_loading_store+0xf9/0x17b
      dev_attr_store+0x20/0x22
      sysfs_write_file+0x101/0x134
      vfs_write+0xac/0xf3
      sys_write+0x4a/0x6e
      system_call_fastpath+0x16/0x1b
      
      The complete backtrace was unfortunately not captured, but details can be found
      here:
      https://bugzilla.redhat.com/show_bug.cgi?id=769920
      
      The cause is fairly clear.
      
      Its caused by the fact that firmware_loading_store has a case 0 in its
      switch statement that reads and writes the fw_priv->fw poniter without the
      protection of the fw_lock mutex.  since there is a window between the time that
      _request_firmware sets fw_priv->fw to NULL and the time the corresponding sysfs
      file is unregistered, its possible for a user space application to race in, and
      write a zero to the loading file, causing a NULL dereference in
      firmware_loading_store.  Fix it by extending the protection of the fw_lock mutex
      to cover all of the firware_loading_store function.
      Signed-off-by: NNeil Horman <nhorman@tuxdriver.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      eea915bb
  12. 10 12月, 2011 1 次提交
    • S
      PM / Sleep: Fix freezer failures due to racy usermodehelper_is_disabled() · b298d289
      Srivatsa S. Bhat 提交于
      Commit a144c6a6 (PM: Print a warning if firmware is requested when tasks
      are frozen) introduced usermodehelper_is_disabled() to warn and exit
      immediately if firmware is requested when usermodehelpers are disabled.
      
      However, it is racy. Consider the following scenario, currently used in
      drivers/base/firmware_class.c:
      
      ...
      if (usermodehelper_is_disabled())
              goto out;
      
      /* Do actual work */
      ...
      
      out:
              return err;
      
      Nothing prevents someone from disabling usermodehelpers just after the check
      in the 'if' condition, which means that it is quite possible to try doing the
      "actual work" with usermodehelpers disabled, leading to undesirable
      consequences.
      
      In particular, this race condition in _request_firmware() causes task freezing
      failures whenever suspend/hibernation is in progress because, it wrongly waits
      to get the firmware/microcode image from userspace when actually the
      usermodehelpers are disabled or userspace has been frozen.
      Some of the example scenarios that cause freezing failures due to this race
      are those that depend on userspace via request_firmware(), such as x86
      microcode module initialization and microcode image reload.
      
      Previous discussions about this issue can be found at:
      http://thread.gmane.org/gmane.linux.kernel/1198291/focus=1200591
      
      This patch adds proper synchronization to fix this issue.
      
      It is to be noted that this patchset fixes the freezing failures but doesn't
      remove the warnings. IOW, it does not attempt to add explicit synchronization
      to x86 microcode driver to avoid requesting microcode image at inopportune
      moments. Because, the warnings were introduced to highlight such cases, in the
      first place. And we need not silence the warnings, since we take care of the
      *real* problem (freezing failure) and hence, after that, the warnings are
      pretty harmless anyway.
      Signed-off-by: NSrivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      b298d289
  13. 25 8月, 2011 1 次提交
  14. 18 5月, 2011 1 次提交
  15. 04 2月, 2011 1 次提交
  16. 24 8月, 2010 1 次提交
  17. 06 8月, 2010 1 次提交