linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	Frederic Weisbecker <fweisbec@gmail.com>,
	John Kacur <jkacur@redhat.com>, Ingo Molnar <mingo@elte.hu>,
	Jan Blunck <jblunck@suse.de>
Subject: Re: [RFC 4/5] BKL: use no BKL in llseek
Date: Thu, 3 Jun 2010 09:41:58 +0200	[thread overview]
Message-ID: <AANLkTil4-BDiE-zwlNaGHm_rEWQroR0F-3fpc7BW366k@mail.gmail.com> (raw)
In-Reply-To: <1275523999-27462-5-git-send-email-arnd@arndb.de>

On Thu, Jun 3, 2010 at 02:13, Arnd Bergmann <arnd@arndb.de> wrote:
> We have shown that the BKL in default_llseek and other
> llseek operations never protects against concurrent access
> from another function:

> --- a/drivers/zorro/proc.c
> +++ b/drivers/zorro/proc.c
> @@ -23,7 +23,7 @@ proc_bus_zorro_lseek(struct file *file, loff_t off, int whence)
>  {
>        loff_t new = -1;
>
> -       lock_kernel();
> +       mutex_lock(&file->f_dentry->d_inode->i_mutex);
>        switch (whence) {
>        case 0:
>                new = off;
> @@ -36,10 +36,10 @@ proc_bus_zorro_lseek(struct file *file, loff_t off, int whence)
>                break;
>        }
>        if (new < 0 || new > sizeof(struct ConfigDev)) {
> -               unlock_kernel();
> +               mutex_unlock(&file->f_dentry->d_inode->i_mutex);
>                return -EINVAL;
>        }
> -       unlock_kernel();
> +       mutex_unlock(&file->f_dentry->d_inode->i_mutex);
>        return (file->f_pos = new);
>  }

I was about to fix this like drivers/pci/proc.c handles it
(origiginally I cloned it from that fil
anyway).
Compared to your version, that also moves the setting of file->f_pos
inside the mutex,
which is probably also needed in other places...

> --- a/drivers/pnp/isapnp/proc.c
> +++ b/drivers/pnp/isapnp/proc.c
> @@ -32,7 +32,7 @@ static loff_t isapnp_proc_bus_lseek(struct file *file, loff_t off, int whence)
>  {
>        loff_t new = -1;
>
> -       lock_kernel();
> +       mutex_lock(&file->f_dentry->d_inode->i_mutex);
>        switch (whence) {
>        case 0:
>                new = off;
> @@ -45,10 +45,10 @@ static loff_t isapnp_proc_bus_lseek(struct file *file, loff_t off, int whence)
>                break;
>        }
>        if (new < 0 || new > 256) {
> -               unlock_kernel();
> +               mutex_unlock(&file->f_dentry->d_inode->i_mutex);
>                return -EINVAL;
>        }
> -       unlock_kernel();
> +       mutex_unlock(&file->f_dentry->d_inode->i_mutex);
>        return (file->f_pos = new);

... like here?

>  }

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

  parent reply	other threads:[~2010-06-03  7:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-03  0:13 [RFC 0/5] BKL removal leftovers Arnd Bergmann
2010-06-03  0:13 ` [RFC 1/5] BKL: autoconvert trivial users to private mutex Arnd Bergmann
2010-06-03  0:35   ` Frederic Weisbecker
2010-06-03 16:50     ` Greg KH
2010-06-03  0:13 ` [RFC 2/5] BKL: remove the BKL from kernel init code Arnd Bergmann
2010-06-03  1:07   ` Steven Rostedt
2010-06-03  0:13 ` [RFC 3/5] BKL: do not take BKL in do_coredump Arnd Bergmann
2010-06-03  0:13 ` [RFC 4/5] BKL: use no BKL in llseek Arnd Bergmann
2010-06-03  0:38   ` Frederic Weisbecker
2010-06-03  7:08     ` Christoph Hellwig
2010-06-03  7:06   ` Christoph Hellwig
2010-06-03 23:47     ` Arnd Bergmann
2010-06-03  7:41   ` Geert Uytterhoeven [this message]
2010-06-03  0:13 ` [RFC 5/5] BKL: introduce CONFIG_BKL 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=AANLkTil4-BDiE-zwlNaGHm_rEWQroR0F-3fpc7BW366k@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=arnd@arndb.de \
    --cc=fweisbec@gmail.com \
    --cc=jblunck@suse.de \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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;
as well as URLs for NNTP newsgroup(s).