Skip to content

ta/pta: qcom: pas: authenticate PIL firmware signatures and device bindings - #7937

Open
zelvam95 wants to merge 8 commits into
OP-TEE:masterfrom
zelvam95:feature/optee-pas-sig-auth
Open

ta/pta: qcom: pas: authenticate PIL firmware signatures and device bindings#7937
zelvam95 wants to merge 8 commits into
OP-TEE:masterfrom
zelvam95:feature/optee-pas-sig-auth

Conversation

@zelvam95

Copy link
Copy Markdown
Contributor

Stacked on PR #7885 (yet to be merged) - which added segment-hash
verification. Segment hashing proves an image matches its own digest table,
but not that the image was signed by a trusted party or is permitted on this
device. On a fused secure-boot Lemans device this PR establishes the image's
provenance at INIT_IMAGE, before the REE loads any segment:
OEM certificate chain, signature, and SW/HW device bindings, all anchored to
hardware fuses. Enabled under the same CFG_QCOM_PAS_AUTH knob as
PR #7885.

Devices whose secure-boot fuse is unblown skip signature authentication and
rely on PR #7885's segment-hash verification alone; segment re-hashing at
AUTH_AND_RESET runs on every device regardless.

Design

Authentication forks on a single fuse read of the secure-boot state and
root-of-trust anchor, and that read fails closed: a fuse-PTA error is
treated as secure-boot enabled, so a transient glitch can never downgrade a
secure-booted board to hash-only verification.

The crypto runs in the qcom_pas user-TA (mbedTLS-backed cert-chain and
signature verification); fuses are reached through a dedicated fuse PTA so the
TA needs no direct driver dependency. UIE-encrypted and QTI-countersigned
images are refused outright — neither decryption nor countersignature
verification is implemented here.

sequenceDiagram
    participant REE as REE (Linux)
    participant TA as qcom_pas TA
    participant FPTA as fuse PTA
    participant PTA as PAS PTA

    Note over REE,PTA: INIT_IMAGE - signature authentication (secure-boot devices)
    REE->>TA: INIT_IMAGE(pas_id, metadata_blob)
    TA->>PTA: PTA_QCOM_PAS_INIT_IMAGE
    PTA-->>TA: TEE_SUCCESS
    TA->>TA: pas_auth_save_metadata()<br/>TEE-private copy keyed by pas_id
    TA->>FPTA: read secure-boot state + root-of-trust anchor
    FPTA-->>TA: secboot_on, anchor<br/>(read error is treated as secboot_on)
    alt secure boot enabled
        TA->>TA: pas_mbn_parse() extracts hash_table
        TA->>FPTA: read device id fuses
        FPTA-->>TA: fuse values
        TA->>TA: verify cert chain vs fused anchor
        TA->>TA: verify signature over OEM-signed region
        TA->>TA: enforce SW/HW bindings
    else secure boot disabled
        TA->>TA: pas_mbn_parse() extracts hash_table<br/>(no signature auth)
    end
    TA-->>REE: TEE_SUCCESS (or TEE_ERROR_SECURITY on any failure)

    Note over REE,PTA: MEM_SETUP + REE segment load (unchanged from PR 19)

    Note over REE,PTA: AUTH_AND_RESET - segment hash verification + release
    REE->>TA: AUTH_AND_RESET(pas_id, fw_base, fw_size)
    TA->>PTA: PTA_QCOM_PAS_VERIFY_IMAGE with metadata and hash_table
    PTA->>PTA: re-hash each PT_LOAD segment vs hash_table entry
    PTA-->>TA: TEE_SUCCESS
    TA->>PTA: PTA_QCOM_PAS_AUTH_AND_RESET
    PTA-->>TA: TEE_SUCCESS peripheral released from reset
    TA-->>REE: TEE_SUCCESS
Loading

Any failure — cert-chain break, signature mismatch, or an SW/HW-binding
mismatch — fails INIT_IMAGE with TEE_ERROR_SECURITY;
the image is never loaded and the peripheral is never released from reset.

Testing

  • Built PLATFORM=qcom-lemans CFG_QCOM_PAS_AUTH=y CFG_WERROR=y; checkpatch
    clean across the series.
  • On a Lemans board, both fuse configurations:
    • secure-boot on: positive path authenticates and boots; signature mismatch,
      cert-chain break, and SW/HW-binding mismatch are each rejected and the
      peripheral stays in reset;
    • secure-boot off: signature path skipped, segment-hash verification still
      enforced.

@github-actions

Copy link
Copy Markdown

FYI @kishorebatta-ossqcom @ldts @b49020

@zelvam95
zelvam95 force-pushed the feature/optee-pas-sig-auth branch from 3e84f40 to 7f8ce54 Compare August 19, 2026 01:37
@jenswikl

Copy link
Copy Markdown
Contributor

How about making this a draft, since it still depends on other PRs to be merged?
That should help with keeping focus on the PRs that are next in line.

@zelvam95
zelvam95 marked this pull request as draft August 19, 2026 07:52
@zelvam95

Copy link
Copy Markdown
Contributor Author

How about making this a draft, since it still depends on other PRs to be merged? That should help with keeping focus on the PRs that are next in line.

Sorry, missed to mark as draft. Have moved this PR to draft.

@zelvam95 zelvam95 changed the title Feature/optee pas sig auth ta/pta: qcom: pas: authenticate PIL firmware signatures and device bindings Aug 19, 2026
@zelvam95
zelvam95 force-pushed the feature/optee-pas-sig-auth branch from 7f8ce54 to ab96976 Compare August 19, 2026 10:02
Comment thread core/drivers/qcom/qfprom/lemans/qfprom_target.h Outdated
Comment thread core/drivers/qcom/qfprom/lemans/qfprom_target.h Outdated
Comment thread core/drivers/qcom/qfprom/lemans/qfprom_target.h
Comment thread core/drivers/qcom/qfprom/qfprom_secboot.c Outdated
Comment thread core/drivers/qcom/qfprom/qfprom_secboot.c Outdated
Comment thread ta/qcom_pas/include/auth/pas_meta.h Outdated
Comment thread ta/qcom_pas/src/auth/pas_meta.c Outdated
Comment thread ta/qcom_pas/src/auth/pas_auth.c Outdated
Comment thread ta/qcom_pas/include/auth/pas_fuse.h Outdated
Comment thread ta/qcom_pas/src/auth/pas_sig_auth.c Outdated
@zelvam95
zelvam95 force-pushed the feature/optee-pas-sig-auth branch 15 times, most recently from 80b23ff to 8d6ed6b Compare August 20, 2026 14:07
Comment thread core/drivers/qcom/qfprom/qfprom_secboot.c Outdated
Comment thread core/drivers/qcom/qfprom/qfprom_secboot.c Outdated
@zelvam95
zelvam95 force-pushed the feature/optee-pas-sig-auth branch from 8d6ed6b to d4e9a92 Compare August 21, 2026 07:35
@zelvam95
zelvam95 marked this pull request as ready for review August 21, 2026 07:35
Comment thread ta/qcom_pas/src/auth/pas_auth.c
@zelvam95
zelvam95 force-pushed the feature/optee-pas-sig-auth branch 2 times, most recently from 2aba9ee to b5a1a83 Compare August 24, 2026 16:19
Comment thread ta/qcom_pas/src/auth/pas_fuse.c
Comment thread ta/qcom_pas/src/auth/pas_meta.c Outdated
Comment thread ta/qcom_pas/src/auth/pas_policy.c Outdated
Comment thread ta/qcom_pas/src/auth/pas_sig_auth.c Outdated
Comment thread ta/qcom_pas/src/auth/pas_sig_auth.c Outdated
Comment thread ta/qcom_pas/src/auth/pas_sig_auth.c Outdated
Comment thread core/drivers/qcom/qfprom/sub.mk
Comment thread core/drivers/qcom/qfprom/qfprom_secboot.c Outdated
Comment thread core/drivers/qcom/qfprom/qfprom_secboot.c Outdated
@zelvam95
zelvam95 force-pushed the feature/optee-pas-sig-auth branch 3 times, most recently from 962a72c to c93180a Compare August 26, 2026 19:48
@zelvam95
zelvam95 force-pushed the feature/optee-pas-sig-auth branch from c93180a to c83efce Compare August 26, 2026 20:15
@zelvam95

Copy link
Copy Markdown
Contributor Author

@ldts / @harshaldev27 / @kishorebatta-ossqcom,

Have addressed the earlier comments. Let me know if you have any other feedback.

@kishorebatta-ossqcom

Copy link
Copy Markdown

