public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Re: [2.6 patch] unexport uts_sem
       [not found] <20080505182937.GZ17139@cs181133002.pp.htv.fi>
@ 2008-05-20 19:31 ` Frank Ch. Eigler
  2008-05-20 19:32   ` Christoph Hellwig
  0 siblings, 1 reply; 10+ messages in thread
From: Frank Ch. Eigler @ 2008-05-20 19:31 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: linux-kernel, David S. Miller, Andrew Morton, systemtap

Adrian Bunk <bunk@kernel.org> writes:

> With the removal of the Solaris binary emulation the export of 
> uts_sem became unused. [...]
>
> -EXPORT_SYMBOL(uts_sem);

Am I correct that this would makes it invalid for modules to call
utsname() (since the protective semaphore is now hidden)?  Systemtap
has been using them in order to validate the modules it builds against
possible kernel vs. kernel-devel differences.

- FChE

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [2.6 patch] unexport uts_sem
  2008-05-20 19:31 ` [2.6 patch] unexport uts_sem Frank Ch. Eigler
@ 2008-05-20 19:32   ` Christoph Hellwig
  2008-05-20 19:54     ` Frank Ch. Eigler
  0 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2008-05-20 19:32 UTC (permalink / raw)
  To: Frank Ch. Eigler
  Cc: Adrian Bunk, linux-kernel, David S. Miller, Andrew Morton, systemtap

On Tue, May 20, 2008 at 01:16:19PM -0400, Frank Ch. Eigler wrote:
> Am I correct that this would makes it invalid for modules to call
> utsname() (since the protective semaphore is now hidden)?

Yesm they should never had done that anyway.  The module support
does it's own version checking already.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [2.6 patch] unexport uts_sem
  2008-05-20 19:32   ` Christoph Hellwig
@ 2008-05-20 19:54     ` Frank Ch. Eigler
  2008-05-21 18:11       ` Christoph Hellwig
  0 siblings, 1 reply; 10+ messages in thread
From: Frank Ch. Eigler @ 2008-05-20 19:54 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Adrian Bunk, linux-kernel, David S. Miller, Andrew Morton, systemtap

Hi -

On Tue, May 20, 2008 at 01:27:30PM -0400, Christoph Hellwig wrote:
> > Am I correct that this would makes it invalid for modules to call
> > utsname() (since the protective semaphore is now hidden)?
> 
> Yesm they should never had done that anyway.  The module support
> does it's own version checking already.

Sorry, I misspoke - this check is intended not to cross-check
kernel-devel and the kernel itself, but the debuginfo or similar data
that is given to describe target of a systemtap script.  I guess for
new enough kernels we'll just do that using buildid hash codes.

By the way, there do appear to be a few suspect in-tree users of
utsname() without uts_sem locking (usb/storage/usb.c, cifs/connect.c,
char/random.cc, fs/lockd/clntproc.c, ...).  If these need to be fixed,
then wouldn't uts_sem need to come back exported?

- FChE

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [2.6 patch] unexport uts_sem
  2008-05-20 19:54     ` Frank Ch. Eigler
@ 2008-05-21 18:11       ` Christoph Hellwig
  2008-05-21 19:01         ` [PATCH] usb-storage: don't call utsname() Alan Stern
  0 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2008-05-21 18:11 UTC (permalink / raw)
  To: Frank Ch. Eigler
  Cc: Christoph Hellwig, Adrian Bunk, linux-kernel, David S. Miller,
	Andrew Morton, systemtap, usb-storage, linux-cifs-client,
	linux-nfs

On Tue, May 20, 2008 at 02:38:02PM -0400, Frank Ch. Eigler wrote:
> Sorry, I misspoke - this check is intended not to cross-check
> kernel-devel and the kernel itself, but the debuginfo or similar data
> that is given to describe target of a systemtap script.  I guess for
> new enough kernels we'll just do that using buildid hash codes.
> 
> By the way, there do appear to be a few suspect in-tree users of
> utsname() without uts_sem locking (usb/storage/usb.c

Just a debug printk.  Note sure why this particular one needs to
print the version, but if it really wants to do it it should rather use
UTS_RELEASE.

> cifs/connect.c,

This one is quite fishy. Not sure what it needs the name for but the
kernel utsname is probably a bad choise.  And yes, this one actually
is racy because the host name can change.

> char/random.c,

random.c is always built-in and utsname is called during the
single-threaded kernel initialization phase, so this is safe.

> fs/lockd/clntproc.c, ...).

Yes, this one is racy.  Should probably be fixed by starting lockd
with CLONE_NEWUTS so that it never changed during it's lifetime.
It's probably not a good idea when it changes with outstanding lockd
request anyway.

> If these need to be fixed,
> then wouldn't uts_sem need to come back exported?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] usb-storage: don't call utsname()
  2008-05-21 18:11       ` Christoph Hellwig
@ 2008-05-21 19:01         ` Alan Stern
  2008-05-21 19:36           ` Greg KH
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Stern @ 2008-05-21 19:01 UTC (permalink / raw)
  To: Greg KH, Matthew Dharm
  Cc: Christoph Hellwig, Frank Ch. Eigler, Adrian Bunk,
	USB Storage list, Kernel development list, David S. Miller,
	systemtap, Andrew Morton, linux-cifs-client, linux-nfs

This patch (as1100) replaces the core-kernel function call to utsname()
in usb-storage with the UTS_RELEASE macro.  It's used only for warning
about extra unusual_devs entries.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>

---

Index: usb-2.6/drivers/usb/storage/usb.c
===================================================================
--- usb-2.6.orig/drivers/usb/storage/usb.c
+++ usb-2.6/drivers/usb/storage/usb.c
@@ -53,7 +53,7 @@
 #include <linux/slab.h>
 #include <linux/kthread.h>
 #include <linux/mutex.h>
-#include <linux/utsname.h>
+#include <linux/utsrelease.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
@@ -531,8 +531,8 @@ static int get_device_info(struct us_dat
 		if (msg >= 0 && !(us->fflags & US_FL_NEED_OVERRIDE))
 			printk(KERN_NOTICE USB_STORAGE "This device "
 				"(%04x,%04x,%04x S %02x P %02x)"
-				" has %s in unusual_devs.h (kernel"
-				" %s)\n"
+				" has %s in unusual_devs.h (kernel "
+				UTS_RELEASE ")\n"
 				"   Please send a copy of this message to "
 				"<linux-usb@vger.kernel.org> and "
 				"<usb-storage@lists.one-eyed-alien.net>\n",
@@ -541,8 +541,7 @@ static int get_device_info(struct us_dat
 				le16_to_cpu(ddesc->bcdDevice),
 				idesc->bInterfaceSubClass,
 				idesc->bInterfaceProtocol,
-				msgs[msg],
-				utsname()->release);
+				msgs[msg]);
 	}
 
 	return 0;

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] usb-storage: don't call utsname()
  2008-05-21 19:01         ` [PATCH] usb-storage: don't call utsname() Alan Stern
@ 2008-05-21 19:36           ` Greg KH
  2008-05-21 19:48             ` Steve French (smfltc)
  2008-05-21 20:08             ` Christoph Hellwig
  0 siblings, 2 replies; 10+ messages in thread
From: Greg KH @ 2008-05-21 19:36 UTC (permalink / raw)
  To: Alan Stern
  Cc: Matthew Dharm, Christoph Hellwig, Frank Ch. Eigler, Adrian Bunk,
	USB Storage list, Kernel development list, David S. Miller,
	systemtap, Andrew Morton, linux-cifs-client, linux-nfs

On Wed, May 21, 2008 at 01:51:17PM -0400, Alan Stern wrote:
> This patch (as1100) replaces the core-kernel function call to utsname()
> in usb-storage with the UTS_RELEASE macro.  It's used only for warning
> about extra unusual_devs entries.
> 
> Signed-off-by: Alan Stern <stern@rowland.harvard.edu>

Why?  With this change, if you change the version number, the file will
have to be rebuilt.  Without the change, the file will not need to be
rebuilt, right?

I thought that was why this change was made a while ago, to prevent
things from having to be rebuilt that didn't need to be.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Re: [PATCH] usb-storage: don't call utsname()
  2008-05-21 19:36           ` Greg KH
@ 2008-05-21 19:48             ` Steve French (smfltc)
  2008-05-21 20:08             ` Christoph Hellwig
  1 sibling, 0 replies; 10+ messages in thread
From: Steve French (smfltc) @ 2008-05-21 19:48 UTC (permalink / raw)
  To: Greg KH
  Cc: Alan Stern, Matthew Dharm, Christoph Hellwig, Frank Ch. Eigler,
	Adrian Bunk, USB Storage list, Kernel development list,
	David S. Miller, systemtap, Andrew Morton, linux-cifs-client,
	linux-nfs

Greg KH wrote:
> On Wed, May 21, 2008 at 01:51:17PM -0400, Alan Stern wrote:
>   
>> This patch (as1100) replaces the core-kernel function call to utsname()
>> in usb-storage with the UTS_RELEASE macro.  It's used only for warning
>> about extra unusual_devs entries.
>>
>> Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
>>     
>
> Why?  With this change, if you change the version number, the file will
> have to be rebuilt.  Without the change, the file will not need to be
> rebuilt, right?
>
> I thought that was why this change was made a while ago, to prevent
> things from having to be rebuilt that didn't need to be
>   
I agree - what was wrong with utsname->release ... it seems odd to 
statically build the kernel's version
number into a module - it should be something we should be able to query 
(and it shouldn't change without
reboot so accessing it is not racy).  Access to other fields in the 
structure (nodename, domainname etc.) might
need to be included in a macro but I didn't see one in utsname.h for this.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] usb-storage: don't call utsname()
  2008-05-21 19:36           ` Greg KH
  2008-05-21 19:48             ` Steve French (smfltc)
@ 2008-05-21 20:08             ` Christoph Hellwig
  2008-05-21 20:55               ` Greg KH
  1 sibling, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2008-05-21 20:08 UTC (permalink / raw)
  To: Greg KH
  Cc: Alan Stern, Matthew Dharm, Christoph Hellwig, Frank Ch. Eigler,
	Adrian Bunk, USB Storage list, Kernel development list,
	David S. Miller, systemtap, Andrew Morton, linux-cifs-client,
	linux-nfs

On Wed, May 21, 2008 at 11:09:57AM -0700, Greg KH wrote:
> Why?  With this change, if you change the version number, the file will
> have to be rebuilt.  Without the change, the file will not need to be
> rebuilt, right?

Because thanks to the container patches it utsname fields other than
hostname can actually change at runtime now and you'll get races looking
at them.  And probably not the output you want if someone in your
container changes the kernel version to trick applications.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] usb-storage: don't call utsname()
  2008-05-21 20:08             ` Christoph Hellwig
@ 2008-05-21 20:55               ` Greg KH
  2008-05-22  9:37                 ` Steve French (smfltc)
  0 siblings, 1 reply; 10+ messages in thread
From: Greg KH @ 2008-05-21 20:55 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Alan Stern, Matthew Dharm, Frank Ch. Eigler, Adrian Bunk,
	USB Storage list, Kernel development list, David S. Miller,
	systemtap, Andrew Morton, linux-cifs-client, linux-nfs

On Wed, May 21, 2008 at 02:52:51PM -0400, Christoph Hellwig wrote:
> On Wed, May 21, 2008 at 11:09:57AM -0700, Greg KH wrote:
> > Why?  With this change, if you change the version number, the file will
> > have to be rebuilt.  Without the change, the file will not need to be
> > rebuilt, right?
> 
> Because thanks to the container patches it utsname fields other than
> hostname can actually change at runtime now and you'll get races looking
> at them.  And probably not the output you want if someone in your
> container changes the kernel version to trick applications.

So, do we now go and rip out all usages of utsname()->release and put
back the #define just because of the loonacy of containers?

No kernel should have to change it's version number to trick an
application, why would an application care about the version number to
start with?  In the "enterprise kernel" world, version numbers have
little to no relevance on the functionality or features of the kernel,
so any check of something like this is sure to be wrong to start with.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Re: [PATCH] usb-storage: don't call utsname()
  2008-05-21 20:55               ` Greg KH
@ 2008-05-22  9:37                 ` Steve French (smfltc)
  0 siblings, 0 replies; 10+ messages in thread
From: Steve French (smfltc) @ 2008-05-22  9:37 UTC (permalink / raw)
  To: Greg KH
  Cc: Christoph Hellwig, Alan Stern, Matthew Dharm, Frank Ch. Eigler,
	Adrian Bunk, USB Storage list, Kernel development list,
	David S. Miller, systemtap, Andrew Morton, linux-cifs-client,
	linux-nfs

Greg KH wrote:
> On Wed, May 21, 2008 at 02:52:51PM -0400, Christoph Hellwig wrote:
>   
>> On Wed, May 21, 2008 at 11:09:57AM -0700, Greg KH wrote:
>>     
>>> Why?  With this change, if you change the version number, the file will
>>> have to be rebuilt.  Without the change, the file will not need to be
>>> rebuilt, right?
>>>       
>> Because thanks to the container patches it utsname fields other than
>> hostname can actually change at runtime now and you'll get races looking
>> at them.  And probably not the output you want if someone in your
>> container changes the kernel version to trick applications.
>>     
>
> So, do we now go and rip out all usages of utsname()->release and put
> back the #define just because of the loonacy of containers?
>
> No kernel should have to change it's version number to trick an
> application, why would an application care about the version number to
>   
The version number (of the OS not just of the SMB/CIFS implementation, 
both of which are exchanged by client and server) has sometimes been 
useful in debugging problems that I and others and the Samba team look 
at (you can see it in wireshark/tcpdump traces, and it can be logged 
easily on either end as well).

If containers are crazy enough to change the version number, not just 
the hostname, why don't we simply define a three line macro for 
retrieving this which is safe and put it in utsname.h?

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-05-21 21:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20080505182937.GZ17139@cs181133002.pp.htv.fi>
2008-05-20 19:31 ` [2.6 patch] unexport uts_sem Frank Ch. Eigler
2008-05-20 19:32   ` Christoph Hellwig
2008-05-20 19:54     ` Frank Ch. Eigler
2008-05-21 18:11       ` Christoph Hellwig
2008-05-21 19:01         ` [PATCH] usb-storage: don't call utsname() Alan Stern
2008-05-21 19:36           ` Greg KH
2008-05-21 19:48             ` Steve French (smfltc)
2008-05-21 20:08             ` Christoph Hellwig
2008-05-21 20:55               ` Greg KH
2008-05-22  9:37                 ` Steve French (smfltc)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).