vestigia

Detect where execution depends on secrets.
git clone git://git.ppad.tech/vestigia.git
Log | Files | Refs | README | LICENSE

qemu-getrandom.patch (978B)


      1 QEMU's user mode answers a guest's getrandom from the host, which
      2 -seed does not reach: two runs of one program draw different entropy,
      3 and every instruction computing on it differs between them. The host
      4 still answers the call, so its flags are checked and its length and
      5 errors chosen as the kernel would; the bytes it returned are then
      6 drawn from the guest generator, which -seed makes deterministic and
      7 which, unseeded, draws from the host.
      8 
      9 --- a/linux-user/syscall.c
     10 +++ b/linux-user/syscall.c
     11 @@ -10899,6 +10899,14 @@
     12              return -TARGET_EFAULT;
     13          }
     14          ret = get_errno(getrandom(p, arg2, arg3));
     15 +        if (ret > 0) {
     16 +            /*
     17 +             * The host checked the flags and chose the length; the
     18 +             * bytes come from the guest generator, which -seed makes
     19 +             * deterministic.
     20 +             */
     21 +            qemu_guest_getrandom_nofail(p, ret);
     22 +        }
     23          unlock_user(p, arg1, ret);
     24          return ret;
     25  #endif