News for hackers. Stuff that matters.
Re:A 100LOC C impl of memset, that is faster than glibc's by rurban on Friday November 12, 2021 @08:48AM (#29199196)
I have a memset that's not only 10x faster than glibc, but also secure. The trick is to bypass the generic asm, and let the compiler optimize it, esp. with constant sizes and known alignments. Esp. with clang.
Re:A 100LOC C impl of memset, that is faster than glibc's by errcorrectcode on Friday November 12, 2021 @09:16AM (#29199423)
Don't do this. Security. explicit_bzero() won't be optimized away.
Re:A 100LOC C impl of memset, that is faster than glibc's by rurban on Sunday November 14, 2021 @02:37AM (#29215934)
I do it because nobody else implemented a secure memset. What they call secure is just avoiding that the compiler ignores it. A secure memset also cleans the caches with a memory barrier, so that meltdown cannot read it.

explicit_bzero and it's numerous variants are not only insecure, but also slow. (byte wise!)

Only safelibc has a secure memset_s. https://github.com/rurban/safeclib/blob/master/tests/perf_me...