From: Yousef Alhouseen <alhouseenyousef@gmail.com>
To: "Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>
Cc: David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org,
Yousef Alhouseen <alhouseenyousef@gmail.com>
Subject: [PATCH v2] drm/amdgpu: reject mapping info when BO VA is gone
Date: Thu, 25 Jun 2026 15:53:41 +0200 [thread overview]
Message-ID: <20260625135341.1159-1-alhouseenyousef@gmail.com> (raw)
In-Reply-To: <20260624172029.2508-1-alhouseenyousef@gmail.com>
AMDGPU_GEM_OP_GET_MAPPING_INFO looks up the GEM object from the file
handle and then locks the object and VM before resolving the BO-VA. The
GEM object reference keeps the BO alive, but it does not keep the
per-file handle open.
If a racing close drops the last handle reference in that window,
amdgpu_gem_object_close() can remove the BO-VA before
amdgpu_vm_bo_find() runs. The ioctl then walks the BO-VA mapping lists
unconditionally.
Return -EINVAL if the BO is no longer associated with this VM.
Suggested-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Yousef Alhouseen <alhouseenyousef@gmail.com>
---
Changes in v2:
- Describe the handle-close race instead of an initially unmapped BO.
- Return -EINVAL instead of -ENOENT.
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 212c14d99..6f5b6f4c2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -1087,6 +1087,12 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,
struct drm_amdgpu_gem_vm_entry *vm_entries;
struct amdgpu_bo_va_mapping *mapping;
int num_mappings = 0;
+
+ if (!bo_va) {
+ r = -EINVAL;
+ goto out_exec;
+ }
+
/*
* num_entries is set as an input to the size of the user-allocated array of
* drm_amdgpu_gem_vm_entry stored at args->value.
--
2.54.0
next prev parent reply other threads:[~2026-06-25 13:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-24 17:20 [PATCH] drm/amdgpu: reject mapping info for unmapped BOs Yousef Alhouseen
2026-06-25 8:46 ` Christian König
2026-06-25 9:07 ` Yousef Alhouseen
2026-06-25 12:50 ` Christian König
2026-06-25 13:53 ` Yousef Alhouseen [this message]
2026-06-25 14:26 ` [PATCH v2] drm/amdgpu: reject mapping info when BO VA is gone Yousef Alhouseen
2026-06-29 12:33 ` Christian König
2026-06-29 13:56 ` Yousef Alhouseen
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=20260625135341.1159-1-alhouseenyousef@gmail.com \
--to=alhouseenyousef@gmail.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=simona@ffwll.ch \
/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
all inboxes | Powered by JetHome®