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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Tue, 13 Jan 2009 09:27:45 +0100
From:	Pavel Machek <pavel@...e.cz>
To:	Paul Clements <paul.clements@...eleye.com>
Cc:	kernel list <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...l.org>
Subject: Re: do not allow two nbd-clients at same time

On Mon 2009-01-12 08:55:10, Paul Clements wrote:
> Pavel Machek wrote:
>> Two nbd-clients at same time are bad idea, and cause WARN_ON from nbd
>> in 2.6.28-rc7 from sysfs_add_one. This simply prevents that from
>> happening.
>
> Thanks for this. But I think we also need the following:
>
> --- drivers/block/nbd.c        2008-12-24 18:26:37.000000000 -0500
> +++ drivers/block/nbd.c 2009-01-12 08:50:17.000000000 -0500
> @@ -406,6 +406,7 @@ static int nbd_do_it(struct nbd_device *
>         ret = sysfs_create_file(&disk_to_dev(lo->disk)->kobj,  
> &pid_attr.attr);
>         if (ret) {
>                 printk(KERN_ERR "nbd: sysfs_create_file failed!");
> +               lo->pid = 0;
>                 return ret;
>         }
>
>

Yep, thanks.

> To zero out pid in the error case. Otherwise, it looks good.

Ok, new patch below.
								Pavel

--- 
Two nbd-clients at same time are bad idea, and cause WARN_ON from nbd
in 2.6.28-rc7 from sysfs_add_one. This simply prevents that from
happening.

To reproduce:

 cat /dev/zero | head -c 10000000 > /tmp/delme.fstest.fs
 nbd-server 9100 -l /anyone.can.connect > /tmp/delme.fstest.fs &
 sleep 1
 nbd-client localhost 9100 /dev/nd0 &
 nbd-client localhost 9100 /dev/nd0 &

Signed-off-by: Pavel Machek <pavel@...e.cz>
Acked-by: Paul Clements <paul.clements@...eleye.com>

---
commit 831d1b7c7c5b16b1115d7e08ddf9038704653a03
tree 1ae30466acfb40b88cb7c20613f327c3871274ee
parent 66d8f12491f52e259e42148af099a3fc83425a7b
author Pavel <pavel@....ucw.cz> Tue, 13 Jan 2009 09:26:22 +0100
committer Pavel <pavel@....ucw.cz> Tue, 13 Jan 2009 09:26:22 +0100

 drivers/block/nbd.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 670e89d..caf6458 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -406,6 +406,7 @@ static int nbd_do_it(struct nbd_device *
 	ret = sysfs_create_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr);
 	if (ret) {
 		printk(KERN_ERR "nbd: sysfs_create_file failed!");
+		lo->pid = 0;
 		return ret;
 	}
 
@@ -413,6 +414,7 @@ static int nbd_do_it(struct nbd_device *
 		nbd_end_request(req);
 
 	sysfs_remove_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr);
+	lo->pid = 0;
 	return 0;
 }
 
@@ -646,6 +648,8 @@ static int nbd_ioctl(struct block_device
 		set_capacity(lo->disk, lo->bytesize >> 9);
 		return 0;
 	case NBD_DO_IT:
+		if (lo->pid)
+			return -EBUSY;
 		if (!lo->file)
 			return -EINVAL;
 		thread = kthread_create(nbd_thread, lo, lo->disk->disk_name);

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
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