linux/drivers/char/tpm
Javier Martinez Canillas 095531f891 tpm: return a TPM_RC_COMMAND_CODE response if command is not implemented
According to the TPM Library Specification, a TPM device must do a command
header validation before processing and return a TPM_RC_COMMAND_CODE code
if the command is not implemented.

So user-space will expect to handle that response as an error. But if the
in-kernel resource manager is used (/dev/tpmrm?), an -EINVAL errno code is
returned instead if the command isn't implemented. This confuses userspace
since it doesn't expect that error value.

This also isn't consistent with the behavior when not using TPM spaces and
accessing the TPM directly (/dev/tpm?). In this case, the command is sent
to the TPM even when not implemented and the TPM responds with an error.

Instead of returning an -EINVAL errno code when the tpm_validate_command()
function fails, synthesize a TPM command response so user-space can get a
TPM_RC_COMMAND_CODE as expected when a chip doesn't implement the command.

The TPM only sets 12 of the 32 bits in the TPM_RC response, so the TSS and
TAB specifications define that higher layers in the stack should use some
of the unused 20 bits to specify from which level of the stack the error
is coming from.

Since the TPM_RC_COMMAND_CODE response code is sent by the kernel resource
manager, set the error level to the TAB/RM layer so user-space is aware of
this.

Suggested-by: Jason Gunthorpe <jgg@ziepe.ca>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: William Roberts <william.c.roberts@intel.com>
Reviewed-by: Philip Tricca <philip.b.tricca@intel.com>
Reviewed-by: Jarkko Sakkinen  <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen  <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen  <jarkko.sakkinen@linux.intel.com>
2018-01-08 12:58:36 +02:00
..
st33zp24 License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Kconfig tpm: Move Linux RNG connection to hwrng 2018-01-08 12:58:36 +02:00
Makefile tpm: parse TPM event logs based on EFI table 2018-01-08 12:58:35 +02:00
tpm1_eventlog.c tpm: parse TPM event logs based on EFI table 2018-01-08 12:58:35 +02:00
tpm2_eventlog.c tpm: move tpm_eventlog.h outside of drivers folder 2018-01-08 12:58:34 +02:00
tpm2-cmd.c tpm: fix type of a local variable in tpm2_get_cc_attrs_tbl() 2017-10-18 18:28:48 +03:00
tpm2-space.c tpm: fix type of a local variable in tpm2_map_command() 2017-10-18 18:28:48 +03:00
tpm_atmel.c tpm/tpm_atmel: remove unnecessary NULL check 2017-06-19 02:36:04 +02:00
tpm_atmel.h tpm: remove tpm_read_index and tpm_write_index from tpm.h 2017-02-03 22:03:14 +02:00
tpm_crb.c tpm/tpm_crb: Use start method value from ACPI table directly 2017-10-18 18:28:45 +03:00
tpm_eventlog_acpi.c tpm: parse TPM event logs based on EFI table 2018-01-08 12:58:35 +02:00
tpm_eventlog_efi.c tpm: parse TPM event logs based on EFI table 2018-01-08 12:58:35 +02:00
tpm_eventlog_of.c tpm: parse TPM event logs based on EFI table 2018-01-08 12:58:35 +02:00
tpm_i2c_atmel.c tpm: Factor out common startup code 2016-07-19 17:43:38 +03:00
tpm_i2c_infineon.c tpm: Apply a sane minimum adapterlimit value for retransmission. 2017-06-13 22:02:08 +03:00
tpm_i2c_nuvoton.c tpm: add sleep only for retry in i2c_nuvoton_write_status() 2017-04-03 22:46:02 +03:00
tpm_ibmvtpm.c tpm: ibmvtpm: simplify crq initialization and document crq format 2017-09-23 21:51:38 -07:00
tpm_ibmvtpm.h tpm_ibmvtpm: properly handle interrupted packet receptions 2015-12-20 15:27:12 +02:00
tpm_infineon.c tpm: replace msleep() with usleep_range() in TPM 1.2/2.0 generic drivers 2017-09-23 21:51:00 -07:00
tpm_nsc.c tpm: remove tpm_read_index and tpm_write_index from tpm.h 2017-02-03 22:03:14 +02:00
tpm_ppi.c ACPI: Switch to use generic guid_t in acpi_evaluate_dsm() 2017-06-07 12:20:49 +02:00
tpm_tis_core.c tpm: reduce tpm polling delay in tpm_tis_core 2018-01-08 12:58:33 +02:00
tpm_tis_core.h tpm: constify transmit data pointers 2017-10-18 18:28:45 +03:00
tpm_tis_spi.c tpm: fix type of a local variables in tpm_tis_spi.c 2017-10-18 18:28:48 +03:00
tpm_tis.c tpm, tpm_tis: use ARRAY_SIZE() to define TPM_HID_USR_IDX 2017-10-18 18:28:49 +03:00
tpm_vtpm_proxy.c tpm: vtpm_proxy: Prevent userspace from sending driver command 2017-06-13 22:02:09 +03:00
tpm-chip.c tpm: Move Linux RNG connection to hwrng 2018-01-08 12:58:36 +02:00
tpm-dev-common.c treewide: setup_timer() -> timer_setup() 2017-11-21 15:57:07 -08:00
tpm-dev.c tpm: split out tpm-dev.c into tpm-dev.c and tpm-common-dev.c 2017-04-03 22:46:01 +03:00
tpm-dev.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
tpm-interface.c tpm: return a TPM_RC_COMMAND_CODE response if command is not implemented 2018-01-08 12:58:36 +02:00
tpm-sysfs.c tpm: migrate pubek_show to struct tpm_buf 2017-10-12 14:28:59 +03:00
tpm.h tpm: return a TPM_RC_COMMAND_CODE response if command is not implemented 2018-01-08 12:58:36 +02:00
tpmrm-dev.c tpm, tpmrm: Mark tpmrm_write as static 2017-06-13 22:02:08 +03:00
xen-tpmfront.c tpm: move wait_for_tpm_stat() to respective driver files 2017-12-16 20:27:32 +02:00