All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add a personality to report 2.6.x version numbers
@ 2011-08-19 23:15 Andi Kleen
  2011-08-21 22:28 ` Arnaud Lacombe
                   ` (4 more replies)
  0 siblings, 5 replies; 35+ messages in thread
From: Andi Kleen @ 2011-08-19 23:15 UTC (permalink / raw)
  To: torvalds; +Cc: akpm, linux-kernel, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

Reposting due to popular demand. Several other people are running
into the same problem with all kinds of software.

Only change is rebase against current master.

-Andi

--

I ran into a couple of programs which broke with the new Linux 3.0 version.
Some of those were binary only. I tried to use LD_PRELOAD to work
around it, but it was quite difficult and in one case impossible
because of a mix of 32bit and 64bit executables.

This patch adds a UNAME26 personality that makes the kernel
report a 2.6.40+x version number instead. The x is the x in 3.x.

I know this is somewhat ugly, but I didn't find a better workaround,
and compatibility to existing programs is important.

Some programs also read /proc/sys/kernel/osrelease. This can be worked
around in user space with mount --bind (and a mount namespace)

To use:

wget ftp://ftp.kernel.org/pub/linux/kernel/people/ak/uname26/uname26.c
gcc -o uname26 uname26.c
./uname26 program

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 include/linux/personality.h |    1 +
 kernel/sys.c                |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/include/linux/personality.h b/include/linux/personality.h
