From: Vasiliy Kulikov <segoon@openwall.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Manuel Lauss <manuel.lauss@googlemail.com>,
Richard Weinberger <richard@nod.at>,
Linus Torvalds <torvalds@linux-foundation.org>,
Marc Zyngier <marc.zyngier@arm.com>,
linux-kernel@vger.kernel.org
Subject: Re: + shm-fix-a-race-between-shm_exit-and-shm_init.patch added to -mm tree
Date: Wed, 3 Aug 2011 22:24:17 +0400 [thread overview]
Message-ID: <20110803182417.GA2510@albatros> (raw)
In-Reply-To: <20110803140456.GA14393@redhat.com>
On Wed, Aug 03, 2011 at 16:04 +0200, Oleg Nesterov wrote:
> > 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?
Agreed. But I second Linus that partial initialization only hides the
real problem. And some initcall chain movement is still needed.
--
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments
next prev parent reply other threads:[~2011-08-03 18:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110803182417.GA2510@albatros \
--to=segoon@openwall.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manuel.lauss@googlemail.com \
--cc=marc.zyngier@arm.com \
--cc=oleg@redhat.com \
--cc=richard@nod.at \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox