[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110803140456.GA14393@redhat.com>
Date: Wed, 3 Aug 2011 16:04:56 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Vasiliy Kulikov <segoon@...nwall.com>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: Manuel Lauss <manuel.lauss@...glemail.com>,
Richard Weinberger <richard@....at>,
Marc Zyngier <marc.zyngier@....com>,
linux-kernel@...r.kernel.org
Subject: Re: + shm-fix-a-race-between-shm_exit-and-shm_init.patch added to
-mm tree
> From: Vasiliy Kulikov <segoon@...nwall.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.
--
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