[edk2-devel] [PATCH 1/2] SecurityPkg: add TIS sanity check (tpm2)

Gerd Hoffmann posted 2 patches 2 years, 9 months ago
[edk2-devel] [PATCH 1/2] SecurityPkg: add TIS sanity check (tpm2)
Posted by Gerd Hoffmann 2 years, 9 months ago
The code blindly assumes a TIS interface is present in case both CRB and
FIFO checks fail.  Check the InterfaceType for TIS instead and only
return Tpm2PtpInterfaceTis in case it matches, Tpm2PtpInterfaceMax
otherwise.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
index 1f9ac5ab5a30..eac9f0e29941 100644
--- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
+++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
@@ -464,7 +464,11 @@ Tpm2GetPtpInterface (
     return Tpm2PtpInterfaceFifo;
   }
 
-  return Tpm2PtpInterfaceTis;
+  if (InterfaceId.Bits.InterfaceType == PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_TIS) {
+    return Tpm2PtpInterfaceTis;
+  }
+
+  return Tpm2PtpInterfaceMax;
 }
 
 /**
-- 
2.40.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103661): https://edk2.groups.io/g/devel/message/103661
Mute This Topic: https://groups.io/mt/98518597/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH 1/2] SecurityPkg: add TIS sanity check (tpm2)
Posted by Yao, Jiewen 2 years, 9 months ago
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Gerd
> Hoffmann
> Sent: Thursday, April 27, 2023 12:24 AM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Pawel Polawski
> <ppolawsk@redhat.com>; Oliver Steffen <osteffen@redhat.com>; Yao,
> Jiewen <jiewen.yao@intel.com>; Gerd Hoffmann <kraxel@redhat.com>
> Subject: [edk2-devel] [PATCH 1/2] SecurityPkg: add TIS sanity check (tpm2)
> 
> The code blindly assumes a TIS interface is present in case both CRB and
> FIFO checks fail.  Check the InterfaceType for TIS instead and only
> return Tpm2PtpInterfaceTis in case it matches, Tpm2PtpInterfaceMax
> otherwise.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
> b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
> index 1f9ac5ab5a30..eac9f0e29941 100644
> --- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
> +++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c
> @@ -464,7 +464,11 @@ Tpm2GetPtpInterface (
>      return Tpm2PtpInterfaceFifo;
>    }
> 
> -  return Tpm2PtpInterfaceTis;
> +  if (InterfaceId.Bits.InterfaceType ==
> PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_TIS) {
> +    return Tpm2PtpInterfaceTis;
> +  }
> +
> +  return Tpm2PtpInterfaceMax;
>  }
> 
>  /**
> --
> 2.40.0
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103716): https://edk2.groups.io/g/devel/message/103716
Mute This Topic: https://groups.io/mt/98518597/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-