Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/xe: Validate user fence during creation
@ 2024-07-17 14:04 Matthew Brost
  2024-07-17 14:04 ` [PATCH 2/2] drm/xe: Remove used xe_sync_entry_wait Matthew Brost
                   ` (9 more replies)
  0 siblings, 10 replies; 14+ messages in thread
From: Matthew Brost @ 2024-07-17 14:04 UTC (permalink / raw)
  To: intel-xe

Fail invalidate addresses during user fence creation.

Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
 drivers/gpu/drm/xe/xe_sync.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_sync.c b/drivers/gpu/drm/xe/xe_sync.c
index 2883d9aca404..f2e5e3c8c0cd 100644
--- a/drivers/gpu/drm/xe/xe_sync.c
+++ b/drivers/gpu/drm/xe/xe_sync.c
@@ -53,14 +53,18 @@ static struct xe_user_fence *user_fence_create(struct xe_device *xe, u64 addr,
 					       u64 value)
 {
 	struct xe_user_fence *ufence;
+	u64 __user *ptr = u64_to_user_ptr(addr);
+
+	if (!access_ok(ptr, sizeof(ptr)))
+		return ERR_PTR(-EFAULT);
 
 	ufence = kmalloc(sizeof(*ufence), GFP_KERNEL);
 	if (!ufence)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	ufence->xe = xe;
 	kref_init(&ufence->refcount);
-	ufence->addr = u64_to_user_ptr(addr);
+	ufence->addr = ptr;
 	ufence->value = value;
 	ufence->mm = current->mm;
 	mmgrab(ufence->mm);
@@ -183,8 +187,8 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef,
 		} else {
 			sync->ufence = user_fence_create(xe, sync_in.addr,
 							 sync_in.timeline_value);
-			if (XE_IOCTL_DBG(xe, !sync->ufence))
-				return -ENOMEM;
+			if (XE_IOCTL_DBG(xe, IS_ERR(sync->ufence)))
+				return PTR_ERR(sync->ufence);
 		}
 
 		break;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-07-17 19:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-17 14:04 [PATCH 1/2] drm/xe: Validate user fence during creation Matthew Brost
2024-07-17 14:04 ` [PATCH 2/2] drm/xe: Remove used xe_sync_entry_wait Matthew Brost
2024-07-17 14:41   ` Nirmoy Das
2024-07-17 18:35   ` Dixit, Ashutosh
2024-07-17 19:06     ` Matthew Brost
2024-07-17 14:19 ` ✓ CI.Patch_applied: success for series starting with [1/2] drm/xe: Validate user fence during creation Patchwork
2024-07-17 14:19 ` ✓ CI.checkpatch: " Patchwork
2024-07-17 14:21 ` ✓ CI.KUnit: " Patchwork
2024-07-17 14:33 ` ✓ CI.Build: " Patchwork
2024-07-17 14:35 ` ✓ CI.Hooks: " Patchwork
2024-07-17 14:36 ` ✓ CI.checksparse: " Patchwork
2024-07-17 14:40 ` [PATCH 1/2] " Nirmoy Das
2024-07-17 15:12 ` ✓ CI.BAT: success for series starting with [1/2] " Patchwork
2024-07-17 19:55 ` ✗ CI.FULL: failure " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox