]> git.ipfire.org Git - thirdparty/grub.git/commit
tpm: Disable the tpm verifier if the TPM device is not present
authorMichael Chang <mchang@suse.com>
Wed, 22 Mar 2023 04:25:43 +0000 (12:25 +0800)
committerDaniel Kiper <daniel.kiper@oracle.com>
Wed, 29 Mar 2023 18:35:05 +0000 (20:35 +0200)
commit30708dfe3bebd62a5487437554da8a24253f519f
treed3f608fe3f10fb77f8c4d2a15d638aa73fa58487
parent0f5d86063746924b83626960f1d03a85d5e1fc82
tpm: Disable the tpm verifier if the TPM device is not present

When the tpm module is loaded, the verifier reads entire file into
memory, measures it and uses verified content as a backing buffer for
file accesses. However, this process may result in high memory
utilization for file operations, sometimes causing a system to run out
of memory which may finally lead to boot failure. To address this issue,
among others, the commit 887f98f0d (mm: Allow dynamically requesting
additional memory regions) have optimized memory management by
dynamically allocating heap space to maximize memory usage and reduce
threat of memory exhaustion. But in some cases problems may still arise,
e.g., when large ISO images are mounted using loopback or when dealing
with embedded systems with limited memory resources.

Unfortunately current implementation of the tpm module doesn't allow
elimination of the back buffer once it is loaded. Even if the TPM device
is not present or it has been explicitly disabled. This may unnecessary
allocate a lot memory. To solve this issue, a patch has been developed
to detect the TPM status at module load and skip verifier registration
if the device is missing or deactivated. This prevents allocation of
memory for the back buffer, avoiding wasting memory when no real measure
boot functionality is performed. Disabling the TPM device in the system
can reduce memory usage in the GRUB. It is useful in scenarios where
high memory utilization is a concern and measurements of loaded
artifacts are not necessary.

Signed-off-by: Michael Chang <mchang@suse.com>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/commands/efi/tpm.c
grub-core/commands/ieee1275/ibmvtpm.c
grub-core/commands/tpm.c
include/grub/tpm.h