1. 12 Jul, 2011 10 commits
    • Stefan Berger's avatar
      tpm_tis: Fix the probing for interrupts · a7b66822
      Stefan Berger authored
      This patch fixes several aspects of the probing for interrupts.
      
      This patch reads the TPM's timeouts before probing for the interrupts. The
      tpm_get_timeouts() function is invoked in polling mode and gets the proper
      timeouts from the TPM so that we don't need to fall back to 2 minutes timeouts
      for short duration commands while the interrupt probing is happening.
      
      This patch introduces a variable probed_irq into the vendor structure that gets
      the irq number if an interrupt is received while the the tpm_gen_interrupt()
      function is run in polling mode during interrupt probing. Previously some
      parts of tpm_gen_interrupt() were run in polling mode, then the irq variable
      was set in the interrupt handler when an interrupt was received and execution
      of tpm_gen_interrupt() ended up switching over to interrupt mode.
      tpm_gen_interrupt() execution ended up on an event queue where it eventually
      timed out since the probing handler doesn't wake any queues.
      
      Before calling into free_irq() clear all interrupt flags that may have
      been set by the TPM. The reason is that free_irq() will call into the probing
      interrupt handler and may otherwise fool us into thinking that a real interrupt
      happened (because we see the flags as being set) while the TPM's interrupt line
      is not even connected to anything on the motherboard. This solves a problem
      on one machine I did testing on (Thinkpad T60).
      
      If a TPM claims to use a specifc interrupt, the probing is done as well
      to verify that the interrupt is actually working. If a TPM indicates
      that it does not use a specific interrupt (returns '0'), probe all interrupts
      from 3 to 15.
      Signed-off-by: default avatarStefan Berger <stefanb@linux.vnet.ibm.com>
      Signed-off-by: default avatarRajiv Andrade <srajiv@linux.vnet.ibm.com>
      a7b66822
    • Stefan Berger's avatar
      tpm_tis: Delay ACPI S3 suspend while the TPM is busy · 20b87bbf
      Stefan Berger authored
      This patch delays the (ACPI S3) suspend while the TPM is busy processing a
      command and the TPM TIS driver is run in interrupt mode. This is the same
      behavior as we already have it for the TPM TIS driver in polling mode.
      
      Reasoning: Some of the TPM's commands advance the internal state of the TPM.
      An example would be the extending of one of its PCR registers. Upper layers,
      such as IMA or TSS (TrouSerS), would certainly want to be sure that the
      command succeeded rather than getting an error code (-62 = -ETIME) that may
      not give a conclusive answer as for what reason the command failed. Reissuing
      such a command would put the TPM into the wrong state, so waiting for it to
      finish is really the only option.
      
      The downside is that some commands (key creation) can take a long time and
      actually prevent the machine from entering S3 at all before the 20 second
      timeout of the power management subsystem arrives.
      Signed-off-by: default avatarStefan Berger <stefanb@linux.vnet.ibm.com>
      Signed-off-by: default avatarRajiv Andrade <srajiv@linux.vnet.ibm.com>
      20b87bbf
    • Stefan Berger's avatar
      tpm_tis: Re-enable interrupts upon (S3) resume · 45baa1d1
      Stefan Berger authored
      This patch makes sure that if the TPM TIS interface is run in interrupt mode
      (rather than polling mode) that all interrupts are enabled in the TPM's
      interrupt enable register after a resume from ACPI S3 suspend. The registers
      may either have been cleared by the TPM loosing its state during device sleep
      or by the BIOS leaving the TPM in polling mode (after sending a command to
      the TPM for starting it up again)
      
      You may want to check if your TPM runs with interrupts by doing
      
      cat /proc/interrupts | grep -i tpm
      
      and see whether there is an entry or otherwise for it to use interrupts:
      
      modprobe tpm_tis interrupts=1 [add 'itpm=1' for Intel TPM ]
      
      v2:
        - the patch was adapted to work with the pnp and platform driver
          implementations in tpm_tis.c
      Signed-off-by: default avatarStefan Berger <stefanb@linux.vnet.ibm.com>
      Signed-off-by: default avatarRajiv Andrade <srajiv@linux.vnet.ibm.com>
      45baa1d1
    • Stefan Berger's avatar
      tpm: Fix display of data in pubek sysfs entry · 5a79444f
      Stefan Berger authored
      This patch fixes the TPM's pubek sysfs entry that is accessible as long
      as the TPM doesn't have an owner. It was necessary to shift the access to the
      data by -10 -- the first byte immediately follows the 10 byte header. The
      line
      
       	data = tpm_cmd.params.readpubek_out_buffer;
      
      sets it at the offset '10' in the packet, so we can read the data array
      starting at offset '0'.
      
      Before:
      
      Algorithm: 00 0C 00 00
      Encscheme: 08 00
      Sigscheme: 00 00
      Parameters: 00 00 00 00 01 00 AC E2 5E 3C A0 78
      Modulus length: -563306801
      Modulus:
      28 21 08 0F 82 CD F2 B1 E7 49 F7 74 70 BE 59 8C
      43 78 B1 24 EA 52 E2 FE 52 5C 3A 12 3B DC 61 71
      [...]
      
      After:
      
      Algorithm: 00 00 00 01
      Encscheme: 00 03
      Sigscheme: 00 01
      Parameters: 00 00 08 00 00 00 00 02 00 00 00 00
      Modulus length: 256
      Modulus:
      AC E2 5E 3C A0 78 DE 6C 9E CF 28 21 08 0F 82 CD
      F2 B1 E7 49 F7 74 70 BE 59 8C 43 78 B1 24 EA 52
      [...]
      Signed-off-by: default avatarStefan Berger <stefanb@linux.vnet.ibm.com>
      Signed-off-by: default avatarRajiv Andrade <srajiv@linux.vnet.ibm.com>
      5a79444f
    • Stefan Berger's avatar
      tpm_tis: Add timeouts sysfs entry · 62592101
      Stefan Berger authored
      Display the TPM's interface timeouts in a 'timeouts' sysfs entry. Display
      the entries as having been adjusted when they were scaled due to their values
      being reported in milliseconds rather than microseconds.
      Signed-off-by: default avatarStefan Berger <stefanb@linux.vnet.ibm.com>
      Signed-off-by: default avatarRajiv Andrade <srajiv@linux.vnet.ibm.com>
      62592101
    • Stefan Berger's avatar
      tpm: Adjust interface timeouts if they are too small · e3e1a1e1
      Stefan Berger authored
      Adjust the interface timeouts if they are found to be too small, i.e., if
      they are returned in milliseconds rather than microseconds as we heared
      from Infineon that some (old) Infineon TPMs do.
      Signed-off-by: default avatarStefan Berger <stefanb@linux.vnet.ibm.com>
      Signed-off-by: default avatarRajiv Andrade <srajiv@linux.vnet.ibm.com>
      e3e1a1e1
    • Stefan Berger's avatar
      tpm: Use interface timeouts returned from the TPM · 829bf067
      Stefan Berger authored
      The TPM driver currently discards the interface timeout values returned
      from the TPM. The check of the response packet needs to consider that
      the return_code field is 0 on success and the size of the expected
      packet is equivalent to the header size + u32 length indicator for the
      TPM_GetCapability() result + 4 interface timeout indicators of type u32.
      Signed-off-by: default avatarStefan Berger <stefanb@linux.vnet.ibm.com>
      Signed-off-by: default avatarRajiv Andrade <srajiv@linux.vnet.ibm.com>
      829bf067
    • Stefan Berger's avatar
      tpm_tis: Introduce durations sysfs entry · 04ab2293
      Stefan Berger authored
      Display the TPM's command timeouts in a 'durations' sysfs entry. Display
      the entries as having been adjusted when they were scaled due to their values
      being reported in milliseconds rather than microseconds.
      Signed-off-by: default avatarStefan Berger <stefanb@linux.vnet.ibm.com>
      Tested-by: default avatarGuillaume Chazarain <guichaz@gmail.com>
      Signed-off-by: default avatarRajiv Andrade <srajiv@linux.vnet.ibm.com>
      04ab2293
    • Stefan Berger's avatar
      tpm: Adjust the durations if they are too small · e934acca
      Stefan Berger authored
      Adjust the durations if they are found to be too small, i.e., if they are
      returned in milliseconds rather than microseconds as some Infineon TPMs are
      reported to do.
      Signed-off-by: default avatarStefan Berger <stefanb@linux.vnet.ibm.com>
      Signed-off-by: default avatarRajiv Andrade <srajiv@linux.vnet.ibm.com>
      e934acca
    • Stefan Berger's avatar
      tpm: Use durations returned from TPM · 979b1406
      Stefan Berger authored
      The TPM driver currently discards the durations values returned
      from the TPM. The check of the response packet needs to consider that
      the return_code field is 0 on success and the size of the expected
      packet is equivalent to the header size + u32 length indicator for the
      TPM_GetCapability() result + 3 timeout indicators of type u32.
      
      v4:
      - sysfs entry 'durations' is now a patch of its own
      - the work-around for TPMs reporting durations in milliseconds is now in a
        patch of its own
      
      v3:
      - sysfs entry now called 'durations' to resemble TPM-speak (previously
        was called 'timeouts')
      
      v2:
      - adjusting all timeouts for TPM devices reporting timeouts in msec rather
        than usec
      - also displaying in sysfs whether the timeouts are 'original' or 'adjusted'
      Signed-off-by: default avatarStefan Berger <stefanb@linux.vnet.ibm.com>
      Tested-by: default avatarGuillaume Chazarain <guichaz@gmail.com>
      Signed-off-by: default avatarRajiv Andrade <srajiv@linux.vnet.ibm.com>
      979b1406
  2. 11 Jul, 2011 5 commits
  3. 07 Jul, 2011 1 commit
  4. 30 Jun, 2011 7 commits
  5. 29 Jun, 2011 11 commits
  6. 28 Jun, 2011 6 commits
    • Tetsuo Handa's avatar
      TOMOYO: Make several options configurable. · 0e4ae0e0
      Tetsuo Handa authored
      To be able to start using enforcing mode from the early stage of boot sequence,
      this patch adds support for activating access control without calling external
      policy loader program. This will be useful for systems where operations which
      can lead to the hijacking of the boot sequence are needed before loading the
      policy. For example, you can activate immediately after loading the fixed part
      of policy which will allow only operations needed for mounting a partition
      which contains the variant part of policy and verifying (e.g. running GPG
      check) and loading the variant part of policy. Since you can start using
      enforcing mode from the beginning, you can reduce the possibility of hijacking
      the boot sequence.
      
      This patch makes several variables configurable on build time. This patch also
      adds TOMOYO_loader= and TOMOYO_trigger= kernel command line option to boot the
      same kernel in two different init systems (BSD-style init and systemd).
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarJames Morris <jmorris@namei.org>
      0e4ae0e0
    • Tetsuo Handa's avatar
      TOMOYO: Add built-in policy support. · efe836ab
      Tetsuo Handa authored
      To be able to start using enforcing mode from the early stage of boot sequence,
      this patch adds support for built-in policy configuration (and next patch adds
      support for activating access control without calling external policy loader
      program).
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarJames Morris <jmorris@namei.org>
      efe836ab
    • Tetsuo Handa's avatar
      TOMOYO: Rename meminfo to stat and show more statistics. · b22b8b9f
      Tetsuo Handa authored
      Show statistics such as last policy update time and last policy violation time
      in addition to memory usage.
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarJames Morris <jmorris@namei.org>
      b22b8b9f
    • Tetsuo Handa's avatar
      TOMOYO: Cleanup part 4. · 2c47ab93
      Tetsuo Handa authored
      Gather string constants to one file in order to make the object size smaller.
      Use unsigned type where appropriate.
      read()/write() returns ssize_t.
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarJames Morris <jmorris@namei.org>
      2c47ab93
    • Tetsuo Handa's avatar
      TOMOYO: Fix lockdep warning. · 2e503bbb
      Tetsuo Handa authored
      Currently TOMOYO holds SRCU lock upon open() and releases it upon close()
      because list elements stored in the "struct tomoyo_io_buffer" instances are
      accessed until close() is called. However, such SRCU usage causes lockdep to
      complain about leaving the kernel with SRCU lock held.
      
      This patch solves the warning by holding/releasing SRCU upon each
      read()/write(). This patch is doing something similar to calling kfree()
      without calling synchronize_srcu(), by selectively deferring kfree() by keeping
      track of the "struct tomoyo_io_buffer" instances.
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarJames Morris <jmorris@namei.org>
      2e503bbb
    • Tetsuo Handa's avatar
      TOMOYO: Change pathname for non-rename()able filesystems. · 5625f2e3
      Tetsuo Handa authored
      TOMOYO wants to use /proc/self/ rather than /proc/$PID/ if $PID matches current
      thread's process ID in order to prevent current thread from accessing other
      process's information unless needed.
      
      But since procfs can be mounted on various locations (e.g. /proc/ /proc2/ /p/
      /tmp/foo/100/p/ ), TOMOYO cannot tell that whether the numeric part in the
      string returned by __d_path() represents process ID or not.
      
      Therefore, to be able to convert from $PID to self no matter where procfs is
      mounted, this patch changes pathname representations for filesystems which do
      not support rename() operation (e.g. proc, sysfs, securityfs).
      
      Examples:
        /proc/self/mounts => proc:/self/mounts
        /sys/kernel/security/ => sys:/kernel/security/
        /dev/pts/0 => devpts:/0
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarJames Morris <jmorris@namei.org>
      5625f2e3