Re: [BUGFIX][PATCH] fixing placement of register stack under ulimit -s

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



plz allow me to explain more.

"Why register-stack/memory-stack upside down is bad" is a bit complicated.
So...this is a test and result for explaining bug. 

This is a sample code and its result on 2.6.21-rc3.
Note: base address of memory'stack can be randomly change.

== sample code ==
[kamezawa@drpq ~]$ cat sample.c
#include <stdio.h>

void do_print(int num)
{
        if (num == 0)
                return;
        printf("%d\n",num);
        do_print(num - 1);
}

int main(int argc, char *argv[])
{
        do_print(10000);
        return 0;
}

== before ulimit ==
[kamezawa@drpq ~]$ uname -a
Linux drpq 2.6.21-rc3 #3 SMP Fri Mar 16 11:57:47 JST 2007 ia64 ia64 ia64 GNU/Linux
[kamezawa@drpq ~]$ ulimit -s
8192
[kamezawa@drpq ~]$ ulimit -s -H
unlimited
[kamezawa@drpq ~]$ ./sample
10000
9999
....<snip>
1
[kamezawa@drpq ~]$
== after ulimit -s 8192 ==

[kamezawa@drpq ~]$ ulimit -s
8192
[kamezawa@drpq ~]$ ulimit -s -H
8192
[kamezawa@drpq ~]$ ./sample  
10000
9999
....<snip>

9612
9611
9610
9609
9608
Segmentation fault

[kamezawa@drpq ~]$ ./sample   (when I'm lucky)
10000
9999
....<snip>
1
[kamezawa@drpq ~]$
=====================================

This number 9608 is too short to use up all stack. The reason of this is 
"ulimit -s + memory stack randomization + register-stack-expansion" is buggy.
The program can only use one page for register stack if unlucky.
My patch will fix this case.

-Kame








-
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Sparc Linux]     [DCCP]     [Linux ARM]     [Yosemite News]     [Linux SCSI]     [Linux x86_64]     [Linux for Ham Radio]

  Powered by Linux