1. 17 4月, 2013 1 次提交
    • D
      TPM: Retry SaveState command in suspend path · 32d33b29
      Duncan Laurie 提交于
      If the TPM has already been sent a SaveState command before the driver
      is loaded it may have problems sending that same command again later.
      
      This issue is seen with the Chromebook Pixel due to a firmware bug in
      the legacy mode boot path which is sending the SaveState command
      before booting the kernel.  More information is available at
      http://crbug.com/203524
      
      This change introduces a retry of the SaveState command in the suspend
      path in order to work around this issue.  A future firmware update
      should fix this but this is also a trivial workaround in the driver
      that has no effect on systems that do not show this problem.
      
      When this does happen the TPM responds with a non-fatal TPM_RETRY code
      that is defined in the specification:
      
        The TPM is too busy to respond to the command immediately, but the
        command could be resubmitted at a later time.  The TPM MAY return
        TPM_RETRY for any command at any time.
      
      It can take several seconds before the TPM will respond again.  I
      measured a typical time between 3 and 4 seconds and the timeout is set
      at a safe 5 seconds.
      
      It is also possible to reproduce this with commands via /dev/tpm0.
      The bug linked above has a python script attached which can be used to
      test for this problem.  I tested a variety of TPMs from Infineon,
      Nuvoton, Atmel, and STMicro but was only able to reproduce this with
      LPC and I2C TPMs from Infineon.
      
      The TPM specification only loosely defines this behavior:
      
        TPM Main Level 2 Part 3 v1.2 r116, section 3.3. TPM_SaveState:
        The TPM MAY declare all preserved values invalid in response to any
        command other than TPM_Init.
      
        TCG PC Client BIOS Spec 1.21 section 8.3.1.
        After issuing a TPM_SaveState command, the OS SHOULD NOT issue TPM
        commands before transitioning to S3 without issuing another
        TPM_SaveState command.
      
        TCG PC Client TIS 1.21, section 4. Power Management:
        The TPM_SaveState command allows a Static OS to indicate to the TPM
        that the platform may enter a low power state where the TPM will be
        required to enter into the D3 power state.  The use of the term "may"
        is significant in that there is no requirement for the platform to
        actually enter the low power state after sending the TPM_SaveState
        command.  The software may, in fact, send subsequent commands after
        sending the TPM_SaveState command.
      
      Change-Id: I52b41e826412688e5b6c8ddd3bb16409939704e9
      Signed-off-by: NDuncan Laurie <dlaurie@chromium.org>
      Signed-off-by: NKent Yoder <key@linux.vnet.ibm.com>
      32d33b29
  2. 05 2月, 2013 6 次提交
    • S
      tpm: Fix cancellation of TPM commands (interrupt mode) · 78f09cc2
      Stefan Berger 提交于
      Support cancellation of TPM commands when driver is used in interrupt
      mode.
      Signed-off-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
      Signed-off-by: NKent Yoder <key@linux.vnet.ibm.com>
      78f09cc2
    • S
      tpm: Fix cancellation of TPM commands (polling mode) · 1f866057
      Stefan Berger 提交于
      On one of my machines the cancellation of TPM commands does not work.
      The reason is that by writing into sysfs 'cancel' the tpm_tis_ready
      call causes the status flag TPM_STS_VALID to be set in the statusregister.
      However, the TIS driver seems to wait for TPM_STS_COMMAND_READY.
      Once a 2nd time sysfs 'cancel' is written to, the TPM_STS_COMMAND_READY flag
      also gets set, resulting in TPM_STS_VALID|TPM_STS_COMMAND_READY to be
      read from the status register.
      
      This patch now converts req_canceled into a function to enable more complex
      comparisons against possible cancellation status codes.
      Signed-off-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
      Signed-off-by: NKent Yoder <key@linux.vnet.ibm.com>
      1f866057
    • J
      TPM: Work around buggy TPMs that block during continue self test · 4643826a
      Jason Gunthorpe 提交于
      We've been testing an alternative TPM for our embedded products and
      found random kernel boot failures due to time outs after the continue
      self test command.
      
      This was happening randomly, and has been *very* hard to track down, but
      it
      looks like with this chip there is some kind of race with the
      tpm_tis_status()
      check of TPM_STS_COMMAND_READY. If things get there 'too fast' then
      it sees the chip is ready, or tpm_tis_ready() works. Otherwise it takes
      somewhere over 400ms before the chip will return TPM_STS_COMMAND_READY.
      
      Adding some delay after tpm_continue_selftest() makes things reliably
      hit the failure path, otherwise it is a crapshot.
      
      The spec says it should be returning TPM_WARN_DOING_SELFTEST, not
      holding
      off on ready..
      
      Boot log during this event looks like this:
      
      tpm_tis 70030000.tpm_tis: 1.2 TPM (device-id 0x3204, rev-id 64)
      tpm_tis 70030000.tpm_tis: Issuing TPM_STARTUP
      tpm_tis 70030000.tpm_tis: tpm_transmit: tpm_send: error -62
      tpm_tis 70030000.tpm_tis: [Hardware Error]: TPM command timed out during
      continue self test
      tpm_tis 70030000.tpm_tis: tpm_transmit: tpm_send: error -62
      tpm_tis 70030000.tpm_tis: [Hardware Error]: TPM command timed out during
      continue self test
      tpm_tis 70030000.tpm_tis: tpm_transmit: tpm_send: error -62
      tpm_tis 70030000.tpm_tis: [Hardware Error]: TPM command timed out during
      continue self test
      tpm_tis 70030000.tpm_tis: tpm_transmit: tpm_send: error -62
      tpm_tis 70030000.tpm_tis: [Hardware Error]: TPM command timed out during
      continue self test
      
      The other TPM vendor we use doesn't show this wonky behaviour:
      tpm_tis 70030000.tpm_tis: 1.2 TPM (device-id 0xFE, rev-id 70)
      Signed-off-by: NJason Gunthorpe <jgunthorpe@obsidianresearch.com>
      Signed-off-by: NKent Yoder <key@linux.vnet.ibm.com>
      4643826a
    • J
      TPM: Issue TPM_STARTUP at driver load if the TPM has not been started · c584af19
      Jason Gunthorpe 提交于
      The TPM will respond to TPM_GET_CAP with TPM_ERR_INVALID_POSTINIT if
      TPM_STARTUP has not been issued. Detect this and automatically
      issue TPM_STARTUP.
      
      This is for embedded applications where the kernel is the first thing
      to touch the TPM.
      Signed-off-by: NJason Gunthorpe <jgunthorpe@obsidianresearch.com>
      Tested-by: NPeter Huewe <peter.huewe@infineon.com>
      Reviewed-by: NPeter Huewe <peter.huewe@infineon.com>
      Signed-off-by: NKent Yoder <key@linux.vnet.ibm.com>
      c584af19
    • P
      char/tpm: simplify duration calculation and eliminate smatch warning. · 07b133e6
      Peter Huewe 提交于
      This patch changes the semantics of the duration calculation for an
      ordinal, by masking out the higher bits of a tpm command, which specify
      whether it's an TPM_PROTECTED_COMMAND, TPM_UNPROTECTED_COMMAND,
      TPM_CONNECTION_COMMAND, TPM_CONNECTION_COMMAND, TPM_VENDOR_COMMAND.
      (See TPM Main Spec Part 2 Section 17 for details).
      
      For all TPM_PROTECTED and TPM_CONNECTION commands the results are
      unchanged.
      The TPM_UNPROTECTED commands are TSS commands and thus irrelevant as
      they are not sent to the tpm.
      For vendor commands the semantics change for ordinals 10 and 11 but
      they were probably wrong anyway.
      
      For everything else which has the ordinal set to 10 or 11 the semantics
      change as it now uses TPM_UNDEFINED instead of TPM_SHORT which was
      probably wrong anyway (but irrelevant as not defined by the standard).
      
      This patch also gets rid of the (false positive) smatch warning:
       drivers/char/tpm/tpm.c:360 tpm_calc_ordinal_duration() error: buffer
       overflow 'tpm_protected_ordinal_duration' 12 <= 243
      Signed-off-by: NPeter Huewe <peterhuewe@gmx.de>
      Signed-off-by: NKent Yoder <key@linux.vnet.ibm.com>
      07b133e6
    • P
      char/tpm: Remove duplicated lookup table · 720ca4a9
      Peter Huewe 提交于
      The entries in tpm_protected_ordinal_duration are exactly the same as
      the first 12 in tpm_ordinal_duration, so we can simply remove this one,
      and save some bytes.
      
      This does not change the behavior of the driver.
      Signed-off-by: NPeter Huewe <peterhuewe@gmx.de>
      Signed-off-by: NKent Yoder <key@linux.vnet.ibm.com>
      720ca4a9
  3. 11 10月, 2012 1 次提交
    • P
      tpm: Propagate error from tpm_transmit to fix a timeout hang · abce9ac2
      Peter Huewe 提交于
      tpm_write calls tpm_transmit without checking the return value and
      assigns the return value unconditionally to chip->pending_data, even if
      it's an error value.
      This causes three bugs.
      
      So if we write to /dev/tpm0 with a tpm_param_size bigger than
      TPM_BUFSIZE=0x1000 (e.g. 0x100a)
      and a bufsize also bigger than TPM_BUFSIZE (e.g. 0x100a)
      tpm_transmit returns -E2BIG which is assigned to chip->pending_data as
      -7, but tpm_write returns that TPM_BUFSIZE bytes have been successfully
      been written to the TPM, altough this is not true (bug #1).
      
      As we did write more than than TPM_BUFSIZE bytes but tpm_write reports
      that only TPM_BUFSIZE bytes have been written the vfs tries to write
      the remaining bytes (in this case 10 bytes) to the tpm device driver via
      tpm_write which then blocks at
      
       /* cannot perform a write until the read has cleared
       either via tpm_read or a user_read_timer timeout */
       while (atomic_read(&chip->data_pending) != 0)
      	 msleep(TPM_TIMEOUT);
      
      for 60 seconds, since data_pending is -7 and nobody is able to
      read it (since tpm_read luckily checks if data_pending is greater than
      0) (#bug 2).
      
      After that the remaining bytes are written to the TPM which are
      interpreted by the tpm as a normal command. (bug #3)
      So if the last bytes of the command stream happen to be a e.g.
      tpm_force_clear this gets accidentally sent to the TPM.
      
      This patch fixes all three bugs, by propagating the error code of
      tpm_write and returning -E2BIG if the input buffer is too big,
      since the response from the tpm for a truncated value is bogus anyway.
      Moreover it returns -EBUSY to userspace if there is a response ready to be
      read.
      Signed-off-by: NPeter Huewe <peter.huewe@infineon.com>
      Signed-off-by: NKent Yoder <key@linux.vnet.ibm.com>
      abce9ac2
  4. 10 10月, 2012 1 次提交
  5. 05 9月, 2012 1 次提交
  6. 23 8月, 2012 4 次提交
  7. 21 8月, 2012 1 次提交
    • T
      workqueue: deprecate flush[_delayed]_work_sync() · 43829731
      Tejun Heo 提交于
      flush[_delayed]_work_sync() are now spurious.  Mark them deprecated
      and convert all users to flush[_delayed]_work().
      
      If you're cc'd and wondering what's going on: Now all workqueues are
      non-reentrant and the regular flushes guarantee that the work item is
      not pending or running on any CPU on return, so there's no reason to
      use the sync flushes at all and they're going away.
      
      This patch doesn't make any functional difference.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: Ian Campbell <ian.campbell@citrix.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Mattia Dongili <malattia@linux.it>
      Cc: Kent Yoder <key@linux.vnet.ibm.com>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Jiri Kosina <jkosina@suse.cz>
      Cc: Karsten Keil <isdn@linux-pingi.de>
      Cc: Bryan Wu <bryan.wu@canonical.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Alasdair Kergon <agk@redhat.com>
      Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
      Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: linux-wireless@vger.kernel.org
      Cc: Anton Vorontsov <cbou@mail.ru>
      Cc: Sangbeom Kim <sbkim73@samsung.com>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Eric Van Hensbergen <ericvh@gmail.com>
      Cc: Takashi Iwai <tiwai@suse.de>
      Cc: Steven Whitehouse <swhiteho@redhat.com>
      Cc: Petr Vandrovec <petr@vandrovec.name>
      Cc: Mark Fasheh <mfasheh@suse.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Avi Kivity <avi@redhat.com> 
      43829731
  8. 11 7月, 2012 1 次提交
  9. 13 6月, 2012 3 次提交
  10. 15 2月, 2012 1 次提交
  11. 19 1月, 2012 1 次提交
  12. 16 11月, 2011 5 次提交
  13. 23 9月, 2011 2 次提交
    • P
      TPM: Zero buffer after copying to userspace · 3321c07a
      Peter Huewe 提交于
      Since the buffer might contain security related data it might be a good idea to
      zero the buffer after we have copied it to userspace.
      
      This got assigned CVE-2011-1162.
      Signed-off-by: NRajiv Andrade <srajiv@linux.vnet.ibm.com>
      Cc: Stable Kernel <stable@kernel.org>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      3321c07a
    • P
      TPM: Call tpm_transmit with correct size · 6b07d30a
      Peter Huewe 提交于
      This patch changes the call of tpm_transmit by supplying the size of the
      userspace buffer instead of TPM_BUFSIZE.
      
      This got assigned CVE-2011-1161.
      
      [The first hunk didn't make sense given one could expect
       way less data than TPM_BUFSIZE, so added tpm_transmit boundary
       check over bufsiz instead
       The last parameter of tpm_transmit() reflects the amount
       of data expected from the device, and not the buffer size
       being supplied to it. It isn't ideal to parse it directly,
       so we just set it to the maximum the input buffer can handle
       and let the userspace API to do such job.]
      Signed-off-by: NRajiv Andrade <srajiv@linux.vnet.ibm.com>
      Cc: Stable Kernel <stable@kernel.org>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      6b07d30a
  14. 24 8月, 2011 1 次提交
  15. 13 7月, 2011 8 次提交
  16. 30 3月, 2011 1 次提交
  17. 02 3月, 2011 1 次提交
    • L
      Revert "TPM: Long default timeout fix" · 8d1dc20e
      Linus Torvalds 提交于
      This reverts commit c4ff4b82.
      
      Ted Ts'o reports:
      
       "TPM is working for me so I can log into employer's network in 2.6.37.
        It broke when I tried 2.6.38-rc6, with the following relevant lines
        from my dmesg:
      
        [   11.081627] tpm_tis 00:0b: 1.2 TPM (device-id 0x0, rev-id 78)
        [   25.734114] tpm_tis 00:0b: Operation Timed out
        [   78.040949] tpm_tis 00:0b: Operation Timed out
      
        This caused me to get suspicious, especially since the _other_ TPM
        commit in 2.6.38 had already been reverted, so I tried reverting
        commit c4ff4b82: "TPM: Long default timeout fix".  With this commit
        reverted, my TPM on my Lenovo T410 is once again working."
      Requested-and-tested-by: NTheodore Ts'o <tytso@mit.edu>
      Acked-by: NRajiv Andrade <srajiv@linux.vnet.ibm.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8d1dc20e
  18. 21 2月, 2011 1 次提交
    • L
      Revert "tpm_tis: Use timeouts returned from TPM" · e5871372
      Linus Torvalds 提交于
      This reverts commit 9b29050f.
      
      It has caused hibernate regressions, for example Juri Sladby's report:
      
        "I'm unable to hibernate 2.6.37.1 unless I rmmod tpm_tis:
         [10974.074587] Suspending console(s) (use no_console_suspend to debug)
         [10974.103073] tpm_tis 00:0c: Operation Timed out
         [10974.103089] legacy_suspend(): pnp_bus_suspend+0x0/0xa0 returns -62
         [10974.103095] PM: Device 00:0c failed to freeze: error -62"
      
      and Rafael points out that some of the new conditionals in that commit
      seem to make no sense.  This commit needs more work and testing, let's
      revert it for now.
      Reported-by: NNorbert Preining <preining@logic.at>
      Reported-and-requested-by: NJiri Slaby <jirislaby@gmail.com>
      Cc: Stefan Berger <stefanb@linux.vnet.ibm.com>
      Cc: Guillaume Chazarain <guichaz@gmail.com>
      Cc: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
      Acked-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e5871372