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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20091113153827.GA6475@redhat.com>
Date:	Fri, 13 Nov 2009 16:38:27 +0100
From:	Oleg Nesterov <oleg@...hat.com>
To:	Tejun Heo <tj@...nel.org>
Cc:	Ingo Molnar <mingo@...hat.com>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	lkml <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2.6.32-rc6] workqueue: fix race condition in
	schedule_on_each_cpu()

On 11/13, Tejun Heo wrote:
>
> Commit 65a64464349883891e21e74af16c05d6e1eeb4e9 which allows
> schedule_on_each_cpu() to be called from keventd added a race
> condition.  schedule_on_each_cpu() may race with cpu hotplug and end
> up executing the function twice on a cpu.
>
> Fix it by moving direct execution into the section protected with
> get/put_online_cpus().  While at it, update code such that direct
> execution is done after works have been scheduled for all other cpus
> and drop unnecessary cpu != orig test from flush loop.
>
> Signed-off-by: Tejun Heo <tj@...nel.org>
> Cc: Andi Kleen <ak@...ux.intel.com>
> Cc: Oleg Nesterov <oleg@...hat.com>
> Cc: Ingo Molnar <mingo@...hat.com>
> ---
> Andi, Oleg, this patch tested fine on my machine but it would be great
> if you guys can ack it.  Ingo, upon ack, can you please route this
> patch?

Thanks, I think this is correct.

A very minor nit, schedule_on_each_cpu() still checks "orig" twice,
perhaps it makes sense to do

	for_each_online_cpu(cpu) {
		struct work_struct *work = per_cpu_ptr(works, cpu);

		INIT_WORK(work, func);

		if (likely(cpu != orig))
			schedule_work_on(cpu, work);
		else
			func(work);
	}

instead and simplify the code a little bit.

But this is minor and up to you.

Acked-by: Oleg Nesterov <oleg@...hat.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