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
| ||
|
Date: Thu, 08 Sep 2022 16:29:02 -0300 From: Marcelo Tosatti <mtosatti@...hat.com> To: linux-kernel@...r.kernel.org Cc: Frederic Weisbecker <frederic@...nel.org>, Juri Lelli <juri.lelli@...hat.com>, Daniel Bristot de Oliveira <bristot@...nel.org>, Prasad Pandit <ppandit@...hat.com>, Valentin Schneider <vschneid@...hat.com>, Yair Podemsky <ypodemsk@...hat.com>, Thomas Gleixner <tglx@...utronix.de>, Marcelo Tosatti <mtosatti@...hat.com> Subject: [RFC PATCH 3/7] introduce _fail variants of stop_machine functions Introduce stop_machine_fail and stop_machine_cpuslocked_fail, which check if any online CPU in the system is tagged as a block interference CPU. If so, returns an error. Signed-off-by: Marcelo Tosatti <mtosatti@...hat.com> Index: linux-2.6/include/linux/stop_machine.h =================================================================== --- linux-2.6.orig/include/linux/stop_machine.h +++ linux-2.6/include/linux/stop_machine.h @@ -113,6 +113,9 @@ static inline void print_stop_info(const */ int stop_machine(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus); + +int stop_machine_fail(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus); + /** * stop_machine_cpuslocked: freeze the machine on all CPUs and run this function * @fn: the function to run @@ -124,6 +127,9 @@ int stop_machine(cpu_stop_fn_t fn, void */ int stop_machine_cpuslocked(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus); + +int stop_machine_cpuslocked_fail(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus); + /** * stop_core_cpuslocked: - stop all threads on just one core * @cpu: any cpu in the targeted core Index: linux-2.6/kernel/stop_machine.c =================================================================== --- linux-2.6.orig/kernel/stop_machine.c +++ linux-2.6/kernel/stop_machine.c @@ -22,6 +22,7 @@ #include <linux/atomic.h> #include <linux/nmi.h> #include <linux/sched/wake_q.h> +#include <linux/sched/isolation.h> /* * Structure to determine completion condition and record errors. May @@ -619,6 +620,17 @@ int stop_machine_cpuslocked(cpu_stop_fn_ return stop_cpus(cpu_online_mask, multi_cpu_stop, &msdata); } +int stop_machine_cpuslocked_fail(cpu_stop_fn_t fn, void *data, + const struct cpumask *cpus) +{ + block_interf_assert_held(); + + if (cpumask_intersects(block_interf_cpumask, cpu_online_mask)) + return -EPERM; + + return stop_machine_cpuslocked(fn, data, cpus); +} + int stop_machine(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus) { int ret; @@ -631,6 +643,19 @@ int stop_machine(cpu_stop_fn_t fn, void } EXPORT_SYMBOL_GPL(stop_machine); +int stop_machine_fail(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus) +{ + int ret; + + /* No CPUs can come up or down during this. */ + cpus_read_lock(); + ret = stop_machine_cpuslocked_fail(fn, data, cpus); + cpus_read_unlock(); + return ret; +} +EXPORT_SYMBOL_GPL(stop_machine_fail); + + #ifdef CONFIG_SCHED_SMT int stop_core_cpuslocked(unsigned int cpu, cpu_stop_fn_t fn, void *data) {
Powered by blists - more mailing lists