[tpm2] Tss2_Tcti_Device_Init context not zeroed
Antonio de Moraes, Marcos <marcos.antonio-de-moraes at hpe.com> Mon, 11 Jul 2022 19:13:17 +0000
| Newsgroups | dev.linux.lists.tpm2 |
|---|---|
| Message-ID | <PH0PR84MB1528843BE948A4F8CDB23BA49D879@PH0PR84MB1528.NAMPRD84.PROD.OUTLOOK.COM> |
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, 4 KB)
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi all,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="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:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="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>.
<o:p></o:p></p>
<p class="MsoNormal">ERROR:sys:src/tss2-sys/api/Tss2_Sys_Execute.c:118:Tss2_Sys_ExecuteFinish() Malformed response: Invalid tag in response header: 0”<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="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.<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">TSS2_RC Tss2_Tcti_Device_Init (TSS2_TCTI_CONTEXT *tctiContext, size_t *size, const char *conf);<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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>).<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Regarding tctiContext memory block passed to Tss2_Tcti_Device_Init:<o:p></o:p></p>
<p class="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?<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:36.0pt">2 – No, it isn’t, so is there a bug?<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:36.0pt"><o:p> </o:p></p>
<p class="MsoNormal">My environment:<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:36.0pt">TCTI shared library: libtss2-tcti-device.so.0<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:36.0pt">OS: Enterprise Suse Linux<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks in advance,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Marcos A. de Moraes<o:p></o:p></p>
<p class="MsoNormal">HPE Security Software Engineer<o:p></o:p></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
</div>
</body>
</html>