lkml.org 
[lkml]   [2010]   [Jun]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC 4/5] BKL: use no BKL in llseek
From
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2010-06-03 09:45    [W:0.130 / U:0.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site