index eec3bae..8fc7dd1a 100644
--- a/include/linux/personality.h
+++ b/include/linux/personality.h
@@ -22,6 +22,7 @@ extern int		__set_personality(unsigned int);
  * These occupy the top three bytes.
  */
 enum {
+	UNAME26	=               0x0020000,
 	ADDR_NO_RANDOMIZE = 	0x0040000,	/* disable randomization of VA space */
 	FDPIC_FUNCPTRS =	0x0080000,	/* userspace function ptrs point to descriptors
 						 * (signal handling)
diff --git a/kernel/sys.c b/kernel/sys.c
index a101ba3..bd6d142 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -37,6 +37,8 @@
 #include <linux/fs_struct.h>
 #include <linux/gfp.h>
 #include <linux/syscore_ops.h>
+#include <linux/version.h>
+#include <linux/ctype.h>
 
 #include <linux/compat.h>
 #include <linux/syscalls.h>
@@ -44,6 +46,8 @@
 #include <linux/user_namespace.h>
 
 #include <linux/kmsg_dump.h>
+/* Move somewhere else to avoid recompiling? */
+#include <generated/utsrelease.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -1154,6 +1158,34 @@ DECLARE_RWSEM(uts_sem);
 #define override_architecture(name)	0
 #endif
 
+/* 
+ * Work around broken programs that cannot handle "Linux 3.0".
+ * Instead we map 3.x to 2.6.40+x, so e.g. 3.0 would be 2.6.40
+ */
+static int override_release(char __user *release, int len)
+{	
+	int ret = 0;
+	char buf[len];
+
+	if (current->personality & UNAME26) {
+		char *rest = UTS_RELEASE;
+		int ndots = 0;
+		unsigned v;
+
+		while (*rest) {
+			if (*rest == '.' && ++ndots >= 3)
+				break;
+			if (!isdigit(*rest) && *rest != '.')
+				break;
+			rest++;
+		}
+		v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40;
+		snprintf(buf, len, "2.6.%u%s", v, rest);
+		ret = copy_to_user(release, buf, len);
+	}
+	return ret;
+}
+
 SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
 {
 	int errno = 0;
@@ -1163,6 +1195,8 @@ SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
 		errno = -EFAULT;
 	up_read(&uts_sem);
 
+	if (!errno && override_release(name->release, sizeof(name->release)))
+		errno = -EFAULT;
 	if (!errno && override_architecture(name))
 		errno = -EFAULT;
 	return errno;
@@ -1184,6 +1218,8 @@ SYSCALL_DEFINE1(uname, struct old_utsname __user *, name)
 		error = -EFAULT;
 	up_read(&uts_sem);
 
+	if (!error && override_release(name->release, sizeof(name->release)))
+		error = -EFAULT;
 	if (!error && override_architecture(name))
 		error = -EFAULT;
 	return error;
@@ -1218,6 +1254,8 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
 
 	if (!error && override_architecture(name))
 		error = -EFAULT;
+	if (!error && override_release(name->release, sizeof(name->release)))
+		error = -EFAULT;
 	return error ? -EFAULT : 0;
 }
 #endif
-- 
1.7.4.4


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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-19 23:15 [PATCH] Add a personality to report 2.6.x version numbers Andi Kleen
@ 2011-08-21 22:28 ` Arnaud Lacombe
  2011-08-21 22:37   ` Jesper Juhl
                     ` (2 more replies)
  2011-08-22 18:30 ` Linus Torvalds
                   ` (3 subsequent siblings)
  4 siblings, 3 replies; 35+ messages in thread
From: Arnaud Lacombe @ 2011-08-21 22:28 UTC (permalink / raw)
  To: Andi Kleen; +Cc: torvalds, akpm, linux-kernel, Andi Kleen

Hi,

On Fri, Aug 19, 2011 at 7:15 PM, Andi Kleen <andi@firstfloor.org> wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> Reposting due to popular demand. Several other people are running
> into the same problem with all kinds of software.
>
> Only change is rebase against current master.
>
FWIW, couldn't this be made a boot option ?

That might help some distros, say Fedora, who actually ships
2.6.40+x-branded kernels, or allow people to use no longer supported
distros with recent kernels.

About this last point, once functional, I intend to upgrade my trixbox
install (based on 2.6.18) to a 3.x-ish kernel, that might be fun...

Thanks,
 - Arnaud

> -Andi
>
> --
>
> I ran into a couple of programs which broke with the new Linux 3.0 version.
> Some of those were binary only. I tried to use LD_PRELOAD to work
> around it, but it was quite difficult and in one case impossible
> because of a mix of 32bit and 64bit executables.
>
> This patch adds a UNAME26 personality that makes the kernel
> report a 2.6.40+x version number instead. The x is the x in 3.x.
>
> I know this is somewhat ugly, but I didn't find a better workaround,
> and compatibility to existing programs is important.
>
> Some programs also read /proc/sys/kernel/osrelease. This can be worked
> around in user space with mount --bind (and a mount namespace)
>
> To use:
>
> wget ftp://ftp.kernel.org/pub/linux/kernel/people/ak/uname26/uname26.c
> gcc -o uname26 uname26.c
> ./uname26 program
>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
>  include/linux/personality.h |    1 +
>  kernel/sys.c                |   38 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 39 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/personality.h b/include/linux/personality.h
> index eec3bae..8fc7dd1a 100644
> --- a/include/linux/personality.h
> +++ b/include/linux/personality.h
> @@ -22,6 +22,7 @@ extern int            __set_personality(unsigned int);
>  * These occupy the top three bytes.
>  */
>  enum {
> +       UNAME26 =               0x0020000,
>        ADDR_NO_RANDOMIZE =     0x0040000,      /* disable randomization of VA space */
>        FDPIC_FUNCPTRS =        0x0080000,      /* userspace function ptrs point to descriptors
>                                                 * (signal handling)
> diff --git a/kernel/sys.c b/kernel/sys.c
> index a101ba3..bd6d142 100644
> --- a/kernel/sys.c
> +++ b/kernel/sys.c
> @@ -37,6 +37,8 @@
>  #include <linux/fs_struct.h>
>  #include <linux/gfp.h>
>  #include <linux/syscore_ops.h>
> +#include <linux/version.h>
> +#include <linux/ctype.h>
>
>  #include <linux/compat.h>
>  #include <linux/syscalls.h>
> @@ -44,6 +46,8 @@
>  #include <linux/user_namespace.h>
>
>  #include <linux/kmsg_dump.h>
> +/* Move somewhere else to avoid recompiling? */
> +#include <generated/utsrelease.h>
>
>  #include <asm/uaccess.h>
>  #include <asm/io.h>
> @@ -1154,6 +1158,34 @@ DECLARE_RWSEM(uts_sem);
>  #define override_architecture(name)    0
>  #endif
>
> +/*
> + * Work around broken programs that cannot handle "Linux 3.0".
> + * Instead we map 3.x to 2.6.40+x, so e.g. 3.0 would be 2.6.40
> + */
> +static int override_release(char __user *release, int len)
> +{
> +       int ret = 0;
> +       char buf[len];
> +
> +       if (current->personality & UNAME26) {
> +               char *rest = UTS_RELEASE;
> +               int ndots = 0;
> +               unsigned v;
> +
> +               while (*rest) {
> +                       if (*rest == '.' && ++ndots >= 3)
> +                               break;
> +                       if (!isdigit(*rest) && *rest != '.')
> +                               break;
> +                       rest++;
> +               }
> +               v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40;
> +               snprintf(buf, len, "2.6.%u%s", v, rest);
> +               ret = copy_to_user(release, buf, len);
> +       }
> +       return ret;
> +}
> +
>  SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
>  {
>        int errno = 0;
> @@ -1163,6 +1195,8 @@ SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
>                errno = -EFAULT;
>        up_read(&uts_sem);
>
> +       if (!errno && override_release(name->release, sizeof(name->release)))
> +               errno = -EFAULT;
>        if (!errno && override_architecture(name))
>                errno = -EFAULT;
>        return errno;
> @@ -1184,6 +1218,8 @@ SYSCALL_DEFINE1(uname, struct old_utsname __user *, name)
>                error = -EFAULT;
>        up_read(&uts_sem);
>
> +       if (!error && override_release(name->release, sizeof(name->release)))
> +               error = -EFAULT;
>        if (!error && override_architecture(name))
>                error = -EFAULT;
>        return error;
> @@ -1218,6 +1254,8 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
>
>        if (!error && override_architecture(name))
>                error = -EFAULT;
> +       if (!error && override_release(name->release, sizeof(name->release)))
> +               error = -EFAULT;
>        return error ? -EFAULT : 0;
>  }
>  #endif
> --
> 1.7.4.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-21 22:28 ` Arnaud Lacombe
@ 2011-08-21 22:37   ` Jesper Juhl
  2011-08-21 23:15     ` Andi Kleen
  2011-08-21 23:13   ` Andi Kleen
  2011-08-22  9:54   ` Américo Wang
  2 siblings, 1 reply; 35+ messages in thread
From: Jesper Juhl @ 2011-08-21 22:37 UTC (permalink / raw)
  To: Arnaud Lacombe; +Cc: Andi Kleen, torvalds, akpm, linux-kernel, Andi Kleen

On Sun, 21 Aug 2011, Arnaud Lacombe wrote:

> Hi,
> 
> On Fri, Aug 19, 2011 at 7:15 PM, Andi Kleen <andi@firstfloor.org> wrote:
> > From: Andi Kleen <ak@linux.intel.com>
> >
> > Reposting due to popular demand. Several other people are running
> > into the same problem with all kinds of software.
> >
> > Only change is rebase against current master.
> >
> FWIW, couldn't this be made a boot option ?
> 
> That might help some distros, say Fedora, who actually ships
> 2.6.40+x-branded kernels, or allow people to use no longer supported
> distros with recent kernels.
> 
> About this last point, once functional, I intend to upgrade my trixbox
> install (based on 2.6.18) to a 3.x-ish kernel, that might be fun...
> 

Just a random thought.
Since this is purely to be backwards compatible with binary only software 
that makes bad assumptions about the kernel version (as far as I can 
tell at least), shouldn't we make it explicit from the beginning that this 
will have a limited life time by adding it to 
Documentation/feature-removal-schedule.txt with a removal date at 
somewhere soon(ish) like 3.6 (or something) at day one?
I can't imaging we'd want to support something like this forever going 
forward... or..?

-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-21 22:28 ` Arnaud Lacombe
  2011-08-21 22:37   ` Jesper Juhl
@ 2011-08-21 23:13   ` Andi Kleen
  2011-08-21 23:32     ` Arnaud Lacombe
  2011-08-22  9:54   ` Américo Wang
  2 siblings, 1 reply; 35+ messages in thread
From: Andi Kleen @ 2011-08-21 23:13 UTC (permalink / raw)
  To: Arnaud Lacombe; +Cc: Andi Kleen, torvalds, akpm, linux-kernel, Andi Kleen

On Sun, Aug 21, 2011 at 06:28:28PM -0400, Arnaud Lacombe wrote:
> Hi,
> 
> On Fri, Aug 19, 2011 at 7:15 PM, Andi Kleen <andi@firstfloor.org> wrote:
> > From: Andi Kleen <ak@linux.intel.com>
> >
> > Reposting due to popular demand. Several other people are running
> > into the same problem with all kinds of software.
> >
> > Only change is rebase against current master.
> >
> FWIW, couldn't this be made a boot option ?

init=/script/that/runs/uname26/sbin/init

-Andi

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-21 22:37   ` Jesper Juhl
@ 2011-08-21 23:15     ` Andi Kleen
  0 siblings, 0 replies; 35+ messages in thread
From: Andi Kleen @ 2011-08-21 23:15 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Arnaud Lacombe, Andi Kleen, torvalds, akpm, linux-kernel, Andi Kleen

On Mon, Aug 22, 2011 at 12:37:05AM +0200, Jesper Juhl wrote:
> On Sun, 21 Aug 2011, Arnaud Lacombe wrote:
> 
> > Hi,
> > 
> > On Fri, Aug 19, 2011 at 7:15 PM, Andi Kleen <andi@firstfloor.org> wrote:
> > > From: Andi Kleen <ak@linux.intel.com>
> > >
> > > Reposting due to popular demand. Several other people are running
> > > into the same problem with all kinds of software.
> > >
> > > Only change is rebase against current master.
> > >
> > FWIW, couldn't this be made a boot option ?
> > 
> > That might help some distros, say Fedora, who actually ships
> > 2.6.40+x-branded kernels, or allow people to use no longer supported
> > distros with recent kernels.
> > 
> > About this last point, once functional, I intend to upgrade my trixbox
> > install (based on 2.6.18) to a 3.x-ish kernel, that might be fun...
> > 
> 
> Just a random thought.
> Since this is purely to be backwards compatible with binary only software 
> that makes bad assumptions about the kernel version (as far as I can 

Believe it or not, even users of programs with source do not necessarily
want or are able to to patch the program and recompile.

Also binary compatibility is important. It's one of the things
that made Linux successfull.

> tell at least), shouldn't we make it explicit from the beginning that this 
> will have a limited life time by adding it to 

No.

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only.

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-21 23:13   ` Andi Kleen
@ 2011-08-21 23:32     ` Arnaud Lacombe
  2011-08-22  0:11       ` Andi Kleen
  0 siblings, 1 reply; 35+ messages in thread
From: Arnaud Lacombe @ 2011-08-21 23:32 UTC (permalink / raw)
  To: Andi Kleen; +Cc: torvalds, akpm, linux-kernel, Andi Kleen

Hi,

On Sun, Aug 21, 2011 at 7:13 PM, Andi Kleen <andi@firstfloor.org> wrote:
> On Sun, Aug 21, 2011 at 06:28:28PM -0400, Arnaud Lacombe wrote:
>> Hi,
>>
>> On Fri, Aug 19, 2011 at 7:15 PM, Andi Kleen <andi@firstfloor.org> wrote:
>> > From: Andi Kleen <ak@linux.intel.com>
>> >
>> > Reposting due to popular demand. Several other people are running
>> > into the same problem with all kinds of software.
>> >
>> > Only change is rebase against current master.
>> >
>> FWIW, couldn't this be made a boot option ?
>
> init=/script/that/runs/uname26/sbin/init
>
It does not work if / on a ROM, unless you start using trampoline
partition, but this is starting to become really convoluted...

 - Arnaud

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-21 23:32     ` Arnaud Lacombe
@ 2011-08-22  0:11       ` Andi Kleen
  2011-08-22  1:04         ` Arnaud Lacombe
  0 siblings, 1 reply; 35+ messages in thread
From: Andi Kleen @ 2011-08-22  0:11 UTC (permalink / raw)
  To: Arnaud Lacombe; +Cc: Andi Kleen, torvalds, akpm, linux-kernel, Andi Kleen

> It does not work if / on a ROM, unless you start using trampoline
> partition, but this is starting to become really convoluted...

On a ROM you never change the kernel.

Besides who uses ROMs now when there is flash?

-Andi

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-22  0:11       ` Andi Kleen
@ 2011-08-22  1:04         ` Arnaud Lacombe
  2011-08-22  1:46           ` Andi Kleen
  0 siblings, 1 reply; 35+ messages in thread
From: Arnaud Lacombe @ 2011-08-22  1:04 UTC (permalink / raw)
  To: Andi Kleen; +Cc: torvalds, akpm, linux-kernel, Andi Kleen

Hi,

On Sun, Aug 21, 2011 at 8:11 PM, Andi Kleen <andi@firstfloor.org> wrote:
>> It does not work if / on a ROM, unless you start using trampoline
>> partition, but this is starting to become really convoluted...
>
> On a ROM you never change the kernel.
>
For this particular board, the kernel is on a small read-write NOR
flash, and the userland on write-protected NAND chip.

> Besides who uses ROMs now when there is flash?
>
this is totally irrelevant to the problem...

 - Arnaud

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-22  1:04         ` Arnaud Lacombe
@ 2011-08-22  1:46           ` Andi Kleen
  0 siblings, 0 replies; 35+ messages in thread
From: Andi Kleen @ 2011-08-22  1:46 UTC (permalink / raw)
  To: Arnaud Lacombe; +Cc: Andi Kleen, torvalds, akpm, linux-kernel, Andi Kleen

On Sun, Aug 21, 2011 at 09:04:04PM -0400, Arnaud Lacombe wrote:
> Hi,
> 
> On Sun, Aug 21, 2011 at 8:11 PM, Andi Kleen <andi@firstfloor.org> wrote:
> >> It does not work if / on a ROM, unless you start using trampoline
> >> partition, but this is starting to become really convoluted...
> >
> > On a ROM you never change the kernel.
> >
> For this particular board, the kernel is on a small read-write NOR
> flash, and the userland on write-protected NAND chip.

You can use a initrd

And hopefully it's not connected to any network, because you can't
fix any security holes.

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only.

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-21 22:28 ` Arnaud Lacombe
  2011-08-21 22:37   ` Jesper Juhl
  2011-08-21 23:13   ` Andi Kleen
@ 2011-08-22  9:54   ` Américo Wang
  2 siblings, 0 replies; 35+ messages in thread
From: Américo Wang @ 2011-08-22  9:54 UTC (permalink / raw)
  To: Arnaud Lacombe; +Cc: Andi Kleen, torvalds, akpm, linux-kernel, Andi Kleen

On Mon, Aug 22, 2011 at 6:28 AM, Arnaud Lacombe <lacombar@gmail.com> wrote:
> Hi,
>
> On Fri, Aug 19, 2011 at 7:15 PM, Andi Kleen <andi@firstfloor.org> wrote:
>> From: Andi Kleen <ak@linux.intel.com>
>>
>> Reposting due to popular demand. Several other people are running
>> into the same problem with all kinds of software.
>>
>> Only change is rebase against current master.
>>
> FWIW, couldn't this be made a boot option ?

A boot parameter to change kernel version sounds odd.

>
> That might help some distros, say Fedora, who actually ships
> 2.6.40+x-branded kernels, or allow people to use no longer supported
> distros with recent kernels.
>
> About this last point, once functional, I intend to upgrade my trixbox
> install (based on 2.6.18) to a 3.x-ish kernel, that might be fun...
>

Then a Kconfig option would help.

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-19 23:15 [PATCH] Add a personality to report 2.6.x version numbers Andi Kleen
  2011-08-21 22:28 ` Arnaud Lacombe
@ 2011-08-22 18:30 ` Linus Torvalds
  2011-08-22 18:45   ` Eric Dumazet
                     ` (3 more replies)
  2011-08-23  6:00 ` [PATCH] setarch: Add --uname-2.6 option for personality flag UNAME26 Ben Hutchings
                   ` (2 subsequent siblings)
  4 siblings, 4 replies; 35+ messages in thread
From: Linus Torvalds @ 2011-08-22 18:30 UTC (permalink / raw)
  To: Andi Kleen; +Cc: akpm, linux-kernel, Andi Kleen

On Fri, Aug 19, 2011 at 4:15 PM, Andi Kleen <andi@firstfloor.org> wrote:
>
> Reposting due to popular demand. Several other people are running
> into the same problem with all kinds of software.

I have heard this several times now, but nobody actually ever says
*what* is broken.

The Fedora people seem to have done the 2.6.40 thing without any
actual reason, for example (the two programs they claim were broken
were things that they had already fixed in rawhide, afaik).

I'm not at all interested in these kinds of "all kinds of software" reports.

Details. Examples. Name the f&*cking names already. Shame them publicly.

                         Linus

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-22 18:30 ` Linus Torvalds
@ 2011-08-22 18:45   ` Eric Dumazet
  2011-08-22 19:03     ` David Daney
  2011-08-22 19:34   ` Andi Kleen
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 35+ messages in thread
From: Eric Dumazet @ 2011-08-22 18:45 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andi Kleen, akpm, linux-kernel, Andi Kleen

Le lundi 22 août 2011 à 11:30 -0700, Linus Torvalds a écrit :
> On Fri, Aug 19, 2011 at 4:15 PM, Andi Kleen <andi@firstfloor.org> wrote:
> >
> > Reposting due to popular demand. Several other people are running
> > into the same problem with all kinds of software.
> 
> I have heard this several times now, but nobody actually ever says
> *what* is broken.
> 
> The Fedora people seem to have done the 2.6.40 thing without any
> actual reason, for example (the two programs they claim were broken
> were things that they had already fixed in rawhide, afaik).
> 
> I'm not at all interested in these kinds of "all kinds of software" reports.
> 
> Details. Examples. Name the f&*cking names already. Shame them publicly.

For example, all kind of management software from HP doesnt work, unless
we pretend to run a 2.6 kernel.

$ uname -a
Linux svivoipvnx001 3.0.0-08107-g97cd98f #1062 SMP Fri Aug 12 18:11:45
CEST 2011 i686 i686 i386 GNU/Linux

$ hpacucli ctrl all show

Error: No controllers detected.

$ rpm -qf /usr/sbin/hpacucli
hpacucli-8.75-12.0



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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-22 18:45   ` Eric Dumazet
@ 2011-08-22 19:03     ` David Daney
  0 siblings, 0 replies; 35+ messages in thread
From: David Daney @ 2011-08-22 19:03 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Linus Torvalds, Andi Kleen, akpm, linux-kernel, Andi Kleen

On 08/22/2011 11:45 AM, Eric Dumazet wrote:
> Le lundi 22 août 2011 à 11:30 -0700, Linus Torvalds a écrit :
>> On Fri, Aug 19, 2011 at 4:15 PM, Andi Kleen<andi@firstfloor.org>  wrote:
>>>
>>> Reposting due to popular demand. Several other people are running
>>> into the same problem with all kinds of software.
>>
>> I have heard this several times now, but nobody actually ever says
>> *what* is broken.
>>
>> The Fedora people seem to have done the 2.6.40 thing without any
>> actual reason, for example (the two programs they claim were broken
>> were things that they had already fixed in rawhide, afaik).
>>
>> I'm not at all interested in these kinds of "all kinds of software" reports.
>>
>> Details. Examples. Name the f&*cking names already. Shame them publicly.
>
> For example, all kind of management software from HP doesnt work, unless
> we pretend to run a 2.6 kernel.
>
> $ uname -a
> Linux svivoipvnx001 3.0.0-08107-g97cd98f #1062 SMP Fri Aug 12 18:11:45
> CEST 2011 i686 i686 i386 GNU/Linux
>
> $ hpacucli ctrl all show
>
> Error: No controllers detected.
>

Perhaps the 3.x version change patch should be reverted on the 
never-ever-break-userspace grounds. :-)  It would appear that the 2.6 
version information has become a de facto part of the kernel's ABI.

