[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20070209010037.7f4393c5.akpm@linux-foundation.org>
Date: Fri, 9 Feb 2007 01:00:37 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Alexey Dobriyan <adobriyan@...nvz.org>
Cc: viro@....linux.org.uk, linux-kernel@...r.kernel.org,
duncan.sands@...h.u-psud.fr
Subject: Re: [PATCH v3] Fix rmmod/read/write races in /proc entries
On Thu, 8 Feb 2007 16:20:12 +0300 Alexey Dobriyan <adobriyan@...nvz.org> wrote:
> +again:
> spin_lock(&proc_subdir_lock);
> for (p = &parent->subdir; *p; p=&(*p)->next ) {
> if (!proc_match(len, fn, *p))
> continue;
> de = *p;
> +
> + /*
> + * Stop accepting new readers/writers. If you're dynamically
> + * allocating ->proc_fops, save a pointer somewhere.
> + */
> + spin_lock(&de->pde_unload_lock);
> + de->proc_fops = NULL;
> + /* Wait until all readers/writers are done. */
> + if (de->pde_users > 0) {
> + spin_unlock(&de->pde_unload_lock);
> + spin_unlock(&proc_subdir_lock);
> + schedule();
> + goto again;
> + }
> + spin_unlock(&de->pde_unload_lock);
aergh. This will devolve into busy-wait-until-we-expire-our-timeslice.
Would be nicer to do this with a wait_for_completion().
I guess it doesn't happen very often - if another process happens to
be in the middle or a read or write syscall to that /proc file.
-
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