Patch "drm/i915/gvt: Verify pfn is "valid" before dereferencing "struct page"" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    drm/i915/gvt: Verify pfn is "valid" before dereferencing "struct page"

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     drm-i915-gvt-verify-pfn-is-valid-before-dereferencin.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 84b8b9de22b3c5c07b7b4b0be4093a409407976b
Author: Sean Christopherson <seanjc@xxxxxxxxxx>
Date:   Fri Jul 28 18:35:07 2023 -0700

    drm/i915/gvt: Verify pfn is "valid" before dereferencing "struct page"
    
    [ Upstream commit f046923af79158361295ed4f0a588c80b9fdcc1d ]
    
    Check that the pfn found by gfn_to_pfn() is actually backed by "struct
    page" memory prior to retrieving and dereferencing the page.  KVM
    supports backing guest memory with VM_PFNMAP, VM_IO, etc., and so
    there is no guarantee the pfn returned by gfn_to_pfn() has an associated
    "struct page".
    
    Fixes: b901b252b6cf ("drm/i915/gvt: Add 2M huge gtt support")
    Reviewed-by: Yan Zhao <yan.y.zhao@xxxxxxxxx>
    Tested-by: Yongwei Ma <yongwei.ma@xxxxxxxxx>
    Reviewed-by: Zhi Wang <zhi.a.wang@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20230729013535.1070024-2-seanjc@xxxxxxxxxx
    Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
    Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c
index 80c60754a5c1c..92462cd4bf7cc 100644
--- a/drivers/gpu/drm/i915/gvt/gtt.c
+++ b/drivers/gpu/drm/i915/gvt/gtt.c
@@ -1188,6 +1188,10 @@ static int is_2MB_gtt_possible(struct intel_vgpu *vgpu,
 	pfn = gfn_to_pfn(vgpu->vfio_device.kvm, ops->get_pfn(entry));
 	if (is_error_noslot_pfn(pfn))
 		return -EINVAL;
+
+	if (!pfn_valid(pfn))
+		return -EINVAL;
+
 	return PageTransHuge(pfn_to_page(pfn));
 }
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux