mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 02:50:43 +00:00
io_uring/rsrc: disallow multi-source reg buffers
commit edd4782696
upstream.
If two or more mappings go back to back to each other they can be passed
into io_uring to be registered as a single registered buffer. That would
even work if mappings came from different sources, e.g. it's possible to
mix in this way anon pages and pages from shmem or hugetlb. That is not
a problem but it'd rather be less prone if we forbid such mixing.
Cc: <stable@vger.kernel.org>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
a442f12e47
commit
72783d2af8
1 changed files with 8 additions and 5 deletions
|
@ -9057,14 +9057,17 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov,
|
||||||
pret = pin_user_pages(ubuf, nr_pages, FOLL_WRITE | FOLL_LONGTERM,
|
pret = pin_user_pages(ubuf, nr_pages, FOLL_WRITE | FOLL_LONGTERM,
|
||||||
pages, vmas);
|
pages, vmas);
|
||||||
if (pret == nr_pages) {
|
if (pret == nr_pages) {
|
||||||
|
struct file *file = vmas[0]->vm_file;
|
||||||
|
|
||||||
/* don't support file backed memory */
|
/* don't support file backed memory */
|
||||||
for (i = 0; i < nr_pages; i++) {
|
for (i = 0; i < nr_pages; i++) {
|
||||||
struct vm_area_struct *vma = vmas[i];
|
if (vmas[i]->vm_file != file) {
|
||||||
|
ret = -EINVAL;
|
||||||
if (vma_is_shmem(vma))
|
break;
|
||||||
|
}
|
||||||
|
if (!file)
|
||||||
continue;
|
continue;
|
||||||
if (vma->vm_file &&
|
if (!vma_is_shmem(vmas[i]) && !is_file_hugepages(file)) {
|
||||||
!is_file_hugepages(vma->vm_file)) {
|
|
||||||
ret = -EOPNOTSUPP;
|
ret = -EOPNOTSUPP;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue