RE: [discuss] [Patch] X86_64 TASK_SIZE cleanup - more comments

2005-04-21 Thread Zou, Nanhai
Hi Andi,
PPC64 IA64 and S390 use variable size TASK_SIZE for 32 bit and 64 bit
program.
I feel it is hard to maintain if we try to audit TASK_SIZE use
everywhere, because most of them are in generic code.

And maintaining those audit code in separate place is also a problem.
E.g. in current 32 bit emulation code
TASK_SIZE is defined as 0xfff in elf loading, but defined as
0xe000 in mmaping.

How did that earlier patch break applications?

Thanks
Zou Nan hai
> -Original Message-
> From: Andi Kleen [mailto:[EMAIL PROTECTED]
> Sent: Thursday, April 21, 2005 7:54 PM
> To: Zou, Nanhai
> Cc: Andi Kleen; [EMAIL PROTECTED]; linux-kernel@vger.kernel.org;
Siddha,
> Suresh B
> Subject: Re: [discuss] [Patch] X86_64 TASK_SIZE cleanup - more
comments
> 
> 
> Another comment:
> 
> In general I am not too happy about the variable size TASK_SIZE.
> There was a patch for this earlier, but it broke 32bit emulation
> completely. And I think it needs auditing of all uses of TASK_SIZE,
> because I suspect there are more bugs lurking in it.
> 
> The way hugetlb etc. mmap were supposed to be handled was to
> let the mmap succeed and then check in the mmap wrapper
> if any address is > 4GB and free it. Probably that code
> has some problems or got broken (I think it worked at least
> in 2.4, but there might have been regressions later)
> 
> -Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [discuss] [Patch] X86_64 TASK_SIZE cleanup

2005-04-21 Thread Zou, Nanhai

Isn't that a 
!test_thread_flag(TIF_IA32) && (flags & MAP_32BIT)
in my patch?

Zou Nan hai

> -Original Message-
> From: Andi Kleen [mailto:[EMAIL PROTECTED]
> Sent: Thursday, April 21, 2005 7:51 PM
> To: Zou, Nanhai
> Cc: Andi Kleen; [EMAIL PROTECTED]; linux-kernel@vger.kernel.org;
Siddha,
> Suresh B
> Subject: Re: [discuss] [Patch] X86_64 TASK_SIZE cleanup
> 
> On Thu, Apr 21, 2005 at 01:17:40AM +0800, Zou, Nanhai wrote:
> > Hi Andi,
> >What is your comment on this patch?
> 
> There is at least one wrong change in there, you have a check
> for test_thread_flag(TIF_IA32) && (flags & MAP_32BIT)
> 
> and that is wrong because MAP_32BIT is used from 64bit code
> 
> -Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [discuss] [Patch] X86_64 TASK_SIZE cleanup - more comments

2005-04-21 Thread Andi Kleen

Another comment:

In general I am not too happy about the variable size TASK_SIZE.
There was a patch for this earlier, but it broke 32bit emulation
completely. And I think it needs auditing of all uses of TASK_SIZE,
because I suspect there are more bugs lurking in it.

The way hugetlb etc. mmap were supposed to be handled was to 
let the mmap succeed and then check in the mmap wrapper
if any address is > 4GB and free it. Probably that code
has some problems or got broken (I think it worked at least
in 2.4, but there might have been regressions later)

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


Re: [discuss] [Patch] X86_64 TASK_SIZE cleanup

2005-04-21 Thread Andi Kleen
On Thu, Apr 21, 2005 at 01:17:40AM +0800, Zou, Nanhai wrote:
> Hi Andi,
>What is your comment on this patch?

There is at least one wrong change in there, you have a check
for test_thread_flag(TIF_IA32) && (flags & MAP_32BIT)

and that is wrong because MAP_32BIT is used from 64bit code

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


Re: [discuss] [Patch] X86_64 TASK_SIZE cleanup

2005-04-21 Thread Andi Kleen
On Thu, Apr 21, 2005 at 01:17:40AM +0800, Zou, Nanhai wrote:
 Hi Andi,
What is your comment on this patch?

There is at least one wrong change in there, you have a check
for test_thread_flag(TIF_IA32)  (flags  MAP_32BIT)

and that is wrong because MAP_32BIT is used from 64bit code

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


Re: [discuss] [Patch] X86_64 TASK_SIZE cleanup - more comments

2005-04-21 Thread Andi Kleen

Another comment:

In general I am not too happy about the variable size TASK_SIZE.
There was a patch for this earlier, but it broke 32bit emulation
completely. And I think it needs auditing of all uses of TASK_SIZE,
because I suspect there are more bugs lurking in it.

The way hugetlb etc. mmap were supposed to be handled was to 
let the mmap succeed and then check in the mmap wrapper
if any address is  4GB and free it. Probably that code
has some problems or got broken (I think it worked at least
in 2.4, but there might have been regressions later)

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


RE: [discuss] [Patch] X86_64 TASK_SIZE cleanup

2005-04-21 Thread Zou, Nanhai

Isn't that a 
!test_thread_flag(TIF_IA32)  (flags  MAP_32BIT)
in my patch?

Zou Nan hai

 -Original Message-
 From: Andi Kleen [mailto:[EMAIL PROTECTED]
 Sent: Thursday, April 21, 2005 7:51 PM
 To: Zou, Nanhai
 Cc: Andi Kleen; [EMAIL PROTECTED]; linux-kernel@vger.kernel.org;
Siddha,
 Suresh B
 Subject: Re: [discuss] [Patch] X86_64 TASK_SIZE cleanup
 
 On Thu, Apr 21, 2005 at 01:17:40AM +0800, Zou, Nanhai wrote:
  Hi Andi,
 What is your comment on this patch?
 
 There is at least one wrong change in there, you have a check
 for test_thread_flag(TIF_IA32)  (flags  MAP_32BIT)
 
 and that is wrong because MAP_32BIT is used from 64bit code
 
 -Andi
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [discuss] [Patch] X86_64 TASK_SIZE cleanup - more comments

2005-04-21 Thread Zou, Nanhai
Hi Andi,
PPC64 IA64 and S390 use variable size TASK_SIZE for 32 bit and 64 bit
program.
I feel it is hard to maintain if we try to audit TASK_SIZE use
everywhere, because most of them are in generic code.

And maintaining those audit code in separate place is also a problem.
E.g. in current 32 bit emulation code
TASK_SIZE is defined as 0xfff in elf loading, but defined as
0xe000 in mmaping.

How did that earlier patch break applications?

Thanks
Zou Nan hai
 -Original Message-
 From: Andi Kleen [mailto:[EMAIL PROTECTED]
 Sent: Thursday, April 21, 2005 7:54 PM
 To: Zou, Nanhai
 Cc: Andi Kleen; [EMAIL PROTECTED]; linux-kernel@vger.kernel.org;
Siddha,
 Suresh B
 Subject: Re: [discuss] [Patch] X86_64 TASK_SIZE cleanup - more
comments
 
 
 Another comment:
 
 In general I am not too happy about the variable size TASK_SIZE.
 There was a patch for this earlier, but it broke 32bit emulation
 completely. And I think it needs auditing of all uses of TASK_SIZE,
 because I suspect there are more bugs lurking in it.
 
 The way hugetlb etc. mmap were supposed to be handled was to
 let the mmap succeed and then check in the mmap wrapper
 if any address is  4GB and free it. Probably that code
 has some problems or got broken (I think it worked at least
 in 2.4, but there might have been regressions later)
 
 -Andi
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [discuss] [Patch] X86_64 TASK_SIZE cleanup

2005-04-20 Thread Zou, Nanhai
Hi Andi,
   What is your comment on this patch?
Here is another example bug this patch will fix.
The following piece of code will get a success mmap even if compiled
with -m32. 
   
   int *p;
   p = mmap((void *)(0xE000UL), 0x1UL, PROT_READ|PROT_WRITE,
MAP_FIXED|MAP_PRIVATE|MAP_ANON, 0, 0);

I believe there are other kind of corner case bugs around mm and fs. 
e.g in mremap and munmap.
Those bugs will be fixed by this patch. 

Zou Nan hai
> -Original Message-
> From: Zou, Nanhai
> Sent: Tuesday, April 19, 2005 12:37 AM
> To: 'Andi Kleen'
> Cc: [EMAIL PROTECTED]; linux-kernel@vger.kernel.org; Siddha, Suresh B
> Subject: RE: [discuss] [Patch] X86_64 TASK_SIZE cleanup
> 
> 
> When a 32bit program is mapping a lot of hugepage vm_areas,
> hugetlb_get_unmapped_area may search beyond 4G, then the program will
get a
> SIGFAULT instead of an errno of ENOMEM.
> This patch will fix that.
> I believe there are other inconsistent cases in generic code like mm
and fs.
> 
> Zou Nan hai
> 
> > -Original Message-
> > From: Andi Kleen [mailto:[EMAIL PROTECTED]
> > Sent: Monday, April 18, 2005 5:06 PM
> > To: Zou, Nanhai
> > Cc: [EMAIL PROTECTED]; Andi Kleen; linux-kernel@vger.kernel.org;
Siddha,
> > Suresh B
> > Subject: Re: [discuss] [Patch] X86_64 TASK_SIZE cleanup
> >
> > On Sat, Apr 16, 2005 at 09:34:25AM +0800, Zou, Nanhai wrote:
> > >
> > > Hi,
> > >This patch will clean up the X86_64 compatibility mode
TASK_SIZE
> > > define thus fix some bugs found in X86_64 compatibility mode
program.
> >
> > Fix what bugs exactly?  Please a detailed description.
> >
> > -Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [discuss] [Patch] X86_64 TASK_SIZE cleanup

2005-04-20 Thread Zou, Nanhai
Hi Andi,
   What is your comment on this patch?
Here is another example bug this patch will fix.
The following piece of code will get a success mmap even if compiled
with -m32. 
   
   int *p;
   p = mmap((void *)(0xE000UL), 0x1UL, PROT_READ|PROT_WRITE,
MAP_FIXED|MAP_PRIVATE|MAP_ANON, 0, 0);

I believe there are other kind of corner case bugs around mm and fs. 
e.g in mremap and munmap.
Those bugs will be fixed by this patch. 

Zou Nan hai
 -Original Message-
 From: Zou, Nanhai
 Sent: Tuesday, April 19, 2005 12:37 AM
 To: 'Andi Kleen'
 Cc: [EMAIL PROTECTED]; linux-kernel@vger.kernel.org; Siddha, Suresh B
 Subject: RE: [discuss] [Patch] X86_64 TASK_SIZE cleanup
 
 
 When a 32bit program is mapping a lot of hugepage vm_areas,
 hugetlb_get_unmapped_area may search beyond 4G, then the program will
get a
 SIGFAULT instead of an errno of ENOMEM.
 This patch will fix that.
 I believe there are other inconsistent cases in generic code like mm
and fs.
 
 Zou Nan hai
 
  -Original Message-
  From: Andi Kleen [mailto:[EMAIL PROTECTED]
  Sent: Monday, April 18, 2005 5:06 PM
  To: Zou, Nanhai
  Cc: [EMAIL PROTECTED]; Andi Kleen; linux-kernel@vger.kernel.org;
Siddha,
  Suresh B
  Subject: Re: [discuss] [Patch] X86_64 TASK_SIZE cleanup
 
  On Sat, Apr 16, 2005 at 09:34:25AM +0800, Zou, Nanhai wrote:
  
   Hi,
  This patch will clean up the X86_64 compatibility mode
TASK_SIZE
   define thus fix some bugs found in X86_64 compatibility mode
program.
 
  Fix what bugs exactly?  Please a detailed description.
 
  -Andi
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [discuss] [Patch] X86_64 TASK_SIZE cleanup

2005-04-18 Thread Zou, Nanhai

When a 32bit program is mapping a lot of hugepage vm_areas, 
hugetlb_get_unmapped_area may search beyond 4G, then the program will
get a SIGFAULT instead of an errno of ENOMEM.
This patch will fix that.
I believe there are other inconsistent cases in generic code like mm and
fs.

Zou Nan hai

> -Original Message-
> From: Andi Kleen [mailto:[EMAIL PROTECTED]
> Sent: Monday, April 18, 2005 5:06 PM
> To: Zou, Nanhai
> Cc: [EMAIL PROTECTED]; Andi Kleen; linux-kernel@vger.kernel.org;
Siddha,
> Suresh B
> Subject: Re: [discuss] [Patch] X86_64 TASK_SIZE cleanup
> 
> On Sat, Apr 16, 2005 at 09:34:25AM +0800, Zou, Nanhai wrote:
> >
> > Hi,
> >This patch will clean up the X86_64 compatibility mode TASK_SIZE
> > define thus fix some bugs found in X86_64 compatibility mode
program.
> 
> Fix what bugs exactly?  Please a detailed description.
> 
> -Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [discuss] [Patch] X86_64 TASK_SIZE cleanup

2005-04-18 Thread Andi Kleen
On Sat, Apr 16, 2005 at 09:34:25AM +0800, Zou, Nanhai wrote:
> 
> Hi,
>This patch will clean up the X86_64 compatibility mode TASK_SIZE
> define thus fix some bugs found in X86_64 compatibility mode program.

Fix what bugs exactly?  Please a detailed description.

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


Re: [discuss] [Patch] X86_64 TASK_SIZE cleanup

2005-04-18 Thread Andi Kleen
On Sat, Apr 16, 2005 at 09:34:25AM +0800, Zou, Nanhai wrote:
 
 Hi,
This patch will clean up the X86_64 compatibility mode TASK_SIZE
 define thus fix some bugs found in X86_64 compatibility mode program.

Fix what bugs exactly?  Please a detailed description.

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


RE: [discuss] [Patch] X86_64 TASK_SIZE cleanup

2005-04-18 Thread Zou, Nanhai

When a 32bit program is mapping a lot of hugepage vm_areas, 
hugetlb_get_unmapped_area may search beyond 4G, then the program will
get a SIGFAULT instead of an errno of ENOMEM.
This patch will fix that.
I believe there are other inconsistent cases in generic code like mm and
fs.

Zou Nan hai

 -Original Message-
 From: Andi Kleen [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 18, 2005 5:06 PM
 To: Zou, Nanhai
 Cc: [EMAIL PROTECTED]; Andi Kleen; linux-kernel@vger.kernel.org;
Siddha,
 Suresh B
 Subject: Re: [discuss] [Patch] X86_64 TASK_SIZE cleanup
 
 On Sat, Apr 16, 2005 at 09:34:25AM +0800, Zou, Nanhai wrote:
 
  Hi,
 This patch will clean up the X86_64 compatibility mode TASK_SIZE
  define thus fix some bugs found in X86_64 compatibility mode
program.
 
 Fix what bugs exactly?  Please a detailed description.
 
 -Andi
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/