Reviewed core/drivers/qcom/qfprom/* files.

Reviewed-by: Kishore Batta kishore.batta@oss.qualcomm.com

Comment thread ta/qcom_pas/src/auth/lemans/pas_policy_platform.h Outdated
@zelvam95
zelvam95 force-pushed the feature/optee-pas-sig-auth branch 2 times, most recently from e9ae1d0 to 0f8045e Compare August 28, 2026 07:39
Signature authentication will trust the carveout more heavily than
hash-only verification does, and its TA-side policy will need the
same PAS IDs core code already uses, so put both in place before the
rest of the series builds on them.

The carveout base and size come from the REE, so the range must be
proven non-secure memory before it is mapped for hashing, and the REE
writes it outside this mapping's coherency domain, so hashing could
otherwise see a stale cached copy. Also reject an ELF with
inconsistent header geometry, so segment collection cannot run on a
malformed image.

PAS authentication verifies the firmware contents. TOCTOU protection
for the carveout is expected to come from the kernel/HYP MMU/SMMU
configuration, which controls isolation between non-secure masters.

Move the PAS_ID_* constants out of the core-only pas_data.h and into
the shared pta_qcom_pas.h interface header, so the TA-side policy code
added later in this series references the same values instead of a
second, duplicated set.

Signed-off-by: Selvam Sathappan Periakaruppan <speriaka@qti.qualcomm.com>
Assisted-by: Claude:sonnet-5
Reviewed-by: Sachin Grover <sgrover@qti.qualcomm.com>
The secure-boot fuse accessors need per-target register offsets, masks
and layout to operate. Keep the Lemans values as driver platform data
so a future target only needs its own register layout, not a copy of
the reader code.

Signed-off-by: Selvam Sathappan Periakaruppan <speriaka@qti.qualcomm.com>
Assisted-by: Claude:sonnet-5
Reviewed-by: Sachin Grover <sgrover@qti.qualcomm.com>
Reviewed-by: Kishore Batta <kishore.batta@oss.qualcomm.com>
Signature authentication has to bind an image to the device it runs on,
which requires the OEM root-of-trust anchor and enable state, the device
identity, and the EKU enforcement fuse.

They are gated on CFG_QCOM_FUSE_PTA so a target without the fuse PTA
carries none of this code. No caller reads them yet.

Signed-off-by: Selvam Sathappan Periakaruppan <speriaka@qti.qualcomm.com>
Assisted-by: Claude:sonnet-5
Reviewed-by: Sachin Grover <sgrover@qti.qualcomm.com>
Reviewed-by: Kishore Batta <kishore.batta@oss.qualcomm.com>
The secure-boot fuse readers live in the OP-TEE core, but the PAS TA
that needs them runs in user space. Expose them through a pseudo-TA
restricted to a REE_KERNEL-only login domain, so the TA can obtain
fuse-backed values without a driver dependency of its own.

Signed-off-by: Selvam Sathappan Periakaruppan <speriaka@qti.qualcomm.com>
Assisted-by: Claude:sonnet-5
Reviewed-by: Sachin Grover <sgrover@qti.qualcomm.com>
…rser

Signature authentication binds an image to its device using fields in
the OEM metadata block. Decode the block into typed values, including
anti-rollback and secondary SW ID fields for follow-on checks, so the
authentication backend never re-parses the raw block.

Metadata version and root_cert_sel are readable on their own, because
each selects the hash size the full parse needs as input. The
OEM-signed region masks out the QC-controlled fields, so the
signature covers exactly what the OEM signed.

Replace the hash-segment parser's raw byte-offset macros and untyped
u32 reads with a typed MBN header struct, since the decoder above and
the parser's other callers all dereference the same fields and
byte-offset arithmetic is easy to get wrong on review.

Signed-off-by: Selvam Sathappan Periakaruppan <speriaka@qti.qualcomm.com>
Assisted-by: Claude:sonnet-5
Reviewed-by: Sachin Grover <sgrover@qti.qualcomm.com>
The signature-authentication path makes several fuse reads per image, so
hold one fuse-PTA session per TA session rather than opening one per
read, matching how the TA already holds its PAS PTA session.

The helper applies no policy and fails closed: a read failure propagates
instead of substituting a default, so an untrustworthy fuse value aborts
authentication rather than silently weakening it.

Signed-off-by: Selvam Sathappan Periakaruppan <speriaka@qti.qualcomm.com>
Assisted-by: Claude:sonnet-5
Reviewed-by: Sachin Grover <sgrover@qti.qualcomm.com>
Segment-hash verification proves an image matches its own digest table;
it cannot prove who signed it or that it is permitted on this device, so
establish provenance before the peripheral leaves reset. The fuse read
selecting this path fails closed: an error means secure boot enabled, so
a transient failure cannot downgrade a fused board to hash-only
verification.

UIE-encrypted and QC-countersigned images are refused, as neither is
implemented here, and the chain is limited to one ECDSA P-384 root.

Signed-off-by: Selvam Sathappan Periakaruppan <speriaka@qti.qualcomm.com>
Assisted-by: Claude:sonnet-5
Reviewed-by: Sachin Grover <sgrover@qti.qualcomm.com>
…cation

Signature authentication reads fuses at runtime, so CFG_QCOM_PAS_AUTH
alone is not enough: the fuse PTA and the qfprom driver behind it must
come up with it too.

Fold the existing fuse-provisioning enable into the same block so it and
the new fuse-PTA consumer share one QFPROM enable and cannot drift
apart.

Signed-off-by: Selvam Sathappan Periakaruppan <speriaka@qti.qualcomm.com>
Assisted-by: Claude:sonnet-5
Reviewed-by: Sachin Grover <sgrover@qti.qualcomm.com>
@zelvam95
zelvam95 force-pushed the feature/optee-pas-sig-auth branch from 1d4aac4 to d9fa3df Compare August 30, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants