[tpm2] Re: Tss2_Tcti_Device_Init context not zeroed
Roberts, William C <william.c.roberts at intel.com> Tue, 12 Jul 2022 13:53:20 +0000
| Newsgroups | dev.linux.lists.tpm2 |
|---|---|
| Message-ID | <SN6PR11MB34375418EF61F877313E8171B8869@SN6PR11MB3437.namprd11.prod.outlook.com> |
+ list > 1 – Is mandatory zeroing it before calling Tss2_Tcti_Device_Init? If so, is it a case of missing specification? No it shouldn't be required IIUC > 2 – No, it isn’t, so is there a bug? Looks like a bug and it looks consistent throughout all the init routines for TCTIs. ________________________________ From: Antonio de Moraes, Marcos <marcos.antonio-de-moraes(a)hpe.com> Sent: Monday, July 11, 2022 1:21 PM To: tpm2-owner(a)lists.01.org <tpm2-owner(a)lists.01.org> Subject: Tss2_Tcti_Device_Init context not zeroed Hi all, I noticed when performing subsequent tpm2 calls over a not zeroed tcti context passed to Tss2_Tcti_Device_Init I have errors such as: “WARNING:tcti:src/tss2-tcti/tcti-device.c:321:tcti_device_receive() TPM2 response size disagrees with number of bytes read from fd 3. Header says 0 but we read 29 bytes. ERROR:sys:src/tss2-sys/api/Tss2_Sys_Execute.c:118:Tss2_Sys_ExecuteFinish() Malformed response: Invalid tag in response header: 0” I made some experiments: If I put some content different than 0x00 at offset 89 in memory block passed to RC Tss2_Tcti_Device_Init it fails. That is also true for some other offsets. TSS2_RC Tss2_Tcti_Device_Init (TSS2_TCTI_CONTEXT *tctiContext, size_t *size, const char *conf); I check the description of Tss2_Tcti_Device_Init and didn’t find any observation that tctiContext parameter must point an zeroed memory block, although in the usage examples the allocated memory is zeroed , calling calloc( 1, <needed size>). Regarding tctiContext memory block passed to Tss2_Tcti_Device_Init: 1 – Is mandatory zeroing it before calling Tss2_Tcti_Device_Init? If so, is it a case of missing specification? 2 – No, it isn’t, so is there a bug? My environment: TCTI shared library: libtss2-tcti-device.so.0 OS: Enterprise Suse Linux Thanks in advance, Marcos A. de Moraes HPE Security Software Engineer
attachment.htm
(text/html, 5.4 KB)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
+ list</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span style="text-indent: 36pt;"><br>
</span></div>
<div style="text-indent: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span style="text-indent: 36pt;">> 1 Is mandatory zeroing it before calling Tss2_Tcti_Device_Init? If so, is it a case of missing specification?</span></div>
<div style="text-indent: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span style="text-indent: 36pt;"><br>
</span></div>
<div style="text-indent: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span style="text-indent: 36pt;">No it shouldn't be required IIUC</span></div>
<div style="text-indent: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span style="text-indent: 36pt;"><br>
</span></div>
<div style="text-indent: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span style="text-indent: 36pt;">> 2 No, it isnt, so is there a bug?</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Looks like a bug and it looks consistent throughout all the init routines for TCTIs.</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Antonio de Moraes, Marcos <[email protected]><br>
<b>Sent:</b> Monday, July 11, 2022 1:21 PM<br>
<b>To:</b> [email protected] <[email protected]><br>
<b>Subject:</b> Tss2_Tcti_Device_Init context not zeroed</font>
<div> </div>
</div>
<style>
<!--
@font-face
{font-family:"Cambria Math"}
@font-face
{font-family:Calibri}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif}
.x_MsoChpDefault
{font-family:"Calibri",sans-serif}
@page WordSection1
{margin:72.0pt 72.0pt 72.0pt 72.0pt}
div.x_WordSection1
{}
-->
</style>
<div lang="EN-GB" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="x_WordSection1">
<p class="x_MsoNormal">Hi all,</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"> I noticed when performing subsequent tpm2 calls over a not zeroed tcti context passed to Tss2_Tcti_Device_Init I have errors such as:</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">WARNING:tcti:src/tss2-tcti/tcti-device.c:321:tcti_device_receive() TPM2 response size disagrees with number of bytes read from fd 3<b>. Header says 0 but we read 29 bytes</b>.
</p>
<p class="x_MsoNormal">ERROR:sys:src/tss2-sys/api/Tss2_Sys_Execute.c:118:Tss2_Sys_ExecuteFinish() Malformed response: Invalid tag in response header: 0</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">I made some experiments: If I put some content different than 0x00 at offset 89 in memory block passed to RC Tss2_Tcti_Device_Init it fails. That is also true for some other offsets.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">TSS2_RC Tss2_Tcti_Device_Init (TSS2_TCTI_CONTEXT *tctiContext, size_t *size, const char *conf);</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">I check the description of Tss2_Tcti_Device_Init and didnt find any observation that tctiContext parameter must point an zeroed memory block, although in the usage examples the allocated memory is zeroed , calling calloc( 1, <needed
size>).</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Regarding tctiContext memory block passed to Tss2_Tcti_Device_Init:</p>
<p class="x_MsoNormal" style="text-indent:36.0pt">1 Is mandatory zeroing it before calling Tss2_Tcti_Device_Init? If so, is it a case of missing specification?</p>
<p class="x_MsoNormal" style="text-indent:36.0pt">2 No, it isnt, so is there a bug?</p>
<p class="x_MsoNormal" style="text-indent:36.0pt"> </p>
<p class="x_MsoNormal">My environment:</p>
<p class="x_MsoNormal" style="text-indent:36.0pt">TCTI shared library: libtss2-tcti-device.so.0</p>
<p class="x_MsoNormal" style="text-indent:36.0pt">OS: Enterprise Suse Linux</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Thanks in advance,</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Marcos A. de Moraes</p>
<p class="x_MsoNormal">HPE Security Software Engineer</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"> </p>
</div>
</div>
</body>
</html>