TPM+IMA: tpm_add_char_device() is taking too long for IMA to detect TPM

Open
#4,973 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
c

Research direction

Trace the startup ordering between ima_init(), tpm_default_chip(), tpm_add_char_device(), idr_get_next(), and idr_replace(). Reproduce on the Raspberry Pi 4 with the Infineon SLB9670 using the reported 5.15.30 kernel and capture boot logs around the TPM messages. Done means IMA detects the TPM instead of activating TPM-bypass when the TPM becomes available.

Written by the indexing model from the issue text.

Description

Describe the bug

I'm using a Raspberry 4 with kernel linux 5.15.y and i kit my board with a TPM Infineon SLB9670.
I've noticed that in the function ima_init() there is a call to tpm_default_chip() that should return a valid tpm instance, but in my case always fails to "No TPM chip found, activating TPM-bypass!\n". In that function there is a call to idr_get_next() which return NULL, because the idr_replace() function in tpm_add_char_device() is called after the call to ima_init()->tpm_default_chip().
In the picture the idr_replace() is call at second 2 ("tpm: TPM available" print) which is after ima_init calls tpm_default_chip to get the tpm (which it takes only 1.73 seconds).

ima_tpm_partialFix

Steps to reproduce the behaviour

.

Device (s)

Raspberry Pi 4 Mod. B

System

OS: rpi-5.15.30
Kernel: linux-5.15.30

Logs

No response

Additional context

No response

Dominant language
C
Stars
13.2k
Forks
5.5k
Avg merge
2d 21h
Merged PRs (30d)
21

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from raspberrypi/linux

All issues in raspberrypi/linux

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.