public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH v4 1/5] support: Add support_stack_alloc
Date: Wed, 10 Mar 2021 17:10:37 +0100	[thread overview]
Message-ID: <875z1zrnuq.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20210310152633.3916978-1-adhemerval.zanella@linaro.org> (Adhemerval Zanella via Libc-alpha's message of "Wed, 10 Mar 2021 12:26:29 -0300")

* Adhemerval Zanella via Libc-alpha:

> +  /* Use MAP_NORESERVE so that RAM will not be wasted on the guard
> +     bands; touch all the pages of the actual stack before returning,
> +     so we know they are allocated.  */
> +  void *alloc_base = xmmap (0,
> +                            alloc_size,
> +                            PROT_READ|PROT_WRITE,
> +                            MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE|MAP_STACK,
> +                            -1);
> +  xmprotect (alloc_base, guardsize, PROT_NONE);
> +  xmprotect (alloc_base + guardsize + stacksize, guardsize, PROT_NONE);

The usual pattern is to map with PROT_NONE and then use
PROT_READ|PROT_WRITE with mprotect.

Rest looks okay, thanks.

Florian


  parent reply	other threads:[~2021-03-10 16:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10 15:26 Adhemerval Zanella
2021-03-10 15:26 ` [PATCH v4 2/5] support: Add xclone Adhemerval Zanella
2021-03-10 15:26 ` [PATCH v4 3/5] Linux: Add close_range Adhemerval Zanella
2021-03-24 22:42   ` Alyssa Ross
2021-03-10 15:26 ` [PATCH v4 4/5] io: Add closefrom [BZ #10353] Adhemerval Zanella
2021-03-10 21:54   ` Joseph Myers
2021-03-11 11:24     ` Adhemerval Zanella
2021-03-10 15:26 ` [PATCH v4 5/5] posix: Add posix_spawn_file_actions_closefrom_np Adhemerval Zanella
2021-03-10 16:10 ` Florian Weimer [this message]
2021-03-12 13:24   ` [PATCH v4 1/5] support: Add support_stack_alloc Adhemerval Zanella
2021-03-12 13:35     ` Florian Weimer
2021-03-12 14:01       ` Adhemerval Zanella

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=875z1zrnuq.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).