mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: Removing sbrk and brk
Date: Sun, 22 Dec 2013 19:48:55 +0100	[thread overview]
Message-ID: <20131222184855.GS1685@port70.net> (raw)
In-Reply-To: <20131221234041.GA13204@brightrain.aerifal.cx>

* Rich Felker <dalias@aerifal.cx> [2013-12-21 18:40:41 -0500]:
> As far as I can tell, the only remotely legitimate use for sbrk/brk is
> for applications to provide their own malloc implementation using it.

single-threaded static linked binaries may want to avoid pulling in
the entire malloc implementation with locks etc and use sbrk instead
(i know some plan9 tools did this), i guess that should work if only
async-signal-safe libc calls are used (those cannot use malloc or brk
internally), but i don't think this is common

sbrk(0) is a valid usage and i think that's common (eventhough it is
mostly useless)

> - making them always-fail
> - making the headers break use of them
> - completely removing the symbols
> 
> The latter options are in some ways preferable, since the failure
> would be caught at build-time and the program could be patched (or
> different configure options passed) to fix the incorrect sbrk usage.

i think there is a general problem of dangerous/broken/legacy interfaces

i would prefer a separate tool that can catch these at compile-/run-time
rather than fixing them in the libc (sbrk/brk are special because they
are almost always wrong while the other broken interfaces are possible
to use without invoking ub)

another solution is to split libc into libgood and libbad
(or mark the broken apis in some way to catch their usage easily)

...
> However this option would definitely be a post-1.0 development
> direction, and not something we could do right away (of course I'd
> probably hold off until after 1.0 for any of these changes since
> they're fairly invasive, except possibly the idea of making sbrk
> always-fail).

so the options in increasing effort are

1) leave it as is
2) completely remove sbrk/brk
3) always fail (except for sbrk(0))
4) emulate with mmap+mprotect
5) malloc without brk

i like 1) or 3) for 1.0 and 5) for post-1.0


  parent reply	other threads:[~2013-12-22 18:48 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-21 23:40 Rich Felker
2013-12-22  2:15 ` Luca Barbato
2013-12-22 17:58   ` Richard Pennington
2013-12-22 18:21     ` Luca Barbato
2013-12-22 18:48 ` Szabolcs Nagy [this message]
2013-12-22 21:55   ` Christian Neukirchen
2013-12-23  4:46   ` Rich Felker
2014-01-02 22:03     ` Rich Felker
2014-01-03 11:51       ` Thorsten Glaser
2014-01-03 12:59         ` Daniel Cegiełka
2014-01-03 17:33         ` Rich Felker
2014-01-03 18:19           ` Rich Felker
2014-01-03 19:03             ` Rich Felker
2014-01-06 14:51               ` Thorsten Glaser
2014-01-06 22:40                 ` Rich Felker
2014-01-07  9:43                   ` Thorsten Glaser
2014-01-07 16:06                     ` Rich Felker
2014-01-07 22:00                       ` Rich Felker
2014-02-21 16:03                         ` Daniel Cegiełka
2014-02-21 16:36                           ` Szabolcs Nagy
2014-02-21 16:47                             ` Daniel Cegiełka
2014-02-21 17:09                               ` Rich Felker
2014-02-21 22:34                                 ` Daniel Cegiełka

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=20131222184855.GS1685@port70.net \
    --to=nsz@port70.net \
    --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).