[PATCH] D123958: [randstruct] Randomize all elements of a record

Kees Cook via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 19 11:02:13 PDT 2022

kees added a comment.

In D123958#3459205 <https://reviews.llvm.org/D123958#3459205>, @aaron.ballman wrote:

> I had assumed that any structure not marked for randomization would not be randomized. Based on that, I don't think inner structure objects (anonymous or otherwise) should automatically randomize their fields. WDYT?

Correct, inner structs should be evaluated without looking at the state of the outer randomization.

  struct mixed {
      int a;
      float b;
  } __attribute__((randomize_layout));
  struct ordered {
      int foo;
      char bar[8];
  struct composite {
      int one;
      struct mixed two;
      struct ordered three;
      struct {
          unsigned long am;
          double ordered;
  } __attribute__((randomize_layout));

- Each of the member's relative positions of `struct composite` should be randomized: one, two, three, anon struct.
- The members of `two` should be randomized.
- The members of `three` should //not// be randomized.
- The members of the anon struct should //not// be randomized.

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list