mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: Solving the recursive memcpy/memset/etc. issue
Date: Thu, 1 Aug 2013 13:48:04 -0400	[thread overview]
Message-ID: <20130801174804.GL221@brightrain.aerifal.cx> (raw)
In-Reply-To: <1375345615.27318.228.camel@eris.loria.fr>

On Thu, Aug 01, 2013 at 10:26:55AM +0200, Jens Gustedt wrote:
> Am Donnerstag, den 01.08.2013, 10:03 +0200 schrieb Luca Barbato:
> > > Well, it would be an ugly heuristic like running cc -S -o - on 
> > > src/string/memcpy.c, with -Dmemcpy=noname or something, and grepping 
> > > the output for memcpy...
> > 
> > Indeed.
> 
> there might be the word memcpy in comments or whatever, depends on the
> assembler format etc. might be really relatively difficult to set up
> reliably.

Well as long as they're false-positives for detecting the bug rather
than false-negatives, at worst you'd get a slow memcpy rather than a
crashing libc.

>  - compile it with that -Dmemcpy=noname trick to a normal .o and use
>    nm to look for an undefined symbol "memcpy".

Using nm is undesirable with respect to cross-compiling. It requires
detecting the right version of nm to run, which may be hard; I don't
even have *-linux-musl-nm in my path on my laptop here, just the gcc.
Right now cross-compiling is as simple as setting CC to the cross
compiler, and I don't want to break that.

>  - use a different name for the implementation of the function from
>    the start, __musl_memcpy or so. Then you could do the check for the
>    memcpy symbol on the normally compiled .o and (if everything is ok)
>    rename the __musl_memcpy to memcpy with some linker trick.

This is a lot more ugliness in the build system and I'm not clear on
the benefit over the above methods.

>  - put "#define memcpy __musl_memcpy" at the start of string.h
>    if __musl_memcpy would refer to memcpy this would give an link time
>    error for an undefined symbol.

No linking is done to make libc.a. As for linking applications, the
symbol memcpy must exist. You are always permitted to remove macro
definitions and refer to the underlying function. Even if this were
valid, it would change the ABI in a very ugly hackish way that belongs
in glibc, not musl.

Rich


  reply	other threads:[~2013-08-01 17:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-01  0:49 Rich Felker
2013-08-01  6:05 ` Luca Barbato
2013-08-01  6:20   ` Rich Felker
2013-08-01  8:03     ` Luca Barbato
2013-08-01  8:26       ` Jens Gustedt
2013-08-01 17:48         ` Rich Felker [this message]
2013-08-02  2:52 ` 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=20130801174804.GL221@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --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).