public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: + shm-fix-a-race-between-shm_exit-and-shm_init.patch added to -mm tree
@ 2011-08-03 14:04 Oleg Nesterov
  2011-08-03 18:24 ` Vasiliy Kulikov
  0 siblings, 1 reply; 13+ messages in thread
From: Oleg Nesterov @ 2011-08-03 14:04 UTC (permalink / raw)
  To: Vasiliy Kulikov, Andrew Morton
  Cc: Manuel Lauss, Richard Weinberger, Marc Zyngier, linux-kernel

> From: Vasiliy Kulikov <segoon@openwall.com>
>
> On thread exit shm_exit_ns() is called, it uses shm_ids(ns).rw_mutex.  It
> is initialized in shm_init(), but it is not called yet at the moment of
> kernel threads exit.  Some kernel threads are created in
> do_pre_smp_initcalls(), and shm_init() is called in do_initcalls().
>
> Static initialization of shm_ids(init_ipc_ns).rw_mutex fixes the race.

Yes, it is safe to call down_right() now.

But the code does

	down_write(rw_mutex);
	if (.in_use)
		idr_for_each(.ipcs_idr);

and thus it relies on the static initializer anyway. it is not safe
to do idr_for_each() before idr_init() in theory.

And since we rely on .in_use == 0, why we can't move this check
outside of down_write/up_right to a) optimize the code and b)
fix the problem?

Oleg.


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-08-03 19:47 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-03 14:04 + shm-fix-a-race-between-shm_exit-and-shm_init.patch added to -mm tree Oleg Nesterov
2011-08-03 18:24 ` Vasiliy Kulikov
2011-08-03 18:26   ` [PATCH] shm: fix wrong tests Vasiliy Kulikov
2011-08-03 18:28   ` [PATCH] shm: optimize exit_shm() Vasiliy Kulikov
2011-08-03 19:08     ` Manuel Lauss
2011-08-03 19:16       ` Vasiliy Kulikov
2011-08-03 19:29         ` Oleg Nesterov
2011-08-03 19:41           ` Vasiliy Kulikov
2011-08-03 19:43             ` Oleg Nesterov
2011-08-03 19:21     ` Oleg Nesterov
2011-08-03 19:34       ` Vasiliy Kulikov
2011-08-03 19:39         ` Oleg Nesterov
2011-08-03 19:18   ` + shm-fix-a-race-between-shm_exit-and-shm_init.patch added to -mm tree Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox