LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Duncan Sands <duncan.sands@math.u-psud.fr>
To: Alexey Dobriyan <adobriyan@openvz.org>
Cc: linux-kernel@vger.kernel.org, adobriyan@gmail.com
Subject: Re: remove_proc_entry and read_proc
Date: Mon, 5 Feb 2007 13:05:05 +0100 [thread overview]
Message-ID: <200702051305.06201.duncan.sands@math.u-psud.fr> (raw)
In-Reply-To: <20070205113932.GA5968@localhost.sw.ru>
> Gee, thanks. I sat and wrote code side-by-side, and it looks like, even barriers
> won't fix anything, because they don't affect other CPUs.
?! The whole point of memory barriers is that they affect other CPUs.
Maybe you are thinking of compiler barriers?
> ->proc_fops is valid ->proc_fops is valid
> ->pde_users is 0 ->pde_users is 0
> ------------------------------------------------------------
>
>
> if (!pde->proc_fops)
> goto out;
>
> ->proc_fops = NULL;
> if (atomic_read(->pde_users) > 0)
> goto again;
>
> |
> | atomic_inc(->pde_users);
> |
> |
> |
> V
The proc_fops check *before* the atomic_inc is indeed pointless (notice
how I removed it in the patch I sent?). It's the one after the atomic_inc
that prevents this race, but only if there is a memory barrier between the
atomic_inc and the check... because otherwise they could be reordered (i.e.
seen in reverse order by another CPU) giving the race.
> Modules forget to set ->owner sometimes. Also, it's still racy, because
> of the typical
>
> pde = create_proc_entry();
> /*
> *
> * ->owner is NULL here, effectively, PDE without ->owner.
> *
> */
> if (pde)
> pde->owner = THIS_MODULE;
As long as the module calls remove_proc_entry before being unloaded,
this should be ok.
Best wishes,
Duncan.
next prev parent reply other threads:[~2007-02-05 12:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-01 16:09 Alexey Dobriyan
2007-02-02 7:31 ` Duncan Sands
2007-02-05 11:39 ` Alexey Dobriyan
2007-02-05 12:05 ` Duncan Sands [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-01-31 10:54 Duncan Sands
2007-01-31 18:42 ` Alexey Dobriyan
2007-01-31 19:26 ` Duncan Sands
2007-02-01 10:15 ` Duncan Sands
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=200702051305.06201.duncan.sands@math.u-psud.fr \
--to=duncan.sands@math.u-psud.fr \
--cc=adobriyan@gmail.com \
--cc=adobriyan@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--subject='Re: remove_proc_entry and read_proc' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).