summaryrefslogtreecommitdiffstats
path: root/sys/i386/linux
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2008-02-11 19:35:03 +0000
committerjkim <jkim@FreeBSD.org>2008-02-11 19:35:03 +0000
commit3bffed0becf215b8f75a4303e23fe6844a97b030 (patch)
tree447ae4fa6d4077a63f88138af3d93232bf4ecd56 /sys/i386/linux
parentf5658700c26fc4e1898f4857100be89857d3cb9d (diff)
downloadFreeBSD-src-3bffed0becf215b8f75a4303e23fe6844a97b030.zip
FreeBSD-src-3bffed0becf215b8f75a4303e23fe6844a97b030.tar.gz
Fix Linux mmap with MAP_GROWSDOWN flag.
Reported by: Andriy Gapon (avg at icyb dot net dot ua) Tested by: Andriy Gapon (avg at icyb dot net dot ua) Pointyhat: me MFC after: 3 days
Diffstat (limited to 'sys/i386/linux')
-rw-r--r--sys/i386/linux/linux_machdep.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c
index a92c751..ded3b17 100644
--- a/sys/i386/linux/linux_machdep.c
+++ b/sys/i386/linux/linux_machdep.c
@@ -758,21 +758,22 @@ linux_mmap_common(struct thread *td, struct l_mmap_argv *linux_args)
PROC_UNLOCK(p);
}
- /* This gives us our maximum stack size */
- if (linux_args->len > STACK_SIZE - GUARD_SIZE)
- bsd_args.len = linux_args->len;
- else
- bsd_args.len = STACK_SIZE - GUARD_SIZE;
-
- /*
- * This gives us a new BOS. If we're using VM_STACK, then
- * mmap will just map the top SGROWSIZ bytes, and let
- * the stack grow down to the limit at BOS. If we're
- * not using VM_STACK we map the full stack, since we
- * don't have a way to autogrow it.
+ /*
+ * This gives us our maximum stack size and a new BOS.
+ * If we're using VM_STACK, then mmap will just map
+ * the top SGROWSIZ bytes, and let the stack grow down
+ * to the limit at BOS. If we're not using VM_STACK
+ * we map the full stack, since we don't have a way
+ * to autogrow it.
*/
- bsd_args.addr = (caddr_t)PTRIN(linux_args->addr) -
- bsd_args.len;
+ if (linux_args->len > STACK_SIZE - GUARD_SIZE) {
+ bsd_args.addr = (caddr_t)PTRIN(linux_args->addr);
+ bsd_args.len = linux_args->len;
+ } else {
+ bsd_args.addr = (caddr_t)PTRIN(linux_args->addr) -
+ (STACK_SIZE - GUARD_SIZE - linux_args->len);
+ bsd_args.len = STACK_SIZE - GUARD_SIZE;
+ }
} else {
bsd_args.addr = (caddr_t)PTRIN(linux_args->addr);
bsd_args.len = linux_args->len;
OpenPOWER on IntegriCloud