History

Merge tag 'driver-core-3.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core fix from Greg Kroah-Hartman: "Here's a single patch for the firmware core that resolves a reported oops in the firmware core that people have been hitting." * tag 'driver-core-3.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: firmware loader: fix use-after-free by double abort

Linus Torvalds committed 13 years ago

Commit e10e5772 parents b71055b 87597931 file · +18 −9Browse files

Unified · Split

drivers/base/firmware_class.c+18−9
@@ -450,8 +450,18 @@ static void fw_load_abort(struct firmware_priv *fw_priv) · 449 unmodified lines
450450 {
451451 struct firmware_buf *buf = fw_priv->buf;
452452
453+ /*
454+ * There is a small window in which user can write to 'loading'
455+ * between loading done and disappearance of 'loading'
456+ */
457+ if (test_bit(FW_STATUS_DONE, &buf->status))
458+ return;
459+
453460 set_bit(FW_STATUS_ABORT, &buf->status);
454461 complete_all(&buf->completion);
462+
463+ /* avoid user action after loading abort */
464+ fw_priv->buf = NULL;
455465 }
456466
457467 #define is_fw_load_aborted(buf) \
@@ -528,7 +538,12 @@ static ssize_t firmware_loading_show(struct device *dev, · 70 unmodified lines
528538 struct device_attribute *attr, char *buf)
529539 {
530540 struct firmware_priv *fw_priv = to_firmware_priv(dev);
531− int loading = test_bit(FW_STATUS_LOADING, &fw_priv->buf->status);
541+ int loading = 0;
542+
543+ mutex_lock(&fw_lock);
544+ if (fw_priv->buf)
545+ loading = test_bit(FW_STATUS_LOADING, &fw_priv->buf->status);
546+ mutex_unlock(&fw_lock);
532547
533548 return sprintf(buf, "%d\n", loading);
534549 }
@@ -570,12 +585,12 @@ static ssize_t firmware_loading_store(struct device *dev, · 35 unmodified lines
570585 const char *buf, size_t count)
571586 {
572587 struct firmware_priv *fw_priv = to_firmware_priv(dev);
573− struct firmware_buf *fw_buf = fw_priv->buf;
588+ struct firmware_buf *fw_buf;
574589 int loading = simple_strtol(buf, NULL, 10);
575590 int i;
576591
577592 mutex_lock(&fw_lock);
578−
593+ fw_buf = fw_priv->buf;
579594 if (!fw_buf)
580595 goto out;
581596
@@ -777,10 +792,6 @@ static void firmware_class_timeout_work(struct work_struct *work) · 195 unmodified lines
777792 struct firmware_priv, timeout_work.work);
778793
779794 mutex_lock(&fw_lock);
780− if (test_bit(FW_STATUS_DONE, &(fw_priv->buf->status))) {
781− mutex_unlock(&fw_lock);
782− return;
783− }
784795 fw_load_abort(fw_priv);
785796 mutex_unlock(&fw_lock);
786797 }
@@ -861,8 +872,6 @@ static int _request_firmware_load(struct firmware_priv *fw_priv, bool uevent, · 74 unmodified lines
861872
862873 cancel_delayed_work_sync(&fw_priv->timeout_work);
863874
864− fw_priv->buf = NULL;
865−
866875 device_remove_file(f_dev, &dev_attr_loading);
867876 err_del_bin_attr:
868877 device_remove_bin_file(f_dev, &firmware_attr_data);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t