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: <20091001180500.GA11984@redhat.com>
Date:	Thu, 1 Oct 2009 20:05:00 +0200
From:	"Michael S. Tsirkin" <mst@...hat.com>
To:	Uwe Kleine-König 
	<u.kleine-koenig@...gutronix.de>
Cc:	Christian Borntraeger <borntraeger@...ibm.com>,
	linux-kernel@...r.kernel.org, Sam Ravnborg <sam@...nborg.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Rusty Russell <rusty@...tcorp.com.au>
Subject: Re: [PATCH 31/34] move virtrng_remove to .devexit.text

On Thu, Oct 01, 2009 at 07:41:16PM +0200, Uwe Kleine-König wrote:
> Hello Michael,
> 
> > > But note it's not an error in general to use a .text function as remove
> > > callback.  E.g. take drivers/gpio/twl4030-gpio.c.  gpio_twl4030_remove
> > > is used in gpio_twl4030_probe which is defined using __devinit.  So
> > > using __devexit for gpio_twl4030_remove is wrong.  (So there is a bug,
> > > as gpio_twl4030_remove uses __devexit.)  I didn't try, but as far as I
> > > understand this will result in a compile error if the driver is built-in
> > > with HOTPLUG=n.
> > 
> > Wait a second.
> > As far as I understand, __devexit makes it possible to remove code if
> > hotplug is off.
> right.
>  
> > At least for static functions, it's enough to mark their only use
> > as _devexit_p, and compiler will remove the text as it's unused.
> > 
> > Isn't that right?
> hmm, I don't know.  I'll try, one moment.  OK, you're right.  The
> function is discarded with a compiler warning.
>  
> > If so, what, again, was the motivation for the patches that added
> > __devexit to functions that were already used with __devexit_p?
> I thought it saves some memory, but as it looks now it only fixes a
> compiler warning.

We can redefine __devexit_p(x) to something like
#define __devexit_p(x) ((typeof(x) *)NULL)
and this will shut down the warning without need to fix the code.

Using _devexit_p for static functions is also safer
than __devexit since if you define a function as __devexit
and by mistake call it from another context, it won't link.

Makes sense?

> Note there are two types of errors fixed in this series.  One is:
> 
> 	-static int func(void arg)
> 	+static int __devexit func(void arg)
> 
> if the only usage of func() is wraped by __devexit_p.  This is (as
> seen above) not that critical, there is only a warning fixed.
> 
> The other type results in a build failure:
> 
> 	-remove = __devexit_p(another_func),
> 	+remove = __exit_p(another_func),
> 
> with another_func being defined using __exit.  In the case 
> defined(MODULE) && defined(CONFIG_HOTPLUG) another_func is discarded,
> but __devexit_p(another_func) evaluates to another_func and thus the
> module doesn't link.

Yes, calling __exit function from non- __exit is always a bug.
I think there's a make flag to warn about this, not sure why it's
not the default.

> Best regards
> Uwe
> 
> -- 
> Pengutronix e.K.                              | Uwe Kleine-König            |
> Industrial Linux Solutions                    | http://www.pengutronix.de/  |
--
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