Re: [PATCH] sha: prevent removal of memset as dead store in sha1_update()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Instead of barrier(), this works with gcc-3.2.3 up to gcc-4.4.3
> for the purpose of making the memset() not disappear:
> 
> 	{
> 		struct s { char c[n]; };
> 		asm("" : : "m"(*(struct s *)p));
> 	}
> 
> Every byte in the [p,p+n[ range must be used. If you only use the
> first byte, via e.g. asm("" :: "m"(*(char*)p)), then the compiler
> _will_ skip scrubbing bytes beyond the first.
> 
> An explicit loop that uses each byte individually also works, but
> results in awful code with older compilers.

I suspect it would be worth asking for a __builtin for this.
iirc Visual C already has one.

BTW I remember finding a few more such cases in random user space
code in past code review.

-Andi
-- 
ak@xxxxxxxxxxxxxxx -- Speaking for myself only.
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux