[PATCH] io_uring: rsrc: avoid use of vmas parameter in pin_user_pages()

From: Lorenzo Stoakes
Date: Tue Apr 18 2023 - 12:11:01 EST


Rename function to avoid confusion and correct shmem check as suggested by
David.
---
io_uring/rsrc.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 3a927df9d913..483b975e31b3 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -1138,7 +1138,7 @@ static int io_buffer_account_pin(struct io_ring_ctx *ctx, struct page **pages,
return ret;
}

-static int check_vmas_locked(unsigned long addr, unsigned long len)
+static int check_vmas_compatible(unsigned long addr, unsigned long len)
{
struct file *file;
VMA_ITERATOR(vmi, current->mm, addr);
@@ -1149,15 +1149,16 @@ static int check_vmas_locked(unsigned long addr, unsigned long len)
return -EINVAL;

file = vma->vm_file;
- if (file && !is_file_hugepages(file))
- return -EOPNOTSUPP;

/* don't support file backed memory */
for_each_vma_range(vmi, vma, end) {
if (vma->vm_file != file)
return -EINVAL;

- if (file && !vma_is_shmem(vma))
+ if (!file)
+ continue;
+
+ if (!vma_is_shmem(vma) && !is_file_hugepages(file))
return -EOPNOTSUPP;
}

@@ -1185,7 +1186,7 @@ struct page **io_pin_pages(unsigned long ubuf, unsigned long len, int *npages)
pages, NULL);

if (pret == nr_pages) {
- ret = check_vmas_locked(ubuf, len);
+ ret = check_vmas_compatible(ubuf, len);
*npages = nr_pages;
} else {
ret = pret < 0 ? pret : -EFAULT;
--
2.40.0