lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100603003826.GD5164@nowhere>
Date:	Thu, 3 Jun 2010 02:38:27 +0200
From:	Frederic Weisbecker <fweisbec@...il.com>
To:	Arnd Bergmann <arnd@...db.de>
Cc:	linux-kernel@...r.kernel.org, linux-usb@...r.kernel.org,
	John Kacur <jkacur@...hat.com>, Ingo Molnar <mingo@...e.hu>,
	Jan Blunck <jblunck@...e.de>
Subject: Re: [RFC 4/5] BKL: use no BKL in llseek

On Thu, Jun 03, 2010 at 02:13:18AM +0200, Arnd Bergmann wrote:
> We have shown that the BKL in default_llseek and other
> llseek operations never protects against concurrent access
> from another function:
> 
> * Most drivers never access f_pos
> * Most drivers that access f_pos have their own
>   llseek function
> * Those drivers that use default_llseek and still
>   access f_pos from outside do so without taking the BKL.
> * No file system uses default_llseek.
> 
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> ---
>  drivers/pnp/isapnp/proc.c |    6 +++---
>  drivers/usb/core/inode.c  |    1 -
>  drivers/zorro/proc.c      |    6 +++---
>  fs/read_write.c           |    4 ++--
>  4 files changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/pnp/isapnp/proc.c b/drivers/pnp/isapnp/proc.c
> index 3f94eda..cc22c7c 100644
> --- 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);
>  }
>  
> diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
> index 1a27618..70b1d42 100644
> --- a/drivers/usb/core/inode.c
> +++ b/drivers/usb/core/inode.c
> @@ -39,7 +39,6 @@
>  #include <linux/parser.h>
>  #include <linux/notifier.h>
>  #include <linux/seq_file.h>
> -#include <linux/smp_lock.h>
>  #include <linux/usb/hcd.h>
>  #include <asm/byteorder.h>
>  #include "usb.h"
> diff --git a/drivers/zorro/proc.c b/drivers/zorro/proc.c
> index 3c7046d..8e4c505 100644
> --- 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);
>  }
>  
> diff --git a/fs/read_write.c b/fs/read_write.c
> index 9c04852..31c0be7 100644
> --- a/fs/read_write.c
> +++ b/fs/read_write.c
> @@ -124,7 +124,7 @@ loff_t default_llseek(struct file *file, loff_t offset, int origin)
>  {
>  	loff_t retval;
>  
> -	lock_kernel();
> +	mutex_lock(&file->f_dentry->d_inode->i_mutex);
>  	switch (origin) {
>  		case SEEK_END:
>  			offset += i_size_read(file->f_path.dentry->d_inode);
> @@ -145,7 +145,7 @@ loff_t default_llseek(struct file *file, loff_t offset, int origin)
>  		retval = offset;
>  	}
>  out:
> -	unlock_kernel();
> +	mutex_unlock(&file->f_dentry->d_inode->i_mutex);
>  	return retval;
>  }
>  EXPORT_SYMBOL(default_llseek);



This should be simply dropped and we can make use of generic_file_llseek
instead, as the fallback llseek.

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