Dead store elimination in the kernel?

Andrew Duane aduane at juniper.net
Mon Mar 8 13:54:53 UTC 2010


owner-freebsd-hackers at freebsd.org wrote:
> Hello,
> 
> I'm asking if FreeBSD is safe regarding dead store elimination made
> by gcc? 
> 
> By example, in crypto drivers, sensitive datas are cleared by a
> bzero() after use to avoid potential leakages.  But the bzero() by
> itself is useless, is it removed by gcc?
> 
> Thanks, regards.
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to
> "freebsd-hackers-unsubscribe at freebsd.org"

I would think the "correct" way to handle this is to make sure all appropriate items are declared volatile. This would eliminate dead store elimination, as the compiler can tell they are not dead.

Unfortunately, the history of drivers (or any code) correctly using volatile declarations is intermittent at best.

/Andrew



More information about the freebsd-hackers mailing list