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, 01 Jul 2011 14:33:17 -0500
From:	James Bottomley <James.Bottomley@...senPartnership.com>
To:	Andi Kleen <andi@...stfloor.org>
Cc:	linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
	axboe@...nel.dk, rjw@...k.pl
Subject: Re: Linux 3.0 oopses when pulling a USB CDROM

On Fri, 2011-07-01 at 14:20 -0500, James Bottomley wrote:
> I'll see if I can find the refcounting problem.
> 
> Likely it's a longstanding bug which we didn't actually notice until
> now.

OK, so it looks like we have correct refcounting on the sr_block ops,
but not on the actual cdrom ops, so the device is already gone by the
time the cdrom release function gets called.

This is my best guess at the fix (just add a get into the cdrom ops),
does it work?

James

---

diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 4778e27..ee75983 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -575,7 +575,10 @@ static int sr_open(struct cdrom_device_info *cdi, int purpose)
 {
 	struct scsi_cd *cd = cdi->handle;
 	struct scsi_device *sdev = cd->device;
-	int retval;
+	int retval = scsi_device_get(sdev);
+
+	if (!retval)
+		return retval;
 
 	/*
 	 * If the device is in error recovery, wait until it is done.
@@ -588,6 +591,7 @@ static int sr_open(struct cdrom_device_info *cdi, int purpose)
 	return 0;
 
 error_out:
+	scsi_device_put(sdev);
 	return retval;	
 }
 
@@ -598,6 +602,7 @@ static void sr_release(struct cdrom_device_info *cdi)
 	if (cd->device->sector_size > 2048)
 		sr_set_blocklength(cd, 2048);
 
+	scsi_device_put(cd->device);
 }
 
 static int sr_probe(struct device *dev)


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