lkml.org 
[lkml]   [2010]   [Aug]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRE: [PATCH] guard page for stacks that grow upwards
> But the ia64 grows-up case is tested?

Yes. The attached hacky test program reports that the RSE stack
stomps over the mmap'd segment w/o this patch. With it the
program dies with a SIGBUS. Should be easy to adapt to
test on pa-risc (hint, hint to parisc people).

>> The #ifdefs are ugly - suggestions welcome on how to make
>> the code prettier.
>
> One thing I've considered is to get rid of the CONFIG_STACK_GROWSUP
> crap entirely in code, and instead just make the VM_GROWSUP #define be
> 0 for architectures that don't want it. The compiler should then just
> automatically remove all the code that says
>
> if (vma->vm_flags & VM_GROWSUP) {
> ...
>
> and the code would look more straightforward. Hmm?

You'd also need some stub declaration for expand_upwards().
But overall that would look cleaner.

-Tony
#include <stdio.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

void watch(long depth, char *map)
{
int i;

for (i = 0; i < 0x10000; i++) {
if (map[i]) {
printf("Found %x at %p\n", map[i], &map[i]);
exit(1);
}
}
if (++depth % 5000 == 0)
printf("now at stack depth %ld\n", depth);
watch(depth, map);

/* won't get here .. but stop compiler from doing tail recursion */
for (i = 0; i < 0x10000; i++) {
if (map[i]) {
printf("Found %x at %p\n", map[i], &map[i]);
exit(1);
}
}
}

main()
{
char *p;

p = mmap((void *)0x6008000000000000, 0x10000, PROT_READ|PROT_WRITE,
MAP_ANONYMOUS|MAP_PRIVATE, -1, 0L);

printf("%p\n", p);
memset(p, '\0', 0x10000);

watch(0, p);

return 0;
}
\
 
 \ /
  Last update: 2010-08-24 19:35    [W:0.102 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site