Skip to content

Intel QAT: fix a DMA copy use-after-free, DH input validation, RSA prime carry and DRBG chunking - #12029

Open
dgarske wants to merge 5 commits into
wolfSSL:masterfrom
dgarske:qat_fixes
Open

dgarske wants to merge 5 commits into
wolfSSL:masterfrom
dgarske:qat_fixes

Conversation

@dgarske

@dgarske dgarske commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Description

Fixes to the Intel QuickAssist port:

  • Use-after-free in IntelQaRealloc(): making a DMA copy of a caller's buffer freed the caller's original, so every offloaded AES-GCM record freed ssl->encrypt.nonce and later used and freed it again. Regression in 5.9.4. Only the DMA copy types now keep the caller's buffer; any other type is a normal realloc.
  • DH agree: the QAT path skipped the input checks the software path makes, so peer values of 0, 1, p-1 and p returned success. It now runs the same checks before offloading. IntelQaDhAgreeCallback() also read one byte past the output on an all-zero secret, and now rejects a zero or one secret.
  • RSA prime generation: the carry loop in IntelQaGenPrime() indexed with i instead of j. This broke the carry and, for RSA-1024 and smaller, wrote past the candidate buffer.
  • DRBG: IntelQaDrbg() sized chunks from the previous chunk instead of the remaining length, overrunning the output for requests over 128KB. Later chunks also used a freed buffer.
  • README: building the QAT driver on Linux 7.0, rebuilding after a kernel upgrade, and recovering when the driver cannot get contiguous memory.

Fixes zd22732 (use-after-free), zd22754 and F-9981 (DH agree). DH agree reported by Md. Raisul Islam Mobin (https://mobin.tech | @mobin2021).

Testing

On a C62x with QAT 4.28: testwolfcrypt, including new tests for the DMA copy and for invalid DH peer values, plus TLS 1.3 hybrid ML-KEM, TLS 1.3 FFDHE and TLS 1.2 DHE handshakes with renegotiation, bulk transfers, and RSA-1024 and RSA-2048 key generation. The use-after-free was confirmed with AddressSanitizer against OpenSSL 3.5 clients. The DRBG change is only built for QAT 1.7 and was not compiled or run.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@dgarske dgarske self-assigned this Nov 6, 2026
Copilot AI balanced review requested due to automatic review settings November 6, 2026 00:34
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The change can cause intermittent DH test failures and leak public-key buffers during resizing when QAT is unavailable.

2 open issues
What changed in this PR

This PR addresses memory-safety and cryptographic correctness issues in wolfCrypt’s Intel QuickAssist offload support.

Changes:

  • Updates DMA-copy ownership, RSA prime carry handling, and DRBG chunking.
  • Adds DH input and shared-secret validation, plus regression tests.
  • Documents QAT driver rebuilds, Linux 7.0 compatibility, and memory-allocation recovery.
File Description
wolfcrypt/​test/​test.c Adds DMA-copy ownership and invalid DH peer-value tests.
wolfcrypt/​src/​port/​intel/​README.md Adds driver build and recovery guidance.
wolfcrypt/​src/​port/​intel/​quickassist.c Corrects RSA carry indexing, DH output handling, and DRBG buffers.
wolfcrypt/​src/​port/​intel/​quickassist_mem.c Preserves caller-owned buffers during DMA copies.
wolfcrypt/​src/​dh.c Validates DH inputs before QAT offload.

Review effort: Balanced

Comment thread wolfcrypt/test/test.c Resolved

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #12029

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfcrypt-port-bugs
Not reviewed (no scan target covers them): wolfcrypt/src/port/intel/README.md
Coverage: 4 of 4 in-scope changed file(s) opened by the reviewer

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Max

Comment thread wolfcrypt/test/test.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The rollover path leaves the low byte at 0xFF, turning 12FF into 13FF instead of 1301 and advancing prime candidates by 256 rather than 2.

1 open issue
2 resolved since last review

Review effort: Balanced

Comment thread wolfcrypt/src/port/intel/quickassist.c Resolved

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #12029

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfcrypt-port-bugs
Not reviewed (no scan target covers them): wolfcrypt/src/port/intel/README.md
Coverage: 2 of 2 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed their stale review November 6, 2026 18:03

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

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.

5 participants