Skip to content

hw/ufs: Fix guest-triggerable MCQ crashes

Jeuk Kim qemu-devel 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4hw/ufs: Validate MCQ SQ references before usehw/ufs/ufs.c+19 -20 replies
2/4hw/ufs: Guard MCQ CQ accesses against missing queueshw/ufs/ufs.c hw/ufs/ufs.h+12 -10 replies
3/4hw/ufs: Reject zero-depth MCQ queueshw/ufs/trace-events hw/ufs/ufs.c+18 -20 replies
4/4hw/ufs: Keep MCQ SQs alive while requests are outstandinghw/ufs/trace-events hw/ufs/ufs.c+43 -70 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/4] hw/ufs: Fix guest-triggerable MCQ crashes

This series fixes four guest-triggerable bugs in the UFS MCQ emulation, all reachable via MMIO writes to the UFS PCI BAR with mcq=on.

Patches 1-2 fix bugs reported by Rayhan Ramdhany Hanaputra:

- Out-of-bounds array read: SQATTR.CQID is not checked against

    mcq_maxq before indexing u->cq[].

- NULL dereference: SQ doorbell is processed without checking whether the SQ exists.
- NULL dereference: CQ head doorbell is processed without checking whether the CQ exists.

Patches 3-4 fix additional bugs found during review:

- Divide-by-zero: a small SQATTR.SIZE or CQATTR.SIZE produces a zero-depth queue that crashes when its pointers are advanced.
- Use-after-free: disabling an SQ while requests are still in flight on the CQ list or in the SCSI layer frees memory that is still referenced by the completion paths.

Jeuk Kim (4):
hw/ufs: Validate MCQ SQ references before use hw/ufs: Guard MCQ CQ accesses against missing queues hw/ufs: Reject zero-depth MCQ queues
hw/ufs: Keep MCQ SQs alive while requests are outstanding

 hw/ufs/trace-events |  3 ++
 hw/ufs/ufs.c        | 92 +++++++++++++++++++++++++++++++++++++++------
 hw/ufs/ufs.h        |  9 ++++-
 3 files changed, 92 insertions(+), 12 deletions(-)
Signature · 1 line
2.43.0