Skip to contentSkip to conversation

Patch "ACPI/processor: Replace racy task affinity logic" has been added to the 4.4-stable tree

PATCH [email protected] 1 participant 1 message Mar 22, 2018

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

ACPI/processor: Replace racy task affinity logic

to the 4.4-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:
acpi-processor-replace-racy-task-affinity-logic.patch
and it can be found in the queue-4.4 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 foo@baz Thu Mar 22 14:57:32 CET 2018

From: Thomas Gleixner <[email protected]>
Date: Wed, 12 Apr 2017 22:07:34 +0200
Subject: ACPI/processor: Replace racy task affinity logic

From: Thomas Gleixner <[email protected]>

[ Upstream commit 8153f9ac43897f9f4786b30badc134fcc1a4fb11 ]

acpi_processor_get_throttling() requires to invoke the getter function on the target CPU. This is achieved by temporarily setting the affinity of the calling user space thread to the requested CPU and reset it to the original affinity afterwards.

That's racy vs. CPU hotplug and concurrent affinity settings for that thread resulting in code executing on the wrong CPU and overwriting the new affinity setting.

acpi_processor_get_throttling() is invoked in two ways:

1) The CPU online callback, which is already running on the target CPU and obviously protected against hotplug and not affected by affinity settings.

2) The ACPI driver probe function, which is not protected against hotplug during modprobe.

Switch it over to work_on_cpu() and protect the probe function against CPU hotplug.

Cc Fenghua Yu <[email protected]>
Cc Tony Luck <[email protected]>
Cc Herbert Xu <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Sebastian Siewior <[email protected]>
Cc Lai Jiangshan <[email protected]>
Cc Viresh Kumar <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Tejun Heo <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Len Brown <[email protected]>
---
 drivers/acpi/processor_driver.c     |    7 +++-
 drivers/acpi/processor_throttling.c |   62 ++++++++++++++++++++----------------
 2 files changed, 42 insertions(+), 27 deletions(-)
drivers/acpi/processor_driver.c +6 -1
@@ -270,11 +270,16 @@ err_power_exit:
 static int acpi_processor_start(struct device *dev)
 {
 	struct acpi_device *device = ACPI_COMPANION(dev);
+	int ret;
 
 	if (!device)
 		return -ENODEV;
 
-	return __acpi_processor_start(device);
+	/* Protect against concurrent CPU hotplug operations */
+	get_online_cpus();
+	ret = __acpi_processor_start(device);
+	put_online_cpus();
+	return ret;
 }
 
 static int acpi_processor_stop(struct device *dev)
drivers/acpi/processor_throttling.c +36 -26

116 lines not on this page · raw message

Patches currently in stable-queue which might be from [email protected] are

queue-4.4/acpi-processor-fix-error-handling-in-__acpi_processor_start.patch queue-4.4/acpi-processor-replace-racy-task-affinity-logic.patch queue-4.4/time-change-posix-clocks-ops-interfaces-to-use-timespec64.patch queue-4.4/genirq-use-irqd_get_trigger_type-to-compare-the-trigger-type-for-shared-irqs.patch queue-4.4/cpufreq-sh-replace-racy-task-affinity-logic.patch