David Daney

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-22 18:30 ` Linus Torvalds
  2011-08-22 18:45   ` Eric Dumazet
@ 2011-08-22 19:34   ` Andi Kleen
  2011-08-23 13:15   ` Colin Walters
  2011-09-13 14:12   ` Pavel Machek
  3 siblings, 0 replies; 35+ messages in thread
From: Andi Kleen @ 2011-08-22 19:34 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andi Kleen, akpm, linux-kernel, Andi Kleen, dmueller

> Details. Examples. Name the f&*cking names already. Shame them publicly.

My original motivation for this was pin (http://www.pintool.org/)
However that got fixed in pin after I posted v1.

Then people kept emailing me that they had their own applications with
similar problems. I don't have a lot of details on those, but I hope others
will chime in on this thread.

e.g. Dirk claimed he had a bunch. Dirk?

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only.

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

* [PATCH] setarch: Add --uname-2.6 option for personality flag UNAME26
  2011-08-19 23:15 [PATCH] Add a personality to report 2.6.x version numbers Andi Kleen
  2011-08-21 22:28 ` Arnaud Lacombe
  2011-08-22 18:30 ` Linus Torvalds
@ 2011-08-23  6:00 ` Ben Hutchings
  2011-08-23 10:16   ` Karel Zak
  2011-08-29  9:17   ` Karel Zak
  2011-08-23 12:44 ` [PATCH] Add a personality to report 2.6.x version numbers Arnd Bergmann
  2011-08-26 21:43 ` Greg KH
  4 siblings, 2 replies; 35+ messages in thread
