llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.69k stars 11.86k forks source link

randomize_layout attribute is not documented #111320

Open pinskia opened 2 weeks ago

pinskia commented 2 weeks ago

There is no documentation for the randomize_layout attribute in the clang documentation.

pinskia commented 2 weeks ago

Actualy it is documented: https://clang.llvm.org/docs/AttributeReference.html#randomize-layout-no-randomize-layout

But it does not document how : "The randomization is deterministic based for a given seed, so the entire program should be compiled with the same seed, but keep the seed safe otherwise. " works.

Is it based on the struct name? Or something else? Or the order which the struct is defined? Or is the seed the same for each struct? It is not obvious?

Does clang record the seed and then error out if there are 2 TUs with the same seed? Seems like if this is a security feature then it should warn at least?

pinskia commented 2 weeks ago

Does clang warn about when using randomize_layout with pointers? seems like without this is a security issue waiting to happen.