lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220418195402.2986573-1-jsavitz@redhat.com>
Date:   Mon, 18 Apr 2022 15:54:02 -0400
From:   Joel Savitz <jsavitz@...hat.com>
To:     linux-kernel@...r.kernel.org
Cc:     Joel Savitz <jsavitz@...hat.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Valentin Schneider <valentin.schneider@....com>,
        Peter Zijlstra <peterz@...radead.org>,
        Frederic Weisbecker <frederic@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Yuan ZhaoXiong <yuanzhaoxiong@...du.com>,
        Baokun Li <libaokun1@...wei.com>,
        "Jason A. Donenfeld" <Jason@...c4.com>,
        YueHaibing <yuehaibing@...wei.com>,
        Randy Dunlap <rdunlap@...radead.org>,
        David Hildenbrand <dhildenb@...hat.com>
Subject: [RFC PATCH] kernel/cpu: restart cpu_up when hotplug is disabled

The cpu hotplug path may be utilized while hotplug is disabled for a
brief moment leading to failures. As an example, attempts to perform
cpu hotplug by userspace soon after boot may race with pci_device_probe
leading to inconsistent results.

Proposed idea:
Call restart_syscall instead of returning -EBUSY since
cpu_hotplug_disabled seems to only have a positive value
for short, temporary amounts of time.

Does anyone see any serious problems with this?

Signed-off-by: Joel Savitz <jsavitz@...hat.com>
---
 kernel/cpu.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 5797c2a7a93f..2992c7d1d24e 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -35,6 +35,7 @@
 #include <linux/percpu-rwsem.h>
 #include <linux/cpuset.h>
 #include <linux/random.h>
+#include <linux/delay.h>
 
 #include <trace/events/power.h>
 #define CREATE_TRACE_POINTS
@@ -1401,7 +1402,9 @@ static int cpu_up(unsigned int cpu, enum cpuhp_state target)
 	cpu_maps_update_begin();
 
 	if (cpu_hotplug_disabled) {
-		err = -EBUSY;
+		/* avoid busy looping (5ms of sleep should be enough) */
+		msleep(5);
+		err = restart_syscall();
 		goto out;
 	}
 	if (!cpu_smt_allowed(cpu)) {
-- 
2.27.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