BugTraq
When scrubbing secrets in memory doesn't work Nov 05 2002 10:13PM
Michael Howard (mikehow microsoft com) (3 replies)
Re: When scrubbing secrets in memory doesn't work Nov 08 2002 04:23PM
Michael Zimmermann (zim vegaa de) (1 replies)
Re: When scrubbing secrets in memory doesn't work Nov 11 2002 11:46AM
Jan Echternach (jan goneko de)
Re: When scrubbing secrets in memory doesn't work Nov 06 2002 12:55PM
Gianni Tedesco (gianni ecsc co uk) (1 replies)
Re: When scrubbing secrets in memory doesn't work Nov 08 2002 04:00AM
Valdis Kletnieks vt edu
On Wed, 06 Nov 2002 12:55:26 GMT, Gianni Tedesco <gianni (at) ecsc.co (dot) uk [email concealed]> 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

[ reply ]
Re: When scrubbing secrets in memory doesn't work Nov 05 2002 11:58PM
Perry E. Metzger (perry piermont com) (1 replies)
Re: When scrubbing secrets in memory doesn't work Nov 07 2002 08:08AM
Andy Polyakov (appro fy chalmers se)


 

Privacy Statement
Copyright 2010, SecurityFocus