Bugtraq mailing list archives
Re: When scrubbing secrets in memory doesn't work
From: Valdis.Kletnieks () vt edu
Date: Thu, 07 Nov 2002 23:00:15 -0500
On Wed, 06 Nov 2002 12:55:26 GMT, Gianni Tedesco <gianni () ecsc co uk> said:
FYI: tested on gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-112) which doesn't seem to do this. What compiler version/flags, if any does this depend on?
gcc 3 and later (3.2 is current) are well able to do this optimization, and I'm surprised that the 2.96 version isn't able to as well.
Should this optimisation actually even remove function calls? What if you were depending on that function doing something? eg: writing something to a file... I can understand with memset/memcpy or other builtin functions because it could be hardcoded in the compiler to say 'allow optimiser to remove calls to this function' or whatever.
If it's not flagged 'volatile', and dead code, it can be pruned. memset()/memcpy() is no different than any other function that the compiler is able to inline - the only difference for those "magic" functions is that the compiler already has a body to inline, so you don't have to provide source for it. And once it's inlined, it's fair game for the optimizer. If you were depending on the function doing something, then the function has a side effect and the something won't be optimized away, unless the side effect is also dead code. If all the code in the function is demonstrably dead, the entire function itself may go bye-bye (especially if it's declared as a 'static' function only visible in this source file). I suspect that for non-static functions, it will emit a function prolog/return just to ensure that you don't have an unresolved symbol if other modules call the function. An interesting corner case exists in gcc - often, it's able to inline all references to a function. There's a -fkeep-inline-functions to force the compiler to emit a non-inlined copy as well (which can be a problem with C++ initializers invoked from another module). -- Valdis Kletnieks Computer Systems Senior Engineer Virginia Tech
Attachment:
_bin
Description:
Current thread:
- When scrubbing secrets in memory doesn't work Michael Howard (Nov 05)
- Re: When scrubbing secrets in memory doesn't work Perry E. Metzger (Nov 05)
- Re: When scrubbing secrets in memory doesn't work Andy Polyakov (Nov 07)
- Re: When scrubbing secrets in memory doesn't work Gianni Tedesco (Nov 07)
- Re: When scrubbing secrets in memory doesn't work Valdis . Kletnieks (Nov 08)
- Re: When scrubbing secrets in memory doesn't work Michael Zimmermann (Nov 09)
- Re: When scrubbing secrets in memory doesn't work Jan Echternach (Nov 14)
- <Possible follow-ups>
- When scrubbing secrets in memory doesn't work Michael Howard (Nov 09)
- RE: When scrubbing secrets in memory doesn't work Michael Wojcik (Nov 12)
- RE: When scrubbing secrets in memory doesn't work Michael Wojcik (Nov 17)
- Re: When scrubbing secrets in memory doesn't work Nicholas Weaver (Nov 18)
- Re: When scrubbing secrets in memory doesn't work Richard Moore (Nov 20)
- Re: When scrubbing secrets in memory doesn't work Florian Weimer (Nov 18)
- Re: When scrubbing secrets in memory doesn't work Peter Watkins (Nov 19)
- Re: When scrubbing secrets in memory doesn't work Nicholas Weaver (Nov 18)
- Re: When scrubbing secrets in memory doesn't work Perry E. Metzger (Nov 05)