From: Ben Hutchings @ 2011-08-23  6:00 UTC (permalink / raw)
  To: Andi Kleen; +Cc: torvalds, akpm, linux-kernel, Andi Kleen, util-linux

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
On Fri, 2011-08-19 at 16:15 -0700, Andi Kleen wrote:
[...]
> To use:
> 
> wget ftp://ftp.kernel.org/pub/linux/kernel/people/ak/uname26/uname26.c
> gcc -o uname26 uname26.c
> ./uname26 program
[...]

I would suggest adding this to setarch, as that handles all the other
personality flags.  The following patch to util-linux seems to do the
trick.

Ben.

 configure.ac        |    1 +
 sys-utils/setarch.8 |    3 +++
 sys-utils/setarch.c |   12 +++++++++++-
 3 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 0d3b889..51d06fd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -792,6 +792,7 @@ AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec],,,
 	[#include <sys/stat.h>])
 
 AC_CHECK_DECLS([
+ UNAME26,
  ADDR_NO_RANDOMIZE,
  FDPIC_FUNCPTRS,
  MMAP_PAGE_ZERO,
diff --git a/sys-utils/setarch.8 b/sys-utils/setarch.8
index 0764a45..b6f5b77 100644
--- a/sys-utils/setarch.8
+++ b/sys-utils/setarch.8
@@ -29,6 +29,9 @@ Be verbose.
 .I "\-h," "\-\-help"
 Display help (it is also displayed when setarch takes no arguments).
 .TP
+.I "\-\-uname\-2.6"
+Causes the program to see a kernel version number beginning with 2.6.
+.TP
 .I "\-3," "\-\-3gb"
 Specifies that processes should use a maximum of 3GB of address space on systems where it is supported (ADDR_LIMIT_3GB).
 .TP
diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c
index 35efca4..b53bf36 100644
--- a/sys-utils/setarch.c
+++ b/sys-utils/setarch.c
@@ -41,6 +41,8 @@
 /* Option --4gb has no equivalent short option, use a non-character as a
    pseudo short option. */
 #define OPT_4GB (CHAR_MAX+1)
+/* Similarly for --uname-2.6 */
+#define OPT_UNAME26 (OPT_4GB+1)
 
 #define turn_on(_flag, _opts) \
 	do { \
@@ -50,6 +52,9 @@
 	} while(0)
 

+#if !HAVE_DECL_UNAME26
+# define UNAME26                 0x0020000
+#endif
 #if !HAVE_DECL_ADDR_NO_RANDOMIZE
 # define ADDR_NO_RANDOMIZE       0x0040000
 #endif
@@ -98,6 +103,7 @@ static const struct option longopts[] =
     { "sticky-timeouts",    0, 0, 'T' },
     { "3gb",                0, 0, '3' },
     { "4gb",                0, 0, OPT_4GB },
+    { "uname-2.6",          0, 0, OPT_UNAME26 },
     { NULL,                 0, 0, 0 }
 };
 
@@ -125,7 +131,8 @@ show_help(void)
    " -S, --whole-seconds      turns on WHOLE_SECONDS\n"
    " -T, --sticky-timeouts    turns on STICKY_TIMEOUTS\n"
    " -3, --3gb                limits the used address space to a maximum of 3 GB\n"
-   "     --4gb                ignored (for backward compatibility only)\n"));
+   "     --4gb                ignored (for backward compatibility only)\n"
+   "     --uname-2.6          turns on UNAME26\n"));
 
   printf(_("\nFor more information see setarch(8).\n"));
   exit(EXIT_SUCCESS);
@@ -306,6 +313,9 @@ int main(int argc, char *argv[])
 	break;
     case OPT_4GB:          /* just ignore this one */
       break;
+    case OPT_UNAME26:
+	turn_on(UNAME26, options);
+	break;
     }
   }
 
-- 
1.7.5.4



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

