public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Thadeu Lima de Souza Cascardo <cascardo@holoscopio•com>
To: John Kacur <jkacur@gmail•com>
Cc: Arnd Bergmann <arnd@arndb•de>, Samuel Ortiz <samuel@sortiz•org>,
	"David S. Miller" <davem@davemloft•net>,
	linux-kernel@vger•kernel.org, netdev@vger•kernel.org
Subject: Re: [PATCH] irda: remove BKL from irnet open function
Date: Mon, 1 Feb 2010 18:36:17 -0200	[thread overview]
Message-ID: <20100201203616.GJ1414@holoscopio.com> (raw)
In-Reply-To: <520f0cf11002011232u415146a9md3afe65af4d810a6@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2412 bytes --]

On Mon, Feb 01, 2010 at 09:32:30PM +0100, John Kacur wrote:
> On Mon, Feb 1, 2010 at 7:18 PM, Thadeu Lima de Souza Cascardo
> <cascardo@holoscopio•com> wrote:
> > Commit cddf63d99d0d145f18b293c3d0de4af7dab2a922 has push down the BKL
> > into irnet open function. However, there's nothing that needs locking in
> > there.
> >
> > Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio•com>
> > ---
> >  net/irda/irnet/irnet_ppp.c |    3 ---
> >  1 files changed, 0 insertions(+), 3 deletions(-)
> >
> > diff --git a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c
> > index 156020d..d6b502c 100644
> > --- a/net/irda/irnet/irnet_ppp.c
> > +++ b/net/irda/irnet/irnet_ppp.c
> > @@ -479,7 +479,6 @@ dev_irnet_open(struct inode *       inode,
> >   ap = kzalloc(sizeof(*ap), GFP_KERNEL);
> >   DABORT(ap == NULL, -ENOMEM, FS_ERROR, "Can't allocate struct irnet...\n");
> >
> > -  lock_kernel();
> >   /* initialize the irnet structure */
> >   ap->file = file;
> >
> > @@ -501,7 +500,6 @@ dev_irnet_open(struct inode *       inode,
> >     {
> >       DERROR(FS_ERROR, "Can't setup IrDA link...\n");
> >       kfree(ap);
> > -      unlock_kernel();
> >       return err;
> >     }
> >
> > @@ -512,7 +510,6 @@ dev_irnet_open(struct inode *       inode,
> >   file->private_data = ap;
> >
> >   DEXIT(FS_TRACE, " - ap=0x%p\n", ap);
> > -  unlock_kernel();
> >   return 0;
> >  }
> >
> > --
> > 1.6.6.1
> 
> This is probably NOT safe to do, because the BKL is synchronizing the
> ioctl code.
> 
> Thanks

And is it possible that ioctl will be called before open returns? If it
is, then, yes, this is not safe. But I don't really believe the case. Or
is it?

Or is it only possible to happen with different struct file*? In that
case, open is only allocating and initializing the irnet_socket *ap.
Then, ioctl uses it. There is some race between the different ioctls,
but no race between open/ioctl for different opened devices. That is, a
process may open /dev/irnet while another process is issuing ioctls to
its own opened /dev/irnet.

Besides, dev_irnet_ioctl uses the file private_data to get to the
irnet_socket, which is the last thing the open call does. I assume doing
an attribution to a pointer is atomic in all architectures supported by
Linux currently, isn't it?

Regards,
Cascardo.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2010-02-01 20:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-01 18:18 [PATCH] irda: remove BKL from irnet open function Thadeu Lima de Souza Cascardo
2010-02-01 20:32 ` John Kacur
2010-02-01 20:36   ` Thadeu Lima de Souza Cascardo [this message]
2010-02-01 21:20     ` Arnd Bergmann

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=20100201203616.GJ1414@holoscopio.com \
    --to=cascardo@holoscopio$(echo .)com \
    --cc=arnd@arndb$(echo .)de \
    --cc=davem@davemloft$(echo .)net \
    --cc=jkacur@gmail$(echo .)com \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=samuel@sortiz$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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