i386/tdx: Fix the UAF issue in tdx_fetch_cpuid()
PATCH 1/1 i386/tdx: Fix the UAF issue in tdx_fetch_cpuid()
Fix the UAF issue by reading the returned size before freeing the fetch_cpuid structure.
Reported-by Stefan Weil <[email protected]>
Signed-off-by Xiaoyao Li <[email protected]>
--- target/i386/kvm/tdx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/kvm/tdx.c +1 -1
@@ -847,8 +847,8 @@ static struct kvm_cpuid2 *tdx_fetch_cpuid(CPUState *cpu, int *ret) fetch_cpuid->nent = size; r =tdx_vcpu_ioctl (cpu,KVM_TDX_GET_CPUID ,0 , fetch_cpuid, &local_err);if (r == -E2BIG ) { -g_free (fetch_cpuid); size = fetch_cpuid->nent; +g_free (fetch_cpuid); } }while (r == -E2BIG );
Signature · 1 line
2.43.0
Quoted 4 lines · Xiaoyao Li
Fix the UAF issue by reading the returned size before freeing the
fetch_cpuidstructure.
Fixes e3d1a4a6d1d ("i386/tdx: Fetch and validate CPUID of TD guest")
Quoted 20 lines
Reported-by Stefan Weil <[email protected]>Signed-off-by Xiaoyao Li <[email protected]>--- target/i386/kvm/tdx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/i386/kvm/tdx.c +1
-1@@ -847,8 +847,8 @@ static struct kvm_cpuid2 *tdx_fetch_cpuid(CPUState *cpu, int *ret) fetch_cpuid->nent = size; r =tdx_vcpu_ioctl (cpu,KVM_TDX_GET_CPUID ,0 , fetch_cpuid, &local_err);if (r == -E2BIG ) { -g_free (fetch_cpuid); size = fetch_cpuid->nent; +g_free (fetch_cpuid); } }while (r == -E2BIG );
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 4 lines · Xiaoyao Li
Fix the UAF issue by reading the returned size before freeing the
fetch_cpuidstructure.Fixes e3d1a4a6d1d ("i386/tdx: Fetch and validate CPUID of TD guest")
Oh, I missed this.
Thanks for providing it!
Quoted 21 lines
Quoted 20 lines
Reported-by Stefan Weil <[email protected]>Signed-off-by Xiaoyao Li <[email protected]>---
target/i386/kvm/tdx.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)target/i386/kvm/tdx.c +1
-1@@ -847,8 +847,8 @@ static struct kvm_cpuid2 *tdx_fetch_cpuid(CPUState *cpu, int *ret) fetch_cpuid->nent = size; r = tdx_vcpu_ioctl(cpu, KVM_TDX_GET_CPUID, 0, fetch_cpuid, &local_err); if (r == -E2BIG) { - g_free(fetch_cpuid); size = fetch_cpuid->nent; + g_free(fetch_cpuid); } } while (r == -E2BIG);