Patch "PCI: Fix race condition with driver_override" has been added to the 4.9-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
PCI: Fix race condition with driver_override
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
pci-fix-race-condition-with-driver_override.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
9561475db680f7144d2223a409dd3d7e322aca03Mon Sep 17 00:00:00 2001
From: Nicolai Stange <[email protected]>
Date: Mon, 11 Sep 2017 09:45:40 +0200
Subject: PCI: Fix race condition with driver_override
From: Nicolai Stange <[email protected]>
commit 9561475db680f7144d2223a409dd3d7e322aca03 upstream.
The driver_override implementation is susceptible to a race condition when different threads are reading vs. storing a different driver override. Add locking to avoid the race condition.
This is in close analogy to commit 6265539776a0 ("driver core: platform:
fix race condition with driver_override") from Adrian Salido.
--- drivers/pci/pci-sysfs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/pci/pci-sysfs.c +9 -2
@@ -527,7 +527,7 @@ static ssize_t driver_override_store(str const char *buf, size_t count) {struct pci_dev *pdev =to_pci_dev (dev); -char *driver_override, *old = pdev->driver_override, *cp; +char *driver_override, *old, *cp;/* We need to keep extra room for a newline */ if (count >= (PAGE_SIZE -1 ))
@@ -541,12 +541,15 @@ static ssize_t driver_override_store(strif (cp) *cp ='\0' ; +device_lock (dev); + old = pdev->driver_override;if (strlen (driver_override)) { pdev->driver_override = driver_override; }else {kfree (driver_override); pdev->driver_override =NULL ; } +device_unlock (dev);kfree (old);
@@ -557,8 +560,12 @@ static ssize_t driver_override_show(stru struct device_attribute *attr, char *buf) { struct pci_dev *pdev = to_pci_dev(dev); +ssize_t len; -return snprintf (buf,PAGE_SIZE ,"%s\n" , pdev->driver_override); +device_lock (dev); + len =snprintf (buf,PAGE_SIZE ,"%s\n" , pdev->driver_override); +device_unlock (dev); +return len; }static DEVICE_ATTR_RW (driver_override);
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/pci-fix-race-condition-with-driver_override.patch