Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <51F9FA8D.2000403@gentoo.org>
Date: Thu, 01 Aug 2013 08:05:01 +0200
From: Luca Barbato <lu_zero@...too.org>
To: musl@...ts.openwall.com
Subject: Re: Solving the recursive memcpy/memset/etc. issue

On 01/08/13 02:49, Rich Felker wrote:
> OK, so now that it's hit us for real, what should we do about GCC
> generating code for memcpy, memset, etc. which might contain infinite
> recursion? Aside from the ARM issue (which was separate), we know the
> option causing this bad code generation, and it can be disabled via
> -fno-tree-loop-distribute-patterns. However, if GCC policy is that
> they consider the compiler entitled to generate calls to
> memcpy/memset/memmove/memcmp whenever it wants, then we're just going
> to be playing whack-a-mole.

Sounds lovely.

> The only fully viable option I see is replacing the code for these
> functions with code that uses volatile objects so as to make
> optimization utterly impossible. This will of course make them
> incredibly slow, but at least we would have safe, working C code, and
> we could add asm for each supported arch.

Not exactly great.

> An alternative might be to test the compiler in configure to determine
> if, with the selected CFLAGS, it generates recursive code for these
> functions, and if so, defining a macro that causes musl to revert to
> the volatile code.

Sounds much better.

> Other ideas? For now, if -fno-tree-loop-distribute-patterns fixes it
> (still waiting on confirmation for this) I'm going to commit that to
> configure, but it doesn't seem like a viable long-term solution.

I'd rather check and error out reporting the compiler is broken. Then
have an explicit configure option to try to workaround it.

> My ideal outcome would be a promise from the GCC developers that, in
> future GCC versions, -ffreestanding implies disabling any options
> which would generate calls to the mem* functions. However that sounds
> unlikely.

They have competition, if clang works better then we could just suggest
to use it and nowadays gcc has no deployment advantage to it anymore.


lu

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.