* Re: [2.6 patch] unexport uts_sem [not found] ` <20080520183802.GA686@redhat.com> @ 2008-05-21 12:37 ` Christoph Hellwig 2008-05-21 17:51 ` [PATCH] usb-storage: don't call utsname() Alan Stern 0 siblings, 1 reply; 7+ messages in thread From: Christoph Hellwig @ 2008-05-21 12:37 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] 7+ messages in thread
* [PATCH] usb-storage: don't call utsname() 2008-05-21 12:37 ` [2.6 patch] unexport uts_sem Christoph Hellwig @ 2008-05-21 17:51 ` Alan Stern [not found] ` <Pine.LNX.4.44L0.0805211349480.3409-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: Alan Stern @ 2008-05-21 17:51 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-R2MHTz/CkKAf7BdofF/totBPR1lH4CV8, 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-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org> --- 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-ijkIwGHArpdIPJnuZ7Njw4oP9KaGy4wf@public.gmane.org>\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] 7+ messages in thread
[parent not found: <Pine.LNX.4.44L0.0805211349480.3409-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>]
* Re: [PATCH] usb-storage: don't call utsname() [not found] ` <Pine.LNX.4.44L0.0805211349480.3409-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org> @ 2008-05-21 18:09 ` Greg KH 2008-05-21 18:19 ` Steve French (smfltc) 2008-05-21 18:52 ` Christoph Hellwig 0 siblings, 2 replies; 7+ messages in thread From: Greg KH @ 2008-05-21 18:09 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-R2MHTz/CkKAf7BdofF/totBPR1lH4CV8, 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-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org> 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] 7+ messages in thread
* Re: Re: [PATCH] usb-storage: don't call utsname() 2008-05-21 18:09 ` Greg KH @ 2008-05-21 18:19 ` Steve French (smfltc) 2008-05-21 18:52 ` Christoph Hellwig 1 sibling, 0 replies; 7+ messages in thread From: Steve French (smfltc) @ 2008-05-21 18:19 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-R2MHTz/CkKAf7BdofF/totBPR1lH4CV8, 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-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org> >> > > 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] 7+ messages in thread
* Re: [PATCH] usb-storage: don't call utsname() 2008-05-21 18:09 ` Greg KH 2008-05-21 18:19 ` Steve French (smfltc) @ 2008-05-21 18:52 ` Christoph Hellwig 2008-05-21 19:35 ` Greg KH 1 sibling, 1 reply; 7+ messages in thread From: Christoph Hellwig @ 2008-05-21 18:52 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-R2MHTz/CkKAf7BdofF/totBPR1lH4CV8, 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] 7+ messages in thread
* Re: [PATCH] usb-storage: don't call utsname() 2008-05-21 18:52 ` Christoph Hellwig @ 2008-05-21 19:35 ` Greg KH 2008-05-21 21:01 ` Steve French (smfltc) 0 siblings, 1 reply; 7+ messages in thread From: Greg KH @ 2008-05-21 19:35 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-R2MHTz/CkKAf7BdofF/totBPR1lH4CV8, 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] 7+ messages in thread
* Re: Re: [PATCH] usb-storage: don't call utsname() 2008-05-21 19:35 ` Greg KH @ 2008-05-21 21:01 ` Steve French (smfltc) 0 siblings, 0 replies; 7+ messages in thread From: Steve French (smfltc) @ 2008-05-21 21:01 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-R2MHTz/CkKAf7BdofF/totBPR1lH4CV8, 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] 7+ messages in thread
end of thread, other threads:[~2008-05-21 21:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20080505182937.GZ17139@cs181133002.pp.htv.fi>
[not found] ` <y0mwsloq4kc.fsf@ton.toronto.redhat.com>
[not found] ` <20080520172730.GA2361@infradead.org>
[not found] ` <20080520183802.GA686@redhat.com>
2008-05-21 12:37 ` [2.6 patch] unexport uts_sem Christoph Hellwig
2008-05-21 17:51 ` [PATCH] usb-storage: don't call utsname() Alan Stern
[not found] ` <Pine.LNX.4.44L0.0805211349480.3409-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2008-05-21 18:09 ` Greg KH
2008-05-21 18:19 ` Steve French (smfltc)
2008-05-21 18:52 ` Christoph Hellwig
2008-05-21 19:35 ` Greg KH
2008-05-21 21:01 ` 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