[PATCH] shmat() and CONFIG_STACK_GROWSUP



On PARISC-Linux the stack grows up, which is why on this platform CONFIG_STACK_GROWSUP is #defined by default.
The patch below allows shmat() to map the requested memory region on this platform directly below the start of the stack, without the need to reserve memory for a downward-growing stack.
Basically it gains a small region of 4 Pages in which shmat() may map memory on this platform.

Helge

diff --git a/ipc/shm.c b/ipc/shm.c
index 6d16bb6..f5cc635 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -852,6 +852,7 @@ long do_shmat(int shmid, char __user *sh
user_addr = ERR_PTR(-EINVAL);
if (find_vma_intersection(current->mm, addr, addr + size))
goto invalid;
+#ifndef CONFIG_STACK_GROWSUP
/*
* If shm segment goes below stack, make sure there is some
* space left for the stack to grow (at least 4 pages).
@@ -859,6 +860,7 @@ long do_shmat(int shmid, char __user *sh
if (addr < current->mm->start_stack &&
addr > current->mm->start_stack - size - PAGE_SIZE * 5)
goto invalid;
+#endif
}

user_addr = (void*) do_mmap (file, addr, size, prot, flags, 0);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: multythreading app memory consumption
    ... not physical memory, nor even virtual memory. ... The Posix thread platforms (those that support programmatic setting of ... The platform default thread stack sizes I can recall are: ...
    (comp.lang.python)
  • stack questions
    ... I'm a little confused about the use of stack in a CE platform. ... It has 64Meg memory, of which about 1 meg is used! ... prevent multiple threads from executing simultaneously. ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: If Macs have no spyware....
    ... >had made a complete code review of its operating system and removed all ... and writing new data into those memory locations would ... >but when the data exists on the stack, it can cause very large problems. ... >location that needs to be written in place of the correct execution ...
    (comp.sys.mac.advocacy)
  • Re: If Macs have no spyware....
    ... First you yammer about being a Mac advocate, then bad mouth me for dumping XP in favor of a Mac. ... Supposedly Microsoft had made a complete code review of its operating system and removed all the buffers which could overflow. ... the fundamental problem is that the basic architecture of Windows has two fatal flaws in its memory management and while these remain in the software the ad hoc patches will never be enough to make Windows a secure operating system. ... These problems are bad enough when dealing with data in the one routine but when the data exists on the stack, it can cause very large problems. ...
    (comp.sys.mac.advocacy)
  • Re: Maybe we should stop "Paging Beth Stone" already...
    ... I'll want to work on my OS while running my OS, so the assembler that it's written with has to run under it. ... You have to swap CR3 if you want seperate memory spaces. ... The alternate stacks aren't used by the processor unless the task calls a different protection level, so they're not part of the TSS swap. ... This lets any application use up to a gigabyte of stack before Linux is forced to tell it that it's gone too far. ...
    (alt.lang.asm)