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: <200912042055.55565.oliver@neukum.org>
Date:	Fri, 4 Dec 2009 20:55:55 +0100
From:	Oliver Neukum <oliver@...kum.org>
To:	Greg KH <gregkh@...e.de>
Cc:	Alan Stern <stern@...land.harvard.edu>, stable@...nel.org,
	Rickard Bellini <rickard.bellini@...csson.com>,
	"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
	Torgny Johansson <torgny.johansson@...csson.com>,
	Kernel development list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] Driver core: fix race in dev_driver_string

Am Freitag, 4. Dezember 2009 17:50:40 schrieb Greg KH:
> On Fri, Dec 04, 2009 at 05:16:19PM +0100, Oliver Neukum wrote:
> > Am Freitag, 4. Dezember 2009 17:06:57 schrieb Alan Stern:
> > > Oliver:
> > > 
> > > We don't have to worry about the device structure being deallocated 
> > > while the routine is running.  If that happens it's a bug in the 
> > > caller: improper refcounting.
> >
> > 
> > That raises two points
> > 
> > 1. am I supposed to get a reference just so that I can use dev_err?
> 
> No, you should already have a reference on the device when doing the
> call, right?

No, why? Consider this:

int write(...)
{
	...
	mutex_lock(&instance->lock);
	if (instance->disconnected) {
		dev_dbg(instance->dev,"writing to disconnected device"); 
		rv = -ENODEV;
	} else {
		res = usb_submit_urb(...);
		rv = res < 0 ? -EIO : count;
	}
	mutex_unlock(&instance->lock);
	return rv;
}

void disconnect(...)
{
	...
	mutex_lock(&instance->lock);
	instance->disconnected = 1;
	usb_kill_urb(...);
	usb_kill_urb(...);
	mutex_unlock(&instance->lock);
}

This would be perfectly valid code without any references taken save
for the pesky dev_dbg()

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