From: Thomas Zimmermann <tzimmermann@suse.de>
To: airlied@linux.ie, daniel@ffwll.ch, christian.koenig@amd.com,
ville.syrjala@linux.intel.com, melissa.srw@gmail.com,
jgg@ziepe.ca, lee.jones@linaro.org, chris@chris-wilson.co.uk,
miaoqinglang@huawei.com
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
intel-gfx@lists.freedesktop.org,
Thomas Zimmermann <tzimmermann@suse.de>,
dri-devel@lists.freedesktop.org,
Gerd Hoffmann <kraxel@redhat.com>
Subject: [Intel-gfx] [PATCH] drm/vgem: Restore mmap functionality
Date: Fri, 9 Jul 2021 17:42:56 +0200 [thread overview]
Message-ID: <20210709154256.12005-1-tzimmermann@suse.de> (raw)
Commit 375cca1cfeb5 ("drm/vgem: Implement mmap as GEM object function")
accidentally removed the actual mmap functionality from vgem. Restore
the original implementation and VMA flags.
Fixes access to unmapped memory:
[ 106.591744] BUG: KASAN: vmalloc-out-of-bounds in do_fault+0x38/0x480
[ 106.598154] Read of size 8 at addr ffffffffc10c44a8 by task vgem_basic/1514
[ 106.605173]
[ 106.606678] CPU: 1 PID: 1514 Comm: vgem_basic Tainted: G E 5.13.0-1-default+ #990
[ 106.615535] Hardware name: Dell Inc. OptiPlex 9020/0N4YC8, BIOS A24 10/24/2018
[ 106.622818] Call Trace:
[ 106.625289] dump_stack+0xa5/0xdc
[ 106.628642] print_address_description.constprop.0+0x18/0x100
[ 106.634439] ? do_fault+0x38/0x480
[ 106.637872] kasan_report.cold+0x7c/0xd8
[ 106.641834] ? do_fault+0x38/0x480
[ 106.645274] do_fault+0x38/0x480
[ 106.648535] __handle_mm_fault+0x935/0xb00
[ 106.652676] ? vm_iomap_memory+0xe0/0xe0
[ 106.656634] ? __lock_release+0x12f/0x4e0
[ 106.660696] ? count_memcg_event_mm.part.0+0xb9/0x190
[ 106.665799] handle_mm_fault+0xd0/0x370
[ 106.669675] do_user_addr_fault+0x2a0/0x8c0
[ 106.673908] exc_page_fault+0x64/0xf0
[ 106.677604] ? asm_exc_page_fault+0x8/0x30
[ 106.681739] asm_exc_page_fault+0x1e/0x30
[ 106.685782] RIP: 0033:0x402e12
...
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: 375cca1cfeb5 ("drm/vgem: Implement mmap as GEM object function")
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Christian König <christian.koenig@amd.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: Melissa Wen <melissa.srw@gmail.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Lee Jones <lee.jones@linaro.org>
---
drivers/gpu/drm/vgem/vgem_drv.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c
index df634aa52638..f50fd10c4fad 100644
--- a/drivers/gpu/drm/vgem/vgem_drv.c
+++ b/drivers/gpu/drm/vgem/vgem_drv.c
@@ -364,8 +364,17 @@ static void vgem_prime_vunmap(struct drm_gem_object *obj, struct dma_buf_map *ma
static int vgem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
{
+ int ret;
+
+ if (!obj->filp)
+ return -ENODEV;
+
+ ret = call_mmap(obj->filp, vma);
+ if (ret)
+ return ret;
+
vma_set_file(vma, obj->filp);
- vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
+ vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP;
vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
--
2.32.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next reply other threads:[~2021-07-09 15:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-09 15:42 Thomas Zimmermann [this message]
2021-07-09 18:08 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/vgem: Restore mmap functionality Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210709154256.12005-1-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@linux.ie \
--cc=chris@chris-wilson.co.uk \
--cc=christian.koenig@amd.com \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jgg@ziepe.ca \
--cc=kraxel@redhat.com \
--cc=lee.jones@linaro.org \
--cc=melissa.srw@gmail.com \
--cc=miaoqinglang@huawei.com \
--cc=ville.syrjala@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox