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: <20241108121120.3912918-1-ciprietti@google.com>
Date: Fri,  8 Nov 2024 12:11:20 +0000
From: Andrea Ciprietti <ciprietti@...gle.com>
To: linux-kernel@...r.kernel.org
Cc: Andrea Ciprietti <ciprietti@...gle.com>, Ingo Molnar <mingo@...hat.com>, 
	Peter Zijlstra <peterz@...radead.org>, Juri Lelli <juri.lelli@...hat.com>, 
	Vincent Guittot <vincent.guittot@...aro.org>, Dietmar Eggemann <dietmar.eggemann@....com>, 
	Steven Rostedt <rostedt@...dmis.org>, Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>, 
	Valentin Schneider <vschneid@...hat.com>, Josh Don <joshdon@...gle.com>
Subject: [PATCH] sched/smt: Call sched_core_cpu_deactivate() after error is handled

In sched_cpu_deactivate(), the error path restores most of the initial
state before returning, but, if CONFIG_SCHED_SMT is defined, it does not
undo the previous call to sched_core_cpu_deactivate().

There is no easy way to invert such function since it overrides some shared
state of the leader CPU. Instead, simply move the call past the error
handling code. This is fine since cpuset_cpu_inactive() performs unrelated
operations.

Note that there's no need for #ifdef since cpuset_core_* have empty
definitions when CONFIG_SCHED_SMT is not set (in which case this patch is a
no-op).

Fixes: 3c474b3239f1 ("sched: Fix Core-wide rq->lock for uninitialized CPUs")
Cc: stable@...nel.org
Suggested-by: Josh Don <joshdon@...gle.com>
Signed-off-by: Andrea Ciprietti <ciprietti@...gle.com>
---
 kernel/sched/core.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 719e0ed1e976..4d55bc243ae5 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8187,10 +8187,6 @@ int sched_cpu_deactivate(unsigned int cpu)
 	 */
 	sched_smt_present_dec(cpu);
 
-#ifdef CONFIG_SCHED_SMT
-	sched_core_cpu_deactivate(cpu);
-#endif
-
 	if (!sched_smp_initialized)
 		return 0;
 
@@ -8204,6 +8200,7 @@ int sched_cpu_deactivate(unsigned int cpu)
 		sched_update_numa(cpu, true);
 		return ret;
 	}
+	sched_core_cpu_deactivate(cpu);
 	sched_domains_numa_masks_clear(cpu);
 	return 0;
 }
-- 
2.47.0.277.g8800431eea-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