[PATCH] D40796: [scudo] Get rid of the thread local PRNG & header salt

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 4 11:58:43 PST 2017


cryptoad created this revision.

It was deemed that the salt in the chunk header didn't improve security
significantly (and could actually decrease it). The initial idea was that the
same chunk would different headers on different allocations, allowing for less
predictability. The issue is that gathering the same chunk header with different
salts can give information about the other "secrets" (cookie, pointer), and that
if an attacker leaks a header, they can reuse it anyway for that same chunk
anyway since we don't enforce the salt value.

So we get rid of the salt in the header. This means we also get rid of the
thread local Prng, and that we don't need a global Prng anymore as well. This
makes everything faster.

We reuse those 8 bits to store the `ClassId` of a chunk now (0 for a secondary
based allocation). This way, we get some additional speed gains:

- `ClassId` is computed outside of the locked block;
- `getActuallyAllocatedSize` doesn't need the `GetSizeClass` call;
- same for `deallocatePrimary`;

We add a sanity check at init for this new field (all sanity checks are moved
in their own function, `init` was getting crowded).


https://reviews.llvm.org/D40796

Files:
  lib/scudo/scudo_allocator.cpp
  lib/scudo/scudo_allocator.h
  lib/scudo/scudo_allocator_combined.h
  lib/scudo/scudo_tsd.h
  lib/scudo/scudo_utils.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40796.125396.patch
Type: text/x-patch
Size: 16145 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171204/57fe1b82/attachment.bin>


More information about the llvm-commits mailing list