Skip to content

crypto: qat - bound the live migration import parser

Michael Bommarito linux-crypto lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2crypto: qat - validate migration section header is in boundsdrivers/crypto/intel/qat/qat_common/adf_mstate_mgr.c+12 -20 replies
2/2crypto: qat - add KUnit coverage for the migration import parserdrivers/crypto/intel/qat/Kconfig drivers/crypto/intel/qat/qat_common/adf_mstate_mgr.c drivers/crypto/intel/qat/qat_common/adf_mstate_mgr_test.c+101 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] crypto: qat - bound the live migration import parser

adf_mstate_mgr_init_from_remote() sets the section-walk cursor to mgr->buf + preh_len from a remote-supplied preh_len, and the default preamble checker only rejects preh_len > mgr->size. A remote preamble with preh_len == mgr->size moves the cursor one region past the allocation while n_sects is still honoured, so adf_mstate_sect_validate() reads sect->size before the section header is proven in bounds. The remote stream reaches this parser from the destination-host VFIO migration path (qat_vf_resume_write), so a malformed import reads out of bounds in the destination host kernel (fatal under KASAN / panic_on_warn).

Patch 1 rejects section headers not fully contained in the state buffer. Patch 2 adds KUnit coverage and is offered separately so it can be taken or dropped on its own. The parser was driven on QEMU x86_64 under KASAN via the patch 2 suite (Level-2: buggy code unchanged, surrounding VFIO/PF environment synthesized); the boundary trigger reports the out-of-bounds read on the unfixed parser and is gone after patch 1, with two benign controls passing on both trees.

Michael Bommarito (2):
crypto: qat - validate migration section header is in bounds
crypto: qat - add KUnit coverage for the migration import parser

 drivers/crypto/intel/qat/Kconfig              | 16 ++++
 .../intel/qat/qat_common/adf_mstate_mgr.c     | 18 ++++-
 .../qat/qat_common/adf_mstate_mgr_test.c      | 81 +++++++++++++++++++
 3 files changed, 113 insertions(+), 2 deletions(-)
 create mode 100644 drivers/crypto/intel/qat/qat_common/adf_mstate_mgr_test.c
Signature · 1 line
2.53.0