Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tcti: Add '/dev/tcm0' to default conf #2696

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions doc/tcti.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ flowchart TD
2. `libtss2-tcti-tabrmd.so`
3. `libtss2-tcti-device.so.0:/dev/tpmrm0`
4. `libtss2-tcti-device.so.0:/dev/tpm0`
5. `libtss2-tcti-swtpm.so`
6. `libtss2-tcti-mssim.so`
5. `libtss2-tcti-device.so.0:/dev/tcm0`
6. `libtss2-tcti-swtpm.so`
7. `libtss2-tcti-mssim.so`

Where:

Expand All @@ -118,7 +119,7 @@ Where:
## tcti-device

To put it simply, tcti-device writes to and reads from a file, typically
`/dev/tpm0` or `/dev/tpmrm0`. The character devices are provided by the Linux
`/dev/tpm0` or `/dev/tpmrm0` or `/dev/tcm0`. The character devices are provided by the Linux
kernel module `tpm_tis`. If no files like these are present, verify that the
kernel module is loaded (`lsmod`) and load it if necessary (`modprobe tpm_tis`).

Expand All @@ -136,7 +137,7 @@ flowchart TD

**`conf`**

* path to the character device, typically `/dev/tpm0` or `/dev/tpmrm0`
* path to the character device, typically `/dev/tpm0` or `/dev/tpmrm0` or `/dev/tcm0`

## tcti-tbs

Expand Down
1 change: 1 addition & 0 deletions src/tss2-esys/esys_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* Library libtss2-tcti-tabrmd.so (tabrmd)
* Device /dev/tpmrm0 (kernel resident resource manager)
* Device /dev/tpm0 (hardware TPM)
* Device /dev/tcm0 (hardware TCM)
* TCP socket localhost:2321 (TPM simulator)
* @param esys_context [out] The ESYS_CONTEXT.
* @param tcti [in] The TCTI context used to connect to the TPM (may be NULL).
Expand Down
1 change: 1 addition & 0 deletions src/tss2-tcti/tcti-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ static char *default_conf[] = {
#else
"/dev/tpmrm0",
"/dev/tpm0",
"/dev/tcm0",
#endif /* __VX_WORKS__ */
};

Expand Down
5 changes: 5 additions & 0 deletions src/tss2-tcti/tctildr-dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ struct {
.conf = "/dev/tpm0",
.description = "Access libtss2-tcti-device.so.0 with /dev/tpm0",
},
{
.file = "libtss2-tcti-device.so.0",
.conf = "/dev/tcm0",
.description = "Access libtss2-tcti-device.so.0 with /dev/tcm0",
},
{
.file = "libtss2-tcti-swtpm.so.0",
.description = "Access to libtss2-tcti-swtpm.so",
Expand Down
10 changes: 10 additions & 0 deletions src/tss2-tcti/tctildr-nodl.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ struct {
.conf = "/dev/tpm0",
.description = "Access to /dev/tpm0",
},
{
.names = {
"libtss2-tcti-device.so.0",
"libtss2-tcti-device.so",
"device",
},
.init = Tss2_Tcti_Device_Init,
.conf = "/dev/tcm0",
.description = "Access to /dev/tcm0",
},
#endif /* TCTI_DEVICE */
#endif /* _WIN32 */
#ifdef TCTI_SWTPM
Expand Down
1 change: 1 addition & 0 deletions src/tss2-tcti/tctildr.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ const TSS2_TCTI_INFO tss2_tcti_info = {
" * libtss2-tcti-tabrmd.so\n"
" * libtss2-tcti-device.so.0:/dev/tpmrm0\n"
" * libtss2-tcti-device.so.0:/dev/tpm0\n"
" * libtss2-tcti-device.so.0:/dev/tcm0\n"
" * libtss2-tcti-swtpm.so\n"
" * libtss2-tcti-mssim.so\n"
"Where child_name: if not empty, tctildr will try to dynamically load the child tcti library in the following order:\n"
Expand Down
1 change: 1 addition & 0 deletions test/unit/tcti-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ tcti_device_init_conf_default_fail (void **state)
errno = EACCES; /* Permission denied */
will_return (__wrap_open, -1);
will_return (__wrap_open, -1);
will_return (__wrap_open, -1);
ret = Tss2_Tcti_Device_Init (ctx, &tcti_size, NULL);
assert_true (ret == TSS2_TCTI_RC_IO_ERROR);

Expand Down
17 changes: 17 additions & 0 deletions test/unit/tctildr-dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,23 @@ test_tcti_fail_all (void **state)
expect_value(__wrap_dlopen, flags, RTLD_NOW);
will_return(__wrap_dlopen, NULL);

/* Skip over libtss2-tcti-device.so, /dev/tcm0 */
expect_string(__wrap_dlopen, filename, "libtss2-tcti-device.so.0");
expect_value(__wrap_dlopen, flags, RTLD_NOW);
will_return(__wrap_dlopen, NULL);
expect_string(__wrap_dlopen, filename, "libtss2-tcti-libtss2-tcti-device.so.0.so.0");
expect_value(__wrap_dlopen, flags, RTLD_NOW);
will_return(__wrap_dlopen, NULL);
expect_string(__wrap_dlopen, filename, "libtss2-tcti-libtss2-tcti-device.so.0.so");
expect_value(__wrap_dlopen, flags, RTLD_NOW);
will_return(__wrap_dlopen, NULL);
expect_string(__wrap_dlopen, filename, "libtss2-libtss2-tcti-device.so.0.so.0");
expect_value(__wrap_dlopen, flags, RTLD_NOW);
will_return(__wrap_dlopen, NULL);
expect_string(__wrap_dlopen, filename, "libtss2-libtss2-tcti-device.so.0.so");
expect_value(__wrap_dlopen, flags, RTLD_NOW);
will_return(__wrap_dlopen, NULL);

/* Skip over libtss2-tcti-swtpm.so */
expect_string(__wrap_dlopen, filename, "libtss2-tcti-swtpm.so.0");
expect_value(__wrap_dlopen, flags, RTLD_NOW);
Expand Down
3 changes: 3 additions & 0 deletions test/unit/tctildr-nodl.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ test_tctildr_get_default_all_fail (void **state)
TSS2_TCTI_CONTEXT *tcti_ctx = NULL;

#define TEST_RC 0x65203563
/* device:/dev/tcm0 */
will_return(__wrap_tcti_from_init, tcti_ctx);
will_return(__wrap_tcti_from_init, TEST_RC);
/* device:/dev/tpm0 */
will_return (__wrap_tcti_from_init, tcti_ctx);
will_return (__wrap_tcti_from_init, TEST_RC);
Expand Down
Loading