lkml.org 
[lkml]   [2023]   [Feb]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] pci/mmap: add pci device EBUSY check
Date
When using a pci device through the vfio-pci driver, other software was
also able to access the pci device memory through sysfs.

To prevent this, when mmap is performed through sysfs, a process of
checking whether the device is in use is added.

Signed-off-by: Seunggyun Lee <sglee97@dankook.ac.kr>
---
drivers/pci/mmap.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/pci/mmap.c b/drivers/pci/mmap.c
index 4504039056d1..4c9df2e23e03 100644
--- a/drivers/pci/mmap.c
+++ b/drivers/pci/mmap.c
@@ -25,6 +25,8 @@ int pci_mmap_resource_range(struct pci_dev *pdev, int bar,
{
unsigned long size;
int ret;
+ if (pdev->driver)
+ return -1;

size = ((pci_resource_len(pdev, bar) - 1) >> PAGE_SHIFT) + 1;
if (vma->vm_pgoff + vma_pages(vma) > size)
--
2.25.1
\
 
 \ /
  Last update: 2023-03-27 00:12    [W:0.034 / U:1.636 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site