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]
Date:	Fri, 23 May 2008 03:09:52 +0200
From:	"Rafael J. Wysocki" <rjw@...k.pl>
To:	Alan Cox <alan@...rguk.ukuu.org.uk>
Cc:	linux-kernel@...r.kernel.org, akpm@...l.org
Subject: Re: [PATCH] snapshot: Push BKL down into ioctl handlers

On Thursday, 22 of May 2008, Alan Cox wrote:
> Signed-off-by: Alan Cox <alan@...hat.com>
> 
> diff --git a/kernel/power/user.c b/kernel/power/user.c
> index f5512cb..658262b 100644
> --- a/kernel/power/user.c
> +++ b/kernel/power/user.c
> @@ -23,6 +23,7 @@
>  #include <linux/console.h>
>  #include <linux/cpu.h>
>  #include <linux/freezer.h>
> +#include <linux/smp_lock.h>
>  
>  #include <asm/uaccess.h>
>  
> @@ -164,8 +165,8 @@ static ssize_t snapshot_write(struct file *filp, const char __user *buf,
>  	return res;
>  }
>  
> -static int snapshot_ioctl(struct inode *inode, struct file *filp,
> -                          unsigned int cmd, unsigned long arg)
> +static long snapshot_ioctl(struct file *filp, unsigned int cmd,
> +							unsigned long arg)
>  {
>  	int error = 0;
>  	struct snapshot_data *data;
> @@ -181,6 +182,8 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
>  
>  	data = filp->private_data;
>  
> +	lock_kernel();
> +

Hm, well, I admit I'm a bit ignorant as far as the chardev locking is
concerned, but can you please tell me why would that be wrong if we didn't call
lock_kernel() here at all?

>  	switch (cmd) {
>  
>  	case SNAPSHOT_FREEZE:
> @@ -389,7 +392,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
>  		error = -ENOTTY;
>  
>  	}
> -
> +	unlock_kernel();
>  	return error;
>  }
>  
> @@ -399,7 +402,7 @@ static const struct file_operations snapshot_fops = {
>  	.read = snapshot_read,
>  	.write = snapshot_write,
>  	.llseek = no_llseek,
> -	.ioctl = snapshot_ioctl,
> +	.unlocked_ioctl = snapshot_ioctl,
>  };
>  
>  static struct miscdevice snapshot_device = {

Thanks,
Rafael
--
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