All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@openvz.org>
To: Al Viro <viro@ftp.linux.org.uk>
Cc: linux-kernel@vger.kernel.org, devel@openvz.org
Subject: Re: Racy /proc creations interfaces
Date: Thu, 28 Dec 2006 11:21:47 +0300	[thread overview]
Message-ID: <20061228082147.GA11127@localhost.sw.ru> (raw)
In-Reply-To: <20061227135624.GP17561@ftp.linux.org.uk>

On Wed, Dec 27, 2006 at 01:56:24PM +0000, Al Viro wrote:
> On Wed, Dec 27, 2006 at 04:42:23PM +0300, Alexey Dobriyan wrote:
> > 
> >    	struct proc_entry_raw foo_pe_raw = {
> > 		.owner = THIS_MODULE,
> > 		.name = "foo",
> > 		.mode = 0644,
> > 		.read_proc = foo_read_proc,
> > 		.data = foo_data,
> > 		.parent = foo_parent,
> > 	};
> > 
> > 	pde = create_proc_entry(&foo_pe_raw);
> > 	if (!pde)
> > 		return -ENOMEM;
> > 
> >    where "struct proc_entry_raw" is cut down version of "struct proc_dir_entry"
> 
> Ewwwwwwwwwwwwwww
> 
> Please, please no.  Especially not .parent.  If anything, let's add a
> helper saying "it's all set up now".  And turn create_proc_entry()
> into a macro that would pass THIS_MODULE to underlying function and
> call that helper, so that simple cases wouldn't have to bother at all.

People are setting ->data after create_proc_entry():

drivers/zorro/proc.c:
   110	static int __init zorro_proc_attach_device(u_int slot)
   111	{
   112		struct proc_dir_entry *entry;
   113		char name[4];
   114	
   115		sprintf(name, "%02x", slot);
   116		entry = create_proc_entry(name, 0, proc_bus_zorro_dir);
   117		if (!entry)
   118			return -ENOMEM;
   119		entry->proc_fops = &proc_bus_zorro_operations;
   120		entry->data = &zorro_autocon[slot];
   121		entry->size = sizeof(struct zorro_dev);

If create_proc_entry is a macro doing what you suggest (am I right?)

	#define create_proc_entry(name, mode, parent)
	({
		struct proc_dir_entry *pde;

		pde = __create_proc_entry(name, mode, parent, THIS_MODULE);
		if (pde)
			mark_proc_entry_ready(pde);
		pde;
	})

there is still a problem because we want it to be equivalent to

	pde = create_proc_entry(...);
	if (!pde)
		return -ENOMEM;
	pde->proc_fops = ...;
	pde->data = ...;
	mark_proc_entry_ready(pde);


  reply	other threads:[~2006-12-28  8:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-27 13:42 Racy /proc creations interfaces Alexey Dobriyan
2006-12-27 13:56 ` Al Viro
2006-12-28  8:21   ` Alexey Dobriyan [this message]
2007-01-15 15:39     ` [PATCH] Fix rmmod/read/write races in /proc entries Alexey Dobriyan
2007-01-23 20:58       ` Andrew Morton
2007-01-24 15:22         ` Alexey Dobriyan

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=20061228082147.GA11127@localhost.sw.ru \
    --to=adobriyan@openvz.org \
    --cc=devel@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ftp.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.