FAILED: patch "[PATCH] KVM: arm64: Check the untrusted offset in FF-A memory share" failed to apply to 5.15-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 103e17aac09cdd358133f9e00998b75d6c1f1518
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025112430-imperial-yearling-e395@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 103e17aac09cdd358133f9e00998b75d6c1f1518 Mon Sep 17 00:00:00 2001
From: Sebastian Ene <[email protected]>
Date: Fri, 17 Oct 2025 07:57:10 +0000
Subject: [PATCH] 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.
arch/arm64/kvm/hyp/nvhe/ffa.c +7 -2
@@ -479,7 +479,7 @@ static void __do_ffa_mem_xfer(const u64 func_id,struct ffa_mem_region_attributes *ep_mem_access;struct ffa_composite_mem_region *reg;struct ffa_mem_region *buf; -u32 offset, nr_ranges; +u32 offset, nr_ranges, checked_offset;int ret =0 ; if (addr_mbz || npages_mbz || fraglen > len ||
@@ -516,7 +516,12 @@ static void __do_ffa_mem_xfer(const u64 func_id, goto out_unlock; } -if (fraglen < offset +sizeof (struct ffa_composite_mem_region )) { +if (check_add_overflow (offset,sizeof (struct ffa_composite_mem_region ), &checked_offset)) { + ret =FFA_RET_INVALID_PARAMETERS ; + goto out_unlock; + } + +if (fraglen < checked_offset) { ret =FFA_RET_INVALID_PARAMETERS ; goto out_unlock; }