Skip to contentSkip to conversation

KVM: arm64: Return on kvm_gmem_get_pfn() failure in gmem_abort()

PATCH Applied Fuad Tabba 3 participants 3 messages Oct 22 – Oct 26

Subsystems (2)
lore
Share & tools
lore

Fuad Tabba

author reviewer
#0 lore raw

PATCH 1/1 KVM: arm64: Return on kvm_gmem_get_pfn() failure in gmem_abort()

The kvm-arm64/mmu-fixes-7.4 merge dropped the return from the kvm_gmem_get_pfn() error path in gmem_abort(). Both parents of the merge keep that return. On a failed kvm_gmem_get_pfn(), gmem_abort() then carries on with a zero pfn, and on a nested stage-2 it uses the mapping it has just freed.

Restore the return.

Fixes 65f95b2874a15 ("Merge branch kvm-arm64/mmu-fixes-7.4 into kvmarm-master/next")

---

Notes:
I went through the rest of the merge's conflict resolution with git show --remerge-diff, and this is the only line it dropped.

 arch/arm64/kvm/mmu.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/kvm/mmu.c +1 -0
index a48f3f531e827..ba4fe58222ad5 100644
@@ -1802,6 +1802,7 @@ static int gmem_abort(const struct kvm_s2_fault_desc *s2fd,
 						      s2vi.vma_pagesize, write_fault, exec_fault,
 						      false);
 		kfree(mapping);
+		return ret;
 	}
 
 	if (!(s2fd->memslot->flags & KVM_MEM_READONLY))
Signature · 1 line
2.47.3
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Fuad Tabba

The kvm-arm64/mmu-fixes-7.4 merge dropped the return from the kvm_gmem_get_pfn() error path in gmem_abort(). Both parents of the merge keep that return. On a failed kvm_gmem_get_pfn(), gmem_abort() then carries on with a zero pfn, and on a nested stage-2 it uses the mapping it has just freed.

Restore the return.

Fixes 65f95b2874a15 ("Merge branch kvm-arm64/mmu-fixes-7.4 into kvmarm-master/next")

---

Notes:
I went through the rest of the merge's conflict resolution with git show --remerge-diff, and this is the only line it dropped.

  arch/arm64/kvm/mmu.c | 1 +
  1 file changed, 1 insertion(+)
arch/arm64/kvm/mmu.c +0 -0
index a48f3f531e827..ba4fe58222ad5 100644

arch/arm64/kvm/mmu.c static int gmem_abort(const struct kvm_s2_fault_desc *s2fd, · line 1808

Quoted 7 lines
arch/arm64/kvm/mmu.c +1 -0
@@ -1802,6 +1802,7 @@ static int gmem_abort(const struct kvm_s2_fault_desc *s2fd,
  						      s2vi.vma_pagesize, write_fault, exec_fault,
  						      false);
  		kfree(mapping);
+		return ret;
  	}
 
  	if (!(s2fd->memslot->flags & KVM_MEM_READONLY))

Thanks for fixing this ! Looks correct to me.

maintainer Applied
#2 lore raw
In reply to Fuad Tabba
Quoted 9 lines · Fuad Tabba

The kvm-arm64/mmu-fixes-7.4 merge dropped the return from the kvm_gmem_get_pfn() error path in gmem_abort(). Both parents of the merge keep that return. On a failed kvm_gmem_get_pfn(), gmem_abort() then carries on with a zero pfn, and on a nested stage-2 it uses the mapping it has just freed.

Restore the return.

[...]

Applied to fixes, thanks!

[1/1] KVM: arm64: Return on kvm_gmem_get_pfn() failure in gmem_abort()

      commit: c4c362949dcaaaabaa5db34acaa6e91b9912094c

Cheers,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.