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:	Mon, 25 Jan 2010 09:14:39 -0800
From:	Dmitry Torokhov <dmitry.torokhov@...il.com>
To:	Uwe Kleine-König 
	<u.kleine-koenig@...gutronix.de>
Cc:	Greg KH <gregkh@...e.de>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

On Sat, Jan 23, 2010 at 10:49:16AM +0100, Uwe Kleine-König wrote:
> Helle Dmitry,
> 
> On Fri, Jan 22, 2010 at 03:49:37PM -0800, Dmitry Torokhov wrote:
> > On Fri, Jan 22, 2010 at 08:49:18PM +0100, Uwe Kleine-König wrote:
> > > +int platform_driver_register(struct platform_driver *drv)
> > > +{
> > > +	int ret = __platform_driver_register(drv);
> > > +
> > > +#if defined(CONFIG_HOTPLUG)
> > > +	/*
> > > +	 * drivers that are registered by platform_driver_register
> > > +	 * should not have their probe function in .init.text.  The
> > > +	 * reason is that a probe can happen after .init.text is
> > > +	 * discarded which then results in an oops.  The alternatives
> > > +	 * are using .devinit.text for the probe function or "register"
> > > +	 * with platform_driver_probe.
> > > +	 */
> > 
> > 
> > What about CONFIG_MODULE case (without hotplug)? The driver may be
> > compiled in (and thus probe will be discarded) but device might be
> > created by a loadable module which is loaded later.
> I don't see the problem here.

You are right, without hotplug we don't try to bind to devices that
come in later so we are safe to discard probe.

>  If the driver is registered using
> platform_driver_register and the probe function lives in .init.text it
> doesn't matter where the device comes from.  If there is one you can
> unbind and bind at a later time when .init is already discarded.  No?
> 

Yes.

> More general, using platform_driver_register the pointer to the probe
> function have to stay valid as it is saved for later use, so it must not
> be an .init pointer.


> 
> > > +	if (drv->probe && kernel_init_text_address((unsigned long)drv->probe))
> > > +		pr_warning("oops-warning: probe function of platform driver %s"
> > > +			       " lives in .init.text\n", drv->driver.name);
> > > +#else
> > > +	/*
> > > +	 * without HOTPLUG probe functions can be discarded after the driver is
> > > +	 * loaded.
> > > +	 * There is a little chance for false positives, namely if the driver is
> > > +	 * registered after the .init sections are discarded.
> > > +	 */
> > > +	if (drv->probe && !kernel_init_text_address((unsigned long)drv->probe))
> > > +		pr_info("probably the probe function of platform driver %s can"
> > > +				" be moved to .init.text\n", drv->driver.name);
> > 
> > It really depends on the user's (or rather builder's) local
> > configuration so how can we make this suggestion?
> Can you point out a situation that makes the suggestion wrong?  AFAIK
> there only the possibility that the driver is loaded after .init is
> discarded (as written in the comment).
> 

The presence of CONFIG_HOTPLUG depends on particular .config, so, for
example, you may not have it set while I have. So you will boot, get the
suggestion, submit a patch, then I will boot and will get a warning that
the probe function is in wrong section.

So in general I wonder if it is possible to request that all probe
functions are marked as __devinit or not marked at all, regardless of
CONFIG_HOTPLUG and CONFIG_MODULE settings.

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