* Re: [PATCH] setarch: Add --uname-2.6 option for personality flag UNAME26
  2011-08-23  6:00 ` [PATCH] setarch: Add --uname-2.6 option for personality flag UNAME26 Ben Hutchings
@ 2011-08-23 10:16   ` Karel Zak
  2011-08-23 12:15     ` Ben Hutchings
  2011-08-26 21:43     ` Greg KH
  2011-08-29  9:17   ` Karel Zak
  1 sibling, 2 replies; 35+ messages in thread
From: Karel Zak @ 2011-08-23 10:16 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: Andi Kleen, torvalds, akpm, linux-kernel, Andi Kleen, util-linux

On Tue, Aug 23, 2011 at 07:00:01AM +0100, Ben Hutchings wrote:
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> ---
> On Fri, 2011-08-19 at 16:15 -0700, Andi Kleen wrote:
> [...]
> > To use:
> > 
> > wget ftp://ftp.kernel.org/pub/linux/kernel/people/ak/uname26/uname26.c
> > gcc -o uname26 uname26.c
> > ./uname26 program
> [...]
> 
> I would suggest adding this to setarch, as that handles all the other
> personality flags.  The following patch to util-linux seems to do the
> trick.

 I have one simple rule: "Linus' tree first", and I don't see UNAME26
 in include/linux/personality.h ...

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

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

* Re: [PATCH] setarch: Add --uname-2.6 option for personality flag UNAME26
  2011-08-23 10:16   ` Karel Zak
@ 2011-08-23 12:15     ` Ben Hutchings
  2011-08-26 21:43     ` Greg KH
  1 sibling, 0 replies; 35+ messages in thread
From: Ben Hutchings @ 2011-08-23 12:15 UTC (permalink / raw)
  To: Karel Zak
  Cc: Andi Kleen, torvalds, akpm, linux-kernel, Andi Kleen, util-linux

[-- Attachment #1: Type: text/plain, Size: 807 bytes --]

On Tue, 2011-08-23 at 12:16 +0200, Karel Zak wrote:
> On Tue, Aug 23, 2011 at 07:00:01AM +0100, Ben Hutchings wrote:
> > Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> > ---
> > On Fri, 2011-08-19 at 16:15 -0700, Andi Kleen wrote:
> > [...]
> > > To use:
> > > 
> > > wget ftp://ftp.kernel.org/pub/linux/kernel/people/ak/uname26/uname26.c
> > > gcc -o uname26 uname26.c
> > > ./uname26 program
> > [...]
> > 
> > I would suggest adding this to setarch, as that handles all the other
> > personality flags.  The following patch to util-linux seems to do the
> > trick.
> 
>  I have one simple rule: "Linus' tree first", and I don't see UNAME26
>  in include/linux/personality.h ...

Sure, I don't expect this to be applied until and unless Linus takes the
kernel patch.

Ben.


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-19 23:15 [PATCH] Add a personality to report 2.6.x version numbers Andi Kleen
                   ` (2 preceding siblings ...)
  2011-08-23  6:00 ` [PATCH] setarch: Add --uname-2.6 option for personality flag UNAME26 Ben Hutchings
@ 2011-08-23 12:44 ` Arnd Bergmann
  2011-08-26 21:43 ` Greg KH
  4 siblings, 0 replies; 35+ messages in thread
From: Arnd Bergmann @ 2011-08-23 12:44 UTC (permalink / raw)
  To: Andi Kleen; +Cc: torvalds, akpm, linux-kernel, Andi Kleen

On Saturday 20 August 2011, Andi Kleen wrote:
> I ran into a couple of programs which broke with the new Linux 3.0 version.
> Some of those were binary only. I tried to use LD_PRELOAD to work
> around it, but it was quite difficult and in one case impossible
> because of a mix of 32bit and 64bit executables.

I guess another option would be to add a new sys_newnewuname syscall
and change glibc. You could use symbol versioning so that
old applications continue to see the 2.6.x version numbers, while
anything that is built against a new glibc would see the true
version.
 
> This patch adds a UNAME26 personality that makes the kernel
> report a 2.6.40+x version number instead. The x is the x in 3.x.

Why not just always return 3.6.39 or 2.6.40 hardcoded? If an application
does not understand the concept of future kernel versions, it won't need
to know which future version it's running on.
 
	Arnd

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-22 18:30 ` Linus Torvalds
  2011-08-22 18:45   ` Eric Dumazet
  2011-08-22 19:34   ` Andi Kleen
@ 2011-08-23 13:15   ` Colin Walters
  2011-08-23 16:11     ` Andi Kleen
  2011-08-24 14:19     ` Alexey Dobriyan
  2011-09-13 14:12   ` Pavel Machek
  3 siblings, 2 replies; 35+ messages in thread
From: Colin Walters @ 2011-08-23 13:15 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andi Kleen, akpm, linux-kernel, Andi Kleen

On Mon, Aug 22, 2011 at 2:30 PM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:

> Details. Examples. Name the f&*cking names already. Shame them publicly.

A notable one is that Python now reports "linux3" from sys.platform();
which in turn can break things that were checking sys.platform() ==
"linux2".

https://bugzilla.mozilla.org/show_bug.cgi?id=664564

Seems pretty clear to me though it's a bug in the apps that are using
'==' instead of .startswith().

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-23 13:15   ` Colin Walters
@ 2011-08-23 16:11     ` Andi Kleen
  2011-08-23 16:20       ` Colin Walters
  2011-08-24 14:19     ` Alexey Dobriyan
  1 sibling, 1 reply; 35+ messages in thread
From: Andi Kleen @ 2011-08-23 16:11 UTC (permalink / raw)
  To: Colin Walters; +Cc: Linus Torvalds, Andi Kleen, akpm, linux-kernel


> A notable one is that Python now reports "linux3" from sys.platform();
> which in turn can break things that were checking sys.platform() ==
> "linux2".
>
> https://bugzilla.mozilla.org/show_bug.cgi?id=664564
>
> Seems pretty clear to me though it's a bug in the apps that are using
> '==' instead of .startswith().

That's a good point. I googled for this pattern in google codesearch
and there are 10+ in the first two pages.

http://www.google.com/codesearch#search/&q=lang:^python$%20sys.platform%20linux2&p=1&type=cs

-andi



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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-23 16:11     ` Andi Kleen
@ 2011-08-23 16:20       ` Colin Walters
  2011-08-23 17:35         ` Arnaud Lacombe
  0 siblings, 1 reply; 35+ messages in thread
From: Colin Walters @ 2011-08-23 16:20 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Linus Torvalds, Andi Kleen, akpm, linux-kernel

On Tue, Aug 23, 2011 at 12:11 PM, Andi Kleen <ak@linux.intel.com> wrote:
>
> That's a good point. I googled for this pattern in google codesearch
> and there are 10+ in the first two pages.
>
> http://www.google.com/codesearch#search/&q=lang:^python$%20sys.platform%20linux2&p=1&type=cs

Yes, though I should note I wasn't trying to defend having a
compatibility sysctl or whatever - I think it's clear these apps are
broken.  The python docs explicitly say that the returned string is
just a straightforward transformation of uname, and if the apps read
that carefully they'd realize they only want the first part.

The reportlab example will break for FreeBSD 5 too:

     elif sys.platform in ("freebsd4", "darwin", "mac", "linux2"):

I just happen to watch Mozilla bugzilla so I saw that one go by and
wanted to provide data for the discussion.

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-23 16:20       ` Colin Walters
@ 2011-08-23 17:35         ` Arnaud Lacombe
  0 siblings, 0 replies; 35+ messages in thread
From: Arnaud Lacombe @ 2011-08-23 17:35 UTC (permalink / raw)
  To: Colin Walters; +Cc: Andi Kleen, Linus Torvalds, Andi Kleen, akpm, linux-kernel

Hi,

On Tue, Aug 23, 2011 at 12:20 PM, Colin Walters <walters@verbum.org> wrote:
> [...]
> I just happen to watch Mozilla bugzilla so I saw that one go by and
> wanted to provide data for the discussion.
>
Just to provide fuel, you can also just do a regular google search for
"strncmp release 2.6". Lots of exploits, but not only.

 - Arnaud

> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-23 13:15   ` Colin Walters
  2011-08-23 16:11     ` Andi Kleen
@ 2011-08-24 14:19     ` Alexey Dobriyan
  2011-08-24 17:02       ` Arnd Bergmann
  1 sibling, 1 reply; 35+ messages in thread
From: Alexey Dobriyan @ 2011-08-24 14:19 UTC (permalink / raw)
  To: Colin Walters; +Cc: Linus Torvalds, Andi Kleen, akpm, linux-kernel, Andi Kleen

On Tue, Aug 23, 2011 at 4:15 PM, Colin Walters <walters@verbum.org> wrote:
> Seems pretty clear to me though it's a bug in the apps that are using
> '==' instead of .startswith().

This doesn't count under "no userspace breakage" doctrine.
Or rather, it shouldn't.

valgrind _compilation_ was broken by 3.0:
11 	*valgrind-3.6.1-r1 (09 Jun 2011)
12 	
13 	09 Jun 2011; Anthony G. Basile <blueness@gentoo.org>
14 	+valgrind-3.6.1-r1.ebuild, +files/valgrind-3.6.1-linux-3.patch:
15 	Fixed to build against linux-3.x, bug #370857

Was this fixed? Yes.
Will this break one more time? Of course!

         case "${kernel}" in
-             2.6.*)
+             2.6.*|3.*)
         	    AC_MSG_RESULT([2.6 family (${kernel})])

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-24 14:19     ` Alexey Dobriyan
@ 2011-08-24 17:02       ` Arnd Bergmann
  0 siblings, 0 replies; 35+ messages in thread
