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] [day] [month] [year] [list]
Date:	Mon, 12 Oct 2009 15:03:51 +0200
From:	Stefan Richter <stefanr@...6.in-berlin.de>
To:	John Kacur <jkacur@...hat.com>
CC:	linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Ingo Molnar <mingo@...e.hu>,
	Christoph Hellwig <hch@...radead.org>,
	Jonathan Corbet <corbet@....net>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Vincent Sanders <vince@...tec.co.uk>,
	Alan Cox <alan@...rguk.ukuu.org.uk>, linux-scsi@...r.kernel.org
Subject: Re: [PATCH RFC] [PATCH] drivers/scsi/ch.c: Remove BKL in ch_open

On 10/11/2009 3:45 PM, John Kacur wrote:
> Locking in ch_open is covered by the spin_lock, it serializes the calls
> to idr_find and scsi_device_get. The BKL appears redundant to me here.

Superficially this looks OK (i.e. no race with driver init in general).
But I do wonder if there isn't already a race condition possible with
the current code, between ch_probe and the file operations.  ch_probe
makes a scsi_changer instance available in the IDR and creates the
corresponding character device file _before_ the scsi_changer instance
is fully initialized.

(Full quote follows for lsml)

> From b385c85bb5c2579e542cfe55475b729325eb65e1 Mon Sep 17 00:00:00 2001
> From: John Kacur <jkacur@...hat.com>
> Date: Sun, 11 Oct 2009 13:06:54 +0200
> Subject: [PATCH] drivers/scsi/ch.c: Remove BKL in ch_open
> 
> Everything in ch_open is covered by a spin_lock, so the lock_kernel is redundant
> Remove it.
> 
> Signed-off-by: John Kacur <jkacur@...hat.com>
> ---
>  drivers/scsi/ch.c |    5 +----
>  1 files changed, 1 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
> index fe11c1d..4ba8b67 100644
> --- a/drivers/scsi/ch.c
> +++ b/drivers/scsi/ch.c
> @@ -579,19 +579,16 @@ ch_open(struct inode *inode, struct file *file)
>  	scsi_changer *ch;
>  	int minor = iminor(inode);
>  
> -	lock_kernel();
>  	spin_lock(&ch_index_lock);
>  	ch = idr_find(&ch_index_idr, minor);
>  
>  	if (NULL == ch || scsi_device_get(ch->device)) {
>  		spin_unlock(&ch_index_lock);
> -		unlock_kernel();
>  		return -ENXIO;
>  	}
> +	file->private_data = ch;
>  	spin_unlock(&ch_index_lock);
>  
> -	file->private_data = ch;
> -	unlock_kernel();
>  	return 0;
>  }
>  


-- 
Stefan Richter
-=====-==--= =-=- -==--
http://arcgraph.de/sr/
--
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