mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Vasiliy Kulikov <segoon@openwall.com>
To: musl@lists.openwall.com
Subject: Re: malloc and linux memory layout
Date: Thu, 11 Aug 2011 11:43:05 +0400	[thread overview]
Message-ID: <20110811074305.GA4276@albatros> (raw)
In-Reply-To: <20110810195658.GC132@brightrain.aerifal.cx>

On Wed, Aug 10, 2011 at 15:56 -0400, Rich Felker wrote:
> Each process has its own 32- or 64-bit virtual address space.
> Initially, from bottom to top, it looks something like:
> 
> [low unmappable pages]
> [main program text (code) segment]
> [main program data segment]
> [brk segment (heap)]
> [....lots of open virtual address space...]
> [mmap zone]
> [main thread stack]
> [reserved for kernelspace use]
> 
> (Note that there will be small randomized amounts of empty/unused
> address space between these regions if ALSR is enabled.)x
> 
> The brk segment starts just above the program's static data and grows
> upward into the big open space.

Btw, (randomize_va_space):

http://www.mjmwired.net/kernel/Documentation/sysctl/kernel.txt

> The mmap zone (where mmaps are put by
> default) starts just below the stack limit and continues downward as
> more mappings are made.

Not only this zone.  mmap() can return address before main program text if
there is enough space there.


Other minor (Linux-specific) things:

Low unmappable pages region might be absent if the task has CAP_SYS_RAWIO
capability.  But pages before mmap_min_addr will be mmap'ed only by
explicit mmap(addr, ..., MAP_FIXED, ...), no libs will be there.

"Reserved for kernelspace use" region might be absent too for 32-bit
tasks running on 286-64 system.

There could be some specific pages after the stack.  On x86-64 it is
VDSO and vsyscall pages.

-- 
Vasiliy


  reply	other threads:[~2011-08-11  7:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-10 19:56 Rich Felker
2011-08-11  7:43 ` Vasiliy Kulikov [this message]
2011-08-11 14:54   ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110811074305.GA4276@albatros \
    --to=segoon@openwall.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).