Skip to content

Commit 103e17a

Browse files
Sebastian EneMarc Zyngier
authored andcommitted
KVM: arm64: Check the untrusted offset in FF-A memory share
Verify the offset to prevent OOB access in the hypervisor FF-A buffer in case an untrusted large enough value [U32_MAX - sizeof(struct ffa_composite_mem_region) + 1, U32_MAX] is set from the host kernel. Signed-off-by: Sebastian Ene <sebastianene@google.com> Acked-by: Will Deacon <will@kernel.org> Link: https://patch.msgid.link/20251017075710.2605118-1-sebastianene@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent f71f7af commit 103e17a

File tree

1 file changed

+7
-2
lines changed
  • arch/arm64/kvm/hyp/nvhe

1 file changed

+7
-2
lines changed

arch/arm64/kvm/hyp/nvhe/ffa.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ static void __do_ffa_mem_xfer(const u64 func_id,
479479
struct ffa_mem_region_attributes *ep_mem_access;
480480
struct ffa_composite_mem_region *reg;
481481
struct ffa_mem_region *buf;
482-
u32 offset, nr_ranges;
482+
u32 offset, nr_ranges, checked_offset;
483483
int ret = 0;
484484

485485
if (addr_mbz || npages_mbz || fraglen > len ||
@@ -516,7 +516,12 @@ static void __do_ffa_mem_xfer(const u64 func_id,
516516
goto out_unlock;
517517
}
518518

519-
if (fraglen < offset + sizeof(struct ffa_composite_mem_region)) {
519+
if (check_add_overflow(offset, sizeof(struct ffa_composite_mem_region), &checked_offset)) {
520+
ret = FFA_RET_INVALID_PARAMETERS;
521+
goto out_unlock;
522+
}
523+
524+
if (fraglen < checked_offset) {
520525
ret = FFA_RET_INVALID_PARAMETERS;
521526
goto out_unlock;
522527
}

0 commit comments

Comments
 (0)