From: Arnd Bergmann @ 2011-08-24 17:02 UTC (permalink / raw)
  To: Alexey Dobriyan
  Cc: Colin Walters, Linus Torvalds, Andi Kleen, akpm, linux-kernel,
	Andi Kleen

On Wednesday 24 August 2011, Alexey Dobriyan wrote:
> Was this fixed? Yes.
> Will this break one more time? Of course!
> 
>          case "${kernel}" in
> -             2.6.*)
> +             2.6.*|3.*)
>                     AC_MSG_RESULT([2.6 family (${kernel})])

What you need is an exaustive list of past versions plus
a catch-all for future versions:

	case "${kernel}" in
		1.*|2.0.*|2.1.*|2.2.*|2.3.*)
			echo "too old"
			;;
		2.4.*)
			echo "Linux-2.4 style"
			;;
		2.5.*)
			echo "unstable and not supported"
			;;
		*)
			echo "2.6 or newer"
			;;
	esac

We don't break ABIs as a rule, so you should always assume
that a newer version will keep working.

	Arnd

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-19 23:15 [PATCH] Add a personality to report 2.6.x version numbers Andi Kleen
                   ` (3 preceding siblings ...)
  2011-08-23 12:44 ` [PATCH] Add a personality to report 2.6.x version numbers Arnd Bergmann
@ 2011-08-26 21:43 ` Greg KH
  2011-08-26 22:25   ` Andi Kleen
  4 siblings, 1 reply; 35+ messages in thread
From: Greg KH @ 2011-08-26 21:43 UTC (permalink / raw)
  To: Andi Kleen; +Cc: torvalds, akpm, linux-kernel, Andi Kleen

On Fri, Aug 19, 2011 at 04:15:10PM -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
> 
> Reposting due to popular demand. Several other people are running
> into the same problem with all kinds of software.
> 
> Only change is rebase against current master.
> 
> -Andi
> 
> --
> 
> I ran into a couple of programs which broke with the new Linux 3.0 version.
> Some of those were binary only. I tried to use LD_PRELOAD to work
> around it, but it was quite difficult and in one case impossible
> because of a mix of 32bit and 64bit executables.
> 
> This patch adds a UNAME26 personality that makes the kernel
> report a 2.6.40+x version number instead. The x is the x in 3.x.
> 
> I know this is somewhat ugly, but I didn't find a better workaround,
> and compatibility to existing programs is important.
> 
> Some programs also read /proc/sys/kernel/osrelease. This can be worked
> around in user space with mount --bind (and a mount namespace)
> 
> To use:
> 
> wget ftp://ftp.kernel.org/pub/linux/kernel/people/ak/uname26/uname26.c
> gcc -o uname26 uname26.c
> ./uname26 program

I hate to ask, but can you put a proper copyright and license on this
file so that distros can distribute it?

thanks,

greg k-h

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

* Re: [PATCH] setarch: Add --uname-2.6 option for personality flag UNAME26
  2011-08-23 10:16   ` Karel Zak
  2011-08-23 12:15     ` Ben Hutchings
@ 2011-08-26 21:43     ` Greg KH
  1 sibling, 0 replies; 35+ messages in thread
From: Greg KH @ 2011-08-26 21:43 UTC (permalink / raw)
  To: Karel Zak
  Cc: Ben Hutchings, Andi Kleen, torvalds, akpm, linux-kernel,
	Andi Kleen, util-linux

On Tue, Aug 23, 2011 at 12:16:01PM +0200, Karel Zak wrote:
> On Tue, Aug 23, 2011 at 07:00:01AM +0100, Ben Hutchings wrote:
> > Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> > ---
> > On Fri, 2011-08-19 at 16:15 -0700, Andi Kleen wrote:
> > [...]
> > > To use:
> > > 
> > > wget ftp://ftp.kernel.org/pub/linux/kernel/people/ak/uname26/uname26.c
> > > gcc -o uname26 uname26.c
> > > ./uname26 program
> > [...]
> > 
> > I would suggest adding this to setarch, as that handles all the other
> > personality flags.  The following patch to util-linux seems to do the
> > trick.
> 
>  I have one simple rule: "Linus' tree first", and I don't see UNAME26
>  in include/linux/personality.h ...

It's in Linus's tree now, and will be in the next 3.0.y stable release.

thanks,

greg k-h

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-26 21:43 ` Greg KH
@ 2011-08-26 22:25   ` Andi Kleen
  2011-08-26 22:35     ` Greg KH
  2011-08-27 16:36     ` Jesper Juhl
  0 siblings, 2 replies; 35+ messages in thread
From: Andi Kleen @ 2011-08-26 22:25 UTC (permalink / raw)
  To: Greg KH; +Cc: Andi Kleen, torvalds, akpm, linux-kernel, Andi Kleen

> > wget ftp://ftp.kernel.org/pub/linux/kernel/people/ak/uname26/uname26.c
> > gcc -o uname26 uname26.c
> > ./uname26 program
> 
> I hate to ask, but can you put a proper copyright and license on this
> file so that distros can distribute it?

I assumed it's too trivial for that.

Anyways I put a GPL license on it now.

-Andi

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-26 22:25   ` Andi Kleen
@ 2011-08-26 22:35     ` Greg KH
  2011-08-27 16:36     ` Jesper Juhl
  1 sibling, 0 replies; 35+ messages in thread
From: Greg KH @ 2011-08-26 22:35 UTC (permalink / raw)
  To: Andi Kleen; +Cc: torvalds, akpm, linux-kernel, Andi Kleen

On Sat, Aug 27, 2011 at 12:25:44AM +0200, Andi Kleen wrote:
> > > wget ftp://ftp.kernel.org/pub/linux/kernel/people/ak/uname26/uname26.c
> > > gcc -o uname26 uname26.c
> > > ./uname26 program
> > 
> > I hate to ask, but can you put a proper copyright and license on this
> > file so that distros can distribute it?
> 
> I assumed it's too trivial for that.

Lawyers never assume that :)

> Anyways I put a GPL license on it now.

Thanks, much appreciated.

greg k-h

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-26 22:25   ` Andi Kleen
  2011-08-26 22:35     ` Greg KH
@ 2011-08-27 16:36     ` Jesper Juhl
  1 sibling, 0 replies; 35+ messages in thread
From: Jesper Juhl @ 2011-08-27 16:36 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Greg KH, torvalds, akpm, linux-kernel, Andi Kleen

On Sat, 27 Aug 2011, Andi Kleen wrote:

> > > wget ftp://ftp.kernel.org/pub/linux/kernel/people/ak/uname26/uname26.c
> > > gcc -o uname26 uname26.c
> > > ./uname26 program
> > 
> > I hate to ask, but can you put a proper copyright and license on this
> > file so that distros can distribute it?
> 
> I assumed it's too trivial for that.
> 
> Anyways I put a GPL license on it now.
> 

Hi Andi

I assume the mention of "mcelog" is a cut'n'paste error and that it really 
should have been "uname26", so here's a trivial patch to correct that.
I also deleted all trailing whitespace and used EXIT_FAILURE rather than 1 
for exit().

Take it or leave it :)

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---

--- uname26.c.orig	2011-08-27 18:26:46.538017670 +0200
+++ uname26.c	2011-08-27 18:32:21.032163525 +0200
@@ -1,19 +1,19 @@
-/* Copyright (C) 2011 Intel Corporation 
+/* Copyright (C) 2011 Intel Corporation
    Author: Andi Kleen
    Set 2.6.x personality
 
-   mcelog is free software; you can redistribute it and/or
+   uname26 is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
    License as published by the Free Software Foundation; version
    2.
 
-   mcelog is distributed in the hope that it will be useful,
+   uname26 is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.
 
    You should find a copy of v2 of the GNU General Public License somewhere
-   on your Linux system; if not, write to the Free Software Foundation, 
+   on your Linux system; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
 #include <sys/personality.h>
 #include <stdio.h>
@@ -26,15 +26,15 @@
 
 int main(int ac, char **av)
 {
-	if (!av[1]) { 
+	if (!av[1]) {
 		fprintf(stderr, "Usage: uname26 program ...\n"
 				"Run program with the uname 2.6 personality\n");
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 	if (personality(PER_LINUX | UNAME26) < 0)
 		perror("personality"), exit(1);
-	
+
 	execvp(av[1], av + 1);
 	fprintf(stderr, "Cannot execute %s: %s\n", av[1], strerror(errno));
-	exit(1);
+	exit(EXIT_FAILURE);
 }


-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


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

* Re: [PATCH] setarch: Add --uname-2.6 option for personality flag UNAME26
  2011-08-23  6:00 ` [PATCH] setarch: Add --uname-2.6 option for personality flag UNAME26 Ben Hutchings
  2011-08-23 10:16   ` Karel Zak
@ 2011-08-29  9:17   ` Karel Zak
  1 sibling, 0 replies; 35+ messages in thread
From: Karel Zak @ 2011-08-29  9:17 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: Andi Kleen, torvalds, akpm, linux-kernel, Andi Kleen, util-linux

On Tue, Aug 23, 2011 at 07:00:01AM +0100, Ben Hutchings wrote:
>  configure.ac        |    1 +
>  sys-utils/setarch.8 |    3 +++
>  sys-utils/setarch.c |   12 +++++++++++-
>  3 files changed, 15 insertions(+), 1 deletions(-)

 Applied, thanks.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-08-22 18:30 ` Linus Torvalds
                     ` (2 preceding siblings ...)
  2011-08-23 13:15   ` Colin Walters
@ 2011-09-13 14:12   ` Pavel Machek
  2011-09-13 14:36     ` Stratos Psomadakis
  3 siblings, 1 reply; 35+ messages in thread
From: Pavel Machek @ 2011-09-13 14:12 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andi Kleen, akpm, linux-kernel, Andi Kleen

On Mon 2011-08-22 11:30:33, Linus Torvalds wrote:
> On Fri, Aug 19, 2011 at 4:15 PM, Andi Kleen <andi@firstfloor.org> wrote:
> >
> > Reposting due to popular demand. Several other people are running
> > into the same problem with all kinds of software.
> 
> I have heard this several times now, but nobody actually ever says
> *what* is broken.
> 
> The Fedora people seem to have done the 2.6.40 thing without any
> actual reason, for example (the two programs they claim were broken
> were things that they had already fixed in rawhide, afaik).
> 
> I'm not at all interested in these kinds of "all kinds of software" reports.
> 
> Details. Examples. Name the f&*cking names already. Shame them publicly.

ketchup :-(. And no, it is probably not what you wanted, and no, it is
not easy to fix.

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-09-13 14:12   ` Pavel Machek
@ 2011-09-13 14:36     ` Stratos Psomadakis
  2011-09-13 15:50       ` Andi Kleen
  0 siblings, 1 reply; 35+ messages in thread
From: Stratos Psomadakis @ 2011-09-13 14:36 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Linus Torvalds, Andi Kleen, akpm, linux-kernel, Andi Kleen

On 09/13/2011 05:12 PM, Pavel Machek wrote:
> On Mon 2011-08-22 11:30:33, Linus Torvalds wrote:
>> On Fri, Aug 19, 2011 at 4:15 PM, Andi Kleen <andi@firstfloor.org> wrote:
>>> Reposting due to popular demand. Several other people are running
>>> into the same problem with all kinds of software.
>> I have heard this several times now, but nobody actually ever says
>> *what* is broken.
>>
>> The Fedora people seem to have done the 2.6.40 thing without any
>> actual reason, for example (the two programs they claim were broken
>> were things that they had already fixed in rawhide, afaik).
>>
>> I'm not at all interested in these kinds of "all kinds of software" reports.
>>
>> Details. Examples. Name the f&*cking names already. Shame them publicly.
> ketchup :-(. And no, it is probably not what you wanted, and no, it is
> not easy to fix.
>
ketchup? [1]

Well, I think it doesn't really matter at all, if ketchup broke with 3.x
kernels, but there is a (semi-)working version of ketchup (I'm not very
proud of the code I wrote), which works with 3.x kernels (and
fortunately with 4.x and later).

[1] https://github.com/psomas/ketchup

Thanks,

-- 
Stratos Psomadakis
<psomas@gentoo.org>


-- 
Stratos Psomadakis
<s.psomadakis@gmail.com>


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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-09-13 14:36     ` Stratos Psomadakis
@ 2011-09-13 15:50       ` Andi Kleen
  2011-09-13 23:06         ` Stratos Psomadakis
  0 siblings, 1 reply; 35+ messages in thread
From: Andi Kleen @ 2011-09-13 15:50 UTC (permalink / raw)
  To: Stratos Psomadakis
  Cc: Pavel Machek, Linus Torvalds, Andi Kleen, akpm, linux-kernel

> ketchup? [1]

My patch won't fix ketchup. Obviously it cannot download 2.6.40

-Andi

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

* Re: [PATCH] Add a personality to report 2.6.x version numbers
  2011-09-13 15:50       ` Andi Kleen
@ 2011-09-13 23:06         ` Stratos Psomadakis
  0 siblings, 0 replies; 35+ messages in thread
From: Stratos Psomadakis @ 2011-09-13 23:06 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Pavel Machek, Linus Torvalds, Andi Kleen, akpm, linux-kernel

On 09/13/2011 06:50 PM, Andi Kleen wrote:
>> ketchup? [1]
> My patch won't fix ketchup. Obviously it cannot download 2.6.40
>
> -Andi
Well, since ketchup does not in any way rely on the kernel version
reported at 'runtime' (ie by uname), your patch doesn't actually affect
ketchup.

Anyway, I think that this discussion is a bit 'offtopic', since I didn't
think you had ketchup (or similar scripts) in mind for this patch.
I just replied to Pavel, just to let him (and anyone else interested)
know, that ketchup has in fact been updated to handle the newer kernel
versions.

Thanks,

-- 
Stratos Psomadakis
<s.psomadakis@gmail.com>


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

* [PATCH] Add a personality to report 2.6.x version numbers
@ 2011-07-07 23:42 Andi Kleen
  0 siblings, 0 replies; 35+ messages in thread
From: Andi Kleen @ 2011-07-07 23:42 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

I ran into a couple of programs which broke with the new Linux 3.0 version.
Some of those were binary only. I tried to use LD_PRELOAD to work
around it, but it was quite difficult and in one case impossible
because of a mix of 32bit and 64bit executables.

This patch adds a UNAME26 personality that makes the kernel
report a 2.6.40+x version number instead. The x is the x in 3.x.

I know this is somewhat ugly, but I didn't find a better workaround,
and compatibility to existing programs is important.

To use:

wget ftp://ftp.kernel.org/pub/linux/kernel/people/ak/uname26/uname26.c
gcc -o uname26 uname26.c
./uname26 program

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 include/linux/personality.h |    1 +
 kernel/sys.c                |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/include/linux/personality.h b/include/linux/personality.h
index eec3bae..8fc7dd1a 100644
--- a/include/linux/personality.h
+++ b/include/linux/personality.h
@@ -22,6 +22,7 @@ extern int		__set_personality(unsigned int);
  * These occupy the top three bytes.
  */
 enum {
+	UNAME26	=               0x0020000,
 	ADDR_NO_RANDOMIZE = 	0x0040000,	/* disable randomization of VA space */
 	FDPIC_FUNCPTRS =	0x0080000,	/* userspace function ptrs point to descriptors
 						 * (signal handling)
diff --git a/kernel/sys.c b/kernel/sys.c
index e4128b2..a828be0 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -38,6 +38,8 @@
 #include <linux/fs_struct.h>
 #include <linux/gfp.h>
 #include <linux/syscore_ops.h>
+#include <linux/version.h>
+#include <linux/ctype.h>
 
 #include <linux/compat.h>
 #include <linux/syscalls.h>
@@ -45,6 +47,8 @@
 #include <linux/user_namespace.h>
 
 #include <linux/kmsg_dump.h>
+/* Move somewhere else to avoid recompiling? */
+#include <generated/utsrelease.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -1124,6 +1128,34 @@ DECLARE_RWSEM(uts_sem);
 #define override_architecture(name)	0
 #endif
 
+/* 
+ * Work around broken programs that cannot handle "Linux 3.0".
+ * Instead we map 3.x to 2.6.40+x, so e.g. 3.0 would be 2.6.40
+ */
+static int override_release(char __user *release, int len)
+{	
+	int ret = 0;
+	char buf[len];
+
+	if (current->personality & UNAME26) {
+		char *rest = UTS_RELEASE;
+		int ndots = 0;
+		unsigned v;
+
+		while (*rest) {
+			if (*rest == '.' && ++ndots >= 3)
+				break;
+			if (!isdigit(*rest) && *rest != '.')
+				break;
+			rest++;
+		}
+		v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40;
+		snprintf(buf, len, "2.6.%u%s", v, rest);
+		ret = copy_to_user(release, buf, len);
+	}
+	return ret;
+}
+
 SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
 {
 	int errno = 0;
@@ -1133,6 +1165,8 @@ SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
 		errno = -EFAULT;
 	up_read(&uts_sem);
 
+	if (!errno && override_release(name->release, sizeof(name->release)))
+		errno = -EFAULT;
 	if (!errno && override_architecture(name))
 		errno = -EFAULT;
 	return errno;
@@ -1154,6 +1188,8 @@ SYSCALL_DEFINE1(uname, struct old_utsname __user *, name)
 		error = -EFAULT;
 	up_read(&uts_sem);
 
+	if (!error && override_release(name->release, sizeof(name->release)))
+		error = -EFAULT;
 	if (!error && override_architecture(name))
 		error = -EFAULT;
 	return error;
@@ -1188,6 +1224,8 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
 
 	if (!error && override_architecture(name))
 		error = -EFAULT;
+	if (!error && override_release(name->release, sizeof(name->release)))
+		error = -EFAULT;
 	return error ? -EFAULT : 0;
 }
 #endif
-- 
1.7.4.4


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

end of thread, other threads:[~2011-09-13 23:06 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-19 23:15 [PATCH] Add a personality to report 2.6.x version numbers Andi Kleen
2011-08-21 22:28 ` Arnaud Lacombe
2011-08-21 22:37   ` Jesper Juhl
2011-08-21 23:15     ` Andi Kleen
2011-08-21 23:13   ` Andi Kleen
2011-08-21 23:32     ` Arnaud Lacombe
2011-08-22  0:11       ` Andi Kleen
2011-08-22  1:04         ` Arnaud Lacombe
2011-08-22  1:46           ` Andi Kleen
2011-08-22  9:54   ` Américo Wang
2011-08-22 18:30 ` Linus Torvalds
2011-08-22 18:45   ` Eric Dumazet
2011-08-22 19:03     ` David Daney
2011-08-22 19:34   ` Andi Kleen
2011-08-23 13:15   ` Colin Walters
2011-08-23 16:11     ` Andi Kleen
2011-08-23 16:20       ` Colin Walters
2011-08-23 17:35         ` Arnaud Lacombe
2011-08-24 14:19     ` Alexey Dobriyan
2011-08-24 17:02       ` Arnd Bergmann
2011-09-13 14:12   ` Pavel Machek
2011-09-13 14:36     ` Stratos Psomadakis
2011-09-13 15:50       ` Andi Kleen
2011-09-13 23:06         ` Stratos Psomadakis
2011-08-23  6:00 ` [PATCH] setarch: Add --uname-2.6 option for personality flag UNAME26 Ben Hutchings
2011-08-23 10:16   ` Karel Zak
2011-08-23 12:15     ` Ben Hutchings
2011-08-26 21:43     ` Greg KH
2011-08-29  9:17   ` Karel Zak
2011-08-23 12:44 ` [PATCH] Add a personality to report 2.6.x version numbers Arnd Bergmann
2011-08-26 21:43 ` Greg KH
2011-08-26 22:25   ` Andi Kleen
2011-08-26 22:35     ` Greg KH
2011-08-27 16:36     ` Jesper Juhl
  -- strict thread matches above, loose matches on Subject: below --
2011-07-07 23:42 Andi Kleen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.