1. 13 Aug, 2018 1 commit
    • Miquel Raynal's avatar
      tpm: sandbox: fix wrong check on pcr_map · fd973ca6
      Miquel Raynal authored and Tom Rini's avatar Tom Rini committed
      
      
      The second check on pcr_map in sandbox_tpm2_xfer() is wrong. It should
      check for pcr_map not being empty. Instead, it is a pure copy/paste of
      the first check which is redundant.
      
      This has been found thanks to a Coverity Scan report:
      
          CID 183370:  Memory - illegal accesses  (UNINIT)
          Using uninitialized value "pcr_index".
              put_unaligned_be32(tpm->pcr_extensions[pcr_index], recv);
      
      This is because pcr_index is initialized only if the user input is
      correct, ie. at least one valid bit is set in pcr_map.
      
      Fix the second check and also initialize pcr_index to 0 (which is
      harmless in case of error) to make Coverity Scan happy.
      Reported-by: Tom Rini's avatarTom Rini <trini@konsulko.com>
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Reviewed-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      fd973ca6
  2. 28 Jul, 2018 1 commit
    • Miquel Raynal's avatar
      tpm: allow TPM v1 and v2 to be compiled at the same time · 2a2096ea
      Miquel Raynal authored and Tom Rini's avatar Tom Rini committed
      
      
      While there is probably no reason to do so in a real life situation, it
      will allow to compile test both stacks with the same sandbox defconfig.
      
      As we cannot define two 'tpm' commands at the same time, the command for
      TPM v1 is still called 'tpm' and the one for TPM v2 'tpm2'. While this
      is the exact command name that must be written into eg. test files, any
      user already using the TPM v2 stack can continue to do so by just writing
      'tpm' because as long as TPM v1 support is not compiled, U-Boot prompt
      will search for the closest command named after 'tpm'.
      
      The command set can also be changed at runtime (not supported yet, but
      ready to be), but as one can compile only either one stack or the other,
      there is still one spot in the code where conditionals are used: to
      retrieve the v1 or v2 command set.
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Reviewed-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
      [trini: In sandbox_tpm2_fill_buf() use NULL not \0 to ensure NULL
      terminated string due to LLVM warning]
      Signed-off-by: Tom Rini's avatarTom Rini <trini@konsulko.com>
      2a2096ea
  3. 26 May, 2018 1 commit