diff options
author | Jung-uk Kim <jkim@FreeBSD.org> | 2008-02-11 19:35:03 +0000 |
---|---|---|
committer | Jung-uk Kim <jkim@FreeBSD.org> | 2008-02-11 19:35:03 +0000 |
commit | 865df544c635d5c46fba32f0f4fbfc4bff24dc85 (patch) | |
tree | 447ae4fa6d4077a63f88138af3d93232bf4ecd56 /sys/amd64/linux32 | |
parent | d52218b200a9fbe8cde3a8565bf3a8b75c169829 (diff) | |
download | src-865df544c635d5c46fba32f0f4fbfc4bff24dc85.tar.gz src-865df544c635d5c46fba32f0f4fbfc4bff24dc85.zip |
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
Notes
Notes:
svn path=/head/; revision=176193
Diffstat (limited to 'sys/amd64/linux32')
-rw-r--r-- | sys/amd64/linux32/linux32_machdep.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c index 7a7ce0801040..565e6d22e8ea 100644 --- a/sys/amd64/linux32/linux32_machdep.c +++ b/sys/amd64/linux32/linux32_machdep.c @@ -907,21 +907,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